| Application Programmer's I/O Guide - S-3695-35 | ||
|---|---|---|
| Prev Section | Chapter 7. File Structures | Next Section |
The cos or blocked file structure uses control words to mark the beginning of each sector 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. This file structure is the default structure for files declared as unformatted sequential access on UNICOS and UNICOS/mk systems.
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.
In a COS file structure, one or more ENDFILE records are allowed. BACKSPACE statements can be used to reposition a file with this structure.
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:
Table 7-3.
Field | Bits | Description |
|---|---|---|
m | 0-3 | Type of control word; 0 for BCW |
bdf | 11 | Bad Data flag (1-bit). |
bn | 31-54 | Block number (modulo 224). |
fwi | 55-63 | Forward index; the number of words to next control word. |
The following is a representation of the structure of an RCW:
Table 7-5.
Field | Bits | Description |
|---|---|---|
m | 0-3 | Type of control word; 108 for EOR, 168 for EOF, and 178 for EOD. |
ubc | 4-9 | Unused bit count; number of unused low-order bits in last word of previous record. |
tran | 10 | Transparent record field (unused). |
bdf | 11 | Bad data flag (unused). |
srs | 12 | Skip remainder of sector (unused). |
pfi | 20-39 | Previous file index; offset modulo 220 to the block where the current file starts (as defined by the last EOF). |
pri | 40-54 | Previous record index; offset modulo 215 to the block where the current record starts. |
fwi | 55-63 | Forward index; the number of words to next control word. |
| Prev Section | Table of Contents | Title Page | Next Section |
| Text file structure | Up one level | Tape/bmx file structure |