8.8 External Field Separators

A field descriptor such as Fw.d specifies that an input statement is to read w characters from the external record. If the data field in the external record contains fewer than w characters, the input statement reads characters from the next data field in the external record, unless the short field is padded with leading zeros or spaces.

When the field descriptor is numeric, you can avoid padding the input field by using a comma to terminate the field (called short field termination). The comma overrides the field descriptor's field width specification. It is particularly useful when you are entering data from a terminal keyboard. You can use it with the I, O, Z, F, E, D, G, and L field descriptors; for example:

     READ (5,100) I,J,A,B
100  FORMAT (2I6,2F10.2)

Consider that the following record is now read:

1,-2,1.0,35

Based on this input, the following assignments occur:

I = 1
J = -2
A = 1.0
B = 0.35

The physical end of the record also serves as a field terminator. The d part of a w.d specification is not affected by an external field separator.

A comma can only terminate fields less than w characters long. If a comma follows a field of w or more characters, the comma is considered part of the next field.

Two successive commas or a comma after a field of w characters constitutes a null (zero-length) field. Depending on the field descriptor specified, the resulting value assigned is 0, 0.0, 0.D0, 0.Q0, or .FALSE.

A comma cannot terminate a field that is controlled by field descriptor A, edit descriptor H, or a character constant. However, if the record reaches its physical end before w characters are read, short field termination occurs and the characters that were read are assigned successfully. Trailing spaces are appended to fill the corresponding I/O list element or the field descriptor.


Previous Page Next Page Table of Contents