process_command_line Subroutine

public subroutine process_command_line(options, rc)

Arguments

Type IntentOptional Attributes Name
type(CommandLineOptions0), intent(inout) :: options
integer, intent(out), optional :: rc

Calls

proc~~process_command_line~4~~CallsGraph proc~process_command_line~4 process_command_line interface~mapl_assert MAPL_Assert proc~process_command_line~4->interface~mapl_assert proc~mapl_return MAPL_Return proc~process_command_line~4->proc~mapl_return push_back push_back proc~process_command_line~4->push_back at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception

Called by

proc~~process_command_line~4~~CalledByGraph proc~process_command_line~4 process_command_line program~main~15 main program~main~15->proc~process_command_line~4

Source Code

   subroutine process_command_line(options, rc)
      type (CommandLineOptions0), intent(inout) :: options
      integer, optional, intent(out) :: rc

      integer :: n_args
      integer :: i_arg
      character(len=:), allocatable :: argument
      character(len=:), allocatable :: buffer

      n_args = command_argument_count()

      options%N_writer = 0
      options%writer   = ''
      i_arg = 0
      do
         if (i_arg > n_args) exit

         argument = get_next_argument()

         select case (argument)
         case ('-nc', '--npes_client')
            buffer = get_next_argument()
            _ASSERT(buffer /= '-', "no extrea - ")
            read(buffer,*) options%npes_client
         case ('-nsi', '--npes_iserver')
            buffer = get_next_argument()
            _ASSERT(buffer /= '-', "no extrea - ")
            read(buffer,*) options%npes_iserver
         case ('-ngi', '--ng_iserver')
            buffer = get_next_argument()
            _ASSERT(buffer /= '-', "no extrea - ")
            read(buffer,*) options%N_ig
         case ('-nso', '--npes_oserver')
            buffer = get_next_argument()
            _ASSERT(buffer /= '-', "no extrea - ")
            read(buffer,*) options%npes_oserver
         case ('-ngo', '--ng_oserver')
            buffer = get_next_argument()
            _ASSERT(buffer /= '-', "no extrea - ")
            read(buffer,*) options%N_og
         case ('-nw', '--n_writer')
            buffer = get_next_argument()
            _ASSERT(buffer /= '-', "no extrea - ")
            read(buffer,*) options%N_writer
         case ('-w', '--pfio_writer')
            options%writer = get_next_argument()
            _ASSERT(options%server_type /= '-', "no extrea - ")
         case ('-v', '--var')
            buffer = get_next_argument()
            _ASSERT(buffer(1:1) /= '-', "no extrea - ")
            options%requested_variables = parse_vars(buffer)
         case ('-s', '--server_type')
            options%server_type = get_next_argument()
            _ASSERT(options%server_type /= '-', "no extrea - ")
         case ('-d', '--debug')
            options%debug = .true.
         case default
            ! ignore
         end select

      end do
      _RETURN(_SUCCESS)
   contains
      
      function get_next_argument() result(argument)
         character(len=:), allocatable :: argument
         
         integer :: length
         
         i_arg = i_arg + 1
         
         call get_command_argument(i_arg, length=length)
         allocate(character(len=length) :: argument)
         call get_command_argument(i_arg, value=argument)
         
      end function get_next_argument

      function parse_vars(buffer) result(vars)
         type (StringVector) :: vars
         character(len=*), intent(in) :: buffer

         integer :: idx
         character(len=1), parameter :: COMMA = ','
         character(len=:), allocatable :: string

         string = buffer // COMMA
         do
            if (len(string) == 0) exit
            idx = index(string,COMMA)
            call vars%push_back(string(1:idx-1))
            string = string(idx+1:)
         end do

      end function parse_vars


   end subroutine process_command_line