[UP]


Manual Reference Pages  - print_dictionary (3)

NAME

print_dictionary(3f) - [ARGUMENTS:M_CLI] print internal dictionary created by calls to commandline(3f) (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Example
Author
License

SYNOPSIS

subroutine print_dictionary(header)

    character(len=*),intent(in),optional :: header
    logical,intent(in),optional          :: stop

DESCRIPTION

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..

OPTIONS

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.

EXAMPLE

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_dictionary

Sample 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

AUTHOR

John S. Urban, 2019

LICENSE

Public Domain


print_dictionary (3) March 11, 2021
Generated by manServer 1.08 from d055ef74-3e61-48e4-a522-6a4562112fa9 using man macros.