### 10.2.1.1 Unit Specifier

The unit specifier identifies the I/O unit to be accessed. It takes the following form:

  [UNIT=]io-unit
  io-unit
  For external files, it identifies a logical unit and is one of the following:
  - A scalar integer expression that refers to a specific file, I/O device, or pipe. If necessary, the value is converted to integer data type before use. The integer is in the range 0 through 2**31-1.

    Units 5 and 6 are associated with preconnected units. In addition, unit 0 is also associated with a preconnected unit on Tru64 UNIX, Linux, and Windows systems.

  - An asterisk (*). This is the default (or implicit) external unit, which is preconnected for formatted sequential access.

  For internal files, io-unit identifies a scalar or array character variable that is an internal file. An internal file is designated internal storage space (a variable buffer) that is used with formatted (including list-directed) sequential READ and WRITE statements.

The io-unit must be specified in a control list. If the keyword UNIT is omitted, the io-unit must be first in the control list.

A unit number is assigned either explicitly through an OPEN statement or implicitly by the system. If a READ statement implicitly opens a file, the file's status is STATUS='OLD'. If a WRITE statement implicitly opens a file, the file's status is as follows:

- On OpenVMS systems: STATUS='NEW'
- On Tru64 UNIX, Linux, and Windows systems: STATUS='UNKNOWN'

If the internal file is a scalar character variable, the file has only one record; its length is equal to that of the variable.

If the internal file is an array character variable, the file has a record for each element in the array; each record's length is equal to one array element.

An internal file can be read only if the variable has been defined and a value assigned to each record in the file. If the variable representing the internal file is a pointer, it must be associated; if the variable is an allocatable array, it must be currently allocated.

Before data transfer, an internal file is always positioned at the beginning of the first character of the first record.

For More Information:

- On the OPEN statement, see Section 13.6 for details on Tru64 UNIX, Linux, and Windows systems, or Section 12.6 for details on OpenVMS systems.
- On implicit logical assignments, see your user manual or programmer's guide.
- On preconnected units, see your user manual or programmer's guide.
- On using internal files, see your user manual or programmer's guide.

Previous Page Next Page Table of Contents