0

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
  • the file contains binary data. it is not readable by human, but `MPI_File_read()` and friends should be just fine. – Gilles Gouaillardet Oct 06 '17 at 23:27
  • The file contains various information of interests which I need to plot and analyze. Any tips on how to convert the binary data into the human-readable format or some platform where can it be imported? – han_eel Oct 06 '17 at 23:46
  • you can read the file with `MPI-IO` and write into an other file with standard Fortran write. – Gilles Gouaillardet Oct 07 '17 at 01:44
  • Welcome. Be sure to take the [tour] and read [ask]. Use tag [tag:fortran] for all Fortran questions, Fortran 90 is just one old version. – Vladimir F Героям слава Oct 07 '17 at 07:49
  • Do you have some code where you need to add the reading? How do the data structures you need to read look like? – Vladimir F Героям слава Oct 07 '17 at 07:50
  • The data structures that I need to read are stored in a 4-D array towards the end of the program. Eventually, this array will be very large (of the order of billion of elements, since I am processing CFD data). And hence the output binary file will be very large. I am new to both FORTRAN and MPI. Can you please suggest me how should I go ahead with reading these huge binary files so that I can further post-process them? Thank you. – han_eel Oct 07 '17 at 21:43

0 Answers0