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