diff --git a/opm/simulators/utils/readDeck.cpp b/opm/simulators/utils/readDeck.cpp index a103c3277..2da496072 100644 --- a/opm/simulators/utils/readDeck.cpp +++ b/opm/simulators/utils/readDeck.cpp @@ -170,9 +170,7 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d errorGuard = std::make_unique(); } -#if HAVE_MPI - int parseSuccess = 0; -#endif + int parseSuccess = 1; // > 0 is success std::string failureMessage; if (rank==0) { @@ -223,13 +221,12 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d } if (!summaryConfig) summaryConfig = std::make_unique(*deck, *schedule, eclipseState->getTableManager(), *parseContext, *errorGuard); -#if HAVE_MPI - parseSuccess = 1; -#endif + } catch(const std::exception& e) { failureMessage = e.what(); + parseSuccess = 0; } } #if HAVE_MPI @@ -241,28 +238,66 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d if (!eclipseState) eclipseState = std::make_unique(); } - - auto comm = Dune::MPIHelper::getCollectiveCommunication(); - parseSuccess = comm.max(parseSuccess); - if (!parseSuccess) - { - if (*errorGuard) { - errorGuard->dump(); - errorGuard->clear(); - } - MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); - } - - Opm::eclStateBroadcast(*eclipseState, *schedule, *summaryConfig); #endif - Opm::checkConsistentArrayDimensions(*eclipseState, *schedule, *parseContext, *errorGuard); + if (*errorGuard) { // errors encountered + parseSuccess = 0; + } - if (*errorGuard) { - errorGuard->dump(); - errorGuard->clear(); + // print errors and warnings! + errorGuard->dump(); + errorGuard->clear(); - throw std::runtime_error("Unrecoverable errors were encountered while loading input."); + auto comm = Dune::MPIHelper::getCollectiveCommunication(); + parseSuccess = comm.min(parseSuccess); + + if (!parseSuccess) + { + if (rank == 0) + { + OpmLog::error(std::string("Unrecoverable errors were encountered while loading input: ")+failureMessage); + } +#if HAVE_MPI + MPI_Finalize(); +#endif + exit(1); + } + + parseSuccess = 1; + + try + { +#if HAVE_MPI + Opm::eclStateBroadcast(*eclipseState, *schedule, *summaryConfig); +#endif + Opm::checkConsistentArrayDimensions(*eclipseState, *schedule, *parseContext, *errorGuard); + } + catch(const std::exception& e) + { + failureMessage = e.what(); + parseSuccess = 0; + } + + if (*errorGuard) { // errors encountered + parseSuccess = 0; + } + + // Print warnings and erors on every rank! Maybe too much? + errorGuard->dump(); + errorGuard->clear(); + + parseSuccess = comm.min(parseSuccess); + + if (!parseSuccess) + { + if (rank == 0) + { + OpmLog::error(std::string("Unrecoverable errors were encountered while loading input: ")+failureMessage); + } +#if HAVE_MPI + MPI_Finalize(); +#endif + exit(1); } } } // end namespace Opm