Direct I/O

Direct I/O is indicated when direct files and direct arrays are used.

Direct I/O allows more direct control of the actual I/O operations. In certain situations, avoiding suspension of the program is desirable. In other situations, nonstandard I/O operations and masking of certain types of error conditions which could arise are desirable.

When direct I/O is used, the program is responsible for the buffering, blocking, and translation.

The syntax for a direct read or direct write operation employs the <arithmetic expression>, <array row> form of <format and list part>. An event designator is the only allowable form of action labels or finished event for direct I/O. The value of the arithmetic expression has the following meaning:

Field

Contains

[16:17]

Number of words to be transferred

[19:3]

Number of trailing characters to be transferred

The array row is called the I/O area of the user. A direct array identifier must be used for the <array name> part in the array row construct. Thus, the following statement could be used to perform a direct read of 10 words from file FID into direct array A using the event EVT as the finished event:

READ(FID, 10, A[*]) [EVT]

The operating system establishes a relationship between the I/O area and the finished event, if one is specified. Before any subsequent use of the I/O area can be made in the program, either for calculations or for further I/O, the direct I/O operation must be finished.

The finished event can be inspected by one of the following methods:

  • By using the HAPPENED function

  • By obtaining the value of the STATE file attribute using the WAIT statement as a Boolean function and specifying a direct array row as a parameter

  • By using the WAIT statement on the event to deactivate the process until the event is caused

Once the operation has been completed, the happened state of the event should be set to FALSE (not happened) before reusing it. Refer to WAIT Statement for more information.

The finished event can be associated with a direct array row that is declared in a different block. For example, a formal event can be associated with a local array. Such an association can cause compile-time or run-time up-level event errors if the block containing the finished event can be exited before the block that contains the direct array is exited.

In direct I/O, the I/O operations analogous to the SPACE and REWIND statements are performed as if they were read or write operations, except that the IOCW direct array attribute is specifically assigned the proper hardware instructions for the operation.

When performing direct I/O with the SPACE operation, the device's spacing limitation overrides any user-specified spacing. In the case of a line printer, this limitation is two.