This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/21621] New: Inconsistency with binary sequential output
- From: "P dot Schaffnit at access dot rwth-aachen dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 May 2005 13:44:43 -0000
- Subject: [Bug libfortran/21621] New: Inconsistency with binary sequential output
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi!
I think I've found something strange with binary data written SEQUENTIALly...
I was having trouble reading binary data written by gfortran, so I tried to read
that DIRECTly, and... it doesn't to work! (why?)
Here is a small example in f90, and (for the record the same thing in f77, which
worked with g77).
Can someone help me with that?
Thanks!
Philippe
PS: the f90 sources:
!
PROGRAM Check_Record_Length
!
IMPLICIT NONE
!
INTEGER :: IO_Stat
INTEGER, PARAMETER :: Unit_Number = 13
INTEGER, PARAMETER :: Record_Length = 16
! INTEGER, PARAMETER :: Record_Length = 20
INTEGER :: Record_Length_1
INTEGER :: Record_Length_2
INTEGER :: Integer_Variable
!
REAL :: Real_Variable
DOUBLE PRECISION :: Double_Variable
!
CHARACTER ( LEN = * ), PARAMETER :: Name = "Binary_Data"
!
!
! Write 'sequential'
OPEN ( UNIT = Unit_Number, ACTION = "WRITE", FILE = Name, &
& FORM = "UNFORMATTED", ACCESS = "SEQUENTIAL" )
!
Real_Variable = 666
Integer_Variable = 13
WRITE ( UNIT = Unit_Number, IOSTAT = IO_Stat ) &
& Real_Variable, Integer_Variable
!
CLOSE ( UNIT = Unit_Number )
!
!
! Read 'sequential'
OPEN ( UNIT = Unit_Number, ACTION = "READ", FILE = Name, &
& FORM = "UNFORMATTED", ACCESS = "SEQUENTIAL" )
!
READ ( UNIT = Unit_Number, IOSTAT = IO_Stat ) &
& Real_Variable, Integer_Variable
!
WRITE ( 6, "(/G13.5,I13,2I13/)" ) Real_Variable, Integer_Variable
!
CLOSE ( UNIT = Unit_Number )
!
!
! Read 'direct'
OPEN ( UNIT = Unit_Number, ACTION = "READ", FILE = Name, &
& FORM = "UNFORMATTED", ACCESS = "DIRECT", RECL = Record_Length )
!
READ ( UNIT = Unit_Number, REC = 1 ) &
& Record_Length_1, Real_Variable, Integer_Variable, Record_Length_2
! & Record_Length_1, Double_Variable, Integer_Variable, Record_Length_2
! Real_Variable = Double_Variable
!
WRITE ( 6, "(/G13.5,I13,2I13/)" ) Real_Variable, &
& Integer_Variable, Record_Length_1, Record_Length_2
!
CLOSE ( UNIT = Unit_Number )
!
!
END PROGRAM Check_Record_Length
!
PPS: the f77 ones:
!
PROGRAM Check_Record_Length
!
IMPLICIT NONE
!
INTEGER IO_Stat
INTEGER Unit_Number
PARAMETER ( Unit_Number = 13 )
INTEGER Rec_Length
PARAMETER ( Rec_Length = 16 )
INTEGER Record_Length, Record_Length_1, Record_Length_2
INTEGER Integer_Variable
!
REAL Real_Variable
DOUBLE PRECISION Double_Variable
!
CHARACTER ( 11 ) Name
PARAMETER ( Name = "Binary_Data" )
!
!
! Write 'sequential'
OPEN ( UNIT = Unit_Number, FILE = Name,
& FORM = "UNFORMATTED", ACCESS = "SEQUENTIAL" )
!
Real_Variable = 666
Integer_Variable = 13
WRITE ( UNIT = Unit_Number, IOSTAT = IO_Stat )
& Real_Variable, Integer_Variable
!
CLOSE ( UNIT = Unit_Number )
!
!
! Read 'sequential'
OPEN ( UNIT = Unit_Number, FILE = Name,
& FORM = "UNFORMATTED", ACCESS = "SEQUENTIAL" )
!
READ ( UNIT = Unit_Number, IOSTAT = IO_Stat )
& Real_Variable, Integer_Variable
!
WRITE ( 6, "(/G13.5,I13,2I13/)" ) Real_Variable, Integer_Variable
!
CLOSE ( UNIT = Unit_Number )
!
!
! Read 'direct'
OPEN ( UNIT = Unit_Number, FILE = Name,
& FORM = "UNFORMATTED", ACCESS = "DIRECT", RECL = Rec_Length )
!
READ ( UNIT = Unit_Number, REC = 1 )
& Record_Length_1, Real_Variable, Integer_Variable, Record_Length_2
!
WRITE ( 6, "(/G13.5,I13,2I13/)" ) Real_Variable,
& Integer_Variable, Record_Length_1, Record_Length_2
!
CLOSE ( UNIT = Unit_Number )
!
!
END PROGRAM Check_Record_Length
!
--
Summary: Inconsistency with binary sequential output
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: P dot Schaffnit at access dot rwth-aachen dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: GCC 4.1.0 20050517
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21621