1

I have a Fortran code which writes an unformatted direct access file. The problem is that the size and the contents of the file changes when I switch to different platforms:

  • First platform is Windows (32bit version of the program using Intel compiler - version around 2009)

  • Second platform is Linux (64 bit version of the program with gfortran compiler v4.9.0).

Unfortunately the file that is produced in Linux can not be read from windows. The file in LINUX is 5-6 times smaller. However, the total number of records that are written seems to be the same. I opened both files with a hex editor and the main difference is that a lot of zeros exist in the windows version of the file. Is there any way produce exactly the same file in LINUX?

If it helps, you can find both files here: https://www.dropbox.com/sh/erjlf5sps40in0e/AAC4XEi-p4nnTNzhyai_ZCZVa?dl=0

I open the file with the command: OPEN(IAST,FILE=ASTFILR,ACCESS='DIRECT',FORM='UNFORMATTED',RECL=80)

I write with the command: WRITE(IAST,REC=IRC) (SNGL(PHI(I)-REF), I=IBR,IER)

I read with the command: READ(IAST,REC=IRC,ERR=999) (PHIS(I), I=1,ISTEP) where PHIS is a REAL*4 array

helios21
  • 135
  • 1
  • 9

1 Answers1

1

The issue is that by default Intel Fortran specifies that RECL= is in units of words, whereas GFortran uses bytes. There's an Intel Fortran compiler option that you can use to make it use byte units. On Linux that option is

-assume byterecl

for Windows I'm not sure what the syntax is, maybe something like

/assume:byterecl
janneb
  • 36,249
  • 2
  • 81
  • 97