154a8ef01SBarry Smith /* 2f621e05eSBarry Smith Contains all error handling interfaces for PETSc. 354a8ef01SBarry Smith */ 445d48df9SBarry Smith #if !defined(__PETSCERROR_H) 545d48df9SBarry Smith #define __PETSCERROR_H 6c22c1629SBarry Smith #include "petsc.h" 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 130cd5afcaSLois Curfman McInnes 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 */ 17c22c1629SBarry Smith #if !defined(__SDIR__) 182ee1dbe0SBarry Smith #define __SDIR__ "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 */ 63a8c6a408SBarry Smith #define PETSC_ERR_ARG_INCOMP 75 /* two arguments are incompatible */ 644482741eSBarry Smith #define PETSC_ERR_ARG_NULL 85 /* argument is null that should not be */ 65958c9bccSBarry Smith #define PETSC_ERR_ARG_UNKNOWN_TYPE 86 /* type name doesn't match any registered type */ 66c2be2410SBarry Smith #define PETSC_ERR_ARG_DOMAIN 87 /* argument is not in domain of function */ 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 764e2ffeddSBarry Smith #define PETSC_ERR_MAX_VALUE 89 /* this is always the one more than the largest error code */ 772a6744ebSBarry Smith 784b55f32eSBarry Smith #if defined(PETSC_USE_ERRORCHECKING) 7930de9b25SBarry Smith 8030de9b25SBarry Smith /*MC 8130de9b25SBarry Smith SETERRQ - Macro that is called when an error has been detected, 8230de9b25SBarry Smith 8330de9b25SBarry Smith Not Collective 8430de9b25SBarry Smith 8530de9b25SBarry Smith Synopsis: 86f4442326SMatthew Knepley PetscErrorCode SETERRQ(PetscErrorCode errorcode,char *message) 8730de9b25SBarry Smith 8830de9b25SBarry Smith 8930de9b25SBarry Smith Input Parameters: 9030de9b25SBarry Smith + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 9130de9b25SBarry Smith - message - error message 9230de9b25SBarry Smith 9330de9b25SBarry Smith Level: beginner 9430de9b25SBarry Smith 9530de9b25SBarry Smith Notes: 9630de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 9730de9b25SBarry Smith 9830de9b25SBarry Smith See SETERRQ1(), SETERRQ2(), SETERRQ3() for versions that take arguments 9930de9b25SBarry Smith 10058ebbce7SBarry Smith In Fortran MPI_Abort() is always called 10130de9b25SBarry Smith 10230de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 10330de9b25SBarry Smith 10430de9b25SBarry Smith Concepts: error^setting condition 10530de9b25SBarry Smith 10691d3bdf4SKris Buschelman .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3() 10730de9b25SBarry Smith M*/ 1084a2ae208SSatish Balay #define SETERRQ(n,s) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s);} 10930de9b25SBarry Smith 11030de9b25SBarry Smith /*MC 11130de9b25SBarry Smith SETERRQ1 - Macro that is called when an error has been detected, 11230de9b25SBarry Smith 11330de9b25SBarry Smith Not Collective 11430de9b25SBarry Smith 11530de9b25SBarry Smith Synopsis: 116f4442326SMatthew Knepley PetscErrorCode SETERRQ1(PetscErrorCode errorcode,char *formatmessage,arg) 11730de9b25SBarry Smith 11830de9b25SBarry Smith 11930de9b25SBarry Smith Input Parameters: 12030de9b25SBarry Smith + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 12130de9b25SBarry Smith . message - error message in the printf format 12230de9b25SBarry Smith - arg - argument (for example an integer, string or double) 12330de9b25SBarry Smith 12430de9b25SBarry Smith Level: beginner 12530de9b25SBarry Smith 12630de9b25SBarry Smith Notes: 12730de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 12830de9b25SBarry Smith 12930de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 13030de9b25SBarry Smith 13130de9b25SBarry Smith Concepts: error^setting condition 13230de9b25SBarry Smith 13391d3bdf4SKris Buschelman .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ(), SETERRQ2(), SETERRQ3() 13430de9b25SBarry Smith M*/ 1354a2ae208SSatish Balay #define SETERRQ1(n,s,a1) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1);} 13630de9b25SBarry Smith 13730de9b25SBarry Smith /*MC 13830de9b25SBarry Smith SETERRQ2 - Macro that is called when an error has been detected, 13930de9b25SBarry Smith 14030de9b25SBarry Smith Not Collective 14130de9b25SBarry Smith 14230de9b25SBarry Smith Synopsis: 143f4442326SMatthew Knepley PetscErrorCode SETERRQ2(PetscErrorCode errorcode,char *formatmessage,arg1,arg2) 14430de9b25SBarry Smith 14530de9b25SBarry Smith 14630de9b25SBarry Smith Input Parameters: 14730de9b25SBarry Smith + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 14830de9b25SBarry Smith . message - error message in the printf format 14930de9b25SBarry Smith . arg1 - argument (for example an integer, string or double) 15030de9b25SBarry Smith - arg2 - argument (for example an integer, string or double) 15130de9b25SBarry Smith 15230de9b25SBarry Smith Level: beginner 15330de9b25SBarry Smith 15430de9b25SBarry Smith Notes: 15530de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 15630de9b25SBarry Smith 15730de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 15830de9b25SBarry Smith 15930de9b25SBarry Smith Concepts: error^setting condition 16030de9b25SBarry Smith 1616024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ3() 16230de9b25SBarry Smith M*/ 1634a2ae208SSatish Balay #define SETERRQ2(n,s,a1,a2) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2);} 16430de9b25SBarry Smith 16530de9b25SBarry Smith /*MC 16630de9b25SBarry Smith SETERRQ3 - Macro that is called when an error has been detected, 16730de9b25SBarry Smith 16830de9b25SBarry Smith Not Collective 16930de9b25SBarry Smith 17030de9b25SBarry Smith Synopsis: 171f4442326SMatthew Knepley PetscErrorCode SETERRQ3(PetscErrorCode errorcode,char *formatmessage,arg1,arg2,arg3) 17230de9b25SBarry Smith 17330de9b25SBarry Smith 17430de9b25SBarry Smith Input Parameters: 17530de9b25SBarry Smith + errorcode - nonzero error code, see the list of standard error codes in include/petscerror.h 17630de9b25SBarry Smith . message - error message in the printf format 17730de9b25SBarry Smith . arg1 - argument (for example an integer, string or double) 17830de9b25SBarry Smith . arg2 - argument (for example an integer, string or double) 17930de9b25SBarry Smith - arg3 - argument (for example an integer, string or double) 18030de9b25SBarry Smith 18130de9b25SBarry Smith Level: beginner 18230de9b25SBarry Smith 18330de9b25SBarry Smith Notes: 18430de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 18530de9b25SBarry Smith 186f621e05eSBarry Smith There are also versions for 4, 5, 6 and 7 arguments. 187f621e05eSBarry Smith 18830de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 18930de9b25SBarry Smith 19030de9b25SBarry Smith Concepts: error^setting condition 19130de9b25SBarry Smith 1926024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 19330de9b25SBarry Smith M*/ 1944a2ae208SSatish Balay #define SETERRQ3(n,s,a1,a2,a3) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2,a3);} 19530de9b25SBarry Smith 1964a2ae208SSatish Balay #define SETERRQ4(n,s,a1,a2,a3,a4) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2,a3,a4);} 197a30c184eSMatthew Knepley #define SETERRQ5(n,s,a1,a2,a3,a4,a5) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s,a1,a2,a3,a4,a5);} 198a30c184eSMatthew Knepley #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);} 199a30c184eSMatthew Knepley #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);} 200e855a17bSBarry Smith #define SETERRABORT(comm,n,s) {PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,1,s);MPI_Abort(comm,n);} 2019a00fa46SSatish Balay 20230de9b25SBarry Smith /*MC 20330de9b25SBarry Smith CHKERRQ - Checks error code, if non-zero it calls the error handler and then returns 20430de9b25SBarry Smith 20530de9b25SBarry Smith Not Collective 20630de9b25SBarry Smith 20730de9b25SBarry Smith Synopsis: 208f4442326SMatthew Knepley PetscErrorCode CHKERRQ(PetscErrorCode errorcode) 20930de9b25SBarry Smith 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*/ 238c3be3f59SMatthew Knepley #define CHKERRQ(n) if (n) {return PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,0," ");} 23930de9b25SBarry Smith 24007d81ca4SBarry Smith #define CHKERRV(n) if (n) {n = PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,0," ");return;} 24194a56cdfSMatthew Knepley #define CHKERRABORT(comm,n) if (n) {PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,0," ");MPI_Abort(comm,n);} 24294a56cdfSMatthew Knepley #define CHKERRCONTINUE(n) if (n) {PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,0," ");} 24385614651SBarry Smith 244a9c3d0aeSMatthew Knepley #define CHKFPQ(f) if (f != f) {SETERRQ(PETSC_ERR_FP, "Invalid value: NaN");} 245a9c3d0aeSMatthew Knepley 246*fd705b32SMatthew Knepley #ifdef PETSC_CLANGUAGE_CXX 247*fd705b32SMatthew Knepley 248*fd705b32SMatthew Knepley #define CHKERRXX(n) if (n) {PetscErrorCxx(__LINE__,__FUNCT__,__FILE__,__SDIR__,n,0);} 249*fd705b32SMatthew Knepley 250*fd705b32SMatthew Knepley #endif 251*fd705b32SMatthew Knepley 25230de9b25SBarry Smith /*MC 25330de9b25SBarry Smith CHKMEMQ - Checks the memory for corruption, calls error handler if any is detected 25430de9b25SBarry Smith 25530de9b25SBarry Smith Not Collective 25630de9b25SBarry Smith 25730de9b25SBarry Smith Synopsis: 25891d3bdf4SKris Buschelman CHKMEMQ; 25930de9b25SBarry Smith 26030de9b25SBarry Smith Level: beginner 26130de9b25SBarry Smith 26230de9b25SBarry Smith Notes: 263ff002950SBarry Smith Must run with the option -malloc_debug to enable this option 26430de9b25SBarry Smith 26530de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 26630de9b25SBarry Smith 26730de9b25SBarry Smith By defaults prints location where memory that is corrupted was allocated. 26830de9b25SBarry Smith 269f621e05eSBarry Smith Use CHKMEMA for functions that return void 270f621e05eSBarry Smith 27130de9b25SBarry Smith Concepts: memory corruption 27230de9b25SBarry Smith 2736024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 274ff002950SBarry Smith PetscMallocValidate() 27530de9b25SBarry Smith M*/ 276ff002950SBarry Smith #define CHKMEMQ {PetscErrorCode _7_ierr = PetscMallocValidate(__LINE__,__FUNCT__,__FILE__,__SDIR__);CHKERRQ(_7_ierr);} 27785614651SBarry Smith 278e68848bdSBarry Smith #define CHKMEMA {PetscMallocValidate(__LINE__,__FUNCT__,__FILE__,__SDIR__);} 279e68848bdSBarry Smith 2809dd39edbSMatthew Knepley #if defined(PETSC_UNDERSCORE_CHKERR) 2816849ba73SBarry Smith extern PetscErrorCode __gierr; 282f1af5d2fSBarry Smith #define _ __gierr = 283ac355199SBarry Smith #define ___ CHKERRQ(__gierr); 284f1af5d2fSBarry Smith #endif 285f1af5d2fSBarry Smith 286d5e45103SBarry Smith #define PETSC_EXCEPTIONS_MAX 256 287d5e45103SBarry Smith extern PetscErrorCode PetscErrorUncatchable[PETSC_EXCEPTIONS_MAX]; 288d5e45103SBarry Smith extern PetscInt PetscErrorUncatchableCount; 289d5e45103SBarry Smith extern PetscErrorCode PetscExceptions[PETSC_EXCEPTIONS_MAX]; 290d5e45103SBarry Smith extern PetscInt PetscExceptionsCount; 291d5e45103SBarry Smith 2926024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscExceptionPush(PetscErrorCode); 2931853238fSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscExceptionPop(PetscErrorCode); 294d5e45103SBarry Smith 295c132512eSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorSetCatchable(PetscErrorCode,PetscTruth); 29621dd7e22SBarry Smith EXTERN PetscTruth PETSC_DLLEXPORT PetscErrorIsCatchable(PetscErrorCode); 29775febeb1SBarry Smith /*MC 29821dd7e22SBarry Smith PetscExceptionCaught - Indicates if a specific exception zierr was caught. 29975febeb1SBarry Smith 30075febeb1SBarry Smith Not Collective 30175febeb1SBarry Smith 30275febeb1SBarry Smith Synopsis: 30375febeb1SBarry Smith PetscTruth PetscExceptionCaught(PetscErrorCode xierr,PetscErrorCode zierr); 30475febeb1SBarry Smith 30575febeb1SBarry Smith Input Parameters: 3061853238fSBarry Smith + xierr - error code returned from PetscExceptionTry1() or other PETSc routine 30775febeb1SBarry Smith - zierr - error code you want it to be 30875febeb1SBarry Smith 30975febeb1SBarry Smith Level: advanced 31075febeb1SBarry Smith 31175febeb1SBarry Smith Notes: 31275febeb1SBarry Smith PETSc must not be configured using the option --with-errorchecking=0 for this to work 31375febeb1SBarry Smith 3141853238fSBarry Smith Use PetscExceptionValue() to see if an error code is being "tried" 31521dd7e22SBarry Smith 3161853238fSBarry Smith Concepts: exceptions, exception handling 31775febeb1SBarry Smith 31875febeb1SBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 31975febeb1SBarry Smith CHKERRQ(), PetscExceptionTry1(), PetscExceptionValue() 32075febeb1SBarry Smith M*/ 3212a6677a3SSatish Balay PETSC_STATIC_INLINE PetscTruth PetscExceptionCaught(PetscErrorCode xierr,PetscErrorCode zierr) { 322d5e45103SBarry Smith PetscInt i; 323d5e45103SBarry Smith if (xierr != zierr) return PETSC_FALSE; 324d5e45103SBarry Smith for (i=0; i<PetscErrorUncatchableCount; i++) { 325d5e45103SBarry Smith if (PetscErrorUncatchable[i] == zierr) { 326d5e45103SBarry Smith return PETSC_FALSE; 327d5e45103SBarry Smith } 328d5e45103SBarry Smith } 329d5e45103SBarry Smith return PETSC_TRUE; 330d5e45103SBarry Smith } 331d5e45103SBarry Smith 33275febeb1SBarry Smith /*MC 33375febeb1SBarry Smith PetscExceptionValue - Indicates if the error code is one that is currently being tried 334d5e45103SBarry Smith 33575febeb1SBarry Smith Not Collective 33675febeb1SBarry Smith 33775febeb1SBarry Smith Synopsis: 33875febeb1SBarry Smith PetscTruth PetscExceptionValue(PetscErrorCode xierr); 33975febeb1SBarry Smith 34075febeb1SBarry Smith Input Parameters: 34175febeb1SBarry Smith . xierr - error code 34275febeb1SBarry Smith 34375febeb1SBarry Smith Level: developer 34475febeb1SBarry Smith 34575febeb1SBarry Smith Notes: 34675febeb1SBarry Smith PETSc must not be configured using the option --with-errorchecking=0 for this to work 34775febeb1SBarry Smith 34821dd7e22SBarry Smith Use PetscExceptionCaught() to see if the current error code is EXACTLY the one you want 34921dd7e22SBarry Smith 35075febeb1SBarry Smith Concepts: exceptions, exception hanlding 35175febeb1SBarry Smith 35275febeb1SBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 35375febeb1SBarry Smith CHKERRQ(), PetscExceptionTry1(), PetscExceptionCaught() 35475febeb1SBarry Smith M*/ 3552a6677a3SSatish Balay PETSC_STATIC_INLINE PetscTruth PetscExceptionValue(PetscErrorCode zierr) { 356d5e45103SBarry Smith PetscInt i; 357d5e45103SBarry Smith for (i=0; i<PetscExceptionsCount; i++) { 358d5e45103SBarry Smith if (PetscExceptions[i] == zierr) { 359d5e45103SBarry Smith return PETSC_TRUE; 360d5e45103SBarry Smith } 361d5e45103SBarry Smith } 362d5e45103SBarry Smith return PETSC_FALSE; 363d5e45103SBarry Smith } 3646024bd2cSBarry Smith 3656024bd2cSBarry Smith /*MC 3666024bd2cSBarry Smith PetscExceptionTry1 - Runs the routine, causing a particular error code to be treated as an exception, 3676024bd2cSBarry Smith rather than an error. That is if that error code is treated the program returns to this level, 3686024bd2cSBarry Smith but does not call the error handlers 3696024bd2cSBarry Smith 3706024bd2cSBarry Smith Not Collective 3716024bd2cSBarry Smith 3726024bd2cSBarry Smith Synopsis: 3731853238fSBarry Smith PetscErrorCode PetscExceptionTry1(PetscErrorCode routine(....),PetscErrorCode); 3746024bd2cSBarry Smith 3756024bd2cSBarry Smith Level: advanced 3766024bd2cSBarry Smith 3771853238fSBarry Smith No Fortran Equivalent (see PetscExceptionPush() for Fortran) 3781853238fSBarry Smith 3796024bd2cSBarry Smith Notes: 3806024bd2cSBarry Smith PETSc must not be configured using the option --with-errorchecking=0 for this to work 3816024bd2cSBarry Smith 38275febeb1SBarry Smith Note: In general, the outer most try on an exception is the one that will be caught (that is trys down in 38375febeb1SBarry Smith PETSc code will not usually handle an exception that was issued above). See SNESSolve() for an example 38475febeb1SBarry Smith of how the local try is ignored if a higher (in the stack) one is also in effect. 3856024bd2cSBarry Smith 3866024bd2cSBarry Smith Concepts: exceptions, exception hanlding 3876024bd2cSBarry Smith 3886024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 38921dd7e22SBarry Smith CHKERRQ(), PetscExceptionCaught(), PetscExceptionPush(), PetscExceptionPop() 3906024bd2cSBarry Smith M*/ 3916024bd2cSBarry Smith extern PetscErrorCode PetscExceptionTmp; 3921853238fSBarry Smith #define PetscExceptionTry1(a,b) (PetscExceptionTmp = PetscExceptionPush(b)) ? PetscExceptionTmp : (PetscExceptionTmp = a, (PetscExceptionPop(b) || PetscExceptionTmp)) 3936024bd2cSBarry Smith 394f70662edSBarry Smith /* 395f70662edSBarry 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. 396f70662edSBarry Smith */ 397f70662edSBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscExceptionTrySync_Private(MPI_Comm comm,PetscErrorCode xierr,PetscErrorCode zierr) 398f70662edSBarry Smith { 399f70662edSBarry Smith PetscReal in[2],out[2]; 400f70662edSBarry Smith PetscErrorCode ierr; 401f70662edSBarry Smith 402f70662edSBarry Smith if (xierr != zierr) return xierr; 403f70662edSBarry Smith 404f70662edSBarry Smith in[0] = xierr; 405f70662edSBarry Smith in[1] = 0.0; /* dummy value */ 406f70662edSBarry Smith 407f70662edSBarry Smith ierr = MPI_Allreduce(in,out,2,MPIU_REAL,0,comm); if (ierr) {;} 408f70662edSBarry Smith return xierr; 409f70662edSBarry Smith } 410f70662edSBarry Smith 411f70662edSBarry Smith /*MC 412f70662edSBarry Smith PetscExceptionTrySyncNorm - Runs the routine, causing a particular error code to be treated as an exception, 413f70662edSBarry Smith rather than an error. That is if that error code is treated the program returns to this level, 414f70662edSBarry Smith but does not call the error handlers 415f70662edSBarry Smith 416f70662edSBarry Smith Collective on Comm 417f70662edSBarry Smith 418f70662edSBarry Smith Synopsis: 419f70662edSBarry Smith PetscExceptionTrySyncNorm(MPI_Comm comm,PetscErrorCode routine(....),PetscErrorCode); 420f70662edSBarry Smith 421f70662edSBarry Smith Level: advanced 422f70662edSBarry Smith 423f70662edSBarry Smith Notes: This synchronizes the error code across all processes in the communicator IF the code matches PetscErrorCode. The next 424f70662edSBarry Smith call with an MPI_Reduce()/MPI_Allreduce() MUST be VecNorm() [We can added VecDot() and maybe others as needed]. 425f70662edSBarry Smith 426f70662edSBarry Smith PETSc must not be configured using the option --with-errorchecking=0 for this to work 427f70662edSBarry Smith 428f70662edSBarry Smith Note: In general, the outer most try on an exception is the one that will be caught (that is trys down in 429f70662edSBarry Smith PETSc code will not usually handle an exception that was issued above). See SNESSolve() for an example 430f70662edSBarry Smith of how the local try is ignored if a higher (in the stack) one is also in effect. 431f70662edSBarry Smith 432f70662edSBarry Smith Concepts: exceptions, exception hanlding 433f70662edSBarry Smith 434f70662edSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 435f70662edSBarry Smith CHKERRQ(), PetscExceptionCaught(), PetscExceptionPush(), PetscExceptionPop(), PetscExceptionTry1() 436f70662edSBarry Smith M*/ 437f70662edSBarry Smith extern PetscErrorCode PetscExceptionTmp; 438f70662edSBarry Smith #define PetscExceptionTrySyncNorm(comm,a,b) (PetscExceptionTmp = PetscExceptionPush(b)) ? PetscExceptionTmp : \ 439f70662edSBarry Smith (PetscExceptionTmp = a , PetscExceptionPop(b),PetscExceptionTrySyncNorm_Private(comm,PetscExceptionTmp,b)) 440f70662edSBarry Smith 44154a8ef01SBarry Smith #else 442f621e05eSBarry Smith 443f621e05eSBarry Smith /* 444f621e05eSBarry Smith These are defined to be empty for when error checking is turned off, with config/configure.py --with-errorchecking=0 445f621e05eSBarry Smith */ 446f621e05eSBarry Smith 44790d37a7cSBarry Smith #define SETERRQ(n,s) ; 44890d37a7cSBarry Smith #define SETERRQ1(n,s,a1) ; 44990d37a7cSBarry Smith #define SETERRQ2(n,s,a1,a2) ; 45090d37a7cSBarry Smith #define SETERRQ3(n,s,a1,a2,a3) ; 45190d37a7cSBarry Smith #define SETERRQ4(n,s,a1,a2,a3,a4) ; 4529bd8d7fdSSatish Balay #define SETERRQ5(n,s,a1,a2,a3,a4,a5) ; 453742f4fedSDinesh Kaushik #define SETERRQ6(n,s,a1,a2,a3,a4,a5,a6) ; 4541ee4faa0SMatthew Knepley #define SETERRABORT(comm,n,s) ; 45585614651SBarry Smith 4564f227f7cSBarry Smith #define CHKERRQ(n) ; 4571ee4faa0SMatthew Knepley #define CHKERRABORT(comm,n) ; 4581ee4faa0SMatthew Knepley #define CHKERRCONTINUE(n) ; 4598da67ba8SSatish Balay #define CHKFPQ(f) ; 46085614651SBarry Smith #define CHKMEMQ ; 46185614651SBarry Smith 462f1af5d2fSBarry Smith #if !defined(PETSC_SKIP_UNDERSCORE_CHKERR) 463f1af5d2fSBarry Smith #define _ 464f1af5d2fSBarry Smith #define ___ 465f1af5d2fSBarry Smith #endif 466f1af5d2fSBarry Smith 4678da67ba8SSatish Balay #define PetscExceptionPush(a) 0 4681853238fSBarry Smith #define PetscExceptionPop(a) 0 469c132512eSBarry Smith #define PetscErrorSetCatchable(a,b) 0 4708da67ba8SSatish Balay #define PetscErrorIsCatchable(a) PETSC_FALSE 4718da67ba8SSatish Balay 472c132512eSBarry Smith #define PetscExceptionCaught(a,b) PETSC_FALSE 473c132512eSBarry Smith #define PetscExceptionValue(a) PETSC_FALSE 4746024bd2cSBarry Smith #define PetscExceptionTry1(a,b) a 475f70662edSBarry Smith #define PetscExceptionTrySyncNorm(comm,a,b) a 476f70662edSBarry Smith 47754a8ef01SBarry Smith #endif 47854a8ef01SBarry Smith 479ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorPrintfInitialize(void); 480ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorMessage(int,const char*[],char **); 4816024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTraceBackErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 482*fd705b32SMatthew Knepley #ifdef PETSC_CLANGUAGE_CXX 483*fd705b32SMatthew Knepley #include <sstream> 484*fd705b32SMatthew Knepley 485*fd705b32SMatthew Knepley class PetscException : public std::exception { 486*fd705b32SMatthew Knepley std::ostringstream _txt; 487*fd705b32SMatthew Knepley public: 488*fd705b32SMatthew Knepley PetscException() : std::exception() {}; 489*fd705b32SMatthew Knepley explicit PetscException(const std::string& msg) : std::exception() {this->_txt << msg;}; 490*fd705b32SMatthew Knepley explicit PetscException(const std::ostringstream& txt) : std::exception() {this->_txt << txt.str();}; 491*fd705b32SMatthew Knepley PetscException(const PetscException& e) : std::exception() {this->_txt << e._txt.str();}; 492*fd705b32SMatthew Knepley ~PetscException() throw () {}; 493*fd705b32SMatthew Knepley public: 494*fd705b32SMatthew Knepley const std::string msg() const {return this->_txt.str();}; 495*fd705b32SMatthew Knepley const char *message() const {return this->_txt.str().c_str();}; 496*fd705b32SMatthew Knepley // Message input 497*fd705b32SMatthew Knepley template<typename Input> 498*fd705b32SMatthew Knepley PetscException& operator<<(const Input& in) { 499*fd705b32SMatthew Knepley this->_txt << in; 500*fd705b32SMatthew Knepley return *this; 501*fd705b32SMatthew Knepley }; 502*fd705b32SMatthew Knepley // Printing 503*fd705b32SMatthew Knepley template<typename Stream> 504*fd705b32SMatthew Knepley friend Stream& operator<<(Stream& os, const PetscException& e) { 505*fd705b32SMatthew Knepley os << e.message() << std::endl; 506*fd705b32SMatthew Knepley return os; 507*fd705b32SMatthew Knepley }; 508*fd705b32SMatthew Knepley }; 509*fd705b32SMatthew Knepley 510*fd705b32SMatthew Knepley EXTERN void PETSC_DLLEXPORT PetscTraceBackErrorHandlerCxx(int,const char *,const char *,const char *,PetscErrorCode,int, std::ostringstream&); 511*fd705b32SMatthew Knepley #endif 5126024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscIgnoreErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 5136024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscEmacsClientErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 514e8fb0fc0SBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMPIAbortErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 5156024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAbortErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 5166024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAttachDebuggerErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 517e93bc3c1Svictor EXTERN PetscErrorCode PETSC_DLLEXPORT PetscReturnErrorHandler(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*); 5186024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscError(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,...) PETSC_PRINTF_FORMAT_CHECK(7,8); 519*fd705b32SMatthew Knepley EXTERN PetscErrorCode PETSC_DLLEXPORT PetscErrorCxx(int,const char*,const char*,const char*,PetscErrorCode,int); 5206024bd2cSBarry Smith EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPushErrorHandler(PetscErrorCode (*handler)(int,const char*,const char*,const char*,PetscErrorCode,int,const char*,void*),void*); 521ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopErrorHandler(void); 522ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDefaultSignalHandler(int,void*); 523ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPushSignalHandler(PetscErrorCode (*)(int,void *),void*); 524ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopSignalHandler(void); 525329f5518SBarry Smith 526329f5518SBarry Smith typedef enum {PETSC_FP_TRAP_OFF=0,PETSC_FP_TRAP_ON=1} PetscFPTrap; 527ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetFPTrap(PetscFPTrap); 52854a8ef01SBarry Smith 5293a40ed3dSBarry Smith /* 5303a40ed3dSBarry Smith Allows the code to build a stack frame as it runs 5313a40ed3dSBarry Smith */ 53251d3a450SBarry Smith #if defined(PETSC_USE_DEBUG) 5333a40ed3dSBarry Smith 534184914b5SBarry Smith #define PETSCSTACKSIZE 15 535184914b5SBarry Smith 5363a40ed3dSBarry Smith typedef struct { 5370e33f6ddSBarry Smith const char *function[PETSCSTACKSIZE]; 5380e33f6ddSBarry Smith const char *file[PETSCSTACKSIZE]; 5390e33f6ddSBarry Smith const char *directory[PETSCSTACKSIZE]; 540184914b5SBarry Smith int line[PETSCSTACKSIZE]; 541184914b5SBarry Smith int currentsize; 5423a40ed3dSBarry Smith } PetscStack; 5433a40ed3dSBarry Smith 544ff73aad6SKris Buschelman extern PETSC_DLLEXPORT PetscStack *petscstack; 545ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackCopy(PetscStack*,PetscStack*); 546ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackPrint(PetscStack*,FILE* fp); 547184914b5SBarry Smith 548184914b5SBarry Smith #define PetscStackActive (petscstack != 0) 5493a40ed3dSBarry Smith 5506d385327SIbrahima Ba 55130de9b25SBarry Smith /*MC 55230de9b25SBarry Smith PetscFunctionBegin - First executable line of each PETSc function 55330de9b25SBarry Smith used for error handling. 55430de9b25SBarry Smith 55530de9b25SBarry Smith Synopsis: 55630de9b25SBarry Smith void PetscFunctionBegin; 55730de9b25SBarry Smith 55830de9b25SBarry Smith Usage: 55930de9b25SBarry Smith .vb 56030de9b25SBarry Smith int something; 56130de9b25SBarry Smith 56230de9b25SBarry Smith PetscFunctionBegin; 56330de9b25SBarry Smith .ve 56430de9b25SBarry Smith 56530de9b25SBarry Smith Notes: 56630de9b25SBarry Smith Not available in Fortran 56730de9b25SBarry Smith 56830de9b25SBarry Smith Level: developer 56930de9b25SBarry Smith 57030de9b25SBarry Smith .seealso: PetscFunctionReturn() 57130de9b25SBarry Smith 57230de9b25SBarry Smith .keywords: traceback, error handling 57330de9b25SBarry Smith M*/ 5743a40ed3dSBarry Smith #define PetscFunctionBegin \ 575beb17490SBarry Smith {\ 576184914b5SBarry Smith if (petscstack && (petscstack->currentsize < PETSCSTACKSIZE)) { \ 5774a2ae208SSatish Balay petscstack->function[petscstack->currentsize] = __FUNCT__; \ 578184914b5SBarry Smith petscstack->file[petscstack->currentsize] = __FILE__; \ 579184914b5SBarry Smith petscstack->directory[petscstack->currentsize] = __SDIR__; \ 580184914b5SBarry Smith petscstack->line[petscstack->currentsize] = __LINE__; \ 581184914b5SBarry Smith petscstack->currentsize++; \ 5823a40ed3dSBarry Smith }} 5833a40ed3dSBarry Smith 5845cd90555SBarry Smith #define PetscStackPush(n) \ 585184914b5SBarry Smith {if (petscstack && (petscstack->currentsize < PETSCSTACKSIZE)) { \ 586184914b5SBarry Smith petscstack->function[petscstack->currentsize] = n; \ 587184914b5SBarry Smith petscstack->file[petscstack->currentsize] = "unknown"; \ 588184914b5SBarry Smith petscstack->directory[petscstack->currentsize] = "unknown"; \ 589184914b5SBarry Smith petscstack->line[petscstack->currentsize] = 0; \ 590184914b5SBarry Smith petscstack->currentsize++; \ 5915cd90555SBarry Smith }} 5923a40ed3dSBarry Smith 593d64ed03dSBarry Smith #define PetscStackPop \ 594184914b5SBarry Smith {if (petscstack && petscstack->currentsize > 0) { \ 595184914b5SBarry Smith petscstack->currentsize--; \ 596184914b5SBarry Smith petscstack->function[petscstack->currentsize] = 0; \ 597184914b5SBarry Smith petscstack->file[petscstack->currentsize] = 0; \ 598184914b5SBarry Smith petscstack->directory[petscstack->currentsize] = 0; \ 599184914b5SBarry Smith petscstack->line[petscstack->currentsize] = 0; \ 6005cd90555SBarry Smith }}; 601d64ed03dSBarry Smith 60230de9b25SBarry Smith /*MC 60330de9b25SBarry Smith PetscFunctionReturn - Last executable line of each PETSc function 60430de9b25SBarry Smith used for error handling. Replaces return() 60530de9b25SBarry Smith 60630de9b25SBarry Smith Synopsis: 60730de9b25SBarry Smith void PetscFunctionReturn(0); 60830de9b25SBarry Smith 60930de9b25SBarry Smith Usage: 61030de9b25SBarry Smith .vb 61130de9b25SBarry Smith .... 61230de9b25SBarry Smith PetscFunctionReturn(0); 61330de9b25SBarry Smith } 61430de9b25SBarry Smith .ve 61530de9b25SBarry Smith 61630de9b25SBarry Smith Notes: 61730de9b25SBarry Smith Not available in Fortran 61830de9b25SBarry Smith 61930de9b25SBarry Smith Level: developer 62030de9b25SBarry Smith 62130de9b25SBarry Smith .seealso: PetscFunctionBegin() 62230de9b25SBarry Smith 62330de9b25SBarry Smith .keywords: traceback, error handling 62430de9b25SBarry Smith M*/ 6255cd90555SBarry Smith #define PetscFunctionReturn(a) \ 626beb17490SBarry Smith {\ 62706d1fe2cSBarry Smith PetscStackPop; \ 6285cd90555SBarry Smith return(a);} 629d64ed03dSBarry Smith 630ff94ddecSSatish Balay #define PetscFunctionReturnVoid() \ 631ff94ddecSSatish Balay {\ 6321fceb228SKris Buschelman PetscStackPop; \ 6331fceb228SKris Buschelman return;} 634ff94ddecSSatish Balay 6356d385327SIbrahima Ba 6366d385327SIbrahima Ba #else 6376d385327SIbrahima Ba 6383a40ed3dSBarry Smith #define PetscFunctionBegin 6393a40ed3dSBarry Smith #define PetscFunctionReturn(a) return(a) 6405665465eSBarry Smith #define PetscFunctionReturnVoid() return 641d64ed03dSBarry Smith #define PetscStackPop 642d64ed03dSBarry Smith #define PetscStackPush(f) 643d64ed03dSBarry Smith #define PetscStackActive 0 6443a40ed3dSBarry Smith 6453a40ed3dSBarry Smith #endif 6463a40ed3dSBarry Smith 647ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackCreate(void); 648ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackView(PetscViewer); 649ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackDestroy(void); 650ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackPublish(void); 651ff73aad6SKris Buschelman EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStackDepublish(void); 6523a40ed3dSBarry Smith 65306d1fe2cSBarry Smith 654e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 65506d1fe2cSBarry Smith #endif 656