### 7.2.1.2 List-Directed Sequential READ Statement

The list-directed sequential READ statement performs the following operations:

- It reads character data from records accessed under the sequential mode of access.

- It translates data from external to binary form by using the data types of the elements in the I/O list, and the forms of the data, to provide editing.

- It assigns the translated data to the elements in the I/O list in the order, from left to right, in which those elements appear in the list.

The external records from which list-directed READ statements read data contain a sequence of values and value separators. A value in one of these records can be any one of the following:

- A constant: Each constant has the form of the corresponding Fortran constant. Input constants can be any of the following data types: integer, real, logical, complex, and character. The data type of the constant determines the data type of the value and the translation from external to internal form.

  A numeric list element can correspond only to a numeric constant, and a character list element can correspond only to a character constant. If the data types of a numeric list element and its corresponding numeric constant do not match, conversion is performed according to the rules for arithmetic assignment (see Figure 3-1).

  A complex constant has the form of a pair of real or integer constants separated by a comma and enclosed in parentheses. Spaces can occur between the opening parenthesis and the first constant, before and after the separating comma, and between the second constant and the closing parenthesis.

  A logical constant represents true or false values: .TRUE. or any value beginning with T, .T, t, or .t; or .FALSE. or any value beginning with F, .F, f, or .f.

  A character constant must be delimited by apostrophes. An apostrophe (') within a character constant is represented by two consecutive apostrophes.

  Hollerith and bit constants are not permitted.

- A null value: A null value is specified by two consecutive commas with no intervening constant or by an initial comma or trailing comma. Spaces can occur before or after the commas. A null value indicates that the corresponding list element remains unchanged. A null value can represent an entire complex constant, but cannot be used for either part of a complex constant.

- A repetition of constants in the form r*c: The form r*c indicates r occurrences of c, where r is a nonzero, unsigned integer constant and c is a constant. Spaces are not permitted except within the constant c as previously specified.

- A repetition of null values in the form r*: The form r* indicates r occurrences of a null value, where r is an unsigned integer constant.

A record can use any one of the following entities as a value separator, with or without surrounding spaces or tabs:

- A space or tab

- A comma

- A slash

A slash (/) terminates processing of the input statement and the record, leaving all remaining I/O list elements unchanged.

When any of the preceding entities appear in a character constant, they are considered part of the constant, not value separators.

The end of a record is equivalent to a space character except when it occurs in a character constant. In this case, the end of the record is ignored, and the character constant is continued with the next record (the last character in the previous record is immediately followed by the first character of the next record).

Spaces at the beginning of a record are ignored unless they are part of a character constant continued from the previous record. In this case, the spaces at the beginning of the record are considered part of the constant.

Each input statement reads one or more records as required to satisfy the I/O list. If a slash separator occurs or the I/O list is exhausted before all of the values in a record are used, the remainder of the record is ignored.

Example

Consider a program unit with the following statements:

    CHARACTER*14 C

    DOUBLE PRECISION T

    COMPLEX D,E

    LOGICAL L,M

    READ (1,*) I,R,D,E,L,M,J,K,S,T,C,A,B

The following external record is read:

    4 6.3 (3.4,4.2), (3, 2 ) , T,F,,3*14.6 ,'ABC,DEF/GHI''JK'/

Upon execution of the program unit, the following values are assigned to the I/O list elements:

I/O List Element | Value
--- | ---
I | 4
R | 6.3
D | (3.4,4.2)
E | (3.0,2.0)
L | .TRUE.
M | .FALSE.
K | 14
S | 14.6
T | 14.6D0
C | ABC,DEF/GHI'JK

A, B, and J are unchanged.

Previous Page Next Page Table of Contents