parse Subroutine

subroutine parse()

Uses

PUT EVERYTHING TO DO WITH COMMAND PARSING HERE FOR CLARITY

Arguments

None

Contents

Source Code


Variables

Type Visibility Attributes Name Initial
character(len=*), public, parameter :: cmd = ' -x 1 -y 2 -z 3      --point -1,-2,-3    --title "my title"  -l F -L F           '
character(len=:), public, allocatable :: help_text(:)

DEFINE COMMAND PROTOTYPE o All parameters must be listed with a default value o string values must be double-quoted o numeric lists must be comma-delimited. No spaces are allowed o long keynames must be all lowercase

character(len=:), public, allocatable :: version_text(:)

DEFINE COMMAND PROTOTYPE o All parameters must be listed with a default value o string values must be double-quoted o numeric lists must be comma-delimited. No spaces are allowed o long keynames must be all lowercase


Source Code

subroutine parse()
!! PUT EVERYTHING TO DO WITH COMMAND PARSING HERE FOR CLARITY
use M_CLI2,  only : set_args, get_args
use M_CLI2,  only : get_args_fixed_size,get_args_fixed_length
character(len=:),allocatable  :: help_text(:), version_text(:)

!! DEFINE COMMAND PROTOTYPE
!!  o All parameters   must be listed with a default value
!!  o string values    must be double-quoted
!!  o numeric lists    must be comma-delimited. No spaces are allowed
!!  o long keynames    must be all lowercase

character(len=*),parameter :: cmd='&
   & -x 1 -y 2 -z 3     &
   & --point -1,-2,-3   &
   & --title "my title" &
   & -l F -L F          &
   & '

   help_text=[character(len=80) :: &
      'NAME                                                    ', &
      '   myprocedure(1) - make all things possible            ', &
      'SYNOPSIS                                                ', &
      '   function myprocedure(stuff)                          ', &
      '   class(*) :: stuff                                    ', &
      'DESCRIPTION                                             ', &
      '   myprocedure(1) makes all things possible given STUFF ', &
      'OPTIONS                                                 ', &
      '   STUFF  things to do things to                        ', &
      'RETURNS                                                 ', &
      '   MYPROCEDURE  the answers you want                    ', &
      'EXAMPLE                                                 ', &
      '' ]

   version_text=[character(len=80) :: &
      '@(#)PROGRAM:     demo2            >', &
      '@(#)DESCRIPTION: My demo program  >', &
      '@(#)VERSION:     1.0 20200115     >', &
      '@(#)AUTHOR:      me, myself, and I>', &
      '@(#)LICENSE:     Public Domain    >', &
      '' ]

   call set_args(cmd, help_text, version_text)
   call get_args('x',x)
   call get_args('y',y)
   call get_args('z',z)
   call get_args_fixed_size('point',point)
   call get_args_fixed_length('title',title)
   call get_args('l',l)
   call get_args('L',l_)

end subroutine parse