HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
ENDFILE
Chapter 10348
An end-of-file record can occur only as the last record of a disk file. After execution of an
ENDFILE statement, the file is positioned beyond the end-of-file record; any records beyond the
current position are lost—that is, the file is truncated.
Some devices (for example, magnetic tape units) can have multiple end-of-file records, with or
without intervening data records.
An end-of-file record can be written to a sequential file only.
Examples
The following statement writes an end-of-file record to the file connected to unit 10:
ENDFILE 10
The following statement writes an end-of-file record to the file connected to unit 17. If an error
occurs during the execution of the statement, control passes to the statement at label 99, and
the error code is returned in ios:
INTEGER :: ios
...
ENDFILE (17, ERR=99, IOSTAT=ios)
Related statements
BACKSPACE, OPEN, and REWIND
Related concepts
For information about I/O concepts, see Chapter 8, “I/O and file handling,” on page 201, which
also lists example programs that use I/O. For information about I/O formatting, see
Chapter 9, “I/O formatting,” on page 235.