Re: Short records on unformatted reads
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 00:35:11 -0800
Thomas Koenig wrote:
(snip)
If I replace the line
read (10, err=20) ia with
read (10, err=20) ia(1), ia(2)
or
read (10, err=20) (ia(i),i=1,2)
(and add integer::i as appropriate above)
then I would expect ia(1) to be defined, though.
More likely, but still not required.
The one I remember from many years ago when it happened to me
on a DEC compiler, (I think VAX/VMS V4 or so) something like:
READ(5,*,END=3) (A(J),J=1,100)
I expected that when the END= exit was taken that the elements
of A(I) that had been read would be assigned, and that J would
be one more than the last index stored. This was before the
web, almost before internet, and I had no access to a copy of
the standard. I thought about sending in a bug report to DEC,
but never did.
I found out later (mostly from this group) that the standard
didn't, and doesn't, require that. Implied DO is not a DO
loop that keeps its value on exit.
With either an array or with an implied DO it might be done on
one call to the I/O routine, which may then take the END=
exit before storing anything. With ia(1),ia(2) it will more likely
be two calls to the I/O routine, which may store ia(1) before
returning, but it is not required. There is no legal way to determine
that it did or didn't, either.
It was not much later that I started working with C (on a unix machine),
and finding that C made some low level I/O problems much easier may have
been one reason I started doing more in C. The equivalent C routines,
either formatted or unformatted, do guarantee that you get all the values before error or EOF, and that you can find out how many you got.
-- glen
.
- References:
- Short records on unformatted reads
- From: Thomas Koenig
- Re: Short records on unformatted reads
- From: Richard Maine
- Re: Short records on unformatted reads
- From: Thomas Koenig
- Short records on unformatted reads
- Prev by Date: Re: (very) slow recursive function
- Next by Date: IEEE intrinsic modules
- Previous by thread: Re: Short records on unformatted reads
- Next by thread: (very) slow recursive function
- Index(es):
Relevant Pages
|
|