v0.13.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 19 of file ErrorHandler.cpp.

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