diff --git a/extern/cfe/cfe b/extern/cfe/cfe index 5d93227a19..5e3cfc798c 160000 --- a/extern/cfe/cfe +++ b/extern/cfe/cfe @@ -1 +1 @@ -Subproject commit 5d93227a19c090c4a0abca9045b7156af432893e +Subproject commit 5e3cfc798c96c77d6d8b474a4b52b9236c646318 diff --git a/extern/evapotranspiration/evapotranspiration b/extern/evapotranspiration/evapotranspiration index 7c550e5a6d..7cf1c65394 160000 --- a/extern/evapotranspiration/evapotranspiration +++ b/extern/evapotranspiration/evapotranspiration @@ -1 +1 @@ -Subproject commit 7c550e5a6dbb520809311c41c03142a373df2f58 +Subproject commit 7cf1c653947551ebcac5e0e13d2cfeefd3e6966a diff --git a/extern/sloth b/extern/sloth index cf7b7dd95c..fc9c09823c 160000 --- a/extern/sloth +++ b/extern/sloth @@ -1 +1 @@ -Subproject commit cf7b7dd95cfcd636f6382ca0883b43edc9d1461d +Subproject commit fc9c09823c90ca70a388f032fa19d88fc4a96091 diff --git a/extern/topmodel/topmodel b/extern/topmodel/topmodel index 76408d9934..be4c61adf4 160000 --- a/extern/topmodel/topmodel +++ b/extern/topmodel/topmodel @@ -1 +1 @@ -Subproject commit 76408d9934c7bdd499f5c54e75c7e7ea723c2ff0 +Subproject commit be4c61adf48322311569b0ddc6ec7dd1016ac162 diff --git a/src/NGen.cpp b/src/NGen.cpp index 24dac00d07..13cb219ca6 100644 --- a/src/NGen.cpp +++ b/src/NGen.cpp @@ -32,6 +32,7 @@ #if NGEN_WITH_PYTHON #include "python/InterpreterUtil.hpp" #include +#include #endif // NGEN_WITH_PYTHON #if NGEN_WITH_MPI @@ -830,6 +831,17 @@ int main(int argc, char* argv[]) { auto interp = utils::ngenPy::InterpreterUtil::getInstance(); try { result = run_ngen(argc, argv, mpi_num_procs, mpi_rank); + + } catch (pybind11::error_already_set &e) { + // If the error comes from python, + // we cannot rethrow the execption after destroying the interpreter (doing so sometimes caused MPI runs to hang) + // First, copy the python error message so it an be reraised as a runtime_error + std::string error_msg = std::string("Uncaught python error: ") + e.what(); + // destroy the interpreter to let python atexit actions trigger + interp.reset(); + // throw the copied error to ensure MPI acknowledges the termination + throw std::runtime_error(error_msg); + } catch (...) { // If any uncaught exception happens, // explictly destroy the interpreter to ensure any @@ -845,7 +857,7 @@ int main(int argc, char* argv[]) { // this is needed if any python atexit registered functions would interact with MPI MPI_Barrier(MPI_COMM_WORLD); #endif // NGEN_WITH_MPI -#else +#else // not NGEN_WITH_PYTHON result = run_ngen(argc, argv, mpi_num_procs, mpi_rank); #endif // NGEN_WITH_PYTHON