Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] How to avoid abort when calling MPI_Finalize without calling MPI_File_close?
From: James Overfelt (overfelt_at_[hidden])
Date: 2010-11-22 18:40:14


Hello,

    I have a small test case where a file created with MPI_File_open
is still open at the time MPI_Finalize is called. In the actual
program there are lots of open files and it would be nice to avoid the
resulting "Your MPI job will now abort." by either having MPI_Finalize
close the files or honor the error handler and return an error code
without an abort.

  I've tried with with OpenMPI 1.4.3 and 1.5 with the same results.
Attached are the configure, compile and source files and the whole
program follows.

Any help would be appreciated,
Dr. James Overfelt
Sandia National Laboratories

#include <iostream>
#include "mpi.h"
using namespace std;
int main (int argc, char *argv[])
{
  MPI_Init(&argc, &argv);
  MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
  MPI_Info info ;
  MPI_Info_create(&info);
  MPI_File fh;
  if (const int stat = MPI_File_open
    (MPI_COMM_SELF, "File_Test.txt", MPI_MODE_WRONLY |
MPI_MODE_CREATE, info, &fh))
    cerr<< "Error in MPI_File_open"<< stat<<endl;
  MPI_Finalize();
}

When run on a single processor the output is:

*** The MPI_Barrier() function was called after MPI_FINALIZE was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.
[r438767.sandia.gov:2767] Abort after MPI_FINALIZE completed
successfully; not able to guarantee that all other processes were
killed!