Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
macros_dh.h
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack: Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2002) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
43 #ifndef MACROS_DH
44 #define MACROS_DH
45 
46 #ifndef FMAX
47 #define FMAX(a,b) ((FABS(a)) > (FABS(b)) ? (FABS(a)) : (FABS(b)))
48 #endif
49 
50 #ifndef MAX
51 #define MAX(a,b) ((a) > (b) ? (a) : (b))
52 #endif
53 
54 #ifndef MIN
55 #define MIN(a,b) ((a)<(b)?(a):(b))
56 #endif
57 
58 #ifndef ABS
59 #define ABS(x) (((x)<0)?(-(x)):(x))
60 #endif
61 
62 #ifndef FABS
63 #define FABS(a) ((a) < 0 ? -(a) : a)
64 #endif
65 
66 /* used in Mat_SEQ_PrintTriples, so matlab won't discard zeros (yuck!) */
67 #define _MATLAB_ZERO_ 1e-100
68 
69 
70 /*----------------------------------------------------------------------
71  * macros for error handling everyplace except in main.
72  *---------------------------------------------------------------------- */
73 
74 /* for future expansion: should check that "ptr" points to
75  a valid memory address, if not null.
76 */
77 #define ASSERT_DH(ptr) \
78  { \
79  if (ptr == NULL) { \
80  sprintf(msgBuf_dh, "%s is NULL", ptr); \
81  SET_V_ERROR(msgBuf_dh); \
82  } \
83  }
84 
85 
86 #if 0
87 #define CHECK_MPI_V_ERROR(errCode) \
88  { \
89  if (errCode) { \
90  int len; \
91  MPI_Error_string(errCode, msgBuf_dh, &len); \
92  setError_dh(msgBuf_dh, __FUNC__, __FILE__, __LINE__); \
93  return; \
94  } \
95  }
96 
97 #define CHECK_MPI_ERROR(errCode) \
98  { \
99  if (errCode) { \
100  int len; \
101  MPI_Error_string(errCode, msgBuf_dh, &len); \
102  setError_dh(msgBuf_dh, __FUNC__, __FILE__, __LINE__); \
103  return(errCode); \
104  } \
105  }
106 #endif
107 
108 #define CHECK_MPI_V_ERROR(errCode) \
109  { \
110  if (errCode) { \
111  setError_dh("MPI error!", __FUNC__, __FILE__, __LINE__); \
112  printErrorMsg(stderr); \
113  MPI_Abort(comm_dh, -1); \
114  } \
115  }
116 
117 #define CHECK_MPI_ERROR(errCode) \
118  { \
119  if (errCode) { \
120  setError_dh("MPI error!", __FUNC__, __FILE__, __LINE__); \
121  printErrorMsg(stderr); \
122  MPI_Abort(comm_dh, -1); \
123  } \
124  }
125 
126 #define SET_V_ERROR(msg) \
127  { setError_dh(msg, __FUNC__, __FILE__, __LINE__); \
128  printErrorMsg(stderr); \
129  MPI_Abort(comm_dh, -1); \
130  }
131 
132 #define SET_ERROR(retval, msg) \
133  { setError_dh(msg, __FUNC__, __FILE__, __LINE__); \
134  printErrorMsg(stderr); \
135  MPI_Abort(comm_dh, -1); \
136  }
137 
138 #define CHECK_V_ERROR \
139  if (errFlag_dh) { \
140  setError_dh("", __FUNC__, __FILE__, __LINE__); \
141  printErrorMsg(stderr); \
142  MPI_Abort(comm_dh, -1); \
143  }
144 
145 #define CHECK_ERROR(retval) \
146  if (errFlag_dh) { \
147  setError_dh("", __FUNC__, __FILE__, __LINE__); \
148  printErrorMsg(stderr); \
149  MPI_Abort(comm_dh, -1); \
150  }
151 
152 /*----------------------------------------------------------------------
153  * informational macros
154  *---------------------------------------------------------------------- */
155 
156 #define SET_INFO(msg) setInfo_dh(msg, __FUNC__, __FILE__, __LINE__);
157 
158 /*----------------------------------------------------------------------
159  * macros for tracking the function call stack
160  *---------------------------------------------------------------------- */
161 #ifdef OPTIMIZED_DH
162 
163 #define START_FUNC_DH \
164  dh_StartFunc(__FUNC__, __FILE__, __LINE__, 1); \
165  {
166 
167 #define END_FUNC_DH \
168  } \
169  dh_EndFunc(__FUNC__, 1);
170 
171 #define END_FUNC_VAL(a) \
172  dh_EndFunc(__FUNC__, 1); \
173  return a ; \
174  }
175 
176 #define START_FUNC_DH_2
177 #define END_FUNC_DH_2
178 #define END_FUNC_VAL_2(a) return a ;
179 #else
180 
181 #define START_FUNC_DH \
182  dh_StartFunc(__FUNC__, __FILE__, __LINE__, 1); \
183  if (logFuncsToStderr || logFuncsToFile)\
184  Error_dhStartFunc(__FUNC__, __FILE__, __LINE__); \
185  {
186 
187 #define END_FUNC_DH \
188  dh_EndFunc(__FUNC__, 1); \
189  if (logFuncsToStderr || logFuncsToFile) \
190  Error_dhEndFunc(__FUNC__); \
191  return; \
192  } \
193 
194 #define START_FUNC_DH_2 \
195  dh_StartFunc(__FUNC__, __FILE__, __LINE__, 2); \
196  if (logFuncsToStderr || logFuncsToFile)\
197  Error_dhStartFunc(__FUNC__, __FILE__, __LINE__); \
198  {
199 
200 #define END_FUNC_DH_2 \
201  dh_EndFunc(__FUNC__, 2); \
202  if (logFuncsToStderr || logFuncsToFile) \
203  Error_dhEndFunc(__FUNC__); \
204  return; \
205  } \
206 
207 
208 #define END_FUNC_VAL(retval) \
209  dh_EndFunc(__FUNC__, 1); \
210  if (logFuncsToStderr || logFuncsToFile) \
211  Error_dhEndFunc(__FUNC__); \
212  return(retval); \
213  } \
214 
215 #define END_FUNC_VAL_2(retval) \
216  dh_EndFunc(__FUNC__, 2); \
217  if (logFuncsToStderr || logFuncsToFile) \
218  Error_dhEndFunc(__FUNC__); \
219  return(retval); \
220  } \
221 
222 
223 #endif
224 
225 #endif /* #ifndef MACROS_DH */
226 
227 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
228 #ifdef __GNUC__
229 #warning "The Ifpack package is deprecated"
230 #endif
231 #endif
232