FORTRAN Reference Manual

Introduction to File I/O in the HP NonStop
Environment
FORTRAN Reference Manual—528615-001
5-16
File Characteristics
After you compile the program but before you run it, you might enter the following
ASSIGN commands:
1> ASSIGN vector, $data.test.input, REC 400
2> ASSIGN ft003, , OUTPUT, EXT 4
When the object program runs, units 4, 5, and 6 are automatically connected to the
home terminal, standard input file, and standard output file respectively. If the standard
output file does not already exist, FORTRAN creates it as an EDIT format file, because
the UNIT 6 directive specifies file code 101.
The first reference to unit 1 is a WRITE statement. FORTRAN creates the file (as an
unstructured code 0 disk file in the default volume with a temporary file name, onepage
primary and secondary extent sizes, and 132-byte block and record lengths) and
opens it, all automatically, using defaults in the absence of a UNIT directive, ASSIGN
command, or OPEN statement for the unit.
Unit 2 is specified in both a UNIT directive and an ASSIGN command, using the unit
name VECTOR to establish this linkage. The file name and record length in the
ASSIGN command override those of the UNIT directive. The record length provides for
100 type REAL elements of 4 bytes each.
Unit 3 is also specified in both a UNIT directive and an ASSIGN command. In this
case, the default unit name FT003 (corresponding to unit number 3) provides the
linkage. The UNIT directive specifies a file name, a record length, and a protection
attribute, while the ASSIGN command specifies an access mode and an extent size.
The OPEN statement specifies a file name and a record length, overriding those of the
UNIT directive. The typed-in file name will be connected.
The program’s execution will terminate abnormally when it gets to the WRITE
statement after statement 30, because unit 7 does not exist.
File Characteristics
This subsection describes how you use FORTRAN files in the NonStop environment, in
which files are either structured or unstructured. An unstructured file is a byte array. It
is normally used as a code file or EDIT format file. The application process determines
the length and locations of records within the file. Structured files contain logical
records whose order depends on the type of structured file used.
Unstructured Files
You address data stored in an unstructured file (except for EDIT format files) in terms
of fixed-length numbered records. The first record in a file is record number 1, the
second is record number 2, and so forth. All records in the file have the same length
and are stored without any record delimiters, data compression, record indexing, or
other data structuring of any kind. The total size of the file (in bytes) is the record
length times the number of records in the file (given by the highest-numbered record
written so far). Thus, in an unstructured file: