Commit e66cca07 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Assertion macro compatible with MPI

parent 3dfd578d
......@@ -61,4 +61,30 @@ extern int engine_rank;
#define message(s, ...) printf("%s: " s "\n", __FUNCTION__, ##__VA_ARGS__)
#endif
/**
* @brief Assertion macro compatible with MPI
*
*/
#ifdef WITH_MPI
extern int engine_rank;
#define assert(expr) \
{ \
if (!(expr)) { \
fprintf(stderr, "[%03i] %s:%s():%i: FAILED ASSERTION: " #expr " \n", \
engine_rank, __FILE__, __FUNCTION__, __LINE__); \
MPI_Abort(MPI_COMM_WORLD, -1); \
} \
}
#else
#define assert(expr) \
{ \
if (!(expr)) { \
fprintf(stderr, "%s:%s():%i: FAILED ASSERTION: " #expr " \n", __FILE__, \
__FUNCTION__, __LINE__); \
fflush(stderr); \
abort(); \
} \
}
#endif
#endif /* SWIFT_ERROR_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment