mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-31 17:47:45 -05:00
Use cooperative MPI shutdown on parse failure
Remove MPI_Abort() from Main::initialize_() catch block. All exceptions from readDeck() are synchronized across ranks via comm.min(), so returning false is safe and lets Main::~Main() call MPI_Finalize() for cooperative shutdown.
This commit is contained in:
1 parent
0b5a261e7e
commit
98dafe2cae
2 files changed
+10
-5
No files matched your search
@@ -322,15 +322,16 @@ protected:
|
||||
// Catch std::exception (not a subclass) because readDeck()
|
||||
// may throw std::runtime_error on parse failure while other
|
||||
// initialization code may throw std::invalid_argument.
|
||||
// All exceptions here are synchronized across MPI ranks (rank-0-only
|
||||
// exceptions are caught inside readDeck() and converted to a
|
||||
// synchronized throw via comm.min()). Returning false lets
|
||||
// Main::~Main() call MPI_Finalize() for cooperative shutdown.
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
if (outputCout_) {
|
||||
std::cerr << "Failed to create valid EclipseState object." << std::endl;
|
||||
std::cerr << "Exception caught: " << e.what() << std::endl;
|
||||
}
|
||||
#if HAVE_MPI
|
||||
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
|
||||
#endif
|
||||
exitCode = EXIT_FAILURE;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -780,6 +780,10 @@ void Opm::readDeck(Opm::Parallel::Communication comm,
|
||||
errorGuard->clear();
|
||||
}
|
||||
|
||||
// Synchronize parse status across all ranks. This serves two purposes:
|
||||
// 1. Propagate rank 0 failure to all ranks (parsing only happens on rank 0)
|
||||
// 2. Ensure all ranks throw together, enabling cooperative shutdown
|
||||
// via Main::~Main() destructor calling MPI_Finalize()
|
||||
parseSuccess = comm.min(parseSuccess);
|
||||
|
||||
if (! parseSuccess) {
|
||||
@@ -789,8 +793,8 @@ void Opm::readDeck(Opm::Parallel::Communication comm,
|
||||
|
||||
// Throw instead of std::exit() so that callers can handle the
|
||||
// error. In production, Main::initialize_() catches this and
|
||||
// calls MPI_Abort(). In unit tests, Boost.Test catches it and
|
||||
// reports a proper test failure instead of a silent exit.
|
||||
// returns false for cooperative shutdown. In unit tests,
|
||||
// Boost.Test catches it and reports a proper test failure.
|
||||
throw std::runtime_error(failureMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user