HiRep 0.1
Loading...
Searching...
No Matches
error_handling.h File Reference

Functions and macros for error handling. More...

#include <stdio.h>
Include dependency graph for error_handling.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CHECK_MPI(call)
 Check MPI call and log error message on failure.
 

Functions

void error (int test, int no, const char *name, const char *text,...)
 Print message to error file defined on startup.
 
void print_trace (void)
 
void register_sighandlers (void)
 

Detailed Description

Functions and macros for error handling.

Headerfile for:

Macro Definition Documentation

◆ CHECK_MPI

#define CHECK_MPI ( call)
Value:
do { \
const int mpireturn = call; \
if (mpireturn != MPI_SUCCESS) { \
char message[MPI_MAX_ERROR_STRING]; \
int message_length; \
MPI_Error_string(mpireturn, message, &message_length); \
char errmsg[500]; \
sprintf(errmsg, "Error in: %s:%d, function: %s\n \ Communications call exited with code %d: %s\n", \
__FILE__, __LINE__, __func__, mpireturn, message); \
error(1, 1, __func__, errmsg); \
} \
} while (0)

Check MPI call and log error message on failure.

Parameters
callFunction call that should be checked.

Function Documentation

◆ error()

void error ( int test,
int no,
const char * name,
const char * text,
... )

Print message to error file defined on startup.

Parameters
testCondition on whether an error should be raised. 0 for no error and continue 1 for error, stop and print error message
noExit Code Value smaller than zero exits immediately with code 0. Value larger or equal then zero exits with code given after finalizing.
nameFunction name, where the error was raised
textError message text