Assume I have a file (e.g. created via 'line1'//new_line('a')//'line2'):
---------------
line1
line2
---------------
what shall the following program print?
program stream
implicit none
character(len=50) :: r1,r2
open(10,file='test.dat',form='formatted',access='stream',status='old')
read(10,'(a)') r1
read(10,'(a)') r2
print *, ':',trim(r1),':'
print *, ':',trim(r2),':'
end program stream
NAG f95 prints:
---------------
:line1:
:line2:
---------------
gfortran prints:
---------------
:line1
line2
:
::
---------------
I think NAG f95 is right as I find in Fortran 2003, section 10.6.3:
"If the file is connected for stream access, the output may be split
across more than one record if it
contains newline characters. A newline character is a nonblank
character returned by the intrinsic
function NEW LINE. Beginning with the first character of the output
field, each character that is not
a newline is written to the current record in successive positions;
each newline character causes file
positioning at that point as if by slash editing (the current record is
terminated at that point, a new
empty record is created following the current record, this new record
becomes the last and current record
of the file, and the file is positioned at the beginning of this new
record)."
But I'm not 100% sure, whether I read this correctly (or whether this is
the right place in the standard).