Commit b424043b authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Minor improvement for core routines.

* Prevent warnings for unused variables/arguments and make proper check
  if calling MPI_Abort is actually allowed.
parent 5a3fa9a4
......@@ -92,19 +92,30 @@ SymPrefix(set_default_comm)(MPI_Comm comm)
PPMF2C_Data.ppm_default_comm = comm_f;
}
#ifdef USE_MPI
static inline int
callsToMPIAreAllowed(void)
{
int init_flag = 0, finished_flag = 0;
return MPI_Initialized(&init_flag) == MPI_SUCCESS && init_flag
&& MPI_Finalized(&finished_flag) == MPI_SUCCESS && !finished_flag;
}
#endif
void
SymPrefix(abort_default)(MPI_Comm comm, const char *msg, const char *source, int line)
{
int flag = 0;
fprintf(stderr, "Fatal error in %s, line %d: %s\n", source, line, msg);
#ifdef USE_MPI
#if defined (__xlC__) && defined (_AIX)
#pragma omp critical
#endif
if (MPI_Initialized(&flag) == MPI_SUCCESS && flag)
if (callsToMPIAreAllowed())
MPI_Abort(comm, 1);
else
abort();
#else
(void)comm;
#endif
abort();
}
......@@ -122,14 +133,6 @@ FCALLSCSUB0(SymPrefix(restore_default_abort_handler),
symprefix(restore_default_abort_hndl))
#ifdef USE_MPI
static inline int
callsToMPIAreAllowed()
{
int init_flag = 0, finished_flag = 0;
return MPI_Initialized(&init_flag) == MPI_SUCCESS && init_flag
&& MPI_Finalized(&finished_flag) == MPI_SUCCESS && !finished_flag;
}
static inline int
getMPICommWorldRank()
{
......
Supports Markdown
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