Aleksandar Donev writes:
> I have only used NAMELISTs with Lahey so far, and the process is as
> follows: I put all my namelist input in one file, and then REWIND before
> trying to read a namelist, and simply issue the READ statement. This way
> I avoid issues of ordering of the namelists in the file and the order of
> reading, which changes from run to run.
>
> It was my understanding this is what F95 says this is all OK. But NAG is
> now giving me a runtime error:
>
> Expected NAMELIST group /LSDPARTICLESHAPES_DHS/ but found /LSDPACKINGSIZE/
>
> which means it does not skip over the other namelists while looking
> for LSDPARTICLESHAPES_DHS as I expected.
I don't see anywhere that F95 says anything like that. I'm aware that
it is a reasonably common implementation extension, but I don't see
that the standard specifies it (and I'm pretty sure that this is
because the standard doesn't specify it, rather than just because I'm
overlooking it). The F90/f95 namelist is very simplified compared to
some implementations. It is sort of a lowest common denominator.
Yes, the f95 standard says that the namelist input start with
an ampersand and the namelist group name. And yes, this would
provide sufficient information for an implementation to do that
if it wanted, but nowhere do I see even a hint of the standard
specifying that. The only thing it shows as allowed before the
ampersand and group name is "Optional blanks and namelist comments".
Nothing about other namelists, etc.
Just because the standard says that the namelist has to start with
that particular group name, that doesn't imply anything about
requiring the standard to skip forward until it finds such a thing.
Debates about whether that would be a good thing for the standard
to specify are another matter, but for now it is much simpler - the
standard doesn't specify that.
By the way, there are 2 (or more) sides to the question of whether
that would be a good specification to add. With that behavior, a
trivial typo in an input stream with multiple cases could just cause
the bad case to be quietly skipped without any kind of error. There
are no other input forms in which input that doesn't match
expectations is quietly skipped until something matching is
found.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|