This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem reading unformated file and using ERR=


Chris Talley wrote:
I've been helping a co-worker attempt to compile and run a legacy CFD code using gfortran from the 4.2-20061031 (prerelease) build. When reading an unformatted sequential file, the CFD code uses a statement as follows:

READ(1,ERR=10,END=100) I,J,K

The original intent of the ERR specifier was to jump to label 10 if an end-of-record occurred before all the requested data was read. This works as intended using the NAG F95 compiler; however, using gfortran the code jumps to label 100. If the END=100 specifier is remove, gfortran gives a runtime end-of-file error. Is this a bug or am I doing something wrong? Below is a test program and its resulting output.

This is a bug; I've filed it as PR 30010.


However, I think it's worth noting that "end-of-record condition" is only a concept that applies to formatted files. What you have here is an unformatted record with an insufficient number of elements in it, which is an "error condition".

(Incidentally, note that on a formatted file, an end-of-record condition is not an error condition, and if you specify ERR= but not EOR=, the program should terminate; see the last paragraph of section 9.4.3 of the F95 standard.)

- Brooks


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]