The libCLI.a library and related MODULES contain procedures useful for creating a command line interface (CLI) for a Fortran program.
Large repositories of numeric algorithms written in Fortran exist at such sites as the netlib repository. This is a collection of primarily non-numeric Fortran procedures that can be combined to quickly create programs that allow shell-like input syntax.
command line arguments
|M_KRACKEN(3f): command line arguments||The M_KRACKEN(3f) module makes cracking Unix-like arguments off the command line easy|
|NAMELIST-based command line parser||Using new features in 2003/2008 Fortran such as reading NAMELIST groups from internal files and GET_COMMAND_ARGUMENT(3f), crack command line options using a standardized syntax and the least code.|
|look-alikes for Fortran 2003 command-line routines||Use the routines provided by Winteractor in the library "f2kcli" to make a standard way to crack the command line if your compiler does not yet support GET_COMMAND_ARGUMENT(3f).|
|M_PARSE for cracking input files that are written as Unix-line commands||This is a superset of the M_KRACKEN(3f) module that has features to let you read input data into your program that is similar in syntax to common Unix commands.|
|journaling, logging, and general messages||routines that let you have a single routine filter output to journal files; display attention-grabbing messages or reformat messages. These routines are required by several of the other modules located here!|
|JUCALC(3f): evaluate expressions||JUCALC(3f) evaluates simple numeric and string expressions. This allows your input to use expressions and variable names instead of simple values. You will have to comment out or supply some of the functions called, depending on how 2003-compliant your compiler is and whether you have the libJSU library on your system.|
|JUEXPR(3f): Evaluate simple expressions||JUEXPR(3f) is an older simpler FORTRAN77 version of JUCALC(3f) that should compile as-is with any Fortran compiler. It is useful when you want to allow simple expressions in your input instead of just numeric values.|
|COND(3f): conditionally select input||The M_LOGIC(3f) module allows you to use if/else/elseif/endif directives to your input; allowing conditional selection of input lines. Requires an expression parser. It uses JUCALC(3f) by default.|
command line recall and editing
|M_HISTORY(3f): An interactive input editor module||Acting much like a line-mode editor, the REDO(3f) procedure lets you list, edit, save, and modify your interactively entered program input. Built-in help and no dependence on terminal control sequences makes this a simple-to-master and portable input history editor.|
|READLINE(3f): calling readline(3c) from Fortran||The readline(3c) routine lets you edit and then execute previously entered commands. An interface using a small C routine and the standard ISO_C_BINDING module lets the commonly available C routine be called from Fortran. The readline(3c) library is required.|
|Help Utility||read NSAPLOT-like Help files|
|VMS-like Help Utility||read VMS-like Help files|
|GETKEY(3f): read a character from the keyboard in "immediate mode"||A simple C routine for most Unix and GNU/Linux systems that immediately reads a single character keystroke from the keyboard without waiting for a carriage return. An interface using the ISO_C_BINDING interface allows the routine to be called from Fortran.|
An example program that combines many of the components into a simple calculator-like utility that parses command line arguments, evaluates Fortran-like expressions, has interactive command history recall and editing, and supports if/else/elseif/endif directives can be found in example.f90. To avoid having to download and build all the components first the same program is available as a single self-contained program in example_all.f90. This program can process input files such as ...
###################### A=10 if gt(A,100) B=111111 !echo BAD quit else myvalue=sin(A)/3.0d0+4**2 if eq(myvalue,0) !echo myvalue is 0! elseif lt(myvalue,0) !echo myvalue is less than 0! elseif gt(myvalue,0) !echo myvalue is greater than 0! else !echo SHOULD NOT GET HERE quit endif B=222222 !echo GOOD endif $str("after first test B is ",B) ###################### A=200 if gt(A,100) B=333333 !echo GOOD myvalue=myvalue+3 else B=444444 !echo BAD quit endif $str("after second test B is ",B) dump ######################