This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
binary file problem
- From: Roberto Muscari <r dot muscari at insean dot it>
- To: fortran at gcc dot gnu dot org
- Date: Fri, 7 Sep 2007 16:05:48 +0200 (CEST)
- Subject: binary file problem
hi all,
I have a problem with binary files read/written by gfortran
AFAIK, binary files in fortran are written in the form:
lenght_of_the_record_1 record_1 lenght_of_the_record_1
lenght_of_the_record_2 record_2 lenght_of_the_record_2
lenght_of_the_record_3 record_3 lenght_of_the_record_3
........
The problem is that g77, g95, pgf90 (PGI compiler), ... write/read the
lenght_of_the_record as an integer*4
whereas in gfortran it is an integer*8 (at least on my 64bit PC)
For example, the program
integer (kind=4) :: i
write(100) i
generates a 8+4+8=20 bytes file if it is compiled with gfortran whereas
it generates a 4+4+4=12 bytes file if it is compiled with other compilers.
For this reason, I can not read the files written with other fortran
compilers with gfortran, and viceversa.
Does anybody know if there is a way to change this behavior of gfortran?
(
roberto ~> gfortran --version
GNU Fortran 95 (GCC) 4.1.1 20070105 (Red Hat 4.1.1-52)
Copyright (C) 2006 Free Software Foundation, Inc.
)
Thanks in advance
Roberto