v0.14.0
Functions
ErrorHandler.cpp File Reference

Go to the source code of this file.

Functions

static PetscErrorCode mofem_error_handler (MPI_Comm comm, int line, const char *fun, const char *file, PetscErrorCode n, PetscErrorType p, const char *mess, void *ctx)
 

Function Documentation

◆ mofem_error_handler()

static PetscErrorCode mofem_error_handler ( MPI_Comm  comm,
int  line,
const char *  fun,
const char *  file,
PetscErrorCode  n,
PetscErrorType  p,
const char *  mess,
void *  ctx 
)
static

Definition at line 6 of file ErrorHandler.cpp.

9  {
10 
11  static int cnt = 1;
13  PetscVFPrintf = PetscVFPrintfDefault;
14  MoFEM::LogManager::dummy_mofem_fd = PETSC_STDERR;
15 
16  int rank = 0;
17  if (comm != PETSC_COMM_SELF)
18  MPI_Comm_rank(comm, &rank);
19 
20  if (!rank) {
21 
22  if (p == PETSC_ERROR_INITIAL) {
23 
24  char petsc_version[255];
25  PetscGetVersion(petsc_version, 255);
26  MOFEM_LOG_CHANNEL("SELF");
27 
28  MOFEM_LOG_C("SELF", MoFEM::Sev::error, "%s",
29  "--------------------- MoFEM Error Message "
30  "---------------------------------------------------");
31 
32  MOFEM_LOG_C("SELF", MoFEM::Sev::error, "MoFEM version %d.%d.%d (%s %s)",
33  MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD,
34  MOAB_VERSION_STRING, petsc_version);
35 
36  MOFEM_LOG_C("SELF", MoFEM::Sev::error, "MoFEM git commit id %s",
37  GIT_SHA1_NAME);
38 
39  MOFEM_LOG_C("SELF", MoFEM::Sev::error, "%s",
40  "See http://mofem.eng.gla.ac.uk/mofem/html/ "
41  "guidelines_bug_reporting.html for bug reporting.");
42 
44  "SELF", MoFEM::Sev::error, "%s",
45  "Write to https://groups.google.com/forum/#!forum/mofem-group to "
46  "seek help.");
47  }
48 
49  if (n >= MOFEM_DATA_INCONSISTENCY) {
50 
51  if (p == PETSC_ERROR_INITIAL) {
52  if (mess)
53  MOFEM_LOG_C("SELF", MoFEM::Sev::error, "%s", mess);
54  }
55  MOFEM_LOG_C("SELF", MoFEM::Sev::error, "#%d %s() line %d in %s", cnt++,
56  fun, line, file);
57 
58  } else {
59  PetscTraceBackErrorHandler(PETSC_COMM_SELF, line, fun, file, n, p, mess,
60  ctx);
61  }
62 
63  PetscBool ismain, isunknown;
64  PetscStrncmp(fun, "main", 4, &ismain);
65  PetscStrncmp(fun, "unknown", 7, &isunknown);
66  if (ismain || isunknown) {
67 
68  if (n >= MOFEM_DATA_INCONSISTENCY) {
69 #if PETSC_VERSION_GE(3, 7, 0)
70  PetscOptionsView(NULL, PETSC_VIEWER_STDERR_SELF);
71 #else
72  PetscOptionsView(PETSC_VIEWER_STDERR_SELF);
73 #endif
74  }
75 
76  // error_printf_highlight();
77  MOFEM_LOG_C("SELF", MoFEM::Sev::error, "%s",
78  "-- MoFEM End of Error Message -- send entire error "
79  "message to mofem-group@googlegroups.com --");
80  // error_printf_normal();
81  }
82 
83  } else {
84 
85  /* do not print error messages since process 0 will print them, sleep before
86  * aborting so will not accidentally kill process 0*/
87  PetscSleep(10.0);
88  abort();
89  }
90 
92 }
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
MoFEM::LogManager::dummy_mofem_fd
static FILE * dummy_mofem_fd
Dummy file pointer (DO NOT USE)
Definition: LogManager.hpp:191
MOFEM_LOG_C
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
PetscVFPrintfDefault
PetscErrorCode PetscVFPrintfDefault(FILE *fd, const char *format, va_list Argp)
convert.n
n
Definition: convert.py:82
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
fun
auto fun
Function to approximate.
Definition: dg_projection.cpp:36