154a8ef01SBarry Smith /* 2f621e05eSBarry Smith Contains all error handling interfaces for PETSc. 354a8ef01SBarry Smith */ 445d48df9SBarry Smith #if !defined(__PETSCERROR_H) 545d48df9SBarry Smith #define __PETSCERROR_H 66c7e564aSBarry Smith 7e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN 8c22c1629SBarry Smith 954a8ef01SBarry Smith /* 1054a8ef01SBarry Smith Defines the directory where the compiled source is located; used 115e97870eSBarry Smith in printing error messages. Each makefile has an entry 125e97870eSBarry Smith LOCDIR = thedirectory 13330cf3c9SBarry Smith and bmake/common_variables includes in CCPPFLAGS -D__SDIR__=${LOCDIR} 14f621e05eSBarry Smith which is a flag passed to the C/C++ compilers. This declaration below 15f621e05eSBarry Smith is only needed if some code is compiled without the -D__SDIR__ 1654a8ef01SBarry Smith */ 17330cf3c9SBarry Smith #if !defined(__INSDIR__) 18330cf3c9SBarry Smith #define __INSDIR__ "unknowndirectory/" 1954a8ef01SBarry Smith #endif 2054a8ef01SBarry Smith 2154a8ef01SBarry Smith /* 224f227f7cSBarry Smith Defines the function where the compiled source is located; used 23f621e05eSBarry Smith in printing error messages. This is defined here in case the user 24f621e05eSBarry Smith does not declare it. 254f227f7cSBarry Smith */ 264a2ae208SSatish Balay #if !defined(__FUNCT__) 27da9b6338SBarry Smith #define __FUNCT__ "User provided function" 284f227f7cSBarry Smith #endif 294f227f7cSBarry Smith 304f227f7cSBarry Smith /* 31329ffe3dSLois Curfman McInnes These are the generic error codes. These error codes are used 32e2d1d2b7SBarry Smith many different places in the PETSc source code. The string versions are 330e5e90baSSatish Balay at src/sys/error/err.c any changes here must also be made there 340f9cf654SBarry Smith These are also define in include/finclude/petscerror.h any CHANGES here 350f9cf654SBarry Smith must be also made there. 3645d48df9SBarry Smith 3754a8ef01SBarry Smith */ 382a6744ebSBarry Smith #define PETSC_ERR_MIN_VALUE 54 /* should always be one less then the smallest value */ 392a6744ebSBarry Smith 4045d48df9SBarry Smith #define PETSC_ERR_MEM 55 /* unable to allocate requested memory */ 4147794344SBarry Smith #define PETSC_ERR_SUP 56 /* no support for requested operation */ 42e2d1d2b7SBarry Smith #define PETSC_ERR_SUP_SYS 57 /* no support for requested operation on this computer system */ 43e2d1d2b7SBarry Smith #define PETSC_ERR_ORDER 58 /* operation done in wrong order */ 4445d48df9SBarry Smith #define PETSC_ERR_SIG 59 /* signal received */ 45f1caa5a4SBarry Smith #define PETSC_ERR_FP 72 /* floating point exception */ 46a8c6a408SBarry Smith #define PETSC_ERR_COR 74 /* corrupted PETSc object */ 47a8c6a408SBarry Smith #define PETSC_ERR_LIB 76 /* error in library called by PETSc */ 48329ffe3dSLois Curfman McInnes #define PETSC_ERR_PLIB 77 /* PETSc library generated inconsistent data */ 49329ffe3dSLois Curfman McInnes #define PETSC_ERR_MEMC 78 /* memory corruption */ 50b3cc6726SBarry Smith #define PETSC_ERR_CONV_FAILED 82 /* iterative method (KSP or SNES) failed */ 511302d50aSBarry Smith #define PETSC_ERR_USER 83 /* user has not provided needed function */ 524e2ffeddSBarry Smith #define PETSC_ERR_SYS 88 /* error in system call */ 5345d48df9SBarry Smith 5445d48df9SBarry Smith #define PETSC_ERR_ARG_SIZ 60 /* nonconforming object sizes used in operation */ 5545d48df9SBarry Smith #define PETSC_ERR_ARG_IDN 61 /* two arguments not allowed to be the same */ 56a8c6a408SBarry Smith #define PETSC_ERR_ARG_WRONG 62 /* wrong argument (but object probably ok) */ 5745d48df9SBarry Smith #define PETSC_ERR_ARG_CORRUPT 64 /* null or corrupted PETSc object as argument */ 5845d48df9SBarry Smith #define PETSC_ERR_ARG_OUTOFRANGE 63 /* input argument, out of range */ 594f227f7cSBarry Smith #define PETSC_ERR_ARG_BADPTR 68 /* invalid pointer argument */ 604f227f7cSBarry Smith #define PETSC_ERR_ARG_NOTSAMETYPE 69 /* two args must be same object type */ 616831982aSBarry Smith #define PETSC_ERR_ARG_NOTSAMECOMM 80 /* two args must be same communicators */ 62d252947aSBarry Smith #define PETSC_ERR_ARG_WRONGSTATE 73 /* object in argument is in wrong state, e.g. unassembled mat */ 638cda6cd7SBarry Smith #define PETSC_ERR_ARG_TYPENOTSET 89 /* the type of the object has not yet been set */ 64a8c6a408SBarry Smith #define PETSC_ERR_ARG_INCOMP 75 /* two arguments are incompatible */ 654482741eSBarry Smith #define PETSC_ERR_ARG_NULL 85 /* argument is null that should not be */ 66958c9bccSBarry Smith #define PETSC_ERR_ARG_UNKNOWN_TYPE 86 /* type name doesn't match any registered type */ 674f227f7cSBarry Smith 684f227f7cSBarry Smith #define PETSC_ERR_FILE_OPEN 65 /* unable to open file */ 694f227f7cSBarry Smith #define PETSC_ERR_FILE_READ 66 /* unable to read from file */ 704f227f7cSBarry Smith #define PETSC_ERR_FILE_WRITE 67 /* unable to write to file */ 71a8c6a408SBarry Smith #define PETSC_ERR_FILE_UNEXPECTED 79 /* unexpected data in file */ 7245d48df9SBarry Smith 73329ffe3dSLois Curfman McInnes #define PETSC_ERR_MAT_LU_ZRPVT 71 /* detected a zero pivot during LU factorization */ 749e3b2f23SBarry Smith #define PETSC_ERR_MAT_CH_ZRPVT 81 /* detected a zero pivot during Cholesky factorization */ 7554a8ef01SBarry Smith 76bf3909cdSBarry Smith #define PETSC_ERR_FLOP_COUNT 90 77bf3909cdSBarry Smith #define PETSC_ERR_MAX_VALUE 91 /* this is always the one more than the largest error code */ 782a6744ebSBarry Smith 7959aaf355SLisandro Dalcin #define PetscStringizeArg(a) #a 8059aaf355SLisandro Dalcin #define PetscStringize(a) PetscStringizeArg(a) 81330cf3c9SBarry Smith #define __SDIR__ PetscStringize(__INSDIR__) 82330cf3c9SBarry Smith 83e8b7e333SSatish Balay #if defined(PETSC_USE_ERRORCHECKING) 84e8b7e333SSatish Balay 8530de9b25SBarry Smith /*MC 8630de9b25SBarry Smith SETERRQ - Macro that is called when an error has been detected, 8730de9b25SBarry Smith 8830de9b25SBarry Smith Synopsis: 89e7e72b3dSBarry Smith PetscErrorCode SETERRQ(MPI_Comm comm,PetscErrorCode errorcode,char *message) 9030de9b25SBarry Smith 91eca87e8dSBarry Smith Not Collective 9230de9b25SBarry Smith 9330de9b25SBarry Smith Input Parameters: 9430de9b25SBarry Smith + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 9530de9b25SBarry Smith - message - error message 9630de9b25SBarry Smith 9730de9b25SBarry Smith Level: beginner 9830de9b25SBarry Smith 9930de9b25SBarry Smith Notes: 10030de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 10130de9b25SBarry Smith 10230de9b25SBarry Smith See SETERRQ1(), SETERRQ2(), SETERRQ3() for versions that take arguments 10330de9b25SBarry Smith 10458ebbce7SBarry Smith In Fortran MPI_Abort() is always called 10530de9b25SBarry Smith 10630de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 10730de9b25SBarry Smith 10830de9b25SBarry Smith Concepts: error^setting condition 10930de9b25SBarry Smith 11091d3bdf4SKris Buschelman .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3() 11130de9b25SBarry Smith M*/ 112668f157eSBarry Smith #define SETERRQ(comm,n,s) return PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s) 11330de9b25SBarry Smith 11430de9b25SBarry Smith /*MC 11530de9b25SBarry Smith SETERRQ1 - Macro that is called when an error has been detected, 11630de9b25SBarry Smith 11730de9b25SBarry Smith Synopsis: 118e32f2f54SBarry Smith PetscErrorCode SETERRQ1(MPI_Comm comm,PetscErrorCode errorcode,char *formatmessage,arg) 11930de9b25SBarry Smith 120eca87e8dSBarry Smith Not Collective 12130de9b25SBarry Smith 12230de9b25SBarry Smith Input Parameters: 12330de9b25SBarry Smith + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 12430de9b25SBarry Smith . message - error message in the printf format 12530de9b25SBarry Smith - arg - argument (for example an integer, string or double) 12630de9b25SBarry Smith 12730de9b25SBarry Smith Level: beginner 12830de9b25SBarry Smith 12930de9b25SBarry Smith Notes: 13030de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 13130de9b25SBarry Smith 13230de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 13330de9b25SBarry Smith 13430de9b25SBarry Smith Concepts: error^setting condition 13530de9b25SBarry Smith 13691d3bdf4SKris Buschelman .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ(), SETERRQ2(), SETERRQ3() 13730de9b25SBarry Smith M*/ 138668f157eSBarry Smith #define SETERRQ1(comm,n,s,a1) return PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s,a1) 13930de9b25SBarry Smith 14030de9b25SBarry Smith /*MC 14130de9b25SBarry Smith SETERRQ2 - Macro that is called when an error has been detected, 14230de9b25SBarry Smith 14330de9b25SBarry Smith Synopsis: 144f4442326SMatthew Knepley PetscErrorCode SETERRQ2(PetscErrorCode errorcode,char *formatmessage,arg1,arg2) 14530de9b25SBarry Smith 146eca87e8dSBarry Smith Not Collective 14730de9b25SBarry Smith 14830de9b25SBarry Smith Input Parameters: 14930de9b25SBarry Smith + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 15030de9b25SBarry Smith . message - error message in the printf format 15130de9b25SBarry Smith . arg1 - argument (for example an integer, string or double) 15230de9b25SBarry Smith - arg2 - argument (for example an integer, string or double) 15330de9b25SBarry Smith 15430de9b25SBarry Smith Level: beginner 15530de9b25SBarry Smith 15630de9b25SBarry Smith Notes: 15730de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 15830de9b25SBarry Smith 15930de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 16030de9b25SBarry Smith 16130de9b25SBarry Smith Concepts: error^setting condition 16230de9b25SBarry Smith 1636024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ3() 16430de9b25SBarry Smith M*/ 165668f157eSBarry Smith #define SETERRQ2(comm,n,s,a1,a2) return PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s,a1,a2) 16630de9b25SBarry Smith 16730de9b25SBarry Smith /*MC 16830de9b25SBarry Smith SETERRQ3 - Macro that is called when an error has been detected, 16930de9b25SBarry Smith 17030de9b25SBarry Smith Synopsis: 171f4442326SMatthew Knepley PetscErrorCode SETERRQ3(PetscErrorCode errorcode,char *formatmessage,arg1,arg2,arg3) 17230de9b25SBarry Smith 173eca87e8dSBarry Smith Not Collective 17430de9b25SBarry Smith 17530de9b25SBarry Smith Input Parameters: 17630de9b25SBarry Smith + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 17730de9b25SBarry Smith . message - error message in the printf format 17830de9b25SBarry Smith . arg1 - argument (for example an integer, string or double) 17930de9b25SBarry Smith . arg2 - argument (for example an integer, string or double) 18030de9b25SBarry Smith - arg3 - argument (for example an integer, string or double) 18130de9b25SBarry Smith 18230de9b25SBarry Smith Level: beginner 18330de9b25SBarry Smith 18430de9b25SBarry Smith Notes: 18530de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 18630de9b25SBarry Smith 187f621e05eSBarry Smith There are also versions for 4, 5, 6 and 7 arguments. 188f621e05eSBarry Smith 18930de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 19030de9b25SBarry Smith 19130de9b25SBarry Smith Concepts: error^setting condition 19230de9b25SBarry Smith 1936024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 19430de9b25SBarry Smith M*/ 195668f157eSBarry Smith #define SETERRQ3(comm,n,s,a1,a2,a3) return PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s,a1,a2,a3) 19630de9b25SBarry Smith 197668f157eSBarry Smith #define SETERRQ4(comm,n,s,a1,a2,a3,a4) return PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4) 198668f157eSBarry Smith #define SETERRQ5(comm,n,s,a1,a2,a3,a4,a5) return PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4,a5) 199668f157eSBarry Smith #define SETERRQ6(comm,n,s,a1,a2,a3,a4,a5,a6) return PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4,a5,a6) 200668f157eSBarry Smith #define SETERRQ7(comm,n,s,a1,a2,a3,a4,a5,a6,a7) return PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4,a5,a6,a7) 201668f157eSBarry Smith #define SETERRABORT(comm,n,s) PetscError(comm,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_INITIAL,s);MPI_Abort(comm,n) 2029a00fa46SSatish Balay 20330de9b25SBarry Smith /*MC 20430de9b25SBarry Smith CHKERRQ - Checks error code, if non-zero it calls the error handler and then returns 20530de9b25SBarry Smith 20630de9b25SBarry Smith Synopsis: 207f4442326SMatthew Knepley PetscErrorCode CHKERRQ(PetscErrorCode errorcode) 20830de9b25SBarry Smith 209eca87e8dSBarry Smith Not Collective 21030de9b25SBarry Smith 21130de9b25SBarry Smith Input Parameters: 21230de9b25SBarry Smith . errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 21330de9b25SBarry Smith 21430de9b25SBarry Smith Level: beginner 21530de9b25SBarry Smith 21630de9b25SBarry Smith Notes: 21730de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 21830de9b25SBarry Smith 21930de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 2205324ea47SKris Buschelman 221fcecf507SKris Buschelman CHKERRQ(n) is fundamentally a macro replacement for 2225324ea47SKris Buschelman if (n) return(PetscError(...,n,...)); 2235324ea47SKris Buschelman 2245324ea47SKris Buschelman Although typical usage resembles "void CHKERRQ(PetscErrorCode)" as described above, for certain uses it is 2255324ea47SKris Buschelman highly inappropriate to use it in this manner as it invokes return(PetscErrorCode). In particular, 2265324ea47SKris Buschelman it cannot be used in functions which return(void) or any other datatype. In these types of functions, 22758ebbce7SBarry Smith you can use CHKERRV() which returns without an error code (bad idea since the error is ignored or 2285324ea47SKris Buschelman if (n) {PetscError(....); return(YourReturnType);} 22958ebbce7SBarry Smith where you may pass back a PETSC_NULL to indicate an error. You can also call CHKERRABORT(comm,n) to have 23058ebbce7SBarry Smith MPI_Abort() returned immediately. 23158ebbce7SBarry Smith 23258ebbce7SBarry Smith In Fortran MPI_Abort() is always called 23330de9b25SBarry Smith 23430de9b25SBarry Smith Concepts: error^setting condition 23530de9b25SBarry Smith 23691d3bdf4SKris Buschelman .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ2() 23730de9b25SBarry Smith M*/ 238668f157eSBarry Smith #define CHKERRQ(n) do {if (PetscUnlikely(n)) return PetscError(PETSC_COMM_SELF,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_REPEAT," ");} while (0) 23930de9b25SBarry Smith 240668f157eSBarry Smith #define CHKERRV(n) do {if (PetscUnlikely(n)) {n = PetscError(PETSC_COMM_SELF,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_REPEAT," ");return;}} while(0) 241668f157eSBarry Smith #define CHKERRABORT(comm,n) do {if (PetscUnlikely(n)) {PetscError(PETSC_COMM_SELF,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_REPEAT," ");MPI_Abort(comm,n);}} while (0) 242668f157eSBarry Smith #define CHKERRCONTINUE(n) do {if (PetscUnlikely(n)) {PetscError(PETSC_COMM_SELF,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_REPEAT," ");}} while (0) 24385614651SBarry Smith 244fd705b32SMatthew Knepley #ifdef PETSC_CLANGUAGE_CXX 245fd705b32SMatthew Knepley 246cc26af49SMatthew Knepley /*MC 247cc26af49SMatthew Knepley CHKERRXX - Checks error code, if non-zero it calls the C++ error handler which throws an exception 248cc26af49SMatthew Knepley 249cc26af49SMatthew Knepley Synopsis: 250cc26af49SMatthew Knepley void CHKERRXX(PetscErrorCode errorcode) 251cc26af49SMatthew Knepley 252eca87e8dSBarry Smith Not Collective 253cc26af49SMatthew Knepley 254cc26af49SMatthew Knepley Input Parameters: 255cc26af49SMatthew Knepley . errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 256cc26af49SMatthew Knepley 257cc26af49SMatthew Knepley Level: beginner 258cc26af49SMatthew Knepley 259cc26af49SMatthew Knepley Notes: 260cc26af49SMatthew Knepley Once the error handler throws a ??? exception. 261cc26af49SMatthew Knepley 262cc26af49SMatthew Knepley You can use CHKERRV() which returns without an error code (bad idea since the error is ignored) 263cc26af49SMatthew Knepley or CHKERRABORT(comm,n) to have MPI_Abort() returned immediately. 264cc26af49SMatthew Knepley 265cc26af49SMatthew Knepley Concepts: error^setting condition 266cc26af49SMatthew Knepley 267cc26af49SMatthew Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKERRQ(), CHKMEMQ 268cc26af49SMatthew Knepley M*/ 269*d736bfebSBarry Smith #define CHKERRXX(n) do {if (PetscUnlikely(n)) {PetscError(PETSC_COMM_SELF,__LINE__,__FUNCT__,__FILE__,__SDIR__,n,PETSC_ERROR_IN_CXX,0);}} while(0) 270fd705b32SMatthew Knepley 271fd705b32SMatthew Knepley #endif 272fd705b32SMatthew Knepley 27330de9b25SBarry Smith /*MC 27430de9b25SBarry Smith CHKMEMQ - Checks the memory for corruption, calls error handler if any is detected 27530de9b25SBarry Smith 27630de9b25SBarry Smith Synopsis: 27791d3bdf4SKris Buschelman CHKMEMQ; 27830de9b25SBarry Smith 279eca87e8dSBarry Smith Not Collective 280eca87e8dSBarry Smith 28130de9b25SBarry Smith Level: beginner 28230de9b25SBarry Smith 28330de9b25SBarry Smith Notes: 284ff002950SBarry Smith Must run with the option -malloc_debug to enable this option 28530de9b25SBarry Smith 28630de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 28730de9b25SBarry Smith 28830de9b25SBarry Smith By defaults prints location where memory that is corrupted was allocated. 28930de9b25SBarry Smith 290f621e05eSBarry Smith Use CHKMEMA for functions that return void 291f621e05eSBarry Smith 29230de9b25SBarry Smith Concepts: memory corruption 29330de9b25SBarry Smith 2946024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 295ff002950SBarry Smith PetscMallocValidate() 29630de9b25SBarry Smith M*/ 297cb9801acSJed Brown #define CHKMEMQ do {PetscErrorCode _7_ierr = PetscMallocValidate(__LINE__,__FUNCT__,__FILE__,__SDIR__);CHKERRQ(_7_ierr);} while(0) 29885614651SBarry Smith 299cb9801acSJed Brown #define CHKMEMA PetscMallocValidate(__LINE__,__FUNCT__,__FILE__,__SDIR__) 300e68848bdSBarry Smith 3019dd39edbSMatthew Knepley #if defined(PETSC_UNDERSCORE_CHKERR) 3026849ba73SBarry Smith extern PetscErrorCode __gierr; 303f1af5d2fSBarry Smith #define _ __gierr = 304ac355199SBarry Smith #define ___ CHKERRQ(__gierr); 305f1af5d2fSBarry Smith #endif 306f1af5d2fSBarry Smith 307d5e45103SBarry Smith #define PETSC_EXCEPTIONS_MAX 256 308d5e45103SBarry Smith extern PetscErrorCode PetscErrorUncatchable[PETSC_EXCEPTIONS_MAX]; 309d5e45103SBarry Smith extern PetscInt PetscErrorUncatchableCount; 310d5e45103SBarry Smith extern PetscErrorCode PetscExceptions[PETSC_EXCEPTIONS_MAX]; 311d5e45103SBarry Smith extern PetscInt PetscExceptionsCount; 312d5e45103SBarry Smith 3136024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscExceptionPush(PetscErrorCode); 3141853238fSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscExceptionPop(PetscErrorCode); 315d5e45103SBarry Smith 316c132512eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorSetCatchable(PetscErrorCode,PetscTruth); 31721dd7e22SBarry Smith EXTERN PetscTruth PETSC_DLLEXPORT PetscErrorIsCatchable(PetscErrorCode); 31875febeb1SBarry Smith /*MC 31921dd7e22SBarry Smith PetscExceptionCaught - Indicates if a specific exception zierr was caught. 32075febeb1SBarry Smith 32175febeb1SBarry Smith Synopsis: 32275febeb1SBarry Smith PetscTruth PetscExceptionCaught(PetscErrorCode xierr,PetscErrorCode zierr); 32375febeb1SBarry Smith 324eca87e8dSBarry Smith Not Collective 325eca87e8dSBarry Smith 32675febeb1SBarry Smith Input Parameters: 3271853238fSBarry Smith + xierr - error code returned from PetscExceptionTry1() or other PETSc routine 32875febeb1SBarry Smith - zierr - error code you want it to be 32975febeb1SBarry Smith 33075febeb1SBarry Smith Level: advanced 33175febeb1SBarry Smith 33275febeb1SBarry Smith Notes: 33375febeb1SBarry Smith PETSc must not be configured using the option --with-errorchecking=0 for this to work 33475febeb1SBarry Smith 3351853238fSBarry Smith Use PetscExceptionValue() to see if an error code is being "tried" 33621dd7e22SBarry Smith 3371853238fSBarry Smith Concepts: exceptions, exception handling 33875febeb1SBarry Smith 33975febeb1SBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 34075febeb1SBarry Smith CHKERRQ(), PetscExceptionTry1(), PetscExceptionValue() 34175febeb1SBarry Smith M*/ 342d0f46423SBarry Smith PETSC_STATIC_INLINE PetscTruth PetscExceptionCaught(PetscErrorCode xierr,PetscErrorCode zierr) 343d0f46423SBarry Smith { 344d5e45103SBarry Smith PetscInt i; 345d5e45103SBarry Smith if (xierr != zierr) return PETSC_FALSE; 346d5e45103SBarry Smith for (i=0; i<PetscErrorUncatchableCount; i++) { 347d5e45103SBarry Smith if (PetscErrorUncatchable[i] == zierr) { 348d5e45103SBarry Smith return PETSC_FALSE; 349d5e45103SBarry Smith } 350d5e45103SBarry Smith } 351d5e45103SBarry Smith return PETSC_TRUE; 352d5e45103SBarry Smith } 353d5e45103SBarry Smith 35475febeb1SBarry Smith /*MC 35575febeb1SBarry Smith PetscExceptionValue - Indicates if the error code is one that is currently being tried 356d5e45103SBarry Smith 35775febeb1SBarry Smith Synopsis: 35875febeb1SBarry Smith PetscTruth PetscExceptionValue(PetscErrorCode xierr); 35975febeb1SBarry Smith 360eca87e8dSBarry Smith Not Collective 361eca87e8dSBarry Smith 36275febeb1SBarry Smith Input Parameters: 36375febeb1SBarry Smith . xierr - error code 36475febeb1SBarry Smith 36575febeb1SBarry Smith Level: developer 36675febeb1SBarry Smith 36775febeb1SBarry Smith Notes: 36875febeb1SBarry Smith PETSc must not be configured using the option --with-errorchecking=0 for this to work 36975febeb1SBarry Smith 37021dd7e22SBarry Smith Use PetscExceptionCaught() to see if the current error code is EXACTLY the one you want 37121dd7e22SBarry Smith 37275febeb1SBarry Smith Concepts: exceptions, exception hanlding 37375febeb1SBarry Smith 37475febeb1SBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 37575febeb1SBarry Smith CHKERRQ(), PetscExceptionTry1(), PetscExceptionCaught() 37675febeb1SBarry Smith M*/ 377d0f46423SBarry Smith PETSC_STATIC_INLINE PetscTruth PetscExceptionValue(PetscErrorCode zierr) 378d0f46423SBarry Smith { 379d5e45103SBarry Smith PetscInt i; 380d5e45103SBarry Smith for (i=0; i<PetscExceptionsCount; i++) { 381d5e45103SBarry Smith if (PetscExceptions[i] == zierr) { 382d5e45103SBarry Smith return PETSC_TRUE; 383d5e45103SBarry Smith } 384d5e45103SBarry Smith } 385d5e45103SBarry Smith return PETSC_FALSE; 386d5e45103SBarry Smith } 3876024bd2cSBarry Smith 3886024bd2cSBarry Smith /*MC 3896024bd2cSBarry Smith PetscExceptionTry1 - Runs the routine, causing a particular error code to be treated as an exception, 3906024bd2cSBarry Smith rather than an error. That is if that error code is treated the program returns to this level, 3916024bd2cSBarry Smith but does not call the error handlers 3926024bd2cSBarry Smith 3936024bd2cSBarry Smith Synopsis: 3941853238fSBarry Smith PetscErrorCode PetscExceptionTry1(PetscErrorCode routine(....),PetscErrorCode); 3956024bd2cSBarry Smith 396eca87e8dSBarry Smith Not Collective 397eca87e8dSBarry Smith 3986024bd2cSBarry Smith Level: advanced 3996024bd2cSBarry Smith 4001853238fSBarry Smith No Fortran Equivalent (see PetscExceptionPush() for Fortran) 4011853238fSBarry Smith 4026024bd2cSBarry Smith Notes: 4036024bd2cSBarry Smith PETSc must not be configured using the option --with-errorchecking=0 for this to work 4046024bd2cSBarry Smith 40575febeb1SBarry Smith Note: In general, the outer most try on an exception is the one that will be caught (that is trys down in 40675febeb1SBarry Smith PETSc code will not usually handle an exception that was issued above). See SNESSolve() for an example 40775febeb1SBarry Smith of how the local try is ignored if a higher (in the stack) one is also in effect. 4086024bd2cSBarry Smith 4096024bd2cSBarry Smith Concepts: exceptions, exception hanlding 4106024bd2cSBarry Smith 4116024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 41221dd7e22SBarry Smith CHKERRQ(), PetscExceptionCaught(), PetscExceptionPush(), PetscExceptionPop() 4136024bd2cSBarry Smith M*/ 4147b0215c6SHong Zhang extern PetscErrorCode PetscExceptionTmp,PetscExceptionTmp1; 4157b0215c6SHong Zhang #define PetscExceptionTry1(a,b) (PetscExceptionTmp1 = PetscExceptionPush(b)) ? PetscExceptionTmp1 : (PetscExceptionTmp1 = a, (PetscExceptionTmp = PetscExceptionPop(b)) ? PetscExceptionTmp : PetscExceptionTmp1) 4166024bd2cSBarry Smith 417f70662edSBarry Smith /* 418f70662edSBarry Smith Used by PetscExceptionTrySync(). Returns zierr on ALL processes in comm iff xierr is zierr on at least one process and zero on all others. 419f70662edSBarry Smith */ 420f70662edSBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscExceptionTrySync_Private(MPI_Comm comm,PetscErrorCode xierr,PetscErrorCode zierr) 421f70662edSBarry Smith { 422f70662edSBarry Smith PetscReal in[2],out[2]; 423f70662edSBarry Smith PetscErrorCode ierr; 424f70662edSBarry Smith 425f70662edSBarry Smith if (xierr != zierr) return xierr; 426f70662edSBarry Smith 427f70662edSBarry Smith in[0] = xierr; 428f70662edSBarry Smith in[1] = 0.0; /* dummy value */ 429f70662edSBarry Smith 430f70662edSBarry Smith ierr = MPI_Allreduce(in,out,2,MPIU_REAL,0,comm); if (ierr) {;} 431f70662edSBarry Smith return xierr; 432f70662edSBarry Smith } 433f70662edSBarry Smith 434f70662edSBarry Smith /*MC 435f70662edSBarry Smith PetscExceptionTrySyncNorm - Runs the routine, causing a particular error code to be treated as an exception, 436f70662edSBarry Smith rather than an error. That is if that error code is treated the program returns to this level, 437f70662edSBarry Smith but does not call the error handlers 438f70662edSBarry Smith 439f70662edSBarry Smith Synopsis: 440f70662edSBarry Smith PetscExceptionTrySyncNorm(MPI_Comm comm,PetscErrorCode routine(....),PetscErrorCode); 441f70662edSBarry Smith 442eca87e8dSBarry Smith Collective on Comm 443eca87e8dSBarry Smith 444f70662edSBarry Smith Level: advanced 445f70662edSBarry Smith 446f70662edSBarry Smith Notes: This synchronizes the error code across all processes in the communicator IF the code matches PetscErrorCode. The next 447f70662edSBarry Smith call with an MPI_Reduce()/MPI_Allreduce() MUST be VecNorm() [We can added VecDot() and maybe others as needed]. 448f70662edSBarry Smith 449f70662edSBarry Smith PETSc must not be configured using the option --with-errorchecking=0 for this to work 450f70662edSBarry Smith 451f70662edSBarry Smith Note: In general, the outer most try on an exception is the one that will be caught (that is trys down in 452f70662edSBarry Smith PETSc code will not usually handle an exception that was issued above). See SNESSolve() for an example 453f70662edSBarry Smith of how the local try is ignored if a higher (in the stack) one is also in effect. 454f70662edSBarry Smith 455f70662edSBarry Smith Concepts: exceptions, exception hanlding 456f70662edSBarry Smith 457f70662edSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 458f70662edSBarry Smith CHKERRQ(), PetscExceptionCaught(), PetscExceptionPush(), PetscExceptionPop(), PetscExceptionTry1() 459f70662edSBarry Smith M*/ 460f70662edSBarry Smith #define PetscExceptionTrySyncNorm(comm,a,b) (PetscExceptionTmp = PetscExceptionPush(b)) ? PetscExceptionTmp : \ 461f70662edSBarry Smith (PetscExceptionTmp = a , PetscExceptionPop(b),PetscExceptionTrySyncNorm_Private(comm,PetscExceptionTmp,b)) 462f70662edSBarry Smith 46354a8ef01SBarry Smith #else 464f621e05eSBarry Smith 465f621e05eSBarry Smith /* 466e2e64c6bSBarry Smith These are defined to be empty for when error checking is turned off, with ./configure --with-errorchecking=0 467f621e05eSBarry Smith */ 468f621e05eSBarry Smith 4694b209cf6SBarry Smith #define SETERRQ(c,n,s) 4704b209cf6SBarry Smith #define SETERRQ1(c,n,s,a1) 4714b209cf6SBarry Smith #define SETERRQ2(c,n,s,a1,a2) 4724b209cf6SBarry Smith #define SETERRQ3(c,n,s,a1,a2,a3) 4734b209cf6SBarry Smith #define SETERRQ4(c,n,s,a1,a2,a3,a4) 4744b209cf6SBarry Smith #define SETERRQ5(c,n,s,a1,a2,a3,a4,a5) 4754b209cf6SBarry Smith #define SETERRQ6(c,n,s,a1,a2,a3,a4,a5,a6) 4764b209cf6SBarry Smith #define SETERRABORT(comm,n,s) 47785614651SBarry Smith 4784f227f7cSBarry Smith #define CHKERRQ(n) ; 4791ee4faa0SMatthew Knepley #define CHKERRABORT(comm,n) ; 4801ee4faa0SMatthew Knepley #define CHKERRCONTINUE(n) ; 48185614651SBarry Smith #define CHKMEMQ ; 48285614651SBarry Smith 483f1af5d2fSBarry Smith #if !defined(PETSC_SKIP_UNDERSCORE_CHKERR) 484f1af5d2fSBarry Smith #define _ 485f1af5d2fSBarry Smith #define ___ 486f1af5d2fSBarry Smith #endif 487f1af5d2fSBarry Smith 4888da67ba8SSatish Balay #define PetscExceptionPush(a) 0 4891853238fSBarry Smith #define PetscExceptionPop(a) 0 490c132512eSBarry Smith #define PetscErrorSetCatchable(a,b) 0 4918da67ba8SSatish Balay #define PetscErrorIsCatchable(a) PETSC_FALSE 4928da67ba8SSatish Balay 493c132512eSBarry Smith #define PetscExceptionCaught(a,b) PETSC_FALSE 494c132512eSBarry Smith #define PetscExceptionValue(a) PETSC_FALSE 4956024bd2cSBarry Smith #define PetscExceptionTry1(a,b) a 496f70662edSBarry Smith #define PetscExceptionTrySyncNorm(comm,a,b) a 497f70662edSBarry Smith 49854a8ef01SBarry Smith #endif 49954a8ef01SBarry Smith 500668f157eSBarry Smith /*E 501668f157eSBarry Smith PetscErrorType - passed to the PETSc error handling routines indicating if this is the first or a later call to the error handlers 502668f157eSBarry Smith 503668f157eSBarry Smith Level: advanced 504668f157eSBarry Smith 505*d736bfebSBarry Smith PETSC_ERROR_IN_CXX indicates the error was detected in C++ and an exception should be generated 506*d736bfebSBarry Smith 507668f157eSBarry Smith Developer Notes: This is currently used to decide when to print the detailed information about the run in PetscTraceBackErrorHandling() 508668f157eSBarry Smith 509*d736bfebSBarry Smith .seealso: PetscError(), SETERRXX() 510668f157eSBarry Smith E*/ 511*d736bfebSBarry Smith typedef enum {PETSC_ERROR_INITIAL=0,PETSC_ERROR_REPEAT=1,PETSC_ERROR_IN_CXX = 2} PetscErrorType; 5124b209cf6SBarry Smith 513ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorPrintfInitialize(void); 514ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorMessage(int,const char*[],char **); 515668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTraceBackErrorHandler(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 5160577ce7cSSatish Balay #if defined(PETSC_CLANGUAGE_CXX) && !defined(PETSC_USE_EXTERN_CXX) 517fd705b32SMatthew Knepley #include <sstream> 518*d736bfebSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTraceBackErrorHandlerCxx(MPI_Comm,int,const char *,const char *,const char *,PetscErrorCode,PetscErrorType,const char*,void*); 519fd705b32SMatthew Knepley #endif 520668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscIgnoreErrorHandler(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 521668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscEmacsClientErrorHandler(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 522668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMPIAbortErrorHandler(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 523668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAbortErrorHandler(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 524668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAttachDebuggerErrorHandler(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 525668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscReturnErrorHandler(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 526668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscError(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,...) PETSC_PRINTF_FORMAT_CHECK(7,8); 527668f157eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPushErrorHandler(PetscErrorCode (*handler)(MPI_Comm,int,const char*,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*),void*); 528ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopErrorHandler(void); 529ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDefaultSignalHandler(int,void*); 530ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPushSignalHandler(PetscErrorCode (*)(int,void *),void*); 531ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopSignalHandler(void); 532329f5518SBarry Smith 533329f5518SBarry Smith typedef enum {PETSC_FP_TRAP_OFF=0,PETSC_FP_TRAP_ON=1} PetscFPTrap; 534ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetFPTrap(PetscFPTrap); 53554a8ef01SBarry Smith 5363a40ed3dSBarry Smith /* 5373a40ed3dSBarry Smith Allows the code to build a stack frame as it runs 5383a40ed3dSBarry Smith */ 53951d3a450SBarry Smith #if defined(PETSC_USE_DEBUG) 5403a40ed3dSBarry Smith 54199cd645aSJed Brown #define PETSCSTACKSIZE 64 542184914b5SBarry Smith 5433a40ed3dSBarry Smith typedef struct { 5440e33f6ddSBarry Smith const char *function[PETSCSTACKSIZE]; 5450e33f6ddSBarry Smith const char *file[PETSCSTACKSIZE]; 5460e33f6ddSBarry Smith const char *directory[PETSCSTACKSIZE]; 547184914b5SBarry Smith int line[PETSCSTACKSIZE]; 548184914b5SBarry Smith int currentsize; 5493a40ed3dSBarry Smith } PetscStack; 5503a40ed3dSBarry Smith 551ff73aad6SKris Buschelman extern PETSC_DLLEXPORT PetscStack *petscstack; 552ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackCopy(PetscStack*,PetscStack*); 553ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackPrint(PetscStack*,FILE* fp); 554184914b5SBarry Smith 555184914b5SBarry Smith #define PetscStackActive (petscstack != 0) 5563a40ed3dSBarry Smith 5576d385327SIbrahima Ba 55830de9b25SBarry Smith /*MC 55930de9b25SBarry Smith PetscFunctionBegin - First executable line of each PETSc function 56030de9b25SBarry Smith used for error handling. 56130de9b25SBarry Smith 56230de9b25SBarry Smith Synopsis: 56330de9b25SBarry Smith void PetscFunctionBegin; 56430de9b25SBarry Smith 565eca87e8dSBarry Smith Not Collective 566eca87e8dSBarry Smith 56730de9b25SBarry Smith Usage: 56830de9b25SBarry Smith .vb 56930de9b25SBarry Smith int something; 57030de9b25SBarry Smith 57130de9b25SBarry Smith PetscFunctionBegin; 57230de9b25SBarry Smith .ve 57330de9b25SBarry Smith 57430de9b25SBarry Smith Notes: 57530de9b25SBarry Smith Not available in Fortran 57630de9b25SBarry Smith 57730de9b25SBarry Smith Level: developer 57830de9b25SBarry Smith 57930de9b25SBarry Smith .seealso: PetscFunctionReturn() 58030de9b25SBarry Smith 58130de9b25SBarry Smith .keywords: traceback, error handling 58230de9b25SBarry Smith M*/ 5833a40ed3dSBarry Smith #define PetscFunctionBegin \ 584beb17490SBarry Smith {\ 585184914b5SBarry Smith if (petscstack && (petscstack->currentsize < PETSCSTACKSIZE)) { \ 5864a2ae208SSatish Balay petscstack->function[petscstack->currentsize] = __FUNCT__; \ 587184914b5SBarry Smith petscstack->file[petscstack->currentsize] = __FILE__; \ 588184914b5SBarry Smith petscstack->directory[petscstack->currentsize] = __SDIR__; \ 589184914b5SBarry Smith petscstack->line[petscstack->currentsize] = __LINE__; \ 590184914b5SBarry Smith petscstack->currentsize++; \ 5913a40ed3dSBarry Smith }} 5923a40ed3dSBarry Smith 5935cd90555SBarry Smith #define PetscStackPush(n) \ 594184914b5SBarry Smith {if (petscstack && (petscstack->currentsize < PETSCSTACKSIZE)) { \ 595184914b5SBarry Smith petscstack->function[petscstack->currentsize] = n; \ 596184914b5SBarry Smith petscstack->file[petscstack->currentsize] = "unknown"; \ 597184914b5SBarry Smith petscstack->directory[petscstack->currentsize] = "unknown"; \ 598184914b5SBarry Smith petscstack->line[petscstack->currentsize] = 0; \ 599184914b5SBarry Smith petscstack->currentsize++; \ 6005cd90555SBarry Smith }} 6013a40ed3dSBarry Smith 602d64ed03dSBarry Smith #define PetscStackPop \ 603184914b5SBarry Smith {if (petscstack && petscstack->currentsize > 0) { \ 604184914b5SBarry Smith petscstack->currentsize--; \ 605184914b5SBarry Smith petscstack->function[petscstack->currentsize] = 0; \ 606184914b5SBarry Smith petscstack->file[petscstack->currentsize] = 0; \ 607184914b5SBarry Smith petscstack->directory[petscstack->currentsize] = 0; \ 608184914b5SBarry Smith petscstack->line[petscstack->currentsize] = 0; \ 6095cd90555SBarry Smith }}; 610d64ed03dSBarry Smith 61130de9b25SBarry Smith /*MC 61230de9b25SBarry Smith PetscFunctionReturn - Last executable line of each PETSc function 61330de9b25SBarry Smith used for error handling. Replaces return() 61430de9b25SBarry Smith 61530de9b25SBarry Smith Synopsis: 61630de9b25SBarry Smith void PetscFunctionReturn(0); 61730de9b25SBarry Smith 618eca87e8dSBarry Smith Not Collective 619eca87e8dSBarry Smith 62030de9b25SBarry Smith Usage: 62130de9b25SBarry Smith .vb 62230de9b25SBarry Smith .... 62330de9b25SBarry Smith PetscFunctionReturn(0); 62430de9b25SBarry Smith } 62530de9b25SBarry Smith .ve 62630de9b25SBarry Smith 62730de9b25SBarry Smith Notes: 62830de9b25SBarry Smith Not available in Fortran 62930de9b25SBarry Smith 63030de9b25SBarry Smith Level: developer 63130de9b25SBarry Smith 63230de9b25SBarry Smith .seealso: PetscFunctionBegin() 63330de9b25SBarry Smith 63430de9b25SBarry Smith .keywords: traceback, error handling 63530de9b25SBarry Smith M*/ 6365cd90555SBarry Smith #define PetscFunctionReturn(a) \ 637beb17490SBarry Smith {\ 63806d1fe2cSBarry Smith PetscStackPop; \ 6395cd90555SBarry Smith return(a);} 640d64ed03dSBarry Smith 641ff94ddecSSatish Balay #define PetscFunctionReturnVoid() \ 642ff94ddecSSatish Balay {\ 6431fceb228SKris Buschelman PetscStackPop; \ 6441fceb228SKris Buschelman return;} 645ff94ddecSSatish Balay 6466d385327SIbrahima Ba 6476d385327SIbrahima Ba #else 6486d385327SIbrahima Ba 6493a40ed3dSBarry Smith #define PetscFunctionBegin 6503a40ed3dSBarry Smith #define PetscFunctionReturn(a) return(a) 6515665465eSBarry Smith #define PetscFunctionReturnVoid() return 652d64ed03dSBarry Smith #define PetscStackPop 653d64ed03dSBarry Smith #define PetscStackPush(f) 654d64ed03dSBarry Smith #define PetscStackActive 0 6553a40ed3dSBarry Smith 6563a40ed3dSBarry Smith #endif 6573a40ed3dSBarry Smith 658ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackCreate(void); 659ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackView(PetscViewer); 660ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackDestroy(void); 661ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackPublish(void); 662ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackDepublish(void); 6633a40ed3dSBarry Smith 66406d1fe2cSBarry Smith 665e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 66606d1fe2cSBarry Smith #endif 667