I hesitate to argue with the professionals and experts on such a
technical matter, but I've been reading through the standard and I can't
really find an airtight explanation of the process; it seems to me to
allow some room for interpretation, so regard this as nothing more than
my attempt at making sense of things.
On 15-2-2012 8:42, Tobias Burnus wrote:
> Dick Hendrickson<
dick.hen...@att.net> wrote:
>>> Different compilers are giving me different output for the following
>>>
>>> Write( *, '( t25 )', Advance = 'No' )
>>> Write( *, '( "Hello" )' )
>>
>> I think that only the version with 25 leading blanks is correct.
25 blanks or 24 blanks and "Hello" starting at position 25?
> [...]
>> There was an interpretation about Tabbing and next-records many years
>> ago; but I think it was related to the wording for what the new left-tab
>> position was.
>
> I have asked at the J3 mailing list and got a reply by Bob Corbett of Sun
> (now Oracle). He believes that the interpretation request (which he filled)
> is about this issue and that having 25 blanks is correct. There is a pending
> bug report for Oracle Solaris Studio Fortran; he had hoped to fix it for
> 12.3 but ran out of time.
>
> Lacking a convincing argument that column 1 is the correct one, I follow
> the crowd by believing that column 25 is correct. For GCC/gfortran, that's
> tracked as problem report (PR) 52251.
>
> The interpretation request is:
> 000027 "Sequential formatted I/O: position of the left tab"
> at
http://j3-fortran.org/doc/year/02/02-006c2.txt
>
> The crucial sentence (according to DISCUSSION) is:
> "Immediately prior to data transfer, the left tab limit becomes defined as
> the character position of the current record."
I don't see the left tab limit as the central point in this matter.
The way I understand it, the t edit descriptor in the first write
statement in the example doesn't _change_ the positioning of the file.
It only _specifies_ the position at which the next character will be
transferred. Since this is non-advancing output, the file positioning at
the start of the second write statement will be exactly the same as at
the start of the first write statement (i.e. at position 1 of the first
record), so the left tab limit will also be the same.
Now, when the next data transfer takes place, it will do so starting at
the position previously specified by the t edit descriptor.
So in my view the crucial matter is whether the specification made by
the t edit descriptor is persistent from one write statement to the
next. I don't see anything in the standard denying this. It simply states:
"The Tn edit descriptor indicates that the transmission of the next
character to or from a record is to occur at the nth character position
of the record, relative to the left tab limit."
Nothing about whether this transmission of the next character has to
actually take place during the same output statement.
Now that I'm thinking about it, I'm starting to wonder if this behaviour
should also hold for advancing output. Leaving out the advance specifier
from the first write statement would then lead to an empty record,
followed by a record containing 24 blanks and the string "Hello".
In this context I'm also wondering if there is any significance in the
difference in wording between the text for the Tn descriptor and that
for the TLn and TRn descriptors.
The first one speaks about "transmission of the next character to or
from A record" (emphasis mine), while the other two speak about
"transmission of the next character to or from THE record". This seems
to imply that, while TLn and TRn specifications are only valid within
the current record, the Tn specification remains valid even if the next
data transfer takes place in a subsequent record.
(I fear this interpretation is stretching it a bit, and that I'm reading
to much into this minute difference, but I can't get the idea out of my
head that there is significance to every word in the standard.)
All I know for sure right now, is that this is a tricky subject.
Erik.