v0.9.1
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_C_LOG("SELF", Sev::error, "%s",
42  "--------------------- MoFEM Error Message "
43  "---------------------------------------------------");
44 
45  MOFEM_C_LOG("SELF", 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_C_LOG("SELF", Sev::error, "MoFEM git commit id %s", GIT_SHA1_NAME);
50 
51  MOFEM_C_LOG("SELF", Sev::error, "%s",
52  "See http://mofem.eng.gla.ac.uk/mofem/html/ "
53  "guidelines_bug_reporting.html for bug reporting.");
54 
56  "SELF", Sev::error, "%s",
57  "Write to https://groups.google.com/forum/#!forum/mofem-group to "
58  "seek help.");
59  }
60 
61  if (n >= MOFEM_DATA_INCONSISTENCY) {
62 
63  if (p == PETSC_ERROR_INITIAL) {
64  if (mess)
65  MOFEM_C_LOG("SELF", Sev::error, "%s", mess);
66  }
67  MOFEM_C_LOG("SELF", Sev::error, "#%d %s() line %d in %s", cnt++, fun,
68  line, file);
69 
70  } else {
71  PetscTraceBackErrorHandler(PETSC_COMM_SELF, line, fun, file, n, p, mess,
72  ctx);
73  }
74 
75  PetscBool ismain, isunknown;
76  PetscStrncmp(fun, "main", 4, &ismain);
77  PetscStrncmp(fun, "unknown", 7, &isunknown);
78  if (ismain || isunknown) {
79 
80  if (n >= MOFEM_DATA_INCONSISTENCY) {
81 #if PETSC_VERSION_GE(3, 7, 0)
82  PetscOptionsView(NULL, PETSC_VIEWER_STDERR_SELF);
83 #else
84  PetscOptionsView(PETSC_VIEWER_STDERR_SELF);
85 #endif
86  }
87 
88  // error_printf_highlight();
89  MOFEM_C_LOG("SELF", Sev::error, "%s",
90  "-- MoFEM End of Error Message -- send entire error "
91  "message to mofem-group@googlegroups.com --");
92  // error_printf_normal();
93  }
94 
95  } else {
96 
97  /* do not print error messages since process 0 will print them, sleep before
98  * aborting so will not accidentally kill process 0*/
99  PetscSleep(10.0);
100  abort();
101  }
102 
104 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
FTensor::Index< 'n', 2 > n
Definition: PlasticOps.hpp:68
PetscErrorCode PetscVFPrintfDefault(FILE *fd, const char *format, va_list Argp)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514
static FILE * dummy_mofem_fd
Dummy file pointer (DO NOT USE)
Definition: LogManager.hpp:174
#define MOFEM_C_LOG(channel, severity, format,...)
Definition: LogManager.hpp:293
static moab::Error error
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:266