ESDM
Middleware for Earth System Data
debug.h
1 /*
2  * =====================================================================================
3  *
4  * Filename: debug.h
5  *
6  * Description:
7  *
8  * Version: 1.0
9  * Created: 07/20/2017 08:35:43 AM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Eugen Betke, Olga Perevalova
14  * Organization:
15  *
16  * =====================================================================================
17  */
18 
19 #ifndef debug_INC
20 #define debug_INC
21 
22 
23 #include <mpi.h>
24 #include <stdbool.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #define LOG 520
29 // debug
30 #if TRACE
31 # define TRACEMSG(...) \
32  { \
33  int debug_mpi_rank = 0; \
34  MPI_Comm_rank(MPI_COMM_WORLD, &debug_mpi_rank); \
35  printf("[TRACE] (%d) %s:%d - ", debug_mpi_rank, __PRETTY_FUNCTION__, __LINE__); \
36  printf(__VA_ARGS__); \
37  printf("\n"); \
38  }
39 #else
40 # define TRACEMSG(...)
41 #endif
42 
43 // debug
44 #if DEBUG
45 # define DEBUGMSG(...) \
46  { \
47  int debug_mpi_rank = 0; \
48  MPI_Comm_rank(MPI_COMM_WORLD, &debug_mpi_rank); \
49  printf("[DEBUG] (%d) %s:%d - ", debug_mpi_rank, __PRETTY_FUNCTION__, __LINE__); \
50  printf(__VA_ARGS__); \
51  printf("\n"); \
52  }
53 #else
54 # define DEBUGMSG(...)
55 #endif
56 
57 // error
58 #define ERRORMSG(...) \
59  { \
60  int debug_mpi_rank = 0; \
61  MPI_Comm_rank(MPI_COMM_WORLD, &debug_mpi_rank); \
62  printf("[ERROR] (%d) %s:%d - ", debug_mpi_rank, __PRETTY_FUNCTION__, __LINE__); \
63  printf(__VA_ARGS__); \
64  printf("\n"); \
65  eassert(false); \
66  exit(1); \
67  }
68 
69 // todo
70 #define TODOMSG(...) \
71  { \
72  int debug_mpi_rank = 0; \
73  MPI_Comm_rank(MPI_COMM_WORLD, &debug_mpi_rank); \
74  printf("[TODO] (%d) %s:%d - ", debug_mpi_rank, __PRETTY_FUNCTION__, __LINE__); \
75  printf(__VA_ARGS__); \
76  printf("\n"); \
77  }
78 
79 #endif /* ----- #ifndef debug_INC ----- */