The unblocked, pure, text, and F77 file structures can be used.
The I/O library provides four different forms of file processing to indicate an unblocked file structure by using the assign -s ft command: unblocked (unblocked), standard binary (sbin), binary (bin), and undefined (u). These alternative forms provide different types of I/O packages used to access the records of the file, different types of file truncation and data alignment, and different endfile record recognitions in a file.
bin (not recommended)
Access and form
assign -s ft defaults
assign -s ft options
Unformatted sequential BUFFER IN / BUFFER OUT
Formatted direct on IRIX systems
You cannot specify the default for unformatted sequential access with assign -s. You must use assign -F f77.
A file with an unblocked file structure contains undelimited records. Because it does not contain any record control words, it does not have record boundaries. The unblocked file structure can be specified for a file that is opened with either unformatted sequential access or unformatted direct access. It is the default file structure for a file opened as an unformatted direct-access file.
BUFFER IN and BUFFER OUT statements can specify a file that is an unbuffered and unblocked file structure. If the file is specified with assign -s u, BUFFER IN and BUFFER OUT statements can perform asynchronous unformatted I/O.
You can specify the unblocked data file structure by using the assign(1) command in several ways. All methods result in a similar file structure but with different library buffering styles, use of truncation on a file, alignment of data, and recognition of an endfile record in the file. The following unblocked data file structure specifications are available:
|assign -s unblocked|
|assign -F system|
No library buffering
|assign -s u|
No library buffering
|assign -s sbin|
Standard-I/O-compatible buffering; for example, both library and system buffering
The type of file processing for an unblocked data file structure depends on the assign -s ft option declared or assumed for a Fortran file.
An I/O request for a file specified using the assign -s unblocked command does not need to be a multiple of a specific number of bytes. Such a file is truncated after the last record is written to the file. Padding occurs for files specified with the assign -s bin command and the assign -s unblocked command. Padding usually occurs when noncharacter variables follow character variables in an unformatted direct-access file.
No padding is done in an unformatted sequential access file. An unformatted direct-access file contains records that are the same length. The endfile record is recognized in sequential-access files.
You can use an assign -s sbin specification for a Fortran file that is opened with either unformatted direct access or unformatted sequential access. The file does not contain record delimiters. The file created for assign -s sbin in this instance has an unblocked data file structure and uses unblocked file processing.
The assign -s sbin option can be specified for a Fortran file that is declared as formatted sequential access. Because the file contains records that are delimited with the new-line character, it is not an unblocked data file structure. It is the same as a text file structure.
The assign -s sbin option is compatible with the standard C I/O functions. See Chapter 5, “System and C I/O ”, for more details.
|Note: Use of assign -s sbin is discouraged. Use assign -s text for formatted files, and assign -s unblocked for unformatted files.|
An I/O request for a file that is specified with assign -s bin does not need to be a multiple of a specific number of bytes. The I/O library uses an internal buffer for the records. If opened for sequential access, a file is not truncated after each record is written to the file.
The assign -s u command specifies undefined or unknown file processing. An assign -s u specification can be specified for a Fortran file that is declared as unformatted sequential or direct access. Because the file does not contain record delimiters, it has an unblocked data file structure. Both synchronous and asynchronous BUFFER IN and BUFFER OUT processing can be used with u file processing.
For best performance, a Fortran I/O request on a file assigned with the assign -s u command should be a multiple of 4096 bytes. I/O requests are not library buffered. They cause an immediate system call.
Fortran sequential files declared by using assign -s u are not truncated after the last word written. The user must execute an explicit ENDFILE statement on the file to get truncation.
The text file structure consists of a stream of 8-bit ASCII characters. Every record in a text file is terminated by a newline character (\n, ASCII 012). Some utilities may omit the newline character on the last record, but the Fortran library will treat such an occurrence as a malformed record. This file structure can be specified for a file that is declared as formatted sequential access or formatted direct access. It is the default file structure for formatted sequential access files.
The assign -s text command specifies the library-buffered text file structure. Both library and system buffering are done for all text file structures (for more information about library buffering, see Chapter 8, “Buffering”).
An I/O request for a file using assign -s text does not need to be a multiple of a specific number of bytes.
You cannot use BUFFER IN and BUFFER OUT statements with this structure. Use a BACKSPACE statement to reposition a file with this structure.
The cos or blocked file structure uses control words to mark the beginning of each 4096-byte block and to delimit each record. You can specify this file structure for a file that is declared as unformatted sequential access. Synchronous BUFFER IN and BUFFER OUT statements can create and access files with this file structure.
You can specify this file structure with one of the following assign(1) commands:
assign -s cos assign -s blocked assign -F cos assign -F blocked
These four assign commands result in the same file structure.
An I/O request on a blocked file is library buffered. For more information about library buffering, see Chapter 8, “Buffering”.
A blocked file is a stream of words that contains control words called Block Control Word (BCW) and Record Control Words (RCW) to delimit records. Each record is terminated by an EOR (end-of-record) RCW. At the beginning of the stream, and every 512 words thereafter, (including any RCWs), a BCW is inserted. An end-of-file (EOF) control word marks a special record that is always empty. Fortran considers this empty record to be an endfile record. The end-of-data (EOD) control word is always the last control word in any blocked file. The EOD is always immediately preceded by an EOR, or an EOF and a BCW.
Each control word contains a count of the number of data words to be found between it and the next control word. In the case of the EOD, this count is 0. Because there is a BCW every 512 words, these counts never point forward more than 511 words.
A record always begins at a word boundary. If a record ends in the middle of a word, the rest of that word is zero filled; the ubc field of the closing RCW contains the number of unused bits in the last word.
The following is a representation of the structure of a BCW:
Type of control word; 0 for BCW
Bad Data flag (1-bit).
Block number (modulo 224).
Forward index; the number of words to next control word.
The following is a representation of the structure of an RCW:
Type of control word; 108 for EOR, 168 for EOF, and 178 for EOD.
Unused bit count; number of unused low-order bits in last word of previous record.
Transparent record field (unused).
Bad data flag (unused).
Skip remainder of sector (unused).
Previous file index; offset modulo 220 to the block where the current file starts (as defined by the last EOF).
Previous record index; offset modulo 215 to the block where the current record starts.
|Forward index; the number of words to next control word.|