print_dictionary(3f) - [ARGUMENTS:M_CLI] print internal dictionary created by calls to commandline(3f) (LICENSE:PD)
Synopsis
Description
Options
Examples
Author
License
subroutine print_dictionary(header)
character(len=*),intent(in),optional :: header logical,intent(in),optional :: stop
Print the internal dictionary created by calls to commandline(3f). This routine is intended to print the state of the argument list if an error occurs in using the commandline(3f) procedure..
HEADER label to print before printing the state of the command argument list. STOP logical value that if true stops the program after displaying the dictionary.
Typical usage:
program demo_print_dictionary use M_CLI, only : unnamed, commandline, print_dictionary implicit none integer :: i character(len=255) :: message ! use for I/O error messages character(len=:),allocatable :: readme ! stores updated namelist integer :: ios real :: x, y, z logical :: help, h equivalence (help,h) namelist /args/ x,y,z,help,h character(len=*),parameter :: cmd=&ARGS X=1 Y=2 Z=3 HELP=F H=F / ! initialize namelist from string and then update from command line readme=cmd read(readme,nml=args,iostat=ios,iomsg=message) if(ios.eq.0)then ! update cmd with options from command line readme=commandline(cmd) read(readme,nml=args,iostat=ios,iomsg=message) endif if(ios.ne.0)then write(*,("ERROR:",i0,1x,a))ios, trim(message) call print_dictionary(OPTIONS:) stop 1 endif ! all done cracking the command line ! use the values in your program. write(*,nml=args) ! the optional unnamed values on the command line are ! accumulated in the character array "UNNAMED" if(size(unnamed).gt.0)then write(*,(a))files: write(*,(i6.6,3a))(i,[,unnamed(i),],i=1,size(unnamed)) endif end program demo_print_dictionarySample output
Calling the sample program with an unknown parameter produces the following:$ ./print_dictionary -A UNKNOWN SHORT KEYWORD: -A [Keyword] [Present] [Value] z F [3] y F [2] x F [1] help F [F] h F [F]
STOP 2
John S. Urban, 2019
Public Domain
Nemo Release 3.1 | print_dictionary (3) | February 23, 2025 |