• Aucun résultat trouvé

READ (Unformatted, sequential Access) READ statement-Unformatted with Sequent i al Access

Dans le document VS FORTRAN (Page 163-166)

This READ statement transfers data without conversion from an external I/O device into internal storage. The data resides on an external file that is connected for sequential access to a unit (see "OPEN Statement" on page 132).

The sequential I/O statements without format control process records one after the other from the beginning of an external file to its end.

The ENDFILE, REWIND , and BACKSPACE statements may be used to manipulate the file.

syntax

READ ( [UNIT=lyo [, ERR=stnl [, END=stnl [, IOSTAT=iosl ) [list]

UNIT=un

YO is required. It can optionally be preceded by UNIT=. YO is an unsigned integer expression of length 4 (or an asterisk (*». It is the reference to an I/O unit. An asterisk C*) represents an installation~dependent unit.

If UNIT= is not included , YO must appear first in the statement. The other parameters may appear in any order.

If UNIT= is included , all the parameters can appear in any order.

ERR=stn

stn is the number of a statement in the sa.me program un it as the READ statement. Transfer is made to stn if an error is detected.

END=stn

is the number of an executable statement in the program unit containing the READ statement. Transfer is made to stn when the end of the external file is encountered.

IOSTAT=ios

i os is an integer vari able or an integer array element. Its value is positive if an error is detected; negative if an end of file is encountered; and zero if no error condition is detected. VSAM return and reason codes are placed in ios.

is an I/O list. It can contain variable names, array element

names, character substring names , array names,

and

implied

DO 1 i sts.

Valid READ statements:

READ (.Y!l) 1 i st READ (UNIT=gn) list READ (YD.)

READ (IOSTAT=IOS , UNIT=II)

Invalid READ statements:

READ un, 1; st READ, list

gn must be in parentheses.

(yo) must be included.

READ (Unformatted, Sequential Access)

not connected to a file, it is assumed to have been preconnected through job control language and an implicit OPEN is performed to a default file name. If the file is not preconnected, an error is detected.

DATA TRANSMISSION: A READ statement without conversion starts data transmission at the beginning of a record. The data specified by the item in the list is taken from the record and transmitted into the storage associated with the corresponding item in the list. Data transmission stops when data has been transmitted to every item of the list or when the end of file is reached.

If the list is not specified, a record is passed over without transmitting any data.

DATA AND I/O LIST: If the record contains more data than is

necessary to satisfy all the items of the list, the extra data is skipped over. The next READ statement without format will start with the next record if no other I/O statement is executed on that file. If the record contains less data than is necessary' to

satisfy the list, an error is detected.

Transfer is made to the statement specified by ERR if an error is detected. No indication is given of which record or records could not be read, only that an error occur~ed during transmission of data. If IOSTAT=ios is specified, a positive integer value is assi gned to i os when an error is detected. Then execu.t ion continues with the statement- specified with ERR, if present or wi th the next statement if ERR is not speci fi ed. If ERR and IOSTAT are both omitted, program execution is terminated when an error is detected.

END OF FILE: Transfer is made to the statement specified by END when the end of the file is encountered; that is, when a READ statement is executed after the last record on the file has already been read. No indication is given of the number of list

items read into before the end of the file was encountered. If IOSTAT=ios is specified, a negative integer value is assigned to ios when an end of file is detected. Then execution continues with the statement specified with END if present, or with the next statement if END is not specified. If END and IOSTAT are both omitted, program execution is terminated when the end of the file i s encountered.

154 VS FORTRAN language Reference

READ (Internal) READ statement with Internal Files

This READ statement transfers data from one area of internal storage into another area of internal storage. The user specifies in a FORMAT statement (or in a reference to a FORMAT statement) the conversions to be performed during the transfer. The area in internal storage that is read from is called an internal file.

An internal file is always

• Connected to a unit

• Positioned before data transmission at the beginning of the storage area represented by the unit identifier

• Accessed sequentially with a FORMAT statement (see "FORMAT Statement" on page 87)

Syntax

READ ( [UNIT=lyo, [FMT=lfmt [, ERR=stnl [, END=stnl [, IOSTAT=ios] ) [list]

UNIT=un

un is the reference to an area of internal storage called an internal file. It can optionally be preceded by UNIT=. It can be the name of:

A character variable A character array

A character array element A character substring

Its length must not be specified as an asterisk.

If UNIT= is included, FMT= must be used. If UNIT= is not included, the unit reference must appear first.

FMT=fmt

fmt is a required format identifier. It can optionally be preceded by FMT=.

The format identifier can be:

A statement number An integer variable A character constant A character array element A character expression

IBM EXTENSION An array name

END OF IBM EXTENSION _ _ _ _ _ _ _ _ .----J See "READ Statement-Formatted wi th Di rect Access" on page 144 for explanations of these format identifiers.

The format specification must not be!

• In the area .Y.!l.

• Associated with YO through EQUIVALENCE, COMMON or argument passing.

If FMT= is not included, the format specification must appear second.

READ (Internal)

elements, character substring names, array names, implied DO lists, and expressions.

DATA TRANSMISSION:

An internal READ statement starts data

transmission at the beginning. of the storage area specified by yo. character variable, character substring name, character array element specifified by yo when the READ statement is executed.

156 VS FORTRAN Language Reference

Dans le document VS FORTRAN (Page 163-166)

Documents relatifs