Read a cli arg at a given index and return it as a string (character array)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | arg_index |
The index of the cli arg to try and read |
||
| character(len=:), | intent(out), | allocatable | :: | arg |
The string into which to store the cli arg |
subroutine read_cli_arg(arg_index, arg) !> The index of the cli arg to try and read integer, intent(in) :: arg_index !> The string into which to store the cli arg character(len=:), allocatable, intent(out) :: arg integer :: argl character(len=:), allocatable :: cli_arg_temp_store call get_command_argument(arg_index, length=argl) allocate(character(argl) :: cli_arg_temp_store) call get_command_argument(arg_index, cli_arg_temp_store) arg = trim(cli_arg_temp_store) end subroutine read_cli_arg