FORTRAN 77 Language Reference


Unit Identifier

u is either an external unit identifier or an internal file identifier.

An external unit identifier must be one of the following:

If the optional characters UNIT= are omitted from the unit specifier, then u must be the first item in the list of specifiers.

Format Identifier

f is a format identifier and can be:

See "Runtime Formats " for details on formats evaluated at runtime.

If the optional characters, FMT=, are omitted from the format specifier, then f must appear as the second argument for a formatted write; otherwise, it must not appear at all.

f must not be an asterisk for direct access.

f can be an asterisk for internal files. @

If a file is connected for formatted I/O, unformatted data transfer is prohibited, and vice versa.

I/O Status Specifier

ios must be an integer variable, integer array element, or integer record field.

Record Number

rn must be a positive integer expression. This argument can appear only for direct-access files. rn can be specified for internal files. @

Error Specifier

s must be the label of an executable statement in the same program unit in which this WRITE statement occurs.

Output List

iolist can be empty, or it can contain output items or implied DO lists. The output items must be one of the following:

A simple unsubscripted array name specifies all of the elements of the array in memory storage order, with the leftmost subscript increasing more rapidly.

Implied DO lists are described in "Implied DO Lists".

If the output item is a character expression that employs the concatenation operator, the length specifiers of its operands can be an asterisk (*). This rule is nonstandard. @

If a function appears in the output list, that function must not cause an input/output statement to be executed.

Namelist-Directed WRITE

The second form of WRITE is used to output the items of the specified namelist group. Here, grname is the name of the list previously defined in a NAMELIST statement.


Execution proceeds as follows:

  1. The file associated with the specified unit is determined.

    The format, if specified, is established. The file is positioned appropriately prior to data transfer.

  2. If the output list is not empty, data is transferred from the list to the file.

    Data is edited according to the format, if specified.

  3. In the second form of namelist-directed WRITE, the data is transferred from the items of the specified namelist group according to the rules of namelist-directed output.

  4. The file is repositioned appropriately after the data transfer.

  5. If ios is specified, and no error occurs, it is set to zero; otherwise, it is set to a positive value.

  6. If s is specified and an error occurs, control is transferred to s.