[UP]


Manual Reference Pages  - specified (3)

NAME

specified(3f) - [ARGUMENTS:M_CLI2] return true if keyword was present on command line (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

elemental impure function specified(name)

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

DESCRIPTION

specified(3f) returns .true. if the specified keyword was present on the command line.

OPTIONS

NAME name of commandline argument to query the presence of

RETURNS

SPECIFIED
  returns .TRUE. if specified NAME was present on the command line when the program was invoked.

EXAMPLE

Sample program:

   program demo_specified
   use M_CLI2,  only : set_args, get_args, specified
   implicit none
   ! DEFINE ARGS
   integer                 :: flag
   integer,allocatable     :: ints(:)
   real,allocatable        :: twonames(:)

! IT IS A BAD IDEA TO NOT HAVE THE SAME DEFAULT VALUE FOR ALIASED ! NAMES BUT CURRENTLY YOU STILL SPECIFY THEM call set_args(’ -flag 1 -f 1 -ints 1,2,3 -i 1,2,3 -twonames 11.3 -T 11.3’)

! ASSIGN VALUES TO ELEMENTS CONDITIONALLY CALLING WITH SHORT NAME call get_args(’flag’,flag) if(specified(’f’))call get_args(’f’,flag) call get_args(’ints’,ints) if(specified(’i’))call get_args(’i’,ints) call get_args(’twonames’,twonames) if(specified(’T’))call get_args(’T’,twonames)

! IF YOU WANT TO KNOW IF GROUPS OF PARAMETERS WERE SPECIFIED USE ! ANY(3f) and ALL(3f) write(*,*)specified([’twonames’,’T ’]) write(*,*)’ANY:’,any(specified([’twonames’,’T ’])) write(*,*)’ALL:’,all(specified([’twonames’,’T ’]))

! FOR MUTUALLY EXCLUSIVE if (all(specified([’twonames’,’T ’])))then write(*,*)’You specified both names -T and -twonames’ endif

! FOR REQUIRED PARAMETER if (.not.any(specified([’twonames’,’T ’])))then write(*,*)’You must specify -T or -twonames’ endif

! USE VALUES write(*,*)’flag=’,flag write(*,*)’ints=’,ints write(*,*)’twonames=’,twonames end program demo_specified

AUTHOR

John S. Urban, 2019

LICENSE

Public Domain


specified (3) March 11, 2021
Generated by manServer 1.08 from 0cac347b-fb65-4e53-b17d-bd9c24ec703d using man macros.