By enclosing an expression in angle brackets, you can use it in a
FORMAT statement wherever you can use an integer (except as the
specification of the number of characters in the H field). For
example:
20 FORMAT (I<J+1>)
When the format is scanned, the preceding statement performs an I
(integer) data transfer with a field width of J+1. The expression
is reevaluated each time it is encountered in the normal format
scan.
The following rules apply to variable format expressions:
- If the expression is not of integer data type, it is
converted to integer data type before being used.
- The expression can be any valid Fortran expression,
including function calls and references to dummy arguments.
- The value of a variable format expression must obey the
restrictions on magnitude applying to its use in the
format, or an error occurs.
- Variable format expressions are not permitted in run-time
formats.
Variable format expressions can also be used in character format
specifications.
Variable format expressions are evaluated each time they are
encountered in the scan of the format. If the value of the
variable used in the expression changes during the execution of the
I/O statement, the new value is used the next time the format item
containing the expression is processed.