PSCF v1.1
global.h
Go to the documentation of this file.
1#ifndef UTIL_GLOBAL_H
2#define UTIL_GLOBAL_H
3
9//-----------------------------------------------------------------------------
10// MPI Parallelization
11
12#ifdef UTIL_MPI
13#include <mpi.h>
14#endif
15
16//-----------------------------------------------------------------------------
17// Log file
18
22#include <util/misc/Log.h>
23
24//-----------------------------------------------------------------------------
25// Errors: Assertions and and Exception macros
26
27#ifndef UTIL_DEBUG
28
32#define NDEBUG
33
34#endif
35
36#include "assert.h"
37#include "misc/Exception.h"
38
42#define UTIL_FUNC __PRETTY_FUNCTION__
43
47#ifdef UTIL_FUNC
48 #ifndef UTIL_MPI
49 #define UTIL_THROW(msg) throw Exception(UTIL_FUNC, msg, __FILE__, __LINE__)
50 #else
51 #define UTIL_THROW(msg) { \
52 Exception e(UTIL_FUNC, msg, __FILE__, __LINE__); \
53 MpiThrow(e); }
54 #endif
55#else
56 #ifndef UTIL_MPI
57 #define UTIL_THROW(msg) throw Exception(msg, __FILE__, __LINE__)
58 #else
59 #define UTIL_THROW(msg) { \
60 Exception e(msg, __FILE__, __LINE__); \
61 MpiThrow(e); }
62 #endif
63#endif
64
68#define UTIL_CHECK(condition) \
69 if (!(condition)) { UTIL_THROW("Failed assertion: " #condition); }
70
74#ifdef NDEBUG
75#define UTIL_ASSERT(condition) {}
76#else
77#define UTIL_ASSERT(condition) \
78 if (!(condition)) { UTIL_THROW("Failed assertion: " #condition); }
79#endif
80
81#endif