问题
I am having some issues on reading a binary (unformatted restart file ~2GB
) written within a Fortran program, by the call here below:
open(unit=1,file=opfile,status="unknown",form="unformatted")
!
write(1) t
!
write(1) Rho, Rho_ut, Rho_ur, Rho_uz, Rho_Ya
!
close(1)
that has been compiled with ifort
on an Intel Xeon Phi 7250 CPU (KNL)
architecture. When the same code, that has now been compiled with gfortran
on an IBM POWER9 AC922
architecture, read this file with the call here below:
open(unit=1,file=opfile,status="old",form="unformatted",err=99)
!
read(1) t
!
read(1) Rho, Rho_ut, Rho_ur, Rho_uz, Rho_Ya
!
close(1)
I get the following error message:
At line 58 of file src/io/fluid_fields_io.F90 (unit = 1, file = '../run/eje300000.bin')
Fortran runtime error: I/O past end of record on unformatted file
Error termination. Backtrace:
#0 0x2000001bb24b in read_block_direct
at ../.././libgfortran/io/transfer.c:781
#1 0x2000001bb24b in unformatted_read
at ../.././libgfortran/io/transfer.c:1119
#2 0x100422cf in ???
#3 0x1005bcaf in ???
#4 0x1005bf5f in ???
#5 0x1000205b in ???
#6 0x2000004c50ff in ???
I am afraid this is due to the fact I wrote an unformatted
binary file on a machine (using a compiler) and read it on another machine (using another compiler), but the fact is that I have to restart some HPC simulations (from the first machine) on the second one, where the first compiler ifort
is not available.
Do you think there might be also any issue on the endianness
of these two systems?
Or (hopefully) it is just a matter of passing the right arguments to the open
call keywords, for example access="stream"
and so on?...
来源:https://stackoverflow.com/questions/62662469/reading-binary-on-different-architectures-fortran-runtime-error-i-o-past-end