public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/42090]  New: Problems when reading partial records in formatted direct access files
@ 2009-11-18  9:04 ian dot bush at nag dot co dot uk
  2009-11-18 10:57 ` [Bug fortran/42090] " burnus at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: ian dot bush at nag dot co dot uk @ 2009-11-18  9:04 UTC (permalink / raw)
  To: gcc-bugs

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 !


-- 
           Summary: Problems when reading partial records in formatted
                    direct access files
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian dot bush at nag dot co dot uk


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-11-21  3:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-18  9:04 [Bug fortran/42090] New: Problems when reading partial records in formatted direct access files ian dot bush at nag dot co dot uk
2009-11-18 10:57 ` [Bug fortran/42090] " burnus at gcc dot gnu dot org
2009-11-18 11:03 ` [Bug fortran/42090] [4.3/4.4/4.5 Regression] I/O: " burnus at gcc dot gnu dot org
2009-11-18 18:04 ` jvdelisle at gcc dot gnu dot org
2009-11-19  3:49 ` jvdelisle at gcc dot gnu dot org
2009-11-19  4:50 ` jvdelisle at gcc dot gnu dot org
2009-11-19  5:27 ` jvdelisle at gcc dot gnu dot org
2009-11-20  4:00 ` jvdelisle at gcc dot gnu dot org
2009-11-20  4:03 ` jvdelisle at gcc dot gnu dot org
2009-11-21  2:44 ` jvdelisle at gcc dot gnu dot org
2009-11-21  2:46 ` jvdelisle at gcc dot gnu dot org
2009-11-21  3:33 ` jvdelisle at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).