v0.15.0
Loading...
Searching...
No Matches
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;
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 https://mofem.eng.gla.ac.uk/ "
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
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
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}
PetscErrorCode PetscVFPrintfDefault(FILE *fd, const char *format, va_list Argp)
#define MOFEM_LOG_C(channel, severity, format,...)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
auto fun
Function to approximate.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
const double n
refractive index of diffusive medium
static FILE * dummy_mofem_fd
Dummy file pointer (DO NOT USE)