Problem reading unformated file and using ERR=
Brooks Moses
brooks.moses@codesourcery.com
Tue Nov 28 23:05:00 GMT 2006
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
More information about the Fortran
mailing list