C Library Functions  - print_dictionary (3)

NAME

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

CONTENTS

Synopsis
Description
Options
Example
Author
License

SYNOPSIS

subroutine print_dictionary(header)

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

DESCRIPTION

Print the internal dictionary created by calls to get_namelist(3f). This routine is intended to print the state of the argument list if an error occurs in using the get_namelist(3f) procedure..

OPTIONS

HEADER label to print before printing the state of the command argument list.

EXAMPLE

Typical usage:

    program demo_print_dictionary
    use M_args,  only : unnamed, get_namelist, 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=get_namelist(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


Nemo Release 3.1 print_dictionary (3) July 22, 2023
Generated by manServer 1.08 from 6727cfd8-35b2-46e8-b254-31be5fd0920d using man macros.