Hi everyone,
I’m dealing with I/O operations in a MPI Fortran code compiled with mpif90 under nvhpc-23.1. I’m trying to read a binary file in this way:
open(UNIT=fh, file=file_name,FORM='UNFORMATTED',RECL=reclen, &
STATUS='OLD', ACTION='READ',ACCESS='DIRECT')
do k = MINk(Zone)-mnk, MAXk(Zone)+mxk
do j = MINj(Zone)-mnj, MAXj(Zone)+mxj
do i = MINi(Zone)-mni, MAXi(Zone)+mxi
displ = (k - K_IND_MIN(Zone) + GHOSTS)*(range_i*range_j)+ &
(j - J_IND_MIN(Zone) + GHOSTS)*(range_i)+ &
(i - I_IND_MIN(Zone) + GHOSTS) + 1
READ(fh,rec=displ) buf
end do
end do
end do
The code uses OpenACC for GPU offloading but this section should be executed by the CPUs. I do not have problems in compilation but during execution the following issue arise:
FIO-F-219/unformatted read/unit=23/attempt to read/write past end of record.
File name = 'DNS_110.ZONE0', unformatted, direct access record = 1
In source file ../SHARED_FILES/nuovo_read_field.f90, at line number 80
This file (DNS_110.ZONE0), was written by the same code compiled with mpif90 shipped under openmpi_intel17-3.1.2 in the following way:
open(UNIT=fh, file=file_name,FORM='UNFORMATTED',RECL=reclen * range_i, &
STATUS='UNKNOWN',ACTION='WRITE',ACCESS='DIRECT',err=101,iostat=stato)
do k= MINk(Zone)-mnk, MAXk(Zone)+mxk
do j= MINj(Zone)-mnj , MAXj(Zone)+mxj
do i= MINi(Zone)-mni , MAXi(Zone)+mxi
....Some calculations...
displ_f = (k - K_IND_MIN(Zone) + n_ghosts)*(range_j)+ (j - J_IND_MIN(Zone) + n_ghosts) + 1
write(fh, rec=displ_f, err=100, iostat=stato) buf
end do
end do
end do
For the sake of clarity, this code works 100% compiled with openmpi-intel17 but it does not compiled with nvhpc, so the issue. Am I doing something wrong dealing with this type of operation? Should I include some flag during compilation? Thanks everybody in advance for the support!
-Matteo