FOR1910S
locator-text The end of the file was reached. Fortran Version 2 Error Number: AFB200I, AFB217I

Explanation

The execution of the READ statement requested that a record be read even though the file was already positioned beyond the last data record in the file.

This is the end-of-file condition and might not be an error.

For a READ statement that specified namelist formatting, this also could have occurred for the following reason: For the namelist group name given in the FMT specifier on the READ statement, there was no corresponding namelist group in the input file at a point beyond where the file was already positioned. Some syntax error within the input file, such as a missing &END delimiter or a missing quote or apostrophe delimiter, might have caused the namelist group to treated as part of some other construct and thus appear as though it wasn't in the input file.

locator-text gives more information about the location of the error, and can be one of the following:
  • The statement statement for an internal file failed.
  • The statement statement for unit unit-number, which was connected to file-name, failed.

where statement is READ.

System action

If the IOSTAT=ios specifier is present on the READ statement, ios becomes defined either with the value -1 if ios is an integer variable or with the condition token for FOR1910 if ios is a character variable of length 12. If the END=stl specifier is present on the READ statement, control passes to the label stl. If neither the END nor the IOSTAT specifier is present on the READ statement, the condition is signaled. If the condition is unhandled, the application is terminated.

Qualifying Data: Only the basic set of four qualifying data for I/O conditions as shown in Table 1. Within this basic set, statement has a value of READ, and parm_count has a value of 4.

Permissible Resume Actions:

Name Action Taken after Resumption
RN The I/O operation is not completed, and execution continues.
RF If the error occurred on a READ statement for sequential access to an unnamed file that is neither VSAM nor striped, the data set sequence number is increased by 1 and the next subfile is read; otherwise, execution continues.

Programmer response

Ensure that the READ statement refers to the unit that you intended, that the unit is connected to the file that you intended, and that the file definition (DD statement or ALLOCATE command) or the data set name given in the FILE specifier on the OPEN statement refers to the file that you intended. Also ensure that the file was created successfully, either in a program or by some manual process such as an editor.

If the file is the one you want to read, modify the program to detect the end of the file in one of these ways:
  • Use the END specifier on the READ statement so that your program can gain control at some specific label when the end-of-file condition occurs.
  • Use the IOSTAT specifier on the READ statement so that upon completion of the READ statement your program can determine whether the end-of-file condition occurred. A value of -1 in the variable given in the IOSTAT specifier indicates that the end-of-file condition occurred.
  • If you know the number of records in the file before reading them, maintain a count of the number of records read so that your program doesn't attempt to read beyond the last data record.
If your program uses statements that position the file, ensure that the logic of the program and the contents of the file don't cause the file to be inadvertently positioned to the wrong place. The following statements affect the position within the file:
  • ENDFILE
  • BACKSPACE
  • REWIND
  • OPEN with a POSITION specifier that has a value of APPEND
  • READ statement, even with no input item list
  • READ statement with a format specification that has a slash (/) edit descriptor
  • WRITE, which for sequential access causes the record that's written to become the last record in the file

In addition, if the DD statement has the DISP=MOD parameter or the ALLOCATE command has the MOD parameter, the file is positioned beyond the last data record when it's first connected.

If namelist formatting is requested on the READ statement because the FMT specifier refers to the a namelist group name declared in a NAMELIST statement, ensure that the namelist group indicated by the FMT specifier is actually in the file at some point beyond the current position. (There's no attempt to read through the entire file to find the namelist group; the search is only from the current file position.) In the file, identify the namelist group with an ampersand ( & ) followed by the namelist group name with no intervening blanks. Ensure that the ampersand begins in position 2 or later, and that all positions preceding the ampersand in the record are blank.

In a namelist input file, ensure that all namelist groups, especially any that precede the one referenced by the failing READ statement, are coded in the correct format. Remember that all information must start no earlier than position 2 of the records. Pay attention to all delimiters, such as commas, equal signs, quotes, and apostrophes, to ensure that they are used as required. Also ensure that each namelist group is ended by the characters &END.

Symbolic Feedback Code

FOR1910