Re: Does this string processing work for you?
- From: "James Giles" <jamesgiles@xxxxxxxxxxxxxxxx>
- Date: Fri, 30 Sep 2005 02:19:11 GMT
Gary L. Scott wrote:
> Arjen Markus wrote:
>> But what happens with a loop like:
>>
>> read( s, *, err=1 ) ( v(i) ,i=7,100,3 )
>>
>> (By the way the final value of "i" with the Intel Fortran compiler
>> on Linux is 103)
>
> I would think that should be an error. 100 should be interpreted
> as a maximum range value that must not be exceeded. I've no idea
> of standard conformance though.
The loop operates 32 times ((100-7+3)/3) and leaves the
iteration variable set to the next value (that is the value as
incremented past the last in-bound pass through the loop
plus the stride). In this case, the value of I after the loop
is 103. That value is not used as the index of the array
within the loop, it's the value of the iteration value after
the loop terminates.
This is a carry over from the old days where loops were
always implemented by setting the value of the iteration
variable to the initial bound, performing the loop, incrementing
the iteration variable and testing whether to branch back to
the start of the loop or quit. Evidently, when you quit, the
value of the iteration variable was out of range - that is, the
first value encountered for which the loop *wasn't* performed.
Implied loops are, of course, possibly different. They don't
necessarily get executed at run-time at all. In fact, there may
be no looping as such. The above may use the implied loop
at *compile* time to determine which elements, and how many
are to be processed by the READ, and the implementation
may, at run-time just pass that slice of the array as a whole
object to the I/O library. The I/O routine will then fill
the array internally. Since it's processing the whole array,
any I/O error would have to be assumed to call into doubt
*all* the returned elements of the result. That is, indeed,
the semantics as specified by the standard: any I/O
error that happens during a READ means that *all* the
items on the I/O list are considered undefined. That seems
to me to be the correct design.
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
.
- References:
- Does this string processing work for you?
- From: David Frank
- Re: Does this string processing work for you?
- From: Herman D . Knoble
- Re: Does this string processing work for you?
- From: David Frank
- Re: Does this string processing work for you?
- From: Arjen Markus
- Re: Does this string processing work for you?
- From: David Frank
- Re: Does this string processing work for you?
- From: Dan Nagle
- Re: Does this string processing work for you?
- From: David Frank
- Re: Does this string processing work for you?
- From: Arjen Markus
- Re: Does this string processing work for you?
- From: Gary L. Scott
- Does this string processing work for you?
- Prev by Date: Re: OOP with FORTRAN
- Next by Date: Re: compilation cascades and new Fortran features
- Previous by thread: Re: Does this string processing work for you?
- Next by thread: Re: Does this string processing work for you?
- Index(es):
Relevant Pages
|