Reading unformatted files

Tobias Schlüter Tobias.Schlueter@physik.uni-muenchen.de
Thu Apr 24 09:45:00 GMT 2008


Joan Ballester Claramunt wrote:
> Hi,
> I have a problem with unformatted files. I have been working in a
> institute where people use PGF90 for the fortran files. Particularly,
> I have generated many unformatted files with PGF90 and "recl = 4".
> Now that I am back to my institute, I use GFORTRAN 4.0.0, but I cannot
> properly read these files. I have also tried the binaries form version
> 4.4 of GFORTRAN, but numbers that I read from files with "recl = 4"
> are meaningless.
> Many thanks.
> Joan
> 
> PS: I use Red Hat FC4. Architecture is i686

I'm guessing that PGF90's record markers are incompatible with whatever 
gfortran uses, so adding -frecord-marker=8 may cure your problem. 
Extracts from the documentation below.

Influencing runtime behavior

These options affect the runtime behavior of gfortran.
-fconvert=conversion
     Specify the representation of data for unformatted files. Valid 
values for conversion are: native, the default; swap, swap between big- 
and little-endian; big-endian, use big-endian representation for 
unformatted files; little-endian, use little-endian representation for 
unformatted files.

     This option has an effect only when used in the main program. The 
"CONVERT" specifier and the GFORTRAN_CONVERT_UNIT environment variable 
override the default specified by -fconvert.
-frecord-marker=length
     Specify the length of record markers for unformatted files. Valid 
values for length are 4 and 8. Default is whatever "off_t" is specified 
to be on that particular system. Note that specifying length as 4 limits 
the record length of unformatted files to 2 GB . This option does not 
extend the maximum possible record length on systems where "off_t" is a 
four_byte quantity.

Cheers,
- Tobi

-- 
Tobias Schlüter
Am Coulombwall 1, Zi. 326
85748 Garching b. München
Tel.: +49/89/289-14139



More information about the Fortran mailing list