FORTRAN Reference Manual
Introduction to File I/O in the HP NonStop 
Environment
FORTRAN Reference Manual—528615-001
5-10
Unit Existence
Unit Existence
A unit exists for a FORTRAN executable program if and only if its unit number has 
been made known in one or more of the following ways:
•
The unit number appears, in the form of an integer constant or a symbolic constant 
whose value is an integer, as the unit number parameter in at least one FORTRAN 
I/O statement, of any kind, anywhere in the compilation.
•
The unit number is defined in a UNIT compiler directive anywhere in the 
compilation. Use a UNIT compiler directive to establish the existence of a unit only 
if all the I/O statements that refer to that unit use a variable or an expression (other 
than a constant) as their unit designator.
•
Units 4, 5, and 6 always exist by default.
FORTRAN I/O statements other than CLOSE or INQUIRE must refer to units that exist 
for the program.
Unit Assignment
A unit is assigned for a FORTRAN executable program if and only if the unit number 
has been associated with a file name. Assignment can be established in any of the 
following ways:
•
Units 4, 5, and 6 are always assigned by default. Unless one of the other methods 
listed below specifies otherwise, units 4, 5, and 6 are automatically assigned to the 
program’s home terminal, standard input file, and standard output file, respectively. 
The file names for these files are specified or assumed in the runoptions TERM, 
IN, and OUT, respectively, in the command that initiates execution of the program.
•
When the program is compiled, the UNIT compiler directive can specify the file 
name for the unit. If the unit number is 5 or 6 this file-name specification overrides 
the default described above. If the file name is not fully qualified, execution-time 
defaults are supplied for the missing parts of the file name. The UNIT directive can 
also specify a unit name for use in ASSIGN commands. For more information, see 
The ASSIGN Command on page 5-11.
•
Before you run your program, you can specify the file name for the unit in a TACL 
ASSIGN command. The file name you specify in the ASSIGN command overrides 
the file name specified or assumed at compile time by either of the preceding 
methods. The ASSIGN command associates a logical name, for example, FT uuu 
or the name you specify in a UNIT directive, with a physical—or external—file 
name, as shown in the following:
ASSIGN FT009, external-name
•
During execution of the program, the FILE specifier of an OPEN statement can 
establish a new file name for the unit, overriding all the above methods.
Note that assigning a file name to a unit number does not, by itself, cause the file to 
exist (that is, the assignment does not create the file).










