Many, many more comments
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "simulation/mpi_communication.h"
|
||||
|
||||
// if any debug is defined, define the main function to print the debugging message
|
||||
#if defined debug_level3 || defined debug_level2 || defined debug_level1 || \
|
||||
defined debug_level0
|
||||
inline void DEBUG(const std::string& message) {
|
||||
@@ -16,45 +17,78 @@ inline void DEBUG(const std::string& message) {
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// depending on the debug level, activate the corresponding debugging function
|
||||
#if defined debug_level0
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 0
|
||||
inline void DEBUG_LEVEL_0(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 1
|
||||
inline void DEBUG_LEVEL_1(const std::string& message) {}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 2
|
||||
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 3
|
||||
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
||||
#elif defined debug_level1
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 0
|
||||
inline void DEBUG_LEVEL_0(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 1
|
||||
inline void DEBUG_LEVEL_1(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 2
|
||||
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 3
|
||||
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
||||
|
||||
#elif defined debug_level2
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 0
|
||||
inline void DEBUG_LEVEL_0(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 1
|
||||
inline void DEBUG_LEVEL_1(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 2
|
||||
inline void DEBUG_LEVEL_2(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 3
|
||||
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
||||
|
||||
#else
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 0
|
||||
inline void DEBUG_LEVEL_0(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 1
|
||||
inline void DEBUG_LEVEL_1(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 2
|
||||
inline void DEBUG_LEVEL_2(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 3
|
||||
inline void DEBUG_LEVEL_3(const std::string& message) {
|
||||
DEBUG(message);
|
||||
}
|
||||
@@ -62,18 +96,28 @@ inline void DEBUG_LEVEL_3(const std::string& message) {
|
||||
|
||||
#else
|
||||
inline void DEBUG(const std::string& message) {}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 0
|
||||
inline void DEBUG_LEVEL_0(const std::string& message) {}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 1
|
||||
inline void DEBUG_LEVEL_1(const std::string& message) {}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 2
|
||||
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
||||
// prints the message string to stdout if the code has been compiled with a
|
||||
// DEBUG_LEVEL > 3
|
||||
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
||||
#endif
|
||||
|
||||
// for MPI process 0 print the message string to stdout
|
||||
inline void SIM_INFO(const std::string& message) {
|
||||
if (MpiCommunication::mpi_rank == 0) {
|
||||
std::cout << "#INFO: " << message << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// writes message string to stderr and exits the program with an EXIT_FAILURE
|
||||
inline void ERROR(const std::string& message) {
|
||||
fprintf(stderr, "ERROR <%d> %s\n", MpiCommunication::mpi_rank,
|
||||
message.c_str());
|
||||
@@ -81,6 +125,7 @@ inline void ERROR(const std::string& message) {
|
||||
// throw std::runtime_error(message);
|
||||
}
|
||||
|
||||
// assert if value is positive otherwise exit the program and print the message to stderr
|
||||
template <class T>
|
||||
void ASSERT_POSITIVE(T* value, const std::string& message) {
|
||||
if (!(*value > 0)) {
|
||||
@@ -88,6 +133,7 @@ void ASSERT_POSITIVE(T* value, const std::string& message) {
|
||||
}
|
||||
}
|
||||
|
||||
// assert if value is not negative otherwise exit the program and print the message to stderr
|
||||
template <class T>
|
||||
void ASSERT_NOTNEGATIVE(T* value, const std::string& message) {
|
||||
if (!(*value >= 0)) {
|
||||
@@ -95,6 +141,7 @@ void ASSERT_NOTNEGATIVE(T* value, const std::string& message) {
|
||||
}
|
||||
}
|
||||
|
||||
// assert if value exists otherwise exit the program and print the message to stderr
|
||||
template <class T>
|
||||
void ASSERT_EXISTS(T* value, const std::string& message) {
|
||||
if (!value) {
|
||||
@@ -102,12 +149,15 @@ void ASSERT_EXISTS(T* value, const std::string& message) {
|
||||
}
|
||||
}
|
||||
|
||||
// assert if value is finite otherwise exit the program and print the message to stderr
|
||||
inline void ASSERT_FINITE(double value, const std::string& message) {
|
||||
if (!std::isfinite(value)) {
|
||||
ERROR(message);
|
||||
}
|
||||
}
|
||||
|
||||
// assert if the blitz::TinyVector is finite otherwise
|
||||
// exit the program and print the message to stderr
|
||||
inline void ASSERT_FINITE(const blitz::TinyVector<double, 3>& value,
|
||||
const std::string& message) {
|
||||
if (!std::isfinite(value(0)) || !std::isfinite(value(1)) ||
|
||||
|
||||
Reference in New Issue
Block a user