FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-31
ENDFILE Statement
ENDFILE Statement
The ENDFILE statement writes an endfile record as the next record of the file
connected to the specified unit.
You can write the ENDFILE specifiers in any order. However, if you omit the UNIT
keyword when you specify unit, unit must be the first item in the list.
unit
is an integer expression from 1 through 999 that identifies an external unit
connected for sequential access. The unit must be connected to either a magnetic
tape, an unstructured file with fixed-length records, or an EDIT format file.
ios
is an integer variable or integer array element in which FORTRAN returns an error
number if an error occurred while executing the ENDFILE statement. If the
ENDFILE operation is successful, ios is zero. For more information about error
numbers, see the Error Numbers on page 6-5.
lbl
designates the label of an executable statement in the current program unit to
which ENDFILE transfers control if an error occurs while executing the ENDFILE
statement.
Considerations
Following execution of an ENDFILE statement, the file is positioned beyond the
endfile record. You must use a BACKSPACE, POSITION, or REWIND statement to
reposition a file before executing any data transfer I/O statements.
If the file can also be connected for direct access, only those records that precede
the endfile record are considered to have been written, and only those records can
be read during subsequent direct-access connections to the file.
Execution of the ENDFILE statement for a file that is connected, but that does not
exist, creates that file.
Error conditions
If you specify lbl, and an error occurs while writing the end of file, the ENDFILE
statement terminates, the file position becomes indeterminate, and FORTRAN
transfers control to the statement identified by lbl. If you also specified ios, you
can determine the error that occurred by analyzing ios.
ENDFILE
unit
UNIT=[] unit°() , IOSTAT= ios°()[] , ERR= label°()[]()


