- Sequential-access unformatted files:
- An integer that contains the length of the record precedes and
follows each record. The length of the integer is 4 bytes for 32-bit applications. It is 4 bytes if you set the
uwidth run-time option to 32 (the default) and it is 8 bytes if you set
uwidth to 64 for 64-bit applications.
- Sequential-access formatted files:
- XL Fortran programs break these files into records while reading, by using
each newline character (X'0A') as a record separator.
On output, the input/output system writes a newline character at the end of
each record. Programs can also write newline characters for
themselves. This practice is not recommended because the effect is that
the single record that appears to be written is treated as more than one
record when being read or backspaced over.
- Direct access files:
- XL Fortran simulates direct-access files with files whose length is a
multiple of the record length of the XL Fortran file. You must specify,
in an OPEN statement, the record length (RECL) of the
direct-access file. XL Fortran uses this record length to distinguish
records from each other.
For example, the third record of a direct-access file of record length 100
bytes would start at the 201st byte of the single record of a Linux file and
end at the 300th byte.
If the length of the record of a direct-access file is greater than the
total amount of data you want to write to the record, XL Fortran pads the
record on the right with blanks (X'20').
- Stream-access unformatted files:
- Unformatted stream files are viewed as a collection of file storage
units. In XL Fortran, a file storage unit is one byte.
A file connected for unformatted stream access has the following
properties:
- The first file storage unit has position 1. Each subsequent file
storage unit has a position that is one greater than that of the preceding
one.
- For a file that can be positioned, file storage units need not be read or
written in the order of their position. Any file storage unit may be
read from the file while it is connected to a unit, provided that the file
storage unit has been written since the file was created, and if a READ
statement for the connection is permitted.
- Stream-access formatted files:
- A record file connected for formatted stream access has the following
properties:
- Some file storage units may represent record markers. The record
marker is the newline character (X'0A').
- The file will have a record structure in addition to the stream
structure.
- The record structure is inferred from the record markers that are stored
in the file.
- Records can have any length up to the internal limit allowed by XL
Fortran (See Appendix D, XL Fortran Internal Limits.)
- There may or may not be a record marker at the end of the file. If
there is no record marker at the end of the file, the final record is
incomplete, but not empty.
A file connected for formatted stream access has the following
properties:
- The first file storage unit has position 1. Each subsequent file
storage unit has a position that is greater than that of the preceding
one. Unlike unformatted stream access, the positions of successive file
storage units are not always consecutive.
- The position of a file connected for formatted stream access can be
determined by the POS= specifier in an INQUIRE
statement.
- For a file that can be positioned, the file position can be set to a value
that was previously identified by the POS= specifier in
INQUIRE.