HP Fortran Programmer's Reference (September 2007)

I/O and file handling
File access methods
Chapter 8 215
As in list-directed output, character values are output without delimiters by default,
making them unsuitable for namelist-directed input. However, you can use the DELIM=
specifier in the OPEN statement to specify the single or double quotation mark as the
delimiter to use for character constants.
Only character and complex values may be split between two records.
Unformatted I/O
Unformatted I/O does not perform format conversion on data it transfers. Instead, data is
kept in its internal, machine-representable format. You cannot perform unformatted I/O on
files that have been connected for formatted I/O (see “Formatted I/O” on page 209).
Unformatted I/O is more efficient than formatted, list-directed, or namelist-directed I/O
because the transfer occurs without the conversion overhead. However, because unformatted
I/O transfers data in internal format, it is not portable.
Direct access
When performing I/O on a direct-access file, records can be read or written in any order. The
records in a direct-access file are all of the same length.
Reading and writing records is accomplished by READ and WRITE statements containing the
REC= specifier. Each record is identified by a record number that is a positive integer. For
example, the first record is record number 1; the second, number 2; and so on. If REC= is not
specified:
The READ statement inputs from the current record, and the file pointer moves to the next
record.
The WRITE statement outputs to the record at the position of the file pointer, and the file
pointer is advanced to the next record.
As an extension, HP Fortran allows sequential I/O statements to access a file connected for
direct access.
Once established, a record number of a specific record cannot be changed or deleted, although
the record may be rewritten. A direct-access file does not contain an end-of-file record as an
integral part of the file with a specific record number. Therefore, when accessing a file with a
direct-access read or write statement, the END= specifier is not valid and is not allowed.
Direct-access files support both formatted and unformatted record types. Both formatted and
unformatted I/O work exactly as they do for sequential files. However, you cannot perform
list-directed, namelist-directed, or nonadvancing I/O on direct-access files.
For an example program that uses direct access, see “File access” on page 231.