[Bug fortran/37129] New: Problems with access='direct', recl=1 I/O
huwaldtj at saic dot com
gcc-bugzilla@gcc.gnu.org
Fri Aug 15 14:17:00 GMT 2008
In porting legacy Fortran 77 code to gfortran, I encountered an issue that can
be boiled down and reproduced with the following code:
INTEGER*4 HDRPOS,CURPOS
OPEN(UNIT= 9,FILE='fort.9',ACCESS='DIRECT', STATUS='NEW',
& FORM='UNFORMATTED',RECL=1)
INQUIRE(UNIT=9, NEXTREC=HDRPOS)
WRITE(9,REC=HDRPOS) 1,2,3
INQUIRE(UNIT=9, NEXTREC=CURPOS)
WRITE(9,REC=CURPOS) dble(4),dble(5),dble(6)
END
Historically, g77 compiles and runs this code with the behavior expected by the
original authors of the program; a set of three 4 byte integer values are
written followed by a set of three 8 byte double values. gfortran compiles the
code without warning, but at runtime gives the error:
At line 8 of file test.f (unit = 9, file = 'fort.9')
Fortran runtime error: Write exceeds length of DIRECT access record
It appears that gfortran does not interpret recl=1 the way many historic
compilers, including g77, did. So, this bug report is to request that recl=1
be interpreted to mean that the compiler should use the I/O list to determine
how many items to read or write as g77 apparently did.
Detailed information on my setup follows:
gfortran -v -save-temps -Wall test.f
Driving: gfortran -mmacosx-version-min=10.5.4 -v -save-temps -Wall test.f
-lgfortranbegin -lgfortran -shared-libgcc
Using built-in specs.
Target: i386-apple-darwin9.2.0
Configured with: ../gcc-4.4-20080509/configure --enable-languages=fortran,c++
Thread model: posix
gcc version 4.4.0 20080509 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.5.4' '-v' '-save-temps' '-Wall'
'-shared-libgcc' '-mtune=generic'
/usr/local/libexec/gcc/i386-apple-darwin9.2.0/4.4.0/f951 test.f -ffixed-form
-fPIC -quiet -dumpbase test.f -mmacosx-version-min=10.5.4 -mtune=generic
-auxbase test -Wall -version -fintrinsic-modules-path
/usr/local/lib/gcc/i386-apple-darwin9.2.0/4.4.0/finclude -o test.s
GNU Fortran (GCC) version 4.4.0 20080509 (experimental)
(i386-apple-darwin9.2.0)
compiled by GNU C version 4.4.0 20080509 (experimental), GMP version
4.2.1, MPFR version 2.2.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.5.4' '-v' '-save-temps' '-Wall'
'-shared-libgcc' '-mtune=generic'
as -arch i386 -force_cpusubtype_ALL -o test.o test.s
COMPILER_PATH=/usr/local/libexec/gcc/i386-apple-darwin9.2.0/4.4.0/:/usr/local/libexec/gcc/i386-apple-darwin9.2.0/4.4.0/:/usr/local/libexec/gcc/i386-apple-darwin9.2.0/:/usr/local/lib/gcc/i386-apple-darwin9.2.0/4.4.0/:/usr/local/lib/gcc/i386-apple-darwin9.2.0/
LIBRARY_PATH=/usr/local/lib/gcc/i386-apple-darwin9.2.0/4.4.0/:/usr/local/lib/gcc/i386-apple-darwin9.2.0/4.4.0/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.5.4' '-v' '-save-temps' '-Wall'
'-shared-libgcc' '-mtune=generic'
/usr/local/libexec/gcc/i386-apple-darwin9.2.0/4.4.0/collect2 -dynamic -arch
i386 -macosx_version_min 10.5.4 -weak_reference_mismatches non-weak -o a.out
-lcrt1.10.5.o -L/usr/local/lib/gcc/i386-apple-darwin9.2.0/4.4.0
-L/usr/local/lib/gcc/i386-apple-darwin9.2.0/4.4.0/../../.. test.o
-lgfortranbegin -lgfortran -lgcc_s.10.5 -lgcc -lSystem
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.5.4' '-v' '-save-temps' '-Wall'
'-shared-libgcc' '-mtune=generic'
--
Summary: Problems with access='direct', recl=1 I/O
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: huwaldtj at saic dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37129
More information about the Gcc-bugs
mailing list