Re: End of record marker - 32 vs. 64 bit



Chris Theis wrote:

I'm currently dealing with some questions regarding unformatted binary files
on 32 & 64 bit platforms, and probably one of the experienced FORTRAN
programmers might be able to shed some light on this issue. AFAIK records
are delimited by record length markers which are of the size of an integer.
On a 32 bit machine this will be 4 bytes, whereas on a 64 bit machine it
will give me 8 bytes.

Not correct. On the majority of 64-bit systems you are likely to
encounter, the size of an integer is still 32-bits. There will likely
also exist a 64-bit integer kind, but "default integer" is still 32-
bits on the majority of implementations I am aware of.

This does not have a direct bearing on the on-disk record layout for
unformatted files.

My question is whether the record
length marker is specified to be of integer size in the standard or what the
FORTRAN standard says on this issue?

The Fortran standard is completely silent on this issue. It is an
implementation detail, and there exist platforms (VMS is one that
comes to mind) where record lengths are handled by the file system and
not written out as data. It is true that across UNIX, Linux and
Windows compilers, the use of record lengths in the data is very
common, but it is not universal nor is it specified by the standard.

You say you are using g77. I am aware that g77 made the unfortunate
choice of using straight 64-bit record lengths on platforms with 64-
bit virtual addresses. As you discovered, this makes that combination
incompatible with platforms that use 32-bit lengths. I don't know if
g77 has an option to use 32-bit lengths. I do know that Intel
Fortran, DEC/Compaq Fortran and gfortran use a scheme where 32-bit
lengths are used and very long records are split into segments with
specially encoded length values. This preserves compatibility with 32-
bit platforms for nearly all cases, but still allows longer records to
be written and read. I think that gfortran, which recently switched
to the segment scheme, has an option to use 64-bit lengths.

I'm not sure why you feel you are locked to g77.

Steve

.



Relevant Pages

  • Re: Tcl "source" command
    ... I used C wrappers to embed my FORTRAN programs into ... the Tcl interpreter. ... old-fashioned global statement. ... It is true that on some platforms one can shave off many microseconds ...
    (comp.lang.tcl)
  • Re: What would it take to have no undefined behavior in Fortran ?
    ... same input on all platforms it may run on (or (abort at exactly the ... of the language standard. ... there are a number of things the Fortran standard ... OK - can we quickly get finiteness of the real world out of the way as ...
    (comp.lang.fortran)
  • Re: Calculating lengths of runs of 0 and/or 1 in Rainfall data
    ... You should be able to write a short code to do this in Fortran 90 or 95 ... ALL array functions to tabulate runs of different lengths. ... below is a one-line solution using nested implied do loops ...
    (comp.lang.fortran)
  • Re: Get command line via system calls?
    ... > portable between compilers. ... High-level languages are bound to startup wrappers when compiled, ... I don't know fortran personall, but I'd guess your options are: ... provides the same APIs across those platforms) ...
    (Debian-User)
  • Re: Who uses clapack?
    ... been a FORTRAN compiler available for the target platforms that I was ... Even when a FORTRAN compiler is ... on what you are trying to accomplish with a new version of LAPACK. ...
    (comp.lang.fortran)