print_dictionary Subroutine

public subroutine print_dictionary(header, stop)

NAME

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

SYNOPSIS

 subroutine print_dictionary(header,stop)

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

DESCRIPTION

Print the internal dictionary created by calls to set_args(3f).
This routine is intended to print the state of the argument list
if an error occurs in using the set_args(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_CLI2,  only : set_args, get_args
   implicit none
   real :: x, y, z
      call set_args('-x 10 -y 20 -z 30')
      call get_args('x',x,'y',y,'z',z)
      ! all done cracking the command line; use the values in your program.
      write(*,*)x,y,z
   end program demo_print_dictionary

  Sample output

  Calling the sample program with an unknown parameter or the --usage
  switch produces the following:

     $ ./demo_print_dictionary -A
     UNKNOWN SHORT KEYWORD: -A
     KEYWORD             PRESENT  VALUE
     z                   F        [3]
     y                   F        [2]
     x                   F        [1]
     help                F        [F]
     version             F        [F]
     usage               F        [F]

AUTHOR

  John S. Urban, 2019

LICENSE

  Public Domain

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in), optional :: header
logical, intent(in), optional :: stop

Contents

Source Code


Source Code

subroutine print_dictionary(header,stop)
character(len=*),intent(in),optional :: header
logical,intent(in),optional          :: stop
integer          :: i
   if(G_QUIET)return
   if(present(header))then
      if(header /= '')then
         write(warn,'(a)')header
      endif
   endif
   if(allocated(keywords))then
      if(size(keywords) > 0)then
         write(warn,'(a,1x,a,1x,a,1x,a)')atleast('KEYWORD',max(len(keywords),8)),'SHORT','PRESENT','VALUE'
         write(warn,'(*(a,1x,a5,1x,l1,8x,"[",a,"]",/))') &
         & (atleast(keywords(i),max(len(keywords),8)),shorts(i),present_in(i),values(i)(:counts(i)),i=size(keywords),1,-1)
      endif
   endif
   if(allocated(unnamed))then
      if(size(unnamed) > 0)then
         write(warn,'(a)')'UNNAMED'
         write(warn,'(i6.6,3a)')(i,'[',unnamed(i),']',i=1,size(unnamed))
      endif
   endif
   if(allocated(args))then
      if(size(args) > 0)then
         write(warn,'(a)')'ARGS'
         write(warn,'(i6.6,3a)')(i,'[',args(i),']',i=1,size(args))
      endif
   endif
   if(G_remaining /= '')then
      write(warn,'(a)')'REMAINING'
      write(warn,'(a)')G_remaining
   endif
   if(present(stop))then
      if(stop) call mystop(5)
   endif
end subroutine print_dictionary