From: John on
Thanks. Since "Format reversion always causes a new record; there are
no exceptions"; backed up by
your chain of standard references seems to have quelled the dissent,
we will report the various
deviations by some compilers as bugs. As a footnote, some of the
confusion came from the f2008
section C.7.1, which uses the term "format rescan" instead of "format
reversion" and, as you guessed,
from extension behaviors such as "$" in a format and non-standard
stream I/O behavior. Plus, not
everyone had used reversion much (and some have ~50 years FORTRAN
experience).


On Dec 28, 12:55 am, nos...(a)see.signature (Richard Maine) wrote:
> John <urbanj...(a)comcast.net> wrote:
> > Anyhow, the result is we are having a local difference of opinion on
> > when to expect a newline to be generated when re-using a format when a
> > single non-advancing I/O and/or implied DO's write statement
> > "exhausts"
> > the format; ESPECIALLY if formatted stream I/O is used (in particular,
> > should a WRITE(IO,*) be equivalent to calling the NEW_LINE() function
> > when writing to a stream?).
>
> First, it makes no difference whether you are using stream or not. You
> won't find a hint of any such difference anywhere in the standard.
>
> Stream doesn't even change the default for the advance specifier. See
> 9.5.1.3 (ADVANCE= specifier in a data transfer statement) in F2003. The
> last sentence is
>
>   "If this specifier is omitted from an input/output statement that
>    allows the specifier, the default is YES."
>
> Note that there are no conditions relating to stream versus sequential.
> The default is just YES. The condition about statements that allow the
> specifier is for things like internal I/O.
>
> Second, even if one explicitly specifies ADVANCE='no', that has no
> effect on reversion of format. Advancing versus non-advancing I/O
> affects only whether the record is terminated at the end of the output
> statement. It has no effect on new records arising from explicit "/"
> edit descriptors or reversion of format (or from writing newline
> characters in stream output).
>
> See the 3rd para after Note 10.5 in F2003. That's the para that
> describes format reversion. Skipping over the bits that describe when
> reversion happens and how it interacts with I/O list elements, we find
>
>   ".. the file is positioned in a manner identical to the way it is
> positioned what a slash edit descriptor is procesed..."
>
> Note there are no conditions relating to advance='no, stream access, or
> anything of the sort. It just has the effect of a slash. Look in the
> section about slash. That would be 10.7.2. Not only doesn't it exclude
> stream I/O, it specifically includes it.
>
>   "On output to a file connected for sequential or stream acess, a new
> empty record is created following the current record."
>
> I don't see how one could plausibly misread this stuff. Now if one were
> to try to just guess the behavior, or possibly extrapolate from
> nonstandard extensions to f77, one might come to different conclusions.
> But I don't see much wiggle room on this in the standard.
>
> Do note that there is a difference between format reversion (what you
> are calling reuse) and just comming to the end of the i/o list. Format
> reversion always causes a new record; there are no exceptions. Comming
> to the end of the i/o list causes a new record depending on the setting
> of advance (which does not depend on stream versus sequential).
>
> --
> Richard Maine                    | Good judgment comes from experience;
> email: last name at domain . net | experience comes from bad judgment.
> domain: summertriangle           |  -- Mark Twain