-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassert.H
More file actions
79 lines (63 loc) · 1.8 KB
/
assert.H
File metadata and controls
79 lines (63 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
!BOP -------------------------------------------------------------------
!
! !MODULE: assert.H - an #include section of ASSERT() macro for Fortran
!
! !DESCRIPTION:
!
! !INTERFACE:
!
! #define NDEBUG
! #include "assert.H"
! ...
! use m_die,only : assert_
! ...
! ASSERT( <Fortran expression> )
! ALWAYS_ASSERT( <Fortran expression> )
!
! !BUGS
! This macro requires Fortran friendly cpp() for macro processing.
!
! !REVISION HISTORY:
! 19Jan01 - Jing Guo
! - Merged in Tom Clune`s new ASSERT macros.
! 28Aug00 - Jing Guo <[email protected]>
! - modified
! - added the prolog for a brief documentation
! before - Tom Clune
! - Created for MP PSAS
!EOP ___________________________________________________________________
! This implementation allows multiple-"#include" in the same
! source file.
#ifndef ALWAYS_ASSERT
#define ALWAYS_ASSERT(EX) If (.not. (EX) ) call assert_("EX",__FILE__,__LINE__)
#endif
#ifndef ALWAYS_ASSERT_NOMSG
#define ALWAYS_ASSERT_NOMSG(EX) If(.not.(EX))call assert_(__FILE__,__LINE__)
#endif
#ifndef ALWAYS_ASSERT_MSG
#define ALWAYS_ASSERT_MSG(EX,msg) If(.not.(EX))call assert_(msg,__FILE__,__LINE__)
#endif
! ASSERT(EX) and ASSERT_MSG(EX) are always redefined, such that
! one can toggle #define and #undef NDEBUG in the same source
! file.
#ifdef ASSERT
#undef ASSERT
#endif
#ifdef ASSERT_NOMSG
#undef ASSERT_NOMSG
#endif
#ifdef ASSERT_MSG
#undef ASSERT_MSG
#endif
#ifdef NDEBUG
! Skip assertion: EX
#define ASSERT(EX)
#define ASSERT_NOMSG(EX)
#define ASSERT_MSG(EX,msg)
#else
#define ASSERT(EX) ALWAYS_ASSERT(EX)
#define ASSERT_NOMSG(EX) ALWAYS_ASSERT_NOMSG(EX)
#define ASSERT_MSG(EX,msg) ALWAYS_ASSERT_MSG(EX,msg)
#endif