1 /* 2 Contains all error handling interfaces for PETSc. 3 */ 4 #if !defined(__PETSCERROR_H) 5 #define __PETSCERROR_H 6 #include "petsc.h" 7 PETSC_EXTERN_CXX_BEGIN 8 9 /* 10 Defines the directory where the compiled source is located; used 11 in printing error messages. Each makefile has an entry 12 LOCDIR = thedirectory 13 and bmake/common_variables includes in CCPPFLAGS -D__SDIR__='"${LOCDIR}"' 14 which is a flag passed to the C/C++ compilers. This declaration below 15 is only needed if some code is compiled without the -D__SDIR__ 16 */ 17 #if !defined(__SDIR__) 18 #define __SDIR__ "unknowndirectory/" 19 #endif 20 21 /* 22 Defines the function where the compiled source is located; used 23 in printing error messages. This is defined here in case the user 24 does not declare it. 25 */ 26 #if !defined(__FUNCT__) 27 #define __FUNCT__ "User provided function" 28 #endif 29 30 /* 31 These are the generic error codes. These error codes are used 32 many different places in the PETSc source code. The string versions are 33 at src/sys/error/err.c any changes here must also be made there 34 These are also define in include/finclude/petscerror.h any CHANGES here 35 must be also made there. 36 37 */ 38 #define PETSC_ERR_MEM 55 /* unable to allocate requested memory */ 39 #define PETSC_ERR_MEM_MALLOC_0 85 /* cannot malloc zero size */ 40 #define PETSC_ERR_SUP 56 /* no support for requested operation */ 41 #define PETSC_ERR_SUP_SYS 57 /* no support for requested operation on this computer system */ 42 #define PETSC_ERR_ORDER 58 /* operation done in wrong order */ 43 #define PETSC_ERR_SIG 59 /* signal received */ 44 #define PETSC_ERR_FP 72 /* floating point exception */ 45 #define PETSC_ERR_COR 74 /* corrupted PETSc object */ 46 #define PETSC_ERR_LIB 76 /* error in library called by PETSc */ 47 #define PETSC_ERR_PLIB 77 /* PETSc library generated inconsistent data */ 48 #define PETSC_ERR_MEMC 78 /* memory corruption */ 49 #define PETSC_ERR_CONV_FAILED 82 /* iterative method (KSP or SNES) failed */ 50 #define PETSC_ERR_USER 83 /* user has not provided needed function */ 51 52 #define PETSC_ERR_ARG_SIZ 60 /* nonconforming object sizes used in operation */ 53 #define PETSC_ERR_ARG_IDN 61 /* two arguments not allowed to be the same */ 54 #define PETSC_ERR_ARG_WRONG 62 /* wrong argument (but object probably ok) */ 55 #define PETSC_ERR_ARG_CORRUPT 64 /* null or corrupted PETSc object as argument */ 56 #define PETSC_ERR_ARG_OUTOFRANGE 63 /* input argument, out of range */ 57 #define PETSC_ERR_ARG_BADPTR 68 /* invalid pointer argument */ 58 #define PETSC_ERR_ARG_NOTSAMETYPE 69 /* two args must be same object type */ 59 #define PETSC_ERR_ARG_NOTSAMECOMM 80 /* two args must be same communicators */ 60 #define PETSC_ERR_ARG_WRONGSTATE 73 /* object in argument is in wrong state, e.g. unassembled mat */ 61 #define PETSC_ERR_ARG_INCOMP 75 /* two arguments are incompatible */ 62 #define PETSC_ERR_ARG_NULL 85 /* argument is null that should not be */ 63 #define PETSC_ERR_ARG_UNKNOWN_TYPE 86 /* type name doesn't match any registered type */ 64 #define PETSC_ERR_ARG_DOMAIN 87 /* argument is not in domain of function */ 65 66 #define PETSC_ERR_FILE_OPEN 65 /* unable to open file */ 67 #define PETSC_ERR_FILE_READ 66 /* unable to read from file */ 68 #define PETSC_ERR_FILE_WRITE 67 /* unable to write to file */ 69 #define PETSC_ERR_FILE_UNEXPECTED 79 /* unexpected data in file */ 70 71 #define PETSC_ERR_MAT_LU_ZRPVT 71 /* detected a zero pivot during LU factorization */ 72 #define PETSC_ERR_MAT_CH_ZRPVT 81 /* detected a zero pivot during Cholesky factorization */ 73 74 #if defined(PETSC_USE_ERRORCHECKING) 75 76 /*MC 77 SETERRQ - Macro that is called when an error has been detected, 78 79 Not Collective 80 81 Synopsis: 82 void SETERRQ(PetscErrorCode errorcode,char *message) 83 84 85 Input Parameters: 86 + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 87 - message - error message 88 89 Level: beginner 90 91 Notes: 92 Once the error handler is called the calling function is then returned from with the given error code. 93 94 See SETERRQ1(), SETERRQ2(), SETERRQ3() for versions that take arguments 95 96 97 Experienced users can set the error handler with PetscPushErrorHandler(). 98 99 Concepts: error^setting condition 100 101 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3() 102 M*/ 103 #define SETERRQ(n,s) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s);} 104 105 /*MC 106 SETERRQ1 - Macro that is called when an error has been detected, 107 108 Not Collective 109 110 Synopsis: 111 void SETERRQ1(PetscErrorCode errorcode,char *formatmessage,arg) 112 113 114 Input Parameters: 115 + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 116 . message - error message in the printf format 117 - arg - argument (for example an integer, string or double) 118 119 Level: beginner 120 121 Notes: 122 Once the error handler is called the calling function is then returned from with the given error code. 123 124 Experienced users can set the error handler with PetscPushErrorHandler(). 125 126 Concepts: error^setting condition 127 128 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ(), SETERRQ2(), SETERRQ3() 129 M*/ 130 #define SETERRQ1(n,s,a1) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1);} 131 132 /*MC 133 SETERRQ2 - Macro that is called when an error has been detected, 134 135 Not Collective 136 137 Synopsis: 138 void SETERRQ2(PetscErrorCode errorcode,char *formatmessage,arg1,arg2) 139 140 141 Input Parameters: 142 + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 143 . message - error message in the printf format 144 . arg1 - argument (for example an integer, string or double) 145 - arg2 - argument (for example an integer, string or double) 146 147 Level: beginner 148 149 Notes: 150 Once the error handler is called the calling function is then returned from with the given error code. 151 152 Experienced users can set the error handler with PetscPushErrorHandler(). 153 154 Concepts: error^setting condition 155 156 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ3() 157 M*/ 158 #define SETERRQ2(n,s,a1,a2) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2);} 159 160 /*MC 161 SETERRQ3 - Macro that is called when an error has been detected, 162 163 Not Collective 164 165 Synopsis: 166 void SETERRQ3(PetscErrorCode errorcode,char *formatmessage,arg1,arg2,arg3) 167 168 169 Input Parameters: 170 + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 171 . message - error message in the printf format 172 . arg1 - argument (for example an integer, string or double) 173 . arg2 - argument (for example an integer, string or double) 174 - arg3 - argument (for example an integer, string or double) 175 176 Level: beginner 177 178 Notes: 179 Once the error handler is called the calling function is then returned from with the given error code. 180 181 There are also versions for 4, 5, 6 and 7 arguments. 182 183 Experienced users can set the error handler with PetscPushErrorHandler(). 184 185 Concepts: error^setting condition 186 187 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 188 M*/ 189 #define SETERRQ3(n,s,a1,a2,a3) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2,a3);} 190 191 #define SETERRQ4(n,s,a1,a2,a3,a4) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2,a3,a4);} 192 #define SETERRQ5(n,s,a1,a2,a3,a4,a5) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2,a3,a4,a5);} 193 #define SETERRQ6(n,s,a1,a2,a3,a4,a5,a6) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2,a3,a4,a5,a6);} 194 #define SETERRQ7(n,s,a1,a2,a3,a4,a5,a6,a7) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2,a3,a4,a5,a6,a7);} 195 #define SETERRABORT(comm,n,s) {PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s);MPI_Abort(comm,n);} 196 197 /*MC 198 CHKERRQ - Checks error code, if non-zero it calls the error handler and then returns 199 200 Not Collective 201 202 Synopsis: 203 void CHKERRQ(PetscErrorCode errorcode) 204 205 206 Input Parameters: 207 . errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 208 209 Level: beginner 210 211 Notes: 212 Once the error handler is called the calling function is then returned from with the given error code. 213 214 Experienced users can set the error handler with PetscPushErrorHandler(). 215 216 CHKERRQ(n) is fundamentally a macro replacement for 217 if (n) return(PetscError(...,n,...)); 218 219 Although typical usage resembles "void CHKERRQ(PetscErrorCode)" as described above, for certain uses it is 220 highly inappropriate to use it in this manner as it invokes return(PetscErrorCode). In particular, 221 it cannot be used in functions which return(void) or any other datatype. In these types of functions, 222 a more appropriate construct for using PETSc Error Handling would be 223 if (n) {PetscError(....); return(YourReturnType);} 224 225 Concepts: error^setting condition 226 227 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ2() 228 M*/ 229 #define CHKERRQ(n) if (n) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,0," ");} 230 231 #define CHKERRABORT(comm,n) if (n) {PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,0," ");MPI_Abort(comm,n);} 232 #define CHKERRCONTINUE(n) if (n) {PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,0," ");} 233 234 /*MC 235 CHKMEMQ - Checks the memory for corruption, calls error handler if any is detected 236 237 Not Collective 238 239 Synopsis: 240 CHKMEMQ; 241 242 Level: beginner 243 244 Notes: 245 Must run with the option -malloc_debug to enable this option 246 247 Once the error handler is called the calling function is then returned from with the given error code. 248 249 By defaults prints location where memory that is corrupted was allocated. 250 251 Use CHKMEMA for functions that return void 252 253 Concepts: memory corruption 254 255 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 256 PetscMallocValidate() 257 M*/ 258 #define CHKMEMQ {PetscErrorCode _7_ierr = PetscMallocValidate(__LINE__,__FUNCT__,__FILE__,__SDIR__);CHKERRQ(_7_ierr);} 259 260 #define CHKMEMA {PetscMallocValidate(__LINE__,__FUNCT__,__FILE__,__SDIR__);} 261 262 #if defined(PETSC_UNDERSCORE_CHKERR) 263 extern PetscErrorCode __gierr; 264 #define _ __gierr = 265 #define ___ CHKERRQ(__gierr); 266 #endif 267 268 #define PETSC_EXCEPTIONS_MAX 256 269 extern PetscErrorCode PetscErrorUncatchable[PETSC_EXCEPTIONS_MAX]; 270 extern PetscInt PetscErrorUncatchableCount; 271 extern PetscErrorCode PetscExceptions[PETSC_EXCEPTIONS_MAX]; 272 extern PetscInt PetscExceptionsCount; 273 274 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscExceptionPush(PetscErrorCode); 275 EXTERN void PETSC_DLLEXPORT PetscExceptionPop(PetscErrorCode); 276 277 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorSetCatchable(PetscErrorCode,PetscTruth); 278 EXTERN PetscTruth PETSC_DLLEXPORT PetscErrorIsCatchable(PetscErrorCode); 279 /*MC 280 PetscExceptionCaught - Indicates if a specific exception zierr was caught. 281 282 Not Collective 283 284 Synopsis: 285 PetscTruth PetscExceptionCaught(PetscErrorCode xierr,PetscErrorCode zierr); 286 287 Input Parameters: 288 + xierr - error code returned from PetscExceptionTry1() 289 - zierr - error code you want it to be 290 291 Level: advanced 292 293 Notes: 294 PETSc must not be configured using the option --with-errorchecking=0 for this to work 295 296 Use PetscExceptionValue() to see if the current error code is one that has been "tried" 297 298 Concepts: exceptions, exception hanlding 299 300 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 301 CHKERRQ(), PetscExceptionTry1(), PetscExceptionValue() 302 M*/ 303 PETSC_STATIC_INLINE PetscTruth PetscExceptionCaught(PetscErrorCode xierr,PetscErrorCode zierr) { 304 PetscInt i; 305 if (xierr != zierr) return PETSC_FALSE; 306 for (i=0; i<PetscErrorUncatchableCount; i++) { 307 if (PetscErrorUncatchable[i] == zierr) { 308 return PETSC_FALSE; 309 } 310 } 311 return PETSC_TRUE; 312 } 313 314 /*MC 315 PetscExceptionValue - Indicates if the error code is one that is currently being tried 316 317 Not Collective 318 319 Synopsis: 320 PetscTruth PetscExceptionValue(PetscErrorCode xierr); 321 322 Input Parameters: 323 . xierr - error code 324 325 Level: developer 326 327 Notes: 328 PETSc must not be configured using the option --with-errorchecking=0 for this to work 329 330 Use PetscExceptionCaught() to see if the current error code is EXACTLY the one you want 331 332 Concepts: exceptions, exception hanlding 333 334 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 335 CHKERRQ(), PetscExceptionTry1(), PetscExceptionCaught() 336 M*/ 337 PETSC_STATIC_INLINE PetscTruth PetscExceptionValue(PetscErrorCode zierr) { 338 PetscInt i; 339 for (i=0; i<PetscExceptionsCount; i++) { 340 if (PetscExceptions[i] == zierr) { 341 return PETSC_TRUE; 342 } 343 } 344 return PETSC_FALSE; 345 } 346 347 /*MC 348 PetscExceptionTry1 - Runs the routine, causing a particular error code to be treated as an exception, 349 rather than an error. That is if that error code is treated the program returns to this level, 350 but does not call the error handlers 351 352 Not Collective 353 354 Synopsis: 355 PetscExceptionTry1(PetscErrorCode routine(....),PetscErrorCode); 356 357 Level: advanced 358 359 Notes: 360 PETSc must not be configured using the option --with-errorchecking=0 for this to work 361 362 Note: In general, the outer most try on an exception is the one that will be caught (that is trys down in 363 PETSc code will not usually handle an exception that was issued above). See SNESSolve() for an example 364 of how the local try is ignored if a higher (in the stack) one is also in effect. 365 366 Concepts: exceptions, exception hanlding 367 368 .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 369 CHKERRQ(), PetscExceptionCaught(), PetscExceptionPush(), PetscExceptionPop() 370 M*/ 371 extern PetscErrorCode PetscExceptionTmp; 372 #define PetscExceptionTry1(a,b) (PetscExceptionTmp = PetscExceptionPush(b)) ? PetscExceptionTmp : (PetscExceptionTmp = a , PetscExceptionPop(b),PetscExceptionTmp) 373 374 #else 375 376 /* 377 These are defined to be empty for when error checking is turned off, with config/configure.py --with-errorchecking=0 378 */ 379 380 #define SETERRQ(n,s) ; 381 #define SETERRQ1(n,s,a1) ; 382 #define SETERRQ2(n,s,a1,a2) ; 383 #define SETERRQ3(n,s,a1,a2,a3) ; 384 #define SETERRQ4(n,s,a1,a2,a3,a4) ; 385 #define SETERRQ5(n,s,a1,a2,a3,a4,a5) ; 386 #define SETERRQ6(n,s,a1,a2,a3,a4,a5,a6) ; 387 #define SETERRABORT(comm,n,s) ; 388 389 #define CHKERRQ(n) ; 390 #define CHKERRABORT(comm,n) ; 391 #define CHKERRCONTINUE(n) ; 392 393 #define CHKMEMQ ; 394 395 #if !defined(PETSC_SKIP_UNDERSCORE_CHKERR) 396 #define _ 397 #define ___ 398 #endif 399 400 #define PetscErrorSetCatchable(a,b) 0 401 #define PetscExceptionCaught(a,b) PETSC_FALSE 402 #define PetscExceptionValue(a) PETSC_FALSE 403 #define PetscExceptionTry1(a,b) a 404 #endif 405 406 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorPrintfInitialize(void); 407 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorMessage(int,const char*[],char **); 408 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTraceBackErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 409 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscIgnoreErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 410 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscEmacsClientErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 411 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStopErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 412 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAbortErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 413 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAttachDebuggerErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 414 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscReturnErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 415 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscError(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,...) PETSC_PRINTF_FORMAT_CHECK(7,8); 416 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPushErrorHandler(PetscErrorCode (*handler)(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*),void*); 417 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopErrorHandler(void); 418 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDefaultSignalHandler(int,void*); 419 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPushSignalHandler(PetscErrorCode (*)(int,void *),void*); 420 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopSignalHandler(void); 421 422 typedef enum {PETSC_FP_TRAP_OFF=0,PETSC_FP_TRAP_ON=1} PetscFPTrap; 423 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetFPTrap(PetscFPTrap); 424 425 /* 426 Allows the code to build a stack frame as it runs 427 */ 428 #if defined(PETSC_USE_DEBUG) 429 430 #define PETSCSTACKSIZE 15 431 432 typedef struct { 433 const char *function[PETSCSTACKSIZE]; 434 const char *file[PETSCSTACKSIZE]; 435 const char *directory[PETSCSTACKSIZE]; 436 int line[PETSCSTACKSIZE]; 437 int currentsize; 438 } PetscStack; 439 440 extern PETSC_DLLEXPORT PetscStack *petscstack; 441 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackCopy(PetscStack*,PetscStack*); 442 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackPrint(PetscStack*,FILE* fp); 443 444 #define PetscStackActive (petscstack != 0) 445 446 447 /*MC 448 PetscFunctionBegin - First executable line of each PETSc function 449 used for error handling. 450 451 Synopsis: 452 void PetscFunctionBegin; 453 454 Usage: 455 .vb 456 int something; 457 458 PetscFunctionBegin; 459 .ve 460 461 Notes: 462 Not available in Fortran 463 464 Level: developer 465 466 .seealso: PetscFunctionReturn() 467 468 .keywords: traceback, error handling 469 M*/ 470 #define PetscFunctionBegin \ 471 {\ 472 if (petscstack && (petscstack->currentsize < PETSCSTACKSIZE)) { \ 473 petscstack->function[petscstack->currentsize] = __FUNCT__; \ 474 petscstack->file[petscstack->currentsize] = __FILE__; \ 475 petscstack->directory[petscstack->currentsize] = __SDIR__; \ 476 petscstack->line[petscstack->currentsize] = __LINE__; \ 477 petscstack->currentsize++; \ 478 }} 479 480 #define PetscStackPush(n) \ 481 {if (petscstack && (petscstack->currentsize < PETSCSTACKSIZE)) { \ 482 petscstack->function[petscstack->currentsize] = n; \ 483 petscstack->file[petscstack->currentsize] = "unknown"; \ 484 petscstack->directory[petscstack->currentsize] = "unknown"; \ 485 petscstack->line[petscstack->currentsize] = 0; \ 486 petscstack->currentsize++; \ 487 }} 488 489 #define PetscStackPop \ 490 {if (petscstack && petscstack->currentsize > 0) { \ 491 petscstack->currentsize--; \ 492 petscstack->function[petscstack->currentsize] = 0; \ 493 petscstack->file[petscstack->currentsize] = 0; \ 494 petscstack->directory[petscstack->currentsize] = 0; \ 495 petscstack->line[petscstack->currentsize] = 0; \ 496 }}; 497 498 /*MC 499 PetscFunctionReturn - Last executable line of each PETSc function 500 used for error handling. Replaces return() 501 502 Synopsis: 503 void PetscFunctionReturn(0); 504 505 Usage: 506 .vb 507 .... 508 PetscFunctionReturn(0); 509 } 510 .ve 511 512 Notes: 513 Not available in Fortran 514 515 Level: developer 516 517 .seealso: PetscFunctionBegin() 518 519 .keywords: traceback, error handling 520 M*/ 521 #define PetscFunctionReturn(a) \ 522 {\ 523 PetscStackPop; \ 524 return(a);} 525 526 #define PetscFunctionReturnVoid() \ 527 {\ 528 PetscStackPop; \ 529 return;} 530 531 532 #else 533 534 #define PetscFunctionBegin 535 #define PetscFunctionReturn(a) return(a) 536 #define PetscFunctionReturnVoid() return 537 #define PetscStackPop 538 #define PetscStackPush(f) 539 #define PetscStackActive 0 540 541 #endif 542 543 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackCreate(void); 544 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackView(PetscViewer); 545 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackDestroy(void); 546 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackPublish(void); 547 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackDepublish(void); 548 549 550 PETSC_EXTERN_CXX_END 551 #endif 552