read_cli_arg Subroutine

public subroutine read_cli_arg(arg_index, arg)

Read a cli arg at a given index and return it as a string (character array)

Arguments

Type IntentOptional 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


Called by

proc~~read_cli_arg~~CalledByGraph proc~read_cli_arg read_cli_arg program~main main program~main->proc~read_cli_arg

Source Code

    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