I want to read out some output data from a Fortran code to data files for postprocessing. The code given to me uses MPI to write to those data files. For the most basic case, when the number of processors should be 1 and also the Nx, Ny, Nz are all set to 1 and l is 3
, the output of the written to the data file should be all 1. However, the output written to the data file is in some non-readable format, as below:
^@^@^@^@^@^@^@^@^@^@^@^@
The relevant portion of the code which writes to the data file is appended below.
do rst=1,1
fname='phi'
fname = trim('ufs')//":" // trim(fname)
write(buffer,"(i3.3)") 2*rst-1
fname = trim(adjustl(fname))//'.'//trim(adjustl(buffer))
print *, 'The output file to which all the data is written is ', fname
call MPI_FILE_OPEN(MPI_COMM_WORLD,fname,MPI_MODE_WRONLY+MPI_MODE_CREATE,MPI_INFO_NULL,ifile,ierr)
do l=1,numvar
disp = Nx_MOK*Ny_MOK*Nz_MOK*WP_MOK*(l-1)
call MPI_FILE_SET_VIEW(ifile,disp,MPI_REAL_SP,view,"native",MPI_INFO_NULL,ierr)
call MPI_FILE_WRITE_ALL(ifile,phi_xyz(1:Nxp,1:Nyp,1:Nzp,l,2*rst 1),Nxp*Nzp*Nyp, MPI_REAL_SP,status,ierr)
end do
call MPI_FILE_CLOSE(ifile,ierr)
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
end do