45#include "utils/simError.h"
61char checkPointMsg[MAX_SIM_ERROR_MSG_LENGTH];
64void initSimError(
void) {
65 painCave.errMsg[0] =
'\0';
67 painCave.severity = OPENMD_ERROR;
68 painCave.isEventLoop = 0;
71 MPI_Comm_rank(MPI_COMM_WORLD, &worldRank);
78 char errorMsg[MAX_SIM_ERROR_MSG_LENGTH];
83 char nodeMsg[MAX_SIM_ERROR_MSG_LENGTH];
86 strcpy(errorMsg,
"OpenMD ");
87 switch (painCave.severity) {
89 strcat(errorMsg,
"warning");
92 strcat(errorMsg,
"info");
95 if (painCave.isFatal) { strcat(errorMsg,
"FATAL "); }
96 strcat(errorMsg,
"ERROR");
100 if (worldRank == 0) {
101 if (painCave.isEventLoop) {
102 snprintf(nodeMsg, MAX_SIM_ERROR_MSG_LENGTH,
" (reported by MPI node %d)",
104 strncat(errorMsg, nodeMsg,
105 MAX_SIM_ERROR_MSG_LENGTH - strlen(errorMsg) - 1);
106 errorMsg[MAX_SIM_ERROR_MSG_LENGTH - 1] =
'\0';
110 strcat(errorMsg,
":\n\t");
111 strncat(errorMsg, painCave.errMsg,
112 MAX_SIM_ERROR_MSG_LENGTH - strlen(errorMsg) - 1);
113 errorMsg[MAX_SIM_ERROR_MSG_LENGTH - 1] =
'\0';
114 strcat(errorMsg,
"\n");
116 switch (painCave.severity) {
119 fprintf(stdout,
"%s", errorMsg);
122 fprintf(stderr,
"%s", errorMsg);
126 if (painCave.isEventLoop)
return 1;
130 if (painCave.isFatal) {
132 MPI_Allreduce(&myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
140void errorCheckPoint(
void) {
145 MPI_Allreduce(&myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
157#ifdef CHECKPOINT_VERBOSE
161 if (worldRank == 0) {
164 fprintf(stderr,
"Checkpoint #%d reached: %s\n", nChecks, checkPointMsg);