Consider the following: Wot now ? cat da.f90 Program da Implicit None Real :: a, b a = 1.111111111 b = 2.222222222 Open( 10, File = 't.dat', Form = 'Formatted', Access = 'Direct', Recl = 12 ) Write( 10, rec = 1, fmt = '( f6.4, /, f6.4 )' ) a, b Close( 10 ) a = -1.0 b = -1.0 Open( 10, File = 't.dat', Form = 'Formatted', Access = 'Direct', Recl = 12 ) Read( 10, rec = 1, fmt = '( f6.4, /, f6.4 )' ) a, b Write( *, '( "Partial record 1", t25, 2( f6.4, 1x ) )' ) a, b Read( 10, rec = 1, fmt = '( f6.4 )' ) a, b Write( *, '( "Partial record 2", t25, 2( f6.4, 1x ) )' ) a, b Read( 10, rec = 1, fmt = '( f12.4, /, f12.4 )' ) a, b Write( *, '( "Full record 1", t25, 2( f6.4, 1x ) )' ) a, b Read( 10, rec = 1, fmt = '( f12.4 )' ) a, b Write( *, '( "Full record 2", t25, 2( f6.4, 1x ) )' ) a, b Read( 10, rec = 1, fmt = '( f6.4, 6x, /, f6.4, 6x )' ) a, b Write( *, '( "Full record with 6x", t25, 2( f6.4, 1x ) )' ) a, b Read( 10, rec = 1, fmt = '( f6.4 )' ) a Read( 10, rec = 2, fmt = '( f6.4 )' ) b Write( *, '( "Record at a time", t25, 2( f6.4, 1x ) )' ) a, b End Program da Wot now ? ~/Download/usr/local/gfortran/bin/gfortran --version GNU Fortran (GCC) 4.5.0 20091116 (experimental) [trunk revision 154218] Copyright (C) 2009 Free Software Foundation, Inc. GNU Fortran comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of GNU Fortran under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING Wot now ? ~/Download/usr/local/gfortran/bin/gfortran -W -Wall -pedantic -fbounds-check -g -O2 da.f90 Wot now ? ./a.out Partial record 1 1.1111 0.0000 Partial record 2 1.1111 0.0000 Full record 1 1.1111 2.2222 Full record 2 1.1111 2.2222 Full record with 6x 1.1111 2.2222 Record at a time 1.1111 2.2222 Wot now ? Note that when reading partial records gfortran gets the value of b wrong. Compare g95 and the sun fortran compiler: Wot now ? g95 --version G95 (GCC 4.0.3 (g95 0.92!) Mar 27 2009) Copyright (C) 2002-2008 Free Software Foundation, Inc. G95 comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of G95 under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING Wot now ? g95 -W -Wall -pedantic -fbounds-check -g -O2 da.f90 Wot now ? ./a.out Partial record 1 1.1111 2.2222 Partial record 2 1.1111 2.2222 Full record 1 1.1111 2.2222 Full record 2 1.1111 2.2222 Full record with 6x 1.1111 2.2222 Record at a time 1.1111 2.2222 Wot now ? f90 -V f90: Sun Fortran 95 8.4 Linux_i386 2009/06/03 Usage: f90 [ options ] files. Use 'f90 -flags' for details Wot now ? f90 da.f90 Wot now ? ./a.out Partial record 1 1.1111 2.2222 Partial record 2 1.1111 2.2222 Full record 1 1.1111 2.2222 Full record 2 1.1111 2.2222 Full record with 6x 1.1111 2.2222 Record at a time 1.1111 2.2222 I've also checked against the intel, portland group, pathscale and cray compilers and they all give what I think is the correct result, i.e. the same as g95 and the sun compiler Also sorry about screwing up the first attempt at submission !
*** Bug 42089 has been marked as a duplicate of this bug. ***
It's a regression with regards to 4.1.2. Jerry can you have a look?
Yes, I will have a look tonight.
Confirmed and have a patch.
Subject: Bug 42090 Author: jvdelisle Date: Thu Nov 19 04:50:04 2009 New Revision: 154316 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154316 Log: 2009-11-18 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/42090 * io/transfer.c (skip_record): Set bytes_left_subrecord to zero after skipping the remaining bytes in the record. (next_record_r): Call skip_record with the number of bytes_left to be skipped. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/transfer.c
Subject: Bug 42090 Author: jvdelisle Date: Thu Nov 19 05:27:15 2009 New Revision: 154317 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154317 Log: 2009-11-18 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/42090 * gfortran.dg/direct_io_11.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/direct_io_11.f90 Modified: trunk/gcc/testsuite/ChangeLog
Subject: Bug 42090 Author: jvdelisle Date: Fri Nov 20 04:00:03 2009 New Revision: 154355 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154355 Log: 2009-11-19 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/42090 Backport from trunk. * io/transfer.c (skip_record): Set bytes_left_subrecord to zero after skipping the remaining bytes in the record. (next_record_r): Call skip_record with the number of bytes_left to be skipped. Modified: branches/gcc-4_4-branch/libgfortran/ChangeLog branches/gcc-4_4-branch/libgfortran/io/transfer.c
Subject: Bug 42090 Author: jvdelisle Date: Fri Nov 20 04:02:33 2009 New Revision: 154356 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154356 Log: 2009-11-19 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/42090 * gfortran.dg/direct_io_11.f90: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/direct_io_11.f90 Modified: branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Subject: Bug 42090 Author: jvdelisle Date: Sat Nov 21 02:44:01 2009 New Revision: 154397 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154397 Log: 2009-11-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/42090 Backport from trunk. * io/transfer.c (skip_record): Set bytes_left_subrecord to zero after skipping the remaining bytes in the record. (next_record_r): Call skip_record with the number of bytes_left to be skipped. Modified: branches/gcc-4_3-branch/libgfortran/ChangeLog branches/gcc-4_3-branch/libgfortran/io/transfer.c
Subject: Bug 42090 Author: jvdelisle Date: Sat Nov 21 02:45:48 2009 New Revision: 154398 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154398 Log: 2009-11-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/42090 * gfortran.dg/direct_io_11.f90: New test. Added: branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/direct_io_11.f90 Modified: branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
Fixed and closing.