For an empty input list, the cursor is moved to the start of the line following the input. When the input list is exhausted, the cursor is moved to the start of the line following the input. The above two forms operate the same way as the others, except that reading from the keyboard is implied. If s is specified and an error occurs, control is transferred to s. If s is specified and end of file was encountered, control is transferred to s. Ios is set to a positive value, if an error or end of file was encountered.
If ios is specified and no error occurred, it is set to zero. The file is repositioned appropriately after data transfer. In the third and fourth forms of namelist-directed READ, the items of the specified namelist group are processed according to the rules of namelist-directed input. Data editing in formatted READ is done according to the specified format. The next specified item is determined and the value read is transmitted to it. The items are processed in order as long as the input list is not exhausted. If the input list is not empty, data is transferred from the file to the corresponding items in the list. The file is positioned appropriately prior to the data transfer. The format, if specified, is established.
The file associated with the specified unit is determined. The third and fourth forms of the READ statement are used to read the items of the specified namelist group, and grname is the name of the group of variables previously defined in a NAMELIST statement. Implied DO lists are described on "Implied DO Lists". The input items can be any of the following:Ī simple unsubscripted array name specifies all of the elements of the array in memory storage order, with the leftmost subscript increasing more rapidly. Iolist can be empty or can contain input items or implied DO lists. S must be the label of an executable statement in the same program unit in which the READ statement occurs. The END= s and REC= rn specifiers can be present in the same READ statement. Rn must be a positive integer expression, and can be used for direct-access files only. Ios must be an integer variable or an integer array element. a file is connected for formatted I/O, unformatted data transfer is not allowed, and vice versa. List-directed data transfer from direct-access and internal files is allowed hence, f can be an asterisk for such files. Unformatted data transfer from internal files and terminal files is not allowed, hence, f must be present for such files. If the optional characters, FMT=, are omitted from the format specifier, then f must appear as the second argument for a formatted read otherwise, it must not appear at all. "Runtime Formats " for details on formats evaluated at runtime. This is called a runtime format or a variable format. See "List-Directed I/O " for more information.Ī label of a FORMAT statement that appears in the same program unitĪn integer variable name that has been assigned the label of a FORMAT statement that appears in the same program unitĪ character expression or integer array specifying the format string. Format IdentifierĪn asterisk ( *), indicating list-directed I/O. If the optional characters UNIT= are omitted from the unit specifier, then u must be the first item in the list of specifiers. U is either an external unit identifier or an internal file identifier.Īn external unit identifier must be one of these:Īn asterisk ( *), identifying stdin, normally connected to the keyboard The READ statement accepts the following arguments. The options can be specified in any order.
Statement label for end of file processingĪn alternate to the UNIT= u, REC= rn form is as follows: u 'rn. Unit identifier of the unit connected to the file See the Fortran Library Reference Manual. Use the TOPEN() routines to read from tape devices. The READ statement reads data from a file or the keyboard to items in the list.