FORTRAN Formats

The FMT subop accepts a Fortran format specification. This is useful when data are not separated by delimiters (spaces or commas) so that the standard unformatted READ command is inapplicable. A Fortran format specification is a list of format elements describing the variable format (real number in either decimal or exponential form), the width (number of characters) of each variable, and (optionally) the number of decimal places.

Three variable formats are supported: E, F, and G. The most common variable format is the F format for real numbers in decimal form. The syntax for this format is:

Fw.d

where w is the width of the variable and d is the number of decimal places to the right of the (implied) decimal point. For example, F4.0 would read a four digit number with no implied decimal places. (When there are no implied decimal places, as in the case of F4.0, the format description can be simplified to F4 alone.) If, however, the data are written with an implied decimal, the user can specify a decimal point to the left of the last d digits. Thus F4.2 would read `6743' as `67.43' while F4.1 would read `6743' as `674.3'. Any decimal actually coded in the data overrides the format specification.

The E format allows the user to enter data stored in scientific notation. The syntax of the E format is the same as the F format:

Ew.d

Here W is the total width of the variable, including exponent, while D indicates the number of implied decimal places in the mantissa. The data field should contain the mantissa and the letter E followed by an integer indicating the power of ten to which the mantissa is to be raised. For example, E6.0 would read `1234E2' as `123400' (1234.0 x 10^2), while E6.1 would read `1234E2' as `12340' (123.4 x 10^2). As before, any decimal actually coded overrides the format specification, so that both E6.0 and E6.1 would read `123.4E2' as `12340'.

The G format combines the features of the E and F formats. If an exponent is contained in the data field, then it is read using the E format, while if no exponent is contained in the data field, it is read using the F format. Thus, G6.2 would read both `123400' and `1234E2' as `1234'.

An SST extension to the usual set of FORTRAN format operators allows strings to be read from a file and automatically converted to value labels. The format is similar to that for floating point numbers:

Sw

Again w is the total width of the string. For more information on the use of value labels, see LABEL.

To read a string of real numbers, we form a list of variable formats separated by commas. For example, E4.0,F4.0,G4.0 would read `12E3456789E0' as three variables taking the values (in order) `12000' (12 x 10^3), `4567', and `89' (89 x 10^0). The E, F, and G descriptors are repeatable. That is, by placing an integer before the format description, the user can specify that the format description is to be repeated. For instance,

rFw.d

is equivalent to repeating the description FW.d R times. Thus, 3F4.2 is equivalent to F4.2,F4.2,F4.2. Similar examples apply to the E and G formats.

There are several non-repeatable format descriptors that can be placed in format description lists. These include:

'xxxxx'    character constants of any length
nX         n blank spaces (to be skipped)
/          end of record

By including a character string enclosed by apostrophes, the user can output text using the WRITE statement. Apostrophe editing will be accepted in the FMT subop associated with the READ statement, but will be ignored on input. That is, on input the format description xxxxx will have the effect of directing SST to ignore the next five characters. The same result could be obtained by including the descriptor 5X in the format specification list. The slash character `/' directs SST to skip to the next line of either the input or output file. Normally, when the end of the format specification is reached, SST assumes that it is finished with data transmission for the current records and skips to a new line before beginning input or output again. It is possible for subsequent I/O to continue reading from or writing to the same record by terminating the format specification with the backslash character \. Neither the slash or the backslash characters need be separated from other descriptors in the format list by commas.

Normally, Fortran interprets blanks on input as zeros. Thus F4.0 would read `4 7 ' as `4070'. For blanks to be ignored for the remainder of the format specification, enter the descriptor BN in the format specification list. To change the interpretation of blanks back to the default, insert BZ into the format specification list. If BN is in effect for the READ statement, a blank field will be interpreted as missing data.

It is possible to build up complex format specifications by nesting format descriptions within parentheses. Thus:

2(1X,F3.0)

is equivalent to:

1X,F3.0,1X,F3.0


SST Back Plotting