Chombo + EB + MF  3.2
PXStuff.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _PXSTUFF_H_
12 #define _PXSTUFF_H_
13 
14 #include "NamespaceHeader.H" // for Chombo
15 
17 
18 
19 #ifndef unlikely
20 #define unlikely(expr) __builtin_expect((expr), 0)
21 #endif
22 
23 #ifndef likely
24 #define likely(expr) __builtin_expect((expr), 1)
25 #endif
26 
27 
28 //#ifdef __cplusplus
29 //#define RESTRICT __restrict__
30 //#else
31 //#define RESTRICT restrict
32 //#endif
33 
34 extern void PXErrorReport( const char *file, int line, const char *call, int ierr);
35 
36 
37 #define PXError(v,X) { int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ PXErrorRepo\
38 rt(__FILE__, __LINE__, #X, _ier); } (v) = _ier;}
39 #define PXErrorBreak(X) do{ int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ PXErrorRepo\
40 rt(__FILE__, __LINE__, #X, _ier); exit(-1);} } while (0)
41 #define PXErrorReturn(X) do{ int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ PXErrorRepo\
42 rt(__FILE__, __LINE__, #X, _ier); return _ier;} } while (0)
43 #define PXErrorReturnCode(X,Y) do{ int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ PXErrorRepo\
44 rt(__FILE__, __LINE__, #X, _ier); return ( Y);} } while (0)
45 #define PXErrorReturnSilent(X) do{ int _ier; _ier = (X); if (unlikely(_ier != PX_NO_ERROR)){ return _ier\
46 ;} } while (0)
47 
48 
49 #define PX_NO_ERROR 0
50 #define PX_MEMORY_ERROR -1
51 #define PX_BAD_INPUT -2
52 #define PX_NON_PHYSICAL -3
53 #define PX_READWRITE_ERROR -4
54 #define PX_GRID_ERROR -5
55 #define PX_SEARCH_NOT_FOUND -6
56 #define PX_NO_UPDATE -7
57 #define PX_PARALLEL_ERROR -8
58 #define PX_CODE_FLOW_ERROR -9
59 #define PX_SYSTEM_ERROR -10
60 #define PX_DYNAMIC_LIBRARY_ERROR -11
61 #define PX_NOT_CONVERGED -12
62 #define PX_VIZ_ERROR -13
63 #define PX_LAPACK_ERROR -14
64 #define PX_HARD_EXIT -15
65 #define PX_CGNS_ERROR -16
66 
67 extern const char *PXE_ErrorCodeName[];
68 
69 #define AssertDblWithin( truth, actual, delta) \
70  if (Abs((truth) - (actual)) > (delta)) PXErrorReturn(PX_CODE_FLOW_ERROR);
71 
72 #define PXAssertDblEquals( truth, actual ) \
73  CuAssertDblEquals( private_test_struct, truth, actual, 1.0e-15)
74 
75 #define PXAssertDblRelErrWithin( truth, actual, delta) \
76  CuAssertDblRelErrWithin( private_test_struct, truth, actual, delta )
77 
78 #define PXAssertIntWithin( truth, actual, delta ) \
79  if ( abs(truth - actual) > delta){\
80  sprintf(private_test_message,"expected <%d> but was <%d>", truth, actual ); \
81  CuFail( private_test_struct, private_test_message); }
82 
83 #define AssertIntEquals( truth, actual ) \
84  if ((truth) != (actual)) PXErrorReturn(PX_CODE_FLOW_ERROR);
85 
86 #define PXAssertPtrNotNull( ptr ) \
87  CuAssertPtrNotNull( private_test_struct, ptr )
88 
89 #define PXAssertPtrEquals( truth, actual ) \
90  CuAssertPtrEquals( private_test_struct, truth, actual )
91 
92 #define PXAssertStrEquals( truth, actual ) \
93  CuAssertStrEquals( private_test_struct, truth, actual )
94 
95 #define AssertDblGreater( min, actual ) \
96  if ( !((actual) > (min)) ) PXErrorReturn(PX_CODE_FLOW_ERROR);
97 
98 #define PXAssertIsNotNaN( value ) \
99  if ( !(value==value) ){ \
100  sprintf(private_test_message, \
101  "NaN encountered.\n"); \
102  CuFail( private_test_struct, private_test_message ); }
103 
104 #define ErrorAssert(X) do{ int _ier; _ier = (X); if (_ier != PX_NO_ERROR){ printf("Error %d (%s) has o\
105 ccured.\n File : %s Line : %d\n Call : %s\n", _ier,PXE_ErrorCodeName[-_ier], __FILE__, __LINE__, #X); f\
106 flush(stdout); AssertIntEquals(PX_NO_ERROR, _ier);} } while (0)
107 
108 
109 
110 #include "NamespaceFooter.H" // for Chombo
111 
112 #endif
Definition: PXStuff.H:16
Definition: PXStuff.H:16
Definition: PXStuff.H:16
const char * PXE_ErrorCodeName[]
void PXErrorReport(const char *file, int line, const char *call, int ierr)
PXE_Boolean
Definition: PXStuff.H:16