(j3.2006) Partial write in record with nonadvancing I/O
Mon Feb 27 21:03:36 EST 2012
On Mon, 2012-02-27 at 16:11 -0800, Robert Corbett wrote:
> On 02/27/12 12:50, Van Snyder wrote:
> > I have a vague recollection that at least some processors prohibited
> > read-after-write and write-after-read without an intervening REWIND
> > statement. As far as I can determine, there's no such prohibition in
> > any standard.
> The C standard imposes a similar prohibition. The Fortran standard
> permits a processor to signal an input/output error condition for
> cases that are difficult or impossible to handle.
> > But... did we really intend that write-after-nonadvancing-read would be
> > permitted? If so, we really ought to define it more precisely.
> The Fortran standard defines what the program I posted to
> comp.lang.fortran should write (ignoring the possibility of
> processor-defined input/output error conditions). What do
> you think should be defined more precisely?
I disagree that the standard defines what the program ought to write.
It's not obvious at all to me whether "MNOP" should be embedded within
the first record in the file, or should be a second record.
If it should be embedded in the first record, it's not obvious whether
the "IJKL" should be included in that record.
Fortran sequential I/O was originally designed for use with tape. Using
tape, the program in Tobias's example would produce two records, with
"ABCDEFGHIJKL" in the first one, and "MNOP" in the second one, since
it's impossible to overwrite the first record without backspacing, i.e.,
the output from set (c) of processors. It's not obvious whether "MNOP"
would be in position 1 or 3 of the second record.
It should be clear, but it's not, whether write-after-nonadvancing-read
modifies the current record at the current position, where "current
record" was established by the most recent READ statement, or it starts
a new record.
If it should modify the current record, it should be clear, but it's
not, whether the contents of the record include everything read by the
nonadvancing read, or only everything up to the last position written
within the record.
9.8.3 says "Execution of an ENDFILE statement for a file connected for
sequential access writes an endfile record as the next record of the
file." It isn't at all clear whether the current position is the last
position written in the record, or the last position read, or the
maximum of the two, and whether the end of the record is the current
position of the record if one has read a record and then written part of
it using nonadvancing output and a T edit descriptor, as in the example
in Tobias's recent message.
It would be interesting to see the output, using several processors,
from a program similar to Tobias's, but with "WRITE ( 10, * )" inserted
between the final WRITE statement and the second REWIND statement in
that program, or with "FLUSH ( 10 )" inserted at that point, and to know
what the standard specifies the output ought to be.
22.214.171.124p6 says "During ... termination of execution of a program, all
units ... are closed." The discussion of "status" in the second
sentence implies "as if by execution of a CLOSE statement..." but
doesn't come right out and say so.
It's not specified in 9.5.7 or 9.8.3 or 9.8.4 whether execution of a
CLOSE or REWIND statement for a file connected for WRITE or READWRITE
action includes the effect of executing a FLUSH statement and then an
> Bob Corbett
More information about the J3