XL Fortran for AIX 8.1

Language Reference


A file is a sequence of records. The two kinds of files are external and internal. Access to an external file can be sequential or direct.

External Files

An external file is associated with an input/output device, such as a disk, tape, or terminal.

An external file is said to exist for an executable program if it is available to the program for reading or writing, or was created within the program. Creating an external file causes it to exist. Deleting an external file ends its existence. An external file can exist without containing any records.

+-------------------------------IBM Extension--------------------------------+

If an external file is identified by a file name, a valid AIX operating system file name must have a full path name of total length <=1023 characters, with each file name <=255 characters long (though the full path name need not be specified).

+----------------------------End of IBM Extension----------------------------+

The position of an external file is usually established by the preceding input/output operation. An external file can be positioned to:

External File Access Modes: Sequential or Direct

The two methods of accessing the records of an external file are sequential and direct. The method is determined when the file is connected to a unit.

A file connected for sequential access contains records in the order they were written. The records must be either all formatted or all unformatted; the last record of the file must be an endfile record. The records must not be read or written by direct access input/output statements during the time the file is connected for sequential access.

The records of a file connected for direct access can be read or written in any order. The records must be either all formatted or all unformatted; the last record of the file can be an endfile record if the file was previously connected for sequential access. In this case, the endfile record is not considered a part of the file when it is connected for direct access. The records must not be read or written using sequential access, list-directed formatting, namelist formatting, or a nonadvancing input/output statement.

Each record in a file connected for direct access has a record number that identifies its order in the file. The record number is an integer value that must be specified when the record is read or written. Records are numbered sequentially. The first record is number 1. Records need not be read or written in the order of their record numbers. For example, records 9, 5, and 11 can be written in that order without writing the intermediate records.

All records in a file connected for direct access must have the same length, which is specified in the OPEN statement when the file is connected (see OPEN).

Records in a file connected for direct access cannot be deleted, but they can be rewritten with a new value. A record cannot be read unless it has first been written.

Internal Files

An internal file is a character variable that is not an array section with a vector subscript. An internal file always exists.

If an internal file is a scalar character variable, the file consists of one record with a length equal to that of the scalar variable. If an internal file is a character array, each element of the array is a record of the file, with each record having the same length.

Reading and writing records are accomplished by sequential access formatted input/output statements. READ and WRITE are the only input/output statements that can specify an internal file.

If a WRITE statement writes less than an entire record, blanks fill the remainder of the record.

On input, blanks are treated in the same way as for an external file opened with BLANK=NULL specified. Records are padded with blanks as required, unless the noblankpad suboption of the -qxlf77 compiler option is specified, which indicates that records are not padded.

A scalar character variable that is a record of an internal file can become defined or undefined by means other than an output statement. For example, you can define it by a character assignment statement.

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]