[UP]


Manual Reference Pages  - kracken (3)

NAME

kracken(3f) - [ARGUMENTS:M_kracken] crack command line options on Fortran programs, using "-KEYWORD VALUE" syntax (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Example
See Also
Author
License

SYNOPSIS

subroutine kracken(verb, string[,ierror][style])

       character(len=*), intent(in) ::  verb
       character(len=*), intent(in) :: string
       integer, intent(out), optional :: ierror
       character(len=*), intent(in),optional :: style

DESCRIPTION

This is the main public procedure in the M_kracken(3f) module. It is used to define the command line options, their default values, and to crack the command line options using a syntax that looks very much like an execution of the program.

OPTIONS

VERB arbitrary command name, usually ’cmd’ or the name of the program calling the routine. This defines the variable prefix name used by the other functions to retrieve command option values.
STRING prototype command to define keywords and defaults. This string is simply a list of all keywords and their default values exactly as you would type them on the command line, with default values explicitly set.
IERROR If an error occurs such as an unknown keyword the calling program will be stopped unless the optional parameter IERROR is present. If present, it is up to the calling program to decide what to do if a non-zero value is returned.
STYLE parsing style. Either ’kracken’ or ’args’. The default is ’kracken’.

EXAMPLE

Sample program:

      program demo_kracken

use M_kracken ! define command arguments, default values and crack command line call kracken(’cmd’, & & ’-int 20 & & -real 10e3 & & -file input & & -dble 4.11223344556677d0 & & -help .false. & & -version .false. ’& & ) ! that’s it. You defined your command arguments and their default ! values and parsed the user-supplied command line arguments.

! Now you can just retrieve the values as strings using ! names of the form VERB_SWITCHNAME anywhere in your program. ! Note that the special name "VERB_oo" is for the string ! before any switch. if(lget(’cmd_help’))then ! was -help specified? write(*,*)’The help text’ stop endif if(lget(’cmd_version’))then ! was -version specified? write(*,*)’version 1.0 20161030’ stop endif ! convert all the remaining options to scalar values ! and call a procedure with the values call mymain( & & sget(’cmd_file’), & & rget(’cmd_real’), & & dget(’cmd_dble’), & & iget(’cmd_int’) & & ) contains subroutine mymain(filename,value1,value2,ivalue3) ! this routine is using conventional values and does ! not use M_kracken(3fm) module at all implicit none character(len=*),intent(in) :: filename real,intent(in) :: value1 doubleprecision,intent(in) :: value2 integer,intent(in) :: ivalue3 ! just to show the command arguments have ! been processed echo the values print *, ’filename=’,trim(filename) print *, ’values=’,value1,value2,ivalue3 end subroutine mymain end program demo_kracken

expected output from : "./cmd"

         filename=input
         values= 10000.0000  4.1122334455667700  20

expected output from : "./cmd -file myfile -int 1234"

         filename=myfile
         values= 10000.0000  4.1122334455667700  1234

SEE ALSO

M_kracken(3f),
  kracken(3f)
dget(3f), dgets(3f), iget(3f), igets(3f), lget(3f), lgets(3f), rget(3f), rgets(3f), sget(3f), sgets(3f), retrev(3f)

parse(3f), dissect(3f), store(3f), setprompts(3f), show(3f)

AUTHOR

John S. Urban

LICENSE

Public Domain


kracken (3) March 11, 2021
Generated by manServer 1.08 from f34bcd3e-b45c-4dca-82ac-916f0fa7bc05 using man macros.