On Saturday, February 25, 2023 at 7:05:37 AM UTC-8, Ron Shepard wrote:
(snip)
> > 12.8.2:
> > " Backspacing over records written using list-directed or namelist formatting is prohibited."
> This seems to me to be a very strange and overly broad restriction. Even
> if records had been written with list-directed or namelist i/o, in the
> end, they are just records in a file: strings of characters with line
> separators. It seems like one should be able to use normal i/o
> operations thereafter on those records. In fact, for an old file, one
> might not even know exactly how some of the records had been written
> (text editor, shell script, C program, fortran program, etc.). But this
> restriction implies that once written by fortran list-directed i/o, they
> are tainted forever after, even through multiple open and close
> statements or even if opened at some time later in a completely
> different program.
In the case of an actual FORMAT, either a FORMAT statement,
or string constant or variable, the number of records written
by a WRITE statement, or read by a READ statement is known.
(Might be variable with implied-DO, but the variable is known.)
In the case of NAMELIST or list-directed, it isn't.
The standard is a little broader than it could be, but not much.
To be less broad, it would have to define exactly the cases where
you could, and could not, depend on the number of records.
(I believe that WRITE(*,*), and READ(*,*) reliable write and read
one record. Past that, you can't say much.)
Reminds me in Fortran 77 (and VAX/VMS) days, I was reading
in some X, Y data.
READ(5,1,END=2) (X(I), Y(I), I=1,N)
and expecting N to be one more than the number of items read.
In actual DO loops, the DO variable keeps its value when it leaves
the loop. Seems like it should for implied-DO. I even had a
blank DEC bug report form to fill out.
But the standard doesn't require that.