Skip to content

Commit

Permalink
Merge Pull Request E3SM-Project#2984 from E3SM-Project/scream/bartgol…
Browse files Browse the repository at this point in the history
…/eamxx/mpi-abort-on-exception

Automatically Merged using E3SM Pull Request AutoTester
PR Title: Call MPI_Abort in CIME runs when an exception is thrown inside EAMxx
PR Author: bartgol
PR LABELS: AT: AUTOMERGE, AT: Skip weaver, AT: Skip v1 Testing, code usability, MPI
  • Loading branch information
E3SM-Bot authored Sep 23, 2024
2 parents 293cbd5 + 70222af commit b610754
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion components/eamxx/src/mct_coupling/scream_cxx_f90_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,23 @@ void fpe_guard_wrapper (const Lambda& f) {
try {
f();
} catch (std::exception &e) {
// Print exception msg, then call MPI_Abort
fprintf(stderr, "%s\n", e.what());

// Get raw comm before cleaning up singleton
auto& c = ScreamContext::singleton();
auto raw_comm = c.get<ekat::Comm>().mpi_comm();
c.clean_up();

MPI_Abort (raw_comm,1);
} catch (...) {

// Get raw comm before cleaning up singleton
auto& c = ScreamContext::singleton();
auto raw_comm = c.get<ekat::Comm>().mpi_comm();
c.clean_up();
throw;

MPI_Abort (raw_comm,1);
}

// Restore the FPE flag as it was when control was handed to us.
Expand Down

0 comments on commit b610754

Please sign in to comment.