http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52387

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-29 
13:02:21 UTC ---
I think it get's even messier with the following, simpler looking code, which
consists of four variants (without read/with nonadvanced read -- and with
advanced/nonadvanced write):


  OPEN (10, FILE='XXX', status='replace')
  WRITE(10, '(a)') 'ABCDEFGHIJKL'
  WRITE(10, '(a)') '1234567890ab'
  close (10)

  OPEN (10, FILE='XXX', position='REWIND', status='old', &
        action='readwrite') ! or 'write'
!      READ(10, '(tr4)', advance='no') ! << add optionally
  WRITE (10, '(A)', ADVANCE='NO') 'mnop' ! << optional advance == 'yes'
  call FLUSH (10)
  call system ('cat XXX; echo "<"')
  close(10)
  call system ('cat XXX; echo "<"')
end

[With "call flush"->"flush", "system"->"execute_command_line", it should be
F2008 standard conforming.]


-----------------------------------------

With the Cray/Open64/Pathscale compiler, one gets for instance the following:

Without READ:
mnopEFGHIJKL
1234567890ab
<
mnop
<

And with READ (and also with advance='yes') [that's Bobs example, presumably
with the output he expects]:
ABCDmnopIJKL
1234567890ab
<
ABCDmnopIJKL
<

However, without READ and advance='yes' for WRITE, one gets:
MNOP
FGHIJKL
1234567890ab
<
MNOP
<


-----------------------------------------

By contrast, gfortran has for WRITE:
MNOP<
MNOP
<

And for READ:
ABCDMNOP<
ABCDMNOP
<

That's for advance='no'. With advance='yes', each line ends with a line break.

Reply via email to