Based on
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/cfb5f9dca46d5114#

After ENDFILE for non-streams, the current file position should be at the
endfile record. Thus, running the program below with NAG gives:
  READ/WRITE attempted after ENDFILE on unit 10
  Program terminated by I/O error on unit 10 (File="XXX",Formatted,Sequential)

And with Pathf95:
  A WRITE operation is invalid if the file is positioned after the end-of-file.

While with gfortran it simply runs. (Ditto for g95 and ifort.) [One could
continue to do so as extension, but one should do so knowingly.]


F2008: "9.8.3 ENDFILE statement"

"Execution of an ENDFILE statement for a file connected for sequential access
writes an endfile record as the next record of the file. The file is then
positioned after the end file record, which becomes the last record of the 
file. If the file also may be connected for direct access, only those records
before the endfile record are considered to have been written. Thus, only those
records may be read during subsequent direct access connections to the file.
   After execution of an ENDFILE statement for a file connected for sequential
access, a BACKSPACE or REWIND statement shall be used to reposition the file
prior to execution of any data transfer input/output statement or ENDFILE
statement.
   Execution of an ENDFILE statement for a file connected for stream access
causes the terminal point of the file to become equal to the current file
position. Only file storage units before the current position are considered to
have been written; thus only those file storage units may be subsequently
read. Subsequent stream output statements may be used to write further data to
the file.
   Execution of an ENDFILE statement for a file that is connected but does not
exist creates the file; if the file is connected for sequential access, it is
created prior to writing the endfile record."


!-------------------------------------------
       OPEN(10, FILE='XXX', FORM='FORMATTED', &
                 ACTION='WRITE', POSITION='REWIND')
        ENDFILE(10)
      write(10,*) 'aa'
end


-- 
           Summary: Sequential I/O with END FILE: File position should be at
                    EoF
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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

Reply via email to