Building A Fortran CLI
Building A Fortran CLI
html
Introduction
The libCLI library and related modules primarily contain procedures useful for creating a
command line interface (CLI) for a Fortran program.
DOWNLOAD:CLI.tgz
In addition, a collection of utiliies and routines are included found useful in other aspects of
developing Fortran codes, such as regression testing, output processing, compiler tests, ...
Large repositories of numeric algorithms written in Fortran exist at such sites as the netlib
repository. This collection is not a repository of routines solving complex analytical problems.
This is a collection of those "other" Fortran procedures that solve the day-to-day
non-numeric(mostly) issues in programming,
Contributions to the site are encouraged.
Please send an email to the contact found at the home directory if you have found something
useful. It helps in determining what resources should be expended on expanding the site.
libCLI.a
Routine Descriptions
Categories
command line arguments
M_KRACKEN(3f): The M_KRACKEN(3f) module makes cracking Unix-like arguments off the
command line command line easy. This is the frozen simpler self-contained version of
arguments general interest.
M_KRACKEN+(3f): The M_KRACKEN+(3f) module makes cracking Unix-like arguments off the
command line command line easy. This version is expanded to allow use in configuration
arguments files and interactive input as well, and incorporates additional modules. It
requires many other components from libCLI and is generally only
required when generating programs that use shell-like input.
NAMELIST-based Using new features in 2003/2008 Fortran such as reading NAMELIST
command line groups from internal files and GET_COMMAND_ARGUMENT(3f), crack
parser command line options using a standardized syntax and the least code.
strings
M_STRINGS(3f) convert case, change numbers to strings, strings to numbers, parse on
delimiters,edit strings, ... .
date and time
M_TIME(3f) Calculate and display date and time values
expression parsers
JUCALC(3f): JUCALC(3f) evaluates simple numeric and string expressions. This allows
evaluate your input to use expressions and variable names instead of simple
expressions 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): JUEXPR(3f) is an older simpler FORTRAN77 version of JUCALC(3f) that
Evaluate simple should compile as-is with any Fortran compiler. It is useful when you want
1 of 6 6/13/17, 7:45 AM
libCLI FORTRAN and C library : Command Line Pro... http://urbanjost.altervista.org/LIBRARY/libCLI/CLI.html
expressions to allow simple expressions in your input instead of just numeric values.
command line recall and editing
M_HISTORY(3f): Acting much like a line-mode editor, the REDO(3f) procedure lets you list,
An interactive edit, save, and modify your interactively entered program input. Built-in
input editor help and no dependence on terminal control sequences makes this a
module simple-to-master and portable input history editor.
READLINE(3f): The readline(3c) routine lets you edit and then execute previously entered
calling commands. An interface using a small C routine and the standard
readline(3c) from ISO_C_BINDING module lets the commonly available C routine be called
Fortran from Fortran. The readline(3c) library is required.
messages
journaling, routines that let you have a single routine filter output to journal files;
logging, and display attention-grabbing messages or reformat messages. Includes the
general messages M_DEBUG module. These routines are required by several of the other
modules located here!
flow control
M_logic(3f): The M_LOGIC(3f) module allows you to use if/else/elseif/endif directives in
conditionally your input; allowing conditional selection of input lines. Requires an
select input expression parser. It uses JUCALC(3f) by default.
help utilities
Help Utility read USH-like Help files
VMS-like Help read VMS-like Help files
Utility
hot keys
GETKEY(3f): read A simple C routine for most Unix and GNU/Linux systems that immediately
a character from reads a single character keystroke from the keyboard without waiting for a
the keyboard in carriage return. An interface using the ISO_C_BINDING interface allows
"immediate mode" the routine to be called from Fortran.
Fortran/C calls
M_process(3f) Read and write from a process using popen(3c)
Simple calls Some simple but commonly called C routines interfaced to Fortran.
between Fortran Ultimately, these will all be changed to use the ISO_C_BINDING module
and C introduced as part of Fortran 2003.
Directories and files
Directory reading
Environment
Error codes
File characteristics
Input/Output
Process management
Regular expressions
Signal management
2 of 6 6/13/17, 7:45 AM
libCLI FORTRAN and C library : Command Line Pro... http://urbanjost.altervista.org/LIBRARY/libCLI/CLI.html
database
encryption
internet
math
runtime
opengl
parallel
overloading
structures
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 cli.ff. The
program is available as expanded standard Fortran as part of the CLI
download CLI.tgz.
This program can process input files such as ...
######################
set A=10
if gt(A,100)
echo BAD
quit
else
set B=111111*sqrt(12)
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
set B=222222
echo GOOD
endif
set $str("after first test B is ",B)
######################
set A=200
if gt(A,100)
set B=333333
echo GOOD
set myvalue=myvalue+3
else
set B=444444
echo BAD
3 of 6 6/13/17, 7:45 AM
libCLI FORTRAN and C library : Command Line Pro... http://urbanjost.altervista.org/LIBRARY/libCLI/CLI.html
quit
endif
set $str("after second test B is ",B)
set dump
######################
Additional Utilities
Routine Descriptions
Categories
numeric utilities
Compare Float A Fortran module containing routines to perform equality and relational
Numbers comparisons on floating point numbers. That is, you can more safetly
compare real numeric values.
Types and Kinds Fortran KIND definitions used by other parts of the basic utilities
ACCDIG(3f) compare two real numbers only up to a specified number of digits
Color
M_color(3f) The M_color module is a collection of color-related procedures. Routines
to convert between different color models, return RGB values given
common X11 color names, and other simple color-related operations.
Sort
sorting Sort arrays into ascending or descending order
procedures
Unit Conversions
M_units(3f) A collection of unit conversions and constants. Allow degrees instead of
radians in trig functions; convert between Celcius and Fahrenheit, ...
compiler tests
Paranoid Compiler The PARANOID program converted into subroutines that can be called
Test from your programs to verify compiler behavior.
Utility Programs
ufpp
Basic file preprocessor. Used to build these utilities
numdiff
Find numeric differences in ASCII files. Useful for regression testing.
what
Display lines containing SCCS-compatible identifier strings
ttee
Copy stdin to multiple files with output optionally preceeded by a time stamp
colors
Display and convert color descriptions
asa2pdf
Convert files with ASA carriage control to Adobe PDF files. Still useful for printing simple
output files.
4 of 6 6/13/17, 7:45 AM
libCLI FORTRAN and C library : Command Line Pro... http://urbanjost.altervista.org/LIBRARY/libCLI/CLI.html
notabs
Filter that expands tabs and removes trailing carriage returns and new-line characters
dtu.ff
dtu.f90
Convert files to and from Unix and DOS line terminators
now
Display a date in a variety of formats
calen
Display a calendar
sec2days.ff
sec2days.f90
Convert seconds to dd-hh:mm:ss
days2sec.ff
sec2days.f90
Convert dd-hh:mm:ss to seconds
Executing make.shell should build all libraries, modules, and codes and run tests.
All output should go into a log file.
DOCUMENTATION
help text should be a simple readable syntax
html, man page and help routine should be automatically generated from the hel
UNIT TESTING
unit tests and documentation and keys for building with make should all be in
simple text file with the code ; probably as an html document.
COMPILATION
All code should be in libraries whenever possible to promote re-use.
Programs should be able to be compiled with ccall(1).
An SQLite data file should be updated with the results of the unit tests.
As routines are expanded to plain code (via html2f90, f90cpp, and make files)
and compiled, the expanded code should go into ar(1) files.
METADATA
meta data should be partly automatically generated, should be standardized to
point of showing original file name, date of compilation, date of change of fi
PREPROCESSING
preprocessing should be minimal but be available.
5 of 6 6/13/17, 7:45 AM
libCLI FORTRAN and C library : Command Line Pro... http://urbanjost.altervista.org/LIBRARY/libCLI/CLI.html
Change History
6 of 6 6/13/17, 7:45 AM