## Fortran Character String Utilities:

A number of executable programs accept input from a user-provided ASCII
text file. These input files specify which operations to perform and
supply the necessary input data. The string routines supplied here were
developed to simplify the processing of these input files. In
particular, there are subroutines for parsing lines in the input file
into their component parts (e.g., commands, arguments, parameters)
based on prescribed delimiters. There are also subroutines for
performing various string manipulations as well as routines for
evaluating mathematical expressions contained in strings. The Fortran
routines are contained in two modules. The module *strings*
contains the parsing and basic manipulation routines. The module *
evaluate* contains routines for evaluating mathematical expressions
contained in strings.

## Strings Module:

This Fortran module contains routines for parsing input lines such as

**cmd arg1, arg2, arg3**

into the component strings "cmd", "arg1", "arg2", "arg3" based on prescribed delimiters such as commas and spaces. There are also routines for converting number strings into numerical values (integers, reals, single or double precision). Other routines in this module

- convert strings to uppercase or lowercase
- remove portions of strings
- insert strings into other strings
- find matching delimiters such as (), [], {}, <>
- determine whether a character is a letter or a digit (0-9).

A document describing this string module can be opened by clicking on the link below

Fortran Character String Utilities (pdf) File: Strings.pdf (72 KB)

The Fortran source code and associated documentation can be downloaded by clicking on the following link

Source Code for Fortran String Utilities File: Strings.zip (79 KB)

## Evaluate Module:

This module contains routines for evaluating mathematical expressions
contained in strings, e.g., *"cos((a+b)^2+1.6*log(c))
"*. These strings expressions can contain numbers (e.g., 1.5
or 1.5e6), previously defined parameters (like *a,b,c* above),
arithmetic operators (+,-,*,/,^), and any of the functions (cos, sin,
sqrt, exp, log, ln, abs, ang, real, imag, conjg, complex). They can
also contain nested levels of parentheses. The module also contains
routines for defining and retrieving user-specified parameters. The
quantity *pi* and the imaginary unit *i* are pre-defined
parameters. The document describing this Evaluate Module can be opened
by clicking on the link below

Fortran Utilities for Evaluating Expressions (pdf) File: evaluate.pdf (64 KB)

The Evaluate Module and the associated documentation can be downloaded by clicking on the following link

Source Code for Evaluate Utilities File: evaluate.zip (73 KB)

A Windows command-line calculator utilizing the Evaluate Module is contained in the downloadable file calc.zip (248 KB).