Hi, the attached code suggests that the implementation does not conform to the F2003 standard w.r.t. the POSITION= specifier.
The standard says: 9.9.1.22 POSITION= specifier in the INQUIRE statement [...] If the file has been repositioned since the connection, the scalar-default-char-variable is assigned a processor-dependent value, which shall not be REWIND unless the file is positioned at its initial point and shall not be APPEND unless the file is positioned so that its endfile record is the next record or at its terminal point if it has no endfile record. In my interpretation of the above wording, when positioned at the endfile record, the result should be APPEND. The attached program shows that the current libgfortran returns ASIS in this case. REWIND obviously works correctly. The test program generates and then reads a file with a single line. After reaching the end of file, it rewinds and reads again. The output is: Generating test file containing one text line Open file inquire: position = ASIS nextrec = 1 Reading... Read line 1 : iostat = 0 inquire: position = ASIS nextrec = 2 Read line 2 : iostat = -1 inquire: position = ASIS nextrec = 2 Rewind file inquire: position = REWIND nextrec = 1 Reading... Read line 1 : iostat = 0 inquire: position = ASIS nextrec = 2 Read line 2 : iostat = -1 inquire: position = ASIS nextrec = 2 In both cases, after attempting to read line 2, the INQUIRE should return position = APPEND instead of ASIS. -- Summary: INQUIRE(...,POSITION=...) not standard conforming Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: anlauf at gmx dot de GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31532