4.2 Auxiliary Input Features
The program supports the following features to enhance
user-friendliness of input:
- You may refer to a key by any initial substring, provided no other key has the same initial substring.
For instance, if the keys abcabc
and abcdef are known to the program, then abca
will be understood
to denote the key abcabc,
but using abc would be incorrect,
and may either result in an
error or
the program may choose any of the keys that have this initial
substring, and not necessarily the one you
intended.
Initial substrings cannot (yet) be used for the following keys:
define, print, skip.
- Arithmetic expressions
can be used (wherever numbers are required) involving the standard arithmetic
operands in Fortran (+ - * / **), together with parentheses where necessary or
convenient.
Blanks are allowed in expressions and ignored, but they are interpreted as
separators, i.e. as denoting the
end of an expression, whenever the part
before the blank can be evaluated as a correct expression.
For instance '3* 4' will be interpreted as 12, but '3 *4' will be
interpreted
as 3, followed by a character *, followed in turn by the number 4.
All numbers and results are interpreted and handled as being of type real, but
whenever the result is a
whole number (allowing for small round-off
deviations), it will be recognized as possibly denoting an integer.
- The user may define variables
and functions in the input file, and
apply them subsequently in expressions.
The input file is read sequentially
and variables and functions must be defined before they can be used.
Note carefully that replacement of a variable (or function) by its value will occur
wherever possible (textually),
even if it leads to non-sense input. A
frequently occurring mistake is that the user defines a variable 'C'
in his (her) input and
then gets his input corrupted because of subsequent isolated C
characters are
replaced by
the defined numerical value.
Therefore: avoid single-character variables and function names.
Always check carefully that the identifier you introduce is not 'used' already in the input file.
A few variables and functions are pre-defined:
(variables):
pi = 3.1415....
(functions):
sin, cos, tan, asin, acos, atan, exp, log,
sqrt, nint.
The argument list of a function must be enclosed in parentheses, and the arguments
(in case of more than one)
must be separated by commas.
Defining variables and/or functions is done with the block-type key define.
Example (part of input):
DEFINE
ab = sin(pi/3)
s13 = 14*sqrt(2)
func(x,y,z) = x*ab+y**2-y*z
End
AKEY = FUNC (S13/5, S13/7, SIN(PI/6))
Here a function func and variables ab and s13 are defined, using the pre-defined functions sin and sqrt,
as well as the pre-defined variable pi. These are then applied to assign a value to the (hypothetical) key AKEY.
Note 1: the variable ab is also used in the definition of func'; this is allowed because ab is defined before func.
Note 2: variable- and function names
must have the same form as keywords, i.e. only certain characters
are allowed.
Note 3: in the definition of variables and functions blanks are ignored
altogether (in the value part) and will
not be interpreted as possible
separators of the expression that defines the variable or function.
- (Single) quotes can be used to designate strings, i.e.
(parts of) records which are not
to be parsed for expressions, but which are to
be taken as they are. The quotes themselves are ignored.
Double quotes inside a
string are understood to denote the single quote character (as part of the
string).
- Empty records and starting blanks in records are
allowed (and ignored),
and can be used to enhance clarity and readability of
the input file for human readers by structuring its layout.
- You may exclude certain parts of the input file from
being considered by the input-reading routine,
which can thus be used for
instance to include 'comments' and clarifying remarks for later inspection.
This can be done in two ways:
- A double colon (::) is interpreted by the input routine
as denoting the end-of-line,
so that the part of the line after it (including
the double colon itself) is ignored.
- The block-type keyword ignore
starts a block of information that will
completely be ignored by
the program. The ignore-block must end, as usual, with the end-key code.