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