[UP]


Manual Reference Pages  - get_args (3)

NAME

get_args(3f) - [ARGUMENTS:M_CLI2] return keyword values when parsing command line arguments (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Convenience Functions
Example
Author
License

SYNOPSIS

use M_CLI2, only : get_args ! convenience functions use M_CLI2, only : dget, iget, lget, rget, sget, cget use M_CLI2, only : dgets, igets, lgets, rgets, sgets, cgets

subroutine get_args(name,value,delimiters)

     character(len=*),intent(in) :: name

character(len=:),allocatable :: value ! or character(len=:),allocatable :: value(:) ! or [real|doubleprecision|integer|logical|complex] :: value ! or [real|doubleprecision|integer|logical|complex],allocatable :: value(:)

character(len=*),intent(in),optional :: delimiters

DESCRIPTION

GET_ARGS(3f) returns the value of keywords after SET_ARGS(3f) has been called. For fixed-length CHARACTER variables see GET_ARGS_FIXED_LENGTH(3f). For fixed-size arrays see GET_ARGS_FIXED_SIZE(3f).

As a convenience multiple pairs of keywords and variables may be specified if and only if all the values are scalars and the CHARACTER variables are fixed-length or pre-allocated.

OPTIONS

NAME name of commandline argument to obtain the value of
VALUE variable to hold returned value. The kind of the value is used to determine the type of returned value. May be a scalar or allocatable array. If type is CHARACTER the scalar must have an allocatable length.
DELIMITERS
  By default the delimiter for array values are comma, colon, and whitespace. A string containing an alternate list of delimiter characters may be supplied.

CONVENIENCE FUNCTIONS

There are convenience functions that are replacements for calls to get_args(3f) for each supported default intrinsic type

o scalars -- dget(3f), iget(3f), lget(3f), rget(3f), sget(3f), cget(3f)
o vectors -- dgets(3f), igets(3f), lgets(3f), rgets(3f), sgets(3f), cgets(3f)

D is for DOUBLEPRECISION, I for INTEGER, L for LOGICAL, R for REAL, S for string (CHARACTER), and C for COMPLEX.

If the functions are called with no argument they will return the UNNAMED array converted to the specified type.

EXAMPLE

Sample program:

    program demo_get_args
    use M_CLI2,  only : filenames=>unnamed, set_args, get_args
    implicit none
    integer                      :: i
    ! DEFINE ARGS
    real                         :: x, y, z
    real,allocatable             :: p(:)
    character(len=:),allocatable :: title
    logical                      :: l, lbig
    ! DEFINE AND PARSE (TO SET INITIAL VALUES) COMMAND LINE
    !   o only quote strings and use double-quotes
    !   o set all logical values to F or T.
    call set_args(’ &
       &-x 1 -y 2 -z 3 &
       &-p -1,-2,-3 &
       &--title "my title" &
       & -l F -L F  &
       & --label " " &
       & ’)
    ! ASSIGN VALUES TO ELEMENTS
    ! SCALARS
    call get_args(’x’,x,’y’,y,’z’,z)
    call get_args(’l’,l)
    call get_args(’L’,lbig)
    ! ALLOCATABLE STRING
    call get_args(’title’,title)
    ! NON-ALLOCATABLE ARRAYS
    call get_args(’p’,p)
    ! USE VALUES
    write(*,’(1x,g0,"=",g0)’)’x’,x, ’y’,y, ’z’,z
    write(*,*)’p=’,p
    write(*,*)’title=’,title
    write(*,*)’l=’,l
    write(*,*)’L=’,lbig
    if(size(filenames).gt.0)then
       write(*,’(i6.6,3a)’)(i,’[’,filenames(i),’]’,i=1,size(filenames))
    endif
    end program demo_get_args

AUTHOR

John S. Urban, 2019

LICENSE

Public Domain


get_args (3) March 11, 2021
Generated by manServer 1.08 from 3b49384d-ba77-42d1-8688-7ff5de0e4957 using man macros.