Commit a3f0cf9e authored by RudolfWeeber's avatar RudolfWeeber Committed by Michael Kuron
Browse files

Only call MPI_Finalize if we actually called MPI_Init

parent b6c6e2dd
......@@ -103,6 +103,7 @@ void MPIManager::initializeMPI( int* argc, char*** argv, bool abortOnException )
MPI_Initialized( &mpiAlreadyInitialized );
if ( ! mpiAlreadyInitialized ) {
MPI_Init( argc, argv );
finalizeOnDestruction_ = true;
}
isMPIInitialized_ = true;
......@@ -122,9 +123,12 @@ void MPIManager::finalizeMPI()
if( isMPIInitialized_ && !currentlyAborting_ )
{
isMPIInitialized_ = false;
if (finalizeOnDestruction_)
{
MPI_Finalize();
}
}
}
}
......
......@@ -156,9 +156,12 @@ private:
bool currentlyAborting_;
bool finalizeOnDestruction_;
// Singleton
MPIManager() : worldRank_(0), rank_(-1), numProcesses_(1), comm_(MPI_COMM_NULL),
isMPIInitialized_(false), cartesianSetup_(false), currentlyAborting_(false)
isMPIInitialized_(false), cartesianSetup_(false), currentlyAborting_(false),
finalizeOnDestruction_(false)
{ WALBERLA_NON_MPI_SECTION() { rank_ = 0; } }
}; // class MPIManager
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment