Re: reading back a partially-written record on direct access



Thomas König wrote:

Is the following program standard-conforming?

PROGRAM test
IMPLICIT NONE
CHARACTER*8 as_written, as_read
INTEGER irec
INTEGER i
as_written = "12345678"
inquire (iolength=irec) as_written, i
OPEN (76, FILE="test.txt", ACCESS="DIRECT", STATUS="NEW",
& RECL=irec)
WRITE(76, REC=1) as_written
READ(76, REC=1) as_read, i
PRINT *, "as_written = ", as_written, " as_read = ", as_read
CLOSE(76)
END PROGRAM test

I don't think it is, because it reads something that wasn't written
(the variable i). On the other hand, i isn't used, so it may be OK.


9.5.3.4.1 "On output to a file connected for unformatted direct access,
the output list shall not specify more values than can fit
into the record. If the file is connected for direct access
and the values specified by the output list do not fill the
record, the remainder of the record is undefined."

The value of I is at least undefined.

-- glen

.



Relevant Pages