get_arg Function

public function get_arg(i) result(a)

Retrieve a command-line argument as an allocatable string.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i

0-based/1-based index passed to get_command_argument.

Return Value character(len=:), allocatable


Called by

proc~~get_arg~~CalledByGraph proc~get_arg get_arg proc~apply_watch_flag apply_watch_flag proc~apply_watch_flag->proc~get_arg proc~build_child_command build_child_command proc~build_child_command->proc~get_arg proc~choose_self_exe choose_self_exe proc~build_child_command->proc~choose_self_exe proc~choose_self_exe->proc~get_arg proc~join_argv join_argv proc~join_argv->proc~get_arg proc~parse_cli parse_cli proc~parse_cli->proc~get_arg proc~parse_cli->proc~apply_watch_flag proc~parse_cli->proc~join_argv proc~parse_restart_flags parse_restart_flags proc~parse_restart_flags->proc~get_arg proc~maybe_supervise maybe_supervise proc~maybe_supervise->proc~parse_restart_flags proc~supervisor_loop supervisor_loop proc~maybe_supervise->proc~supervisor_loop proc~parse_cli_config parse_cli_config proc~parse_cli_config->proc~parse_cli proc~supervisor_loop->proc~build_child_command

Source Code

   function get_arg(i) result(a)
      integer, intent(in) :: i
      !! 0-based/1-based index passed to `get_command_argument`.
      character(len=:), allocatable :: a
      integer :: n, istat
      n = 0
      call get_command_argument(i, length=n, status=istat)
      if (istat /= 0 .or. n <= 0) then
         a = ""
         return
      end if
      allocate(character(len=n) :: a)
      call get_command_argument(i, value=a, status=istat)
      if (istat /= 0) a = ""
   end function get_arg