Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
2159 Discussions

MPI_FILE_WRITE_SHARED odd behavior?

j0e
New Contributor I
797 Views

I'm using MPI_FILE_WRITE_SHARED to write some error output to a single file.  NFS is used so that all nodes write/read to the same files.  When I run the program on any single node with multiple processes, error output occurs correctly.  However, when I run the code across multiple nodes, nothing get written to the file.  Here's a simple test program

   Program MPIwriteTest   
      use mpi
      implicit none
      integer mpiFHerr, mpiErr, myRank
      character (len=80) string
      character(len=2), parameter:: CRLF = char(13)//char(10) 
      
      ! Initialze MPI and get rank
      call MPI_INIT( mpierr )
      call MPI_COMM_RANK(MPI_COMM_WORLD, myRank, mpierr)
      
      ! open and close file MPIerror.dat to delete any existing file
      call MPI_FILE_OPEN(MPI_COMM_WORLD, 'MPIerror.dat', MPI_MODE_WRONLY+MPI_MODE_CREATE+MPI_MODE_SEQUENTIAL+MPI_MODE_DELETE_ON_CLOSE, &
               MPI_INFO_NULL, mpiFHerr, mpiErr)
      call MPI_FILE_CLOSE(mpiFHerr, mpiErr) ! This will delete the file.          
      ! open but don't delete on close         
      call MPI_FILE_OPEN(MPI_COMM_WORLD, 'MPIerror.dat', MPI_MODE_WRONLY+MPI_MODE_CREATE+MPI_MODE_SEQUENTIAL, &
               MPI_INFO_NULL, mpiFHerr, mpiErr)
   
      ! test code just just does simple write
      write(string,'(a,i0)') 'Error from process: ', myRank
      call MPI_FILE_WRITE_SHARED(mpiFHerr, trim(string)//CRLF, len_trim(string)+2, MPI_CHARACTER, MPI_STATUS_IGNORE, mpiErr)
      
      ! close and end
      call MPI_FILE_CLOSE(mpiFHerr, mpiErr)
      call MPI_FINALIZE(mpierr)    
      
   end program MPIwriteTest

I've also noticed if the file already exists (and I don't do the open and delete_on_close), then the file contains text, but sometime the file is corrupt.  Is there something wrong in this code?  Is MPI not playing well with NFS?

BTW, I'm using parallel studio xe 2019 update 4 cluster ed.  

thanks, -joe

0 Kudos
1 Reply
j0e
New Contributor I
797 Views

Seems to have been fixed with Update 5.  Cool.

0 Kudos
Reply