154a8ef01SBarry Smith /* 2f621e05eSBarry Smith Contains all error handling interfaces for PETSc. 354a8ef01SBarry Smith */ 426bd1501SBarry Smith #if !defined(PETSCERROR_H) 526bd1501SBarry Smith #define PETSCERROR_H 66c7e564aSBarry Smith 754a8ef01SBarry Smith /* 8329ffe3dSLois Curfman McInnes These are the generic error codes. These error codes are used 9e2d1d2b7SBarry Smith many different places in the PETSc source code. The string versions are 100e5e90baSSatish Balay at src/sys/error/err.c any changes here must also be made there 11e951c290SBarry Smith These are also define in src/sys/f90-mod/petscerror.h any CHANGES here 120f9cf654SBarry Smith must be also made there. 1345d48df9SBarry Smith 1454a8ef01SBarry Smith */ 152a6744ebSBarry Smith #define PETSC_ERR_MIN_VALUE 54 /* should always be one less then the smallest value */ 162a6744ebSBarry Smith 1745d48df9SBarry Smith #define PETSC_ERR_MEM 55 /* unable to allocate requested memory */ 1847794344SBarry Smith #define PETSC_ERR_SUP 56 /* no support for requested operation */ 19e2d1d2b7SBarry Smith #define PETSC_ERR_SUP_SYS 57 /* no support for requested operation on this computer system */ 20e2d1d2b7SBarry Smith #define PETSC_ERR_ORDER 58 /* operation done in wrong order */ 2145d48df9SBarry Smith #define PETSC_ERR_SIG 59 /* signal received */ 22f1caa5a4SBarry Smith #define PETSC_ERR_FP 72 /* floating point exception */ 23a8c6a408SBarry Smith #define PETSC_ERR_COR 74 /* corrupted PETSc object */ 24a8c6a408SBarry Smith #define PETSC_ERR_LIB 76 /* error in library called by PETSc */ 25329ffe3dSLois Curfman McInnes #define PETSC_ERR_PLIB 77 /* PETSc library generated inconsistent data */ 26329ffe3dSLois Curfman McInnes #define PETSC_ERR_MEMC 78 /* memory corruption */ 27b3cc6726SBarry Smith #define PETSC_ERR_CONV_FAILED 82 /* iterative method (KSP or SNES) failed */ 281302d50aSBarry Smith #define PETSC_ERR_USER 83 /* user has not provided needed function */ 294e2ffeddSBarry Smith #define PETSC_ERR_SYS 88 /* error in system call */ 30a8b45ee7SBarry Smith #define PETSC_ERR_POINTER 70 /* pointer does not point to valid address */ 313d96e996SBarry Smith #define PETSC_ERR_MPI_LIB_INCOMP 87 /* MPI library at runtime is not compatible with MPI user compiled with */ 3245d48df9SBarry Smith 3345d48df9SBarry Smith #define PETSC_ERR_ARG_SIZ 60 /* nonconforming object sizes used in operation */ 3445d48df9SBarry Smith #define PETSC_ERR_ARG_IDN 61 /* two arguments not allowed to be the same */ 35a8c6a408SBarry Smith #define PETSC_ERR_ARG_WRONG 62 /* wrong argument (but object probably ok) */ 3645d48df9SBarry Smith #define PETSC_ERR_ARG_CORRUPT 64 /* null or corrupted PETSc object as argument */ 3745d48df9SBarry Smith #define PETSC_ERR_ARG_OUTOFRANGE 63 /* input argument, out of range */ 384f227f7cSBarry Smith #define PETSC_ERR_ARG_BADPTR 68 /* invalid pointer argument */ 394f227f7cSBarry Smith #define PETSC_ERR_ARG_NOTSAMETYPE 69 /* two args must be same object type */ 406831982aSBarry Smith #define PETSC_ERR_ARG_NOTSAMECOMM 80 /* two args must be same communicators */ 41d252947aSBarry Smith #define PETSC_ERR_ARG_WRONGSTATE 73 /* object in argument is in wrong state, e.g. unassembled mat */ 428cda6cd7SBarry Smith #define PETSC_ERR_ARG_TYPENOTSET 89 /* the type of the object has not yet been set */ 43a8c6a408SBarry Smith #define PETSC_ERR_ARG_INCOMP 75 /* two arguments are incompatible */ 444482741eSBarry Smith #define PETSC_ERR_ARG_NULL 85 /* argument is null that should not be */ 45958c9bccSBarry Smith #define PETSC_ERR_ARG_UNKNOWN_TYPE 86 /* type name doesn't match any registered type */ 464f227f7cSBarry Smith 474f227f7cSBarry Smith #define PETSC_ERR_FILE_OPEN 65 /* unable to open file */ 484f227f7cSBarry Smith #define PETSC_ERR_FILE_READ 66 /* unable to read from file */ 494f227f7cSBarry Smith #define PETSC_ERR_FILE_WRITE 67 /* unable to write to file */ 50a8c6a408SBarry Smith #define PETSC_ERR_FILE_UNEXPECTED 79 /* unexpected data in file */ 5145d48df9SBarry Smith 52329ffe3dSLois Curfman McInnes #define PETSC_ERR_MAT_LU_ZRPVT 71 /* detected a zero pivot during LU factorization */ 539e3b2f23SBarry Smith #define PETSC_ERR_MAT_CH_ZRPVT 81 /* detected a zero pivot during Cholesky factorization */ 5454a8ef01SBarry Smith 5568e69593SBarry Smith #define PETSC_ERR_INT_OVERFLOW 84 563855c12bSBarry Smith 57bf3909cdSBarry Smith #define PETSC_ERR_FLOP_COUNT 90 58e113a28aSBarry Smith #define PETSC_ERR_NOT_CONVERGED 91 /* solver did not converge */ 5992e8f287SBarry Smith #define PETSC_ERR_MISSING_FACTOR 92 /* MatGetFactor() failed */ 60691b26d3SBarry Smith #define PETSC_ERR_OPT_OVERWRITE 93 /* attempted to over write options which should not be changed */ 61691b26d3SBarry Smith #define PETSC_ERR_WRONG_MPI_SIZE 94 /* example/application run with number of MPI ranks it does not support */ 62691b26d3SBarry Smith #define PETSC_ERR_USER_INPUT 95 /* missing or incorrect user input */ 63589f383fSBarry Smith #define PETSC_ERR_GPU_RESOURCE 96 /* unable to load a GPU resource, for example cuBLAS */ 64589f383fSBarry Smith #define PETSC_ERR_GPU 97 /* An error from a GPU call, this may be due to lack of resources on the GPU or a true error in the call */ 65589f383fSBarry Smith #define PETSC_ERR_MAX_VALUE 98 /* this is always the one more than the largest error code */ 66b9eb5ee8SHong Zhang 6759aaf355SLisandro Dalcin #define PetscStringizeArg(a) #a 6859aaf355SLisandro Dalcin #define PetscStringize(a) PetscStringizeArg(a) 69330cf3c9SBarry Smith 70e8b7e333SSatish Balay 7130de9b25SBarry Smith /*MC 721957e957SBarry Smith SETERRQ - Macro to be called when an error has been detected, 7330de9b25SBarry Smith 7430de9b25SBarry Smith Synopsis: 75aaa7dc30SBarry Smith #include <petscsys.h> 763af045c5SBarry Smith PetscErrorCode SETERRQ(MPI_Comm comm,PetscErrorCode ierr,char *message) 7730de9b25SBarry Smith 78d083f849SBarry Smith Collective 7930de9b25SBarry Smith 8030de9b25SBarry Smith Input Parameters: 813af045c5SBarry Smith + comm - A communicator, use PETSC_COMM_SELF unless you know all ranks of another communicator will detect the error 823af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 8330de9b25SBarry Smith - message - error message 8430de9b25SBarry Smith 8530de9b25SBarry Smith Level: beginner 8630de9b25SBarry Smith 8730de9b25SBarry Smith Notes: 8830de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 8930de9b25SBarry Smith 9030de9b25SBarry Smith See SETERRQ1(), SETERRQ2(), SETERRQ3() for versions that take arguments 9130de9b25SBarry Smith 9230de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 9330de9b25SBarry Smith 943b1008b8SBarry Smith Fortran Notes: 953b1008b8SBarry Smith SETERRQ() may be called from Fortran subroutines but SETERRA() must be called from the 963b1008b8SBarry Smith Fortran main program. 973b1008b8SBarry Smith 9891d3bdf4SKris Buschelman .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3() 9930de9b25SBarry Smith M*/ 1003af045c5SBarry Smith #define SETERRQ(comm,ierr,s) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s) 101986eef2eSBarry Smith 102986eef2eSBarry Smith /*MC 103986eef2eSBarry Smith SETERRMPI - Macro to be called when an error has been detected within an MPI callback function 104986eef2eSBarry Smith 105986eef2eSBarry Smith Synopsis: 106986eef2eSBarry Smith #include <petscsys.h> 107986eef2eSBarry Smith PetscErrorCode SETERRMPI(MPI_Comm comm,PetscErrorCode ierr,char *message) 108986eef2eSBarry Smith 109d083f849SBarry Smith Collective 110986eef2eSBarry Smith 111986eef2eSBarry Smith Input Parameters: 112986eef2eSBarry Smith + comm - A communicator, use PETSC_COMM_SELF unless you know all ranks of another communicator will detect the error 113986eef2eSBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 114986eef2eSBarry Smith - message - error message 115986eef2eSBarry Smith 116986eef2eSBarry Smith Level: developer 117986eef2eSBarry Smith 118986eef2eSBarry Smith Notes: 119986eef2eSBarry Smith This macro is FOR USE IN MPI CALLBACK FUNCTIONS ONLY, such as those passed to MPI_Comm_create_keyval(). It always returns the error code PETSC_MPI_ERROR_CODE 120986eef2eSBarry Smith which is registered with MPI_Add_error_code() when PETSc is initialized. 121986eef2eSBarry Smith 122986eef2eSBarry Smith .seealso: SETERRQ(), CHKERRQ(), CHKERRMPI(), PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3() 123986eef2eSBarry Smith M*/ 12412801b39SBarry Smith #define SETERRMPI(comm,ierr,s) return (PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s),PETSC_MPI_ERROR_CODE) 12530de9b25SBarry Smith 12630de9b25SBarry Smith /*MC 12730de9b25SBarry Smith SETERRQ1 - Macro that is called when an error has been detected, 12830de9b25SBarry Smith 12930de9b25SBarry Smith Synopsis: 130aaa7dc30SBarry Smith #include <petscsys.h> 1313af045c5SBarry Smith PetscErrorCode SETERRQ1(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg) 13230de9b25SBarry Smith 133d083f849SBarry Smith Collective 13430de9b25SBarry Smith 13530de9b25SBarry Smith Input Parameters: 136fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 1373af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 13830de9b25SBarry Smith . message - error message in the printf format 13930de9b25SBarry Smith - arg - argument (for example an integer, string or double) 14030de9b25SBarry Smith 14130de9b25SBarry Smith Level: beginner 14230de9b25SBarry Smith 14330de9b25SBarry Smith Notes: 14430de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 14530de9b25SBarry Smith 14630de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 14730de9b25SBarry Smith 14891d3bdf4SKris Buschelman .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ(), SETERRQ2(), SETERRQ3() 14930de9b25SBarry Smith M*/ 1503af045c5SBarry Smith #define SETERRQ1(comm,ierr,s,a1) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1) 15130de9b25SBarry Smith 15230de9b25SBarry Smith /*MC 15330de9b25SBarry Smith SETERRQ2 - Macro that is called when an error has been detected, 15430de9b25SBarry Smith 15530de9b25SBarry Smith Synopsis: 156aaa7dc30SBarry Smith #include <petscsys.h> 1573af045c5SBarry Smith PetscErrorCode SETERRQ2(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg1,arg2) 15830de9b25SBarry Smith 159d083f849SBarry Smith Collective 16030de9b25SBarry Smith 16130de9b25SBarry Smith Input Parameters: 162fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 1633af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 16430de9b25SBarry Smith . message - error message in the printf format 16530de9b25SBarry Smith . arg1 - argument (for example an integer, string or double) 16630de9b25SBarry Smith - arg2 - argument (for example an integer, string or double) 16730de9b25SBarry Smith 16830de9b25SBarry Smith Level: beginner 16930de9b25SBarry Smith 17030de9b25SBarry Smith Notes: 17130de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 17230de9b25SBarry Smith 17330de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 17430de9b25SBarry Smith 1756024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ3() 17630de9b25SBarry Smith M*/ 1773af045c5SBarry Smith #define SETERRQ2(comm,ierr,s,a1,a2) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1,a2) 17830de9b25SBarry Smith 17930de9b25SBarry Smith /*MC 18030de9b25SBarry Smith SETERRQ3 - Macro that is called when an error has been detected, 18130de9b25SBarry Smith 18230de9b25SBarry Smith Synopsis: 183aaa7dc30SBarry Smith #include <petscsys.h> 1843af045c5SBarry Smith PetscErrorCode SETERRQ3(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg1,arg2,arg3) 18530de9b25SBarry Smith 186d083f849SBarry Smith Collective 18730de9b25SBarry Smith 18830de9b25SBarry Smith Input Parameters: 189fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 1903af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 19130de9b25SBarry Smith . message - error message in the printf format 19230de9b25SBarry Smith . arg1 - argument (for example an integer, string or double) 19330de9b25SBarry Smith . arg2 - argument (for example an integer, string or double) 19430de9b25SBarry Smith - arg3 - argument (for example an integer, string or double) 19530de9b25SBarry Smith 19630de9b25SBarry Smith Level: beginner 19730de9b25SBarry Smith 19830de9b25SBarry Smith Notes: 19930de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 20030de9b25SBarry Smith 201f621e05eSBarry Smith There are also versions for 4, 5, 6 and 7 arguments. 202f621e05eSBarry Smith 20330de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 20430de9b25SBarry Smith 2056024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 20630de9b25SBarry Smith M*/ 2073af045c5SBarry Smith #define SETERRQ3(comm,ierr,s,a1,a2,a3) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1,a2,a3) 20830de9b25SBarry Smith 209fa190f98SMatthew G. Knepley /*MC 210fa190f98SMatthew G. Knepley SETERRQ4 - Macro that is called when an error has been detected, 211fa190f98SMatthew G. Knepley 212fa190f98SMatthew G. Knepley Synopsis: 213fa190f98SMatthew G. Knepley #include <petscsys.h> 21431e9e36bSSatish Balay PetscErrorCode SETERRQ4(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg1,arg2,arg3,arg4) 215fa190f98SMatthew G. Knepley 216d083f849SBarry Smith Collective 217fa190f98SMatthew G. Knepley 218fa190f98SMatthew G. Knepley Input Parameters: 219fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 2203af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 221fa190f98SMatthew G. Knepley . message - error message in the printf format 222fa190f98SMatthew G. Knepley . arg1 - argument (for example an integer, string or double) 223fa190f98SMatthew G. Knepley . arg2 - argument (for example an integer, string or double) 224fa190f98SMatthew G. Knepley . arg3 - argument (for example an integer, string or double) 225fa190f98SMatthew G. Knepley - arg4 - argument (for example an integer, string or double) 226fa190f98SMatthew G. Knepley 227fa190f98SMatthew G. Knepley Level: beginner 228fa190f98SMatthew G. Knepley 229fa190f98SMatthew G. Knepley Notes: 230fa190f98SMatthew G. Knepley Once the error handler is called the calling function is then returned from with the given error code. 231fa190f98SMatthew G. Knepley 232fa190f98SMatthew G. Knepley There are also versions for 4, 5, 6 and 7 arguments. 233fa190f98SMatthew G. Knepley 234fa190f98SMatthew G. Knepley Experienced users can set the error handler with PetscPushErrorHandler(). 235fa190f98SMatthew G. Knepley 236fa190f98SMatthew G. Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 237fa190f98SMatthew G. Knepley M*/ 2383af045c5SBarry Smith #define SETERRQ4(comm,ierr,s,a1,a2,a3,a4) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4) 239fa190f98SMatthew G. Knepley 240fa190f98SMatthew G. Knepley /*MC 241fa190f98SMatthew G. Knepley SETERRQ5 - Macro that is called when an error has been detected, 242fa190f98SMatthew G. Knepley 243fa190f98SMatthew G. Knepley Synopsis: 244fa190f98SMatthew G. Knepley #include <petscsys.h> 24531e9e36bSSatish Balay PetscErrorCode SETERRQ5(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg1,arg2,arg3,arg4,arg5) 246fa190f98SMatthew G. Knepley 247d083f849SBarry Smith Collective 248fa190f98SMatthew G. Knepley 249fa190f98SMatthew G. Knepley Input Parameters: 250fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 2513af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 252fa190f98SMatthew G. Knepley . message - error message in the printf format 253fa190f98SMatthew G. Knepley . arg1 - argument (for example an integer, string or double) 254fa190f98SMatthew G. Knepley . arg2 - argument (for example an integer, string or double) 255fa190f98SMatthew G. Knepley . arg3 - argument (for example an integer, string or double) 256fa190f98SMatthew G. Knepley . arg4 - argument (for example an integer, string or double) 257fa190f98SMatthew G. Knepley - arg5 - argument (for example an integer, string or double) 258fa190f98SMatthew G. Knepley 259fa190f98SMatthew G. Knepley Level: beginner 260fa190f98SMatthew G. Knepley 261fa190f98SMatthew G. Knepley Notes: 262fa190f98SMatthew G. Knepley Once the error handler is called the calling function is then returned from with the given error code. 263fa190f98SMatthew G. Knepley 264fa190f98SMatthew G. Knepley There are also versions for 4, 5, 6 and 7 arguments. 265fa190f98SMatthew G. Knepley 266fa190f98SMatthew G. Knepley Experienced users can set the error handler with PetscPushErrorHandler(). 267fa190f98SMatthew G. Knepley 268fa190f98SMatthew G. Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 269fa190f98SMatthew G. Knepley M*/ 2703af045c5SBarry Smith #define SETERRQ5(comm,ierr,s,a1,a2,a3,a4,a5) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4,a5) 271fa190f98SMatthew G. Knepley 272fa190f98SMatthew G. Knepley /*MC 273fa190f98SMatthew G. Knepley SETERRQ6 - Macro that is called when an error has been detected, 274fa190f98SMatthew G. Knepley 275fa190f98SMatthew G. Knepley Synopsis: 276fa190f98SMatthew G. Knepley #include <petscsys.h> 27731e9e36bSSatish Balay PetscErrorCode SETERRQ6(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg1,arg2,arg3,arg4,arg5,arg6) 278fa190f98SMatthew G. Knepley 279d083f849SBarry Smith Collective 280fa190f98SMatthew G. Knepley 281fa190f98SMatthew G. Knepley Input Parameters: 282fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 2833af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 284fa190f98SMatthew G. Knepley . message - error message in the printf format 285fa190f98SMatthew G. Knepley . arg1 - argument (for example an integer, string or double) 286fa190f98SMatthew G. Knepley . arg2 - argument (for example an integer, string or double) 287fa190f98SMatthew G. Knepley . arg3 - argument (for example an integer, string or double) 288fa190f98SMatthew G. Knepley . arg4 - argument (for example an integer, string or double) 289fa190f98SMatthew G. Knepley . arg5 - argument (for example an integer, string or double) 290fa190f98SMatthew G. Knepley - arg6 - argument (for example an integer, string or double) 291fa190f98SMatthew G. Knepley 292fa190f98SMatthew G. Knepley Level: beginner 293fa190f98SMatthew G. Knepley 294fa190f98SMatthew G. Knepley Notes: 295fa190f98SMatthew G. Knepley Once the error handler is called the calling function is then returned from with the given error code. 296fa190f98SMatthew G. Knepley 297fa190f98SMatthew G. Knepley There are also versions for 4, 5, 6 and 7 arguments. 298fa190f98SMatthew G. Knepley 299fa190f98SMatthew G. Knepley Experienced users can set the error handler with PetscPushErrorHandler(). 300fa190f98SMatthew G. Knepley 301fa190f98SMatthew G. Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 302fa190f98SMatthew G. Knepley M*/ 3033af045c5SBarry Smith #define SETERRQ6(comm,ierr,s,a1,a2,a3,a4,a5,a6) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4,a5,a6) 304fa190f98SMatthew G. Knepley 305fa190f98SMatthew G. Knepley /*MC 306fa190f98SMatthew G. Knepley SETERRQ7 - Macro that is called when an error has been detected, 307fa190f98SMatthew G. Knepley 308fa190f98SMatthew G. Knepley Synopsis: 309fa190f98SMatthew G. Knepley #include <petscsys.h> 31031e9e36bSSatish Balay PetscErrorCode SETERRQ7(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg1,arg2,arg3,arg4,arg5,arg6,arg7) 311fa190f98SMatthew G. Knepley 312d083f849SBarry Smith Collective 313fa190f98SMatthew G. Knepley 314fa190f98SMatthew G. Knepley Input Parameters: 315fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 3163af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 317fa190f98SMatthew G. Knepley . message - error message in the printf format 318fa190f98SMatthew G. Knepley . arg1 - argument (for example an integer, string or double) 319fa190f98SMatthew G. Knepley . arg2 - argument (for example an integer, string or double) 320fa190f98SMatthew G. Knepley . arg3 - argument (for example an integer, string or double) 321fa190f98SMatthew G. Knepley . arg4 - argument (for example an integer, string or double) 322fa190f98SMatthew G. Knepley . arg5 - argument (for example an integer, string or double) 323fa190f98SMatthew G. Knepley . arg6 - argument (for example an integer, string or double) 324fa190f98SMatthew G. Knepley - arg7 - argument (for example an integer, string or double) 325fa190f98SMatthew G. Knepley 326fa190f98SMatthew G. Knepley Level: beginner 327fa190f98SMatthew G. Knepley 328fa190f98SMatthew G. Knepley Notes: 329fa190f98SMatthew G. Knepley Once the error handler is called the calling function is then returned from with the given error code. 330fa190f98SMatthew G. Knepley 331fa190f98SMatthew G. Knepley There are also versions for 4, 5, 6 and 7 arguments. 332fa190f98SMatthew G. Knepley 333fa190f98SMatthew G. Knepley Experienced users can set the error handler with PetscPushErrorHandler(). 334fa190f98SMatthew G. Knepley 335fa190f98SMatthew G. Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 336fa190f98SMatthew G. Knepley M*/ 3373af045c5SBarry Smith #define SETERRQ7(comm,ierr,s,a1,a2,a3,a4,a5,a6,a7) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4,a5,a6,a7) 338fa190f98SMatthew G. Knepley 339fa190f98SMatthew G. Knepley /*MC 340fa190f98SMatthew G. Knepley SETERRQ8 - Macro that is called when an error has been detected, 341fa190f98SMatthew G. Knepley 342fa190f98SMatthew G. Knepley Synopsis: 343fa190f98SMatthew G. Knepley #include <petscsys.h> 34431e9e36bSSatish Balay PetscErrorCode SETERRQ8(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) 345fa190f98SMatthew G. Knepley 346d083f849SBarry Smith Collective 347fa190f98SMatthew G. Knepley 348fa190f98SMatthew G. Knepley Input Parameters: 349fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 3503af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 351fa190f98SMatthew G. Knepley . message - error message in the printf format 352fa190f98SMatthew G. Knepley . arg1 - argument (for example an integer, string or double) 353fa190f98SMatthew G. Knepley . arg2 - argument (for example an integer, string or double) 354fa190f98SMatthew G. Knepley . arg3 - argument (for example an integer, string or double) 355fa190f98SMatthew G. Knepley . arg4 - argument (for example an integer, string or double) 356fa190f98SMatthew G. Knepley . arg5 - argument (for example an integer, string or double) 357fa190f98SMatthew G. Knepley . arg6 - argument (for example an integer, string or double) 358fa190f98SMatthew G. Knepley . arg7 - argument (for example an integer, string or double) 359fa190f98SMatthew G. Knepley - arg8 - argument (for example an integer, string or double) 360fa190f98SMatthew G. Knepley 361fa190f98SMatthew G. Knepley Level: beginner 362fa190f98SMatthew G. Knepley 363fa190f98SMatthew G. Knepley Notes: 364fa190f98SMatthew G. Knepley Once the error handler is called the calling function is then returned from with the given error code. 365fa190f98SMatthew G. Knepley 366fa190f98SMatthew G. Knepley There are also versions for 4, 5, 6 and 7 arguments. 367fa190f98SMatthew G. Knepley 368fa190f98SMatthew G. Knepley Experienced users can set the error handler with PetscPushErrorHandler(). 369fa190f98SMatthew G. Knepley 370fa190f98SMatthew G. Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 371fa190f98SMatthew G. Knepley M*/ 3723af045c5SBarry Smith #define SETERRQ8(comm,ierr,s,a1,a2,a3,a4,a5,a6,a7,a8) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4,a5,a6,a7,a8) 373fa190f98SMatthew G. Knepley 374fa190f98SMatthew G. Knepley /*MC 375ee8199e6SMatthew G. Knepley SETERRQ9 - Macro that is called when an error has been detected, 376ee8199e6SMatthew G. Knepley 377ee8199e6SMatthew G. Knepley Synopsis: 378ee8199e6SMatthew G. Knepley #include <petscsys.h> 37931e9e36bSSatish Balay PetscErrorCode SETERRQ9(MPI_Comm comm,PetscErrorCode ierr,char *formatmessage,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) 380ee8199e6SMatthew G. Knepley 381d083f849SBarry Smith Collective 382ee8199e6SMatthew G. Knepley 383ee8199e6SMatthew G. Knepley Input Parameters: 384ee8199e6SMatthew G. Knepley + comm - A communicator, so that the error can be collective 385ee8199e6SMatthew G. Knepley . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 386ee8199e6SMatthew G. Knepley . message - error message in the printf format 387ee8199e6SMatthew G. Knepley . arg1 - argument (for example an integer, string or double) 388ee8199e6SMatthew G. Knepley . arg2 - argument (for example an integer, string or double) 389ee8199e6SMatthew G. Knepley . arg3 - argument (for example an integer, string or double) 390ee8199e6SMatthew G. Knepley . arg4 - argument (for example an integer, string or double) 391ee8199e6SMatthew G. Knepley . arg5 - argument (for example an integer, string or double) 392ee8199e6SMatthew G. Knepley . arg6 - argument (for example an integer, string or double) 393ee8199e6SMatthew G. Knepley . arg7 - argument (for example an integer, string or double) 394ee8199e6SMatthew G. Knepley . arg8 - argument (for example an integer, string or double) 395ee8199e6SMatthew G. Knepley - arg9 - argument (for example an integer, string or double) 396ee8199e6SMatthew G. Knepley 397ee8199e6SMatthew G. Knepley Level: beginner 398ee8199e6SMatthew G. Knepley 399ee8199e6SMatthew G. Knepley Notes: 400ee8199e6SMatthew G. Knepley Once the error handler is called the calling function is then returned from with the given error code. 401ee8199e6SMatthew G. Knepley 402ee8199e6SMatthew G. Knepley There are also versions for 0 to 9 arguments. 403ee8199e6SMatthew G. Knepley 404ee8199e6SMatthew G. Knepley Experienced users can set the error handler with PetscPushErrorHandler(). 405ee8199e6SMatthew G. Knepley 406ee8199e6SMatthew G. Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 407ee8199e6SMatthew G. Knepley M*/ 408ee8199e6SMatthew G. Knepley #define SETERRQ9(comm,ierr,s,a1,a2,a3,a4,a5,a6,a7,a8,a9) return PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s,a1,a2,a3,a4,a5,a6,a7,a8,a9) 409ee8199e6SMatthew G. Knepley 410ee8199e6SMatthew G. Knepley /*MC 411fa190f98SMatthew G. Knepley SETERRABORT - Macro that can be called when an error has been detected, 412fa190f98SMatthew G. Knepley 413fa190f98SMatthew G. Knepley Synopsis: 414fa190f98SMatthew G. Knepley #include <petscsys.h> 4153af045c5SBarry Smith PetscErrorCode SETERRABORT(MPI_Comm comm,PetscErrorCode ierr,char *message) 416fa190f98SMatthew G. Knepley 417d083f849SBarry Smith Collective 418fa190f98SMatthew G. Knepley 419fa190f98SMatthew G. Knepley Input Parameters: 420fa190f98SMatthew G. Knepley + comm - A communicator, so that the error can be collective 4213af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 422fa190f98SMatthew G. Knepley - message - error message in the printf format 423fa190f98SMatthew G. Knepley 424fa190f98SMatthew G. Knepley Level: beginner 425fa190f98SMatthew G. Knepley 426fa190f98SMatthew G. Knepley Notes: 427fa190f98SMatthew G. Knepley This function just calls MPI_Abort(). 428fa190f98SMatthew G. Knepley 429fa190f98SMatthew G. Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), CHKERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2() 430fa190f98SMatthew G. Knepley M*/ 4313af045c5SBarry Smith #define SETERRABORT(comm,ierr,s) do {PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_INITIAL,s);MPI_Abort(comm,ierr);} while (0) 4329a00fa46SSatish Balay 43330de9b25SBarry Smith /*MC 43430de9b25SBarry Smith CHKERRQ - Checks error code, if non-zero it calls the error handler and then returns 43530de9b25SBarry Smith 43630de9b25SBarry Smith Synopsis: 437aaa7dc30SBarry Smith #include <petscsys.h> 4383af045c5SBarry Smith PetscErrorCode CHKERRQ(PetscErrorCode ierr) 43930de9b25SBarry Smith 440eca87e8dSBarry Smith Not Collective 44130de9b25SBarry Smith 44230de9b25SBarry Smith Input Parameters: 4433af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 44430de9b25SBarry Smith 44530de9b25SBarry Smith Level: beginner 44630de9b25SBarry Smith 44730de9b25SBarry Smith Notes: 44830de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 44930de9b25SBarry Smith 45030de9b25SBarry Smith Experienced users can set the error handler with PetscPushErrorHandler(). 4515324ea47SKris Buschelman 4523af045c5SBarry Smith CHKERRQ(ierr) is fundamentally a macro replacement for 4533af045c5SBarry Smith if (ierr) return(PetscError(...,ierr,...)); 4545324ea47SKris Buschelman 4555324ea47SKris Buschelman Although typical usage resembles "void CHKERRQ(PetscErrorCode)" as described above, for certain uses it is 4565324ea47SKris Buschelman highly inappropriate to use it in this manner as it invokes return(PetscErrorCode). In particular, 4575324ea47SKris Buschelman it cannot be used in functions which return(void) or any other datatype. In these types of functions, 45858ebbce7SBarry Smith you can use CHKERRV() which returns without an error code (bad idea since the error is ignored or 4593af045c5SBarry Smith if (ierr) {PetscError(....); return(YourReturnType);} 4600298fd71SBarry Smith where you may pass back a NULL to indicate an error. You can also call CHKERRABORT(comm,n) to have 46158ebbce7SBarry Smith MPI_Abort() returned immediately. 46258ebbce7SBarry Smith 46391d3bdf4SKris Buschelman .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ2() 46430de9b25SBarry Smith M*/ 465ee74f559SJed Brown #define CHKERRQ(ierr) do {PetscErrorCode ierr__ = (ierr); if (PetscUnlikely(ierr__)) return PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr__,PETSC_ERROR_REPEAT," ");} while (0) 4660219f5dfSJed Brown #define CHKERRV(ierr) do {PetscErrorCode ierr__ = (ierr); if (PetscUnlikely(ierr__)) {PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr__,PETSC_ERROR_REPEAT," ");return;}} while (0) 467ee74f559SJed Brown #define CHKERRABORT(comm,ierr) do {PetscErrorCode ierr__ = (ierr); if (PetscUnlikely(ierr__)) {PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr__,PETSC_ERROR_REPEAT," ");MPI_Abort(comm,ierr);}} while (0) 468ee74f559SJed Brown #define CHKERRCONTINUE(ierr) do {PetscErrorCode ierr__ = (ierr); if (PetscUnlikely(ierr__)) {PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr__,PETSC_ERROR_REPEAT," ");}} while (0) 469986eef2eSBarry Smith 4707c66cc67SJunchao Zhang PETSC_EXTERN PetscErrorCode PetscAbortFindSourceFile_Private(const char*,PetscInt*); 471baae8e41SSatish Balay PETSC_EXTERN PetscBool petscwaitonerrorflg,petscindebugger; 4727c66cc67SJunchao Zhang 4737c66cc67SJunchao Zhang /*MC 4747c66cc67SJunchao Zhang PETSCABORT - Call MPI_Abort with an informative error code 4757c66cc67SJunchao Zhang 4767c66cc67SJunchao Zhang Synopsis: 4777c66cc67SJunchao Zhang #include <petscsys.h> 4787c66cc67SJunchao Zhang PETSCABORT(MPI_Comm comm, PetscErrorCode ierr) 4797c66cc67SJunchao Zhang 4807c66cc67SJunchao Zhang Collective 4817c66cc67SJunchao Zhang 4827c66cc67SJunchao Zhang Input Parameters: 4837c66cc67SJunchao Zhang + comm - A communicator, so that the error can be collective 4847c66cc67SJunchao Zhang - ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 4857c66cc67SJunchao Zhang 486bf4d2887SBarry Smith Level: advanced 4877c66cc67SJunchao Zhang 488bf4d2887SBarry Smith Notes: 489bf4d2887SBarry Smith We pass MPI_Abort() an error code of format XX_YYYY_ZZZ, where XX, YYYY are an index and line number of the file 4907233276eSBarry Smith where PETSCABORT is called, respectively. ZZZ is the PETSc error code. 4917c66cc67SJunchao Zhang 4927233276eSBarry Smith If XX is zero, this means that the call was made in the routine main(). 4937233276eSBarry Smith If XX is one, that means 1) the file is not in PETSc (it may be in users code); OR 2) the file is in PETSc but PetscAbortSourceFiles[] 4947c66cc67SJunchao Zhang is out of date. PETSc developers have to update it. 495a0760fecSJunchao Zhang Otherwise, look up the value of XX in the table PetscAbortSourceFiles[] in src/sys/error/err.c to map XX back to the source file where the PETSCABORT() was called. 4967233276eSBarry Smith 497bf4d2887SBarry Smith If the option -start_in_debugger was used then this calls abort() to stop the program in the debugger. 498bf4d2887SBarry Smith 4997c66cc67SJunchao Zhang M*/ 5007c66cc67SJunchao Zhang #define PETSCABORT(comm,ierr) \ 5017c66cc67SJunchao Zhang do { \ 5027c66cc67SJunchao Zhang PetscInt idx = 0; \ 5037c66cc67SJunchao Zhang PetscMPIInt errcode; \ 5047c66cc67SJunchao Zhang PetscAbortFindSourceFile_Private(__FILE__,&idx); \ 5057c66cc67SJunchao Zhang errcode = (PetscMPIInt)(idx*10000000 + __LINE__*1000 + ierr); \ 506baae8e41SSatish Balay if (petscwaitonerrorflg) PetscSleep(1000); \ 507bf4d2887SBarry Smith if (petscindebugger) abort(); \ 508bf4d2887SBarry Smith else MPI_Abort(comm,errcode); \ 5097c66cc67SJunchao Zhang } while (0) 510986eef2eSBarry Smith 511986eef2eSBarry Smith /*MC 512986eef2eSBarry Smith CHKERRMPI - Checks error code, if non-zero it calls the error handler and then returns 513986eef2eSBarry Smith 514986eef2eSBarry Smith Synopsis: 515986eef2eSBarry Smith #include <petscsys.h> 516986eef2eSBarry Smith PetscErrorCode CHKERRMPI(PetscErrorCode ierr) 517986eef2eSBarry Smith 518986eef2eSBarry Smith Not Collective 519986eef2eSBarry Smith 520986eef2eSBarry Smith Input Parameters: 521986eef2eSBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 522986eef2eSBarry Smith 523986eef2eSBarry Smith Level: developer 524986eef2eSBarry Smith 525986eef2eSBarry Smith Notes: 526986eef2eSBarry Smith This macro is FOR USE IN MPI CALLBACK FUNCTIONS ONLY, such as those passed to MPI_Comm_create_keyval(). It always returns the error code PETSC_MPI_ERROR_CODE 527986eef2eSBarry Smith which is registered with MPI_Add_error_code() when PETSc is initialized. 528986eef2eSBarry Smith 529986eef2eSBarry Smith .seealso: CHKERRQ(), PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ2() 530986eef2eSBarry Smith M*/ 53112801b39SBarry Smith #define CHKERRMPI(ierr) do {if (PetscUnlikely(ierr)) return (PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_REPEAT," "),PETSC_MPI_ERROR_CODE);} while (0) 53285614651SBarry Smith 533fd705b32SMatthew Knepley #ifdef PETSC_CLANGUAGE_CXX 534fd705b32SMatthew Knepley 535cc26af49SMatthew Knepley /*MC 536cc26af49SMatthew Knepley CHKERRXX - Checks error code, if non-zero it calls the C++ error handler which throws an exception 537cc26af49SMatthew Knepley 538cc26af49SMatthew Knepley Synopsis: 539aaa7dc30SBarry Smith #include <petscsys.h> 5403af045c5SBarry Smith void CHKERRXX(PetscErrorCode ierr) 541cc26af49SMatthew Knepley 542eca87e8dSBarry Smith Not Collective 543cc26af49SMatthew Knepley 544cc26af49SMatthew Knepley Input Parameters: 5453af045c5SBarry Smith . ierr - nonzero error code, see the list of standard error codes in include/petscerror.h 546cc26af49SMatthew Knepley 547cc26af49SMatthew Knepley Level: beginner 548cc26af49SMatthew Knepley 549cc26af49SMatthew Knepley Notes: 550cc26af49SMatthew Knepley Once the error handler throws a ??? exception. 551cc26af49SMatthew Knepley 552cc26af49SMatthew Knepley You can use CHKERRV() which returns without an error code (bad idea since the error is ignored) 553cc26af49SMatthew Knepley or CHKERRABORT(comm,n) to have MPI_Abort() returned immediately. 554cc26af49SMatthew Knepley 555cc26af49SMatthew Knepley .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKERRQ(), CHKMEMQ 556cc26af49SMatthew Knepley M*/ 5573af045c5SBarry Smith #define CHKERRXX(ierr) do {if (PetscUnlikely(ierr)) {PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,ierr,PETSC_ERROR_IN_CXX,0);}} while (0) 558fd705b32SMatthew Knepley 559fd705b32SMatthew Knepley #endif 560fd705b32SMatthew Knepley 5617fd2f626SJose E. Roman #if defined(PETSC_HAVE_CUDA) 5627fd2f626SJose E. Roman #define CHKERRCUSOLVER(err) do {if (PetscUnlikely(err)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"CUSOLVER error %d",err);} while (0) 5637fd2f626SJose E. Roman #endif 564*59af0bd3SScott Kruger /* TODO: SEK: Need to figure out the hipsolver issues */ 565*59af0bd3SScott Kruger #if defined(PETSC_HAVE_HIP) 566*59af0bd3SScott Kruger #define CHKERRHIPSOLVER(err) do {if (PetscUnlikely(err)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"HIPSOLVER error %d",err);} while (0) 567*59af0bd3SScott Kruger #endif 56830de9b25SBarry Smith /*MC 56930de9b25SBarry Smith CHKMEMQ - Checks the memory for corruption, calls error handler if any is detected 57030de9b25SBarry Smith 57130de9b25SBarry Smith Synopsis: 572aaa7dc30SBarry Smith #include <petscsys.h> 57391d3bdf4SKris Buschelman CHKMEMQ; 57430de9b25SBarry Smith 575eca87e8dSBarry Smith Not Collective 576eca87e8dSBarry Smith 57730de9b25SBarry Smith Level: beginner 57830de9b25SBarry Smith 57930de9b25SBarry Smith Notes: 580a8d69d7bSBarry Smith We highly recommend using valgrind https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind for finding memory problems. This is useful 5811957e957SBarry Smith on systems that do not have valgrind, but much much less useful. 5821957e957SBarry Smith 58379dccf82SBarry Smith Must run with the option -malloc_debug (-malloc_test in debug mode; or if PetscMallocSetDebug() called) to enable this option 58430de9b25SBarry Smith 58530de9b25SBarry Smith Once the error handler is called the calling function is then returned from with the given error code. 58630de9b25SBarry Smith 58730de9b25SBarry Smith By defaults prints location where memory that is corrupted was allocated. 58830de9b25SBarry Smith 589f621e05eSBarry Smith Use CHKMEMA for functions that return void 590f621e05eSBarry Smith 5916024bd2cSBarry Smith .seealso: PetscTraceBackErrorHandler(), PetscPushErrorHandler(), PetscError(), SETERRQ(), CHKMEMQ, SETERRQ1(), SETERRQ2(), SETERRQ3(), 592ff002950SBarry Smith PetscMallocValidate() 59330de9b25SBarry Smith M*/ 594efca3c55SSatish Balay #define CHKMEMQ do {PetscErrorCode _7_ierr = PetscMallocValidate(__LINE__,PETSC_FUNCTION_NAME,__FILE__);CHKERRQ(_7_ierr);} while (0) 59585614651SBarry Smith 596efca3c55SSatish Balay #define CHKMEMA PetscMallocValidate(__LINE__,PETSC_FUNCTION_NAME,__FILE__) 597e68848bdSBarry Smith 598668f157eSBarry Smith /*E 599668f157eSBarry Smith PetscErrorType - passed to the PETSc error handling routines indicating if this is the first or a later call to the error handlers 600668f157eSBarry Smith 601668f157eSBarry Smith Level: advanced 602668f157eSBarry Smith 603d736bfebSBarry Smith PETSC_ERROR_IN_CXX indicates the error was detected in C++ and an exception should be generated 604d736bfebSBarry Smith 60595452b02SPatrick Sanan Developer Notes: 60695452b02SPatrick Sanan This is currently used to decide when to print the detailed information about the run in PetscTraceBackErrorHandler() 607668f157eSBarry Smith 608d736bfebSBarry Smith .seealso: PetscError(), SETERRXX() 609668f157eSBarry Smith E*/ 610d736bfebSBarry Smith typedef enum {PETSC_ERROR_INITIAL=0,PETSC_ERROR_REPEAT=1,PETSC_ERROR_IN_CXX = 2} PetscErrorType; 6114b209cf6SBarry Smith 612eb9e708aSLisandro Dalcin #if defined(__clang_analyzer__) 613eb9e708aSLisandro Dalcin __attribute__((analyzer_noreturn)) 614eb9e708aSLisandro Dalcin #endif 615eb9e708aSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscError(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,...); 616eb9e708aSLisandro Dalcin 617014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscErrorPrintfInitialize(void); 618014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscErrorMessage(int,const char*[],char **); 619efca3c55SSatish Balay PETSC_EXTERN PetscErrorCode PetscTraceBackErrorHandler(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 620efca3c55SSatish Balay PETSC_EXTERN PetscErrorCode PetscIgnoreErrorHandler(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 621efca3c55SSatish Balay PETSC_EXTERN PetscErrorCode PetscEmacsClientErrorHandler(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 622efca3c55SSatish Balay PETSC_EXTERN PetscErrorCode PetscMPIAbortErrorHandler(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 623efca3c55SSatish Balay PETSC_EXTERN PetscErrorCode PetscAbortErrorHandler(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 624efca3c55SSatish Balay PETSC_EXTERN PetscErrorCode PetscAttachDebuggerErrorHandler(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 625efca3c55SSatish Balay PETSC_EXTERN PetscErrorCode PetscReturnErrorHandler(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*); 626efca3c55SSatish Balay PETSC_EXTERN PetscErrorCode PetscPushErrorHandler(PetscErrorCode (*handler)(MPI_Comm,int,const char*,const char*,PetscErrorCode,PetscErrorType,const char*,void*),void*); 627014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscPopErrorHandler(void); 6288d359177SBarry Smith PETSC_EXTERN PetscErrorCode PetscSignalHandlerDefault(int,void*); 629014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscPushSignalHandler(PetscErrorCode (*)(int,void *),void*); 630014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscPopSignalHandler(void); 63128559dc8SJed Brown PETSC_EXTERN PetscErrorCode PetscCheckPointerSetIntensity(PetscInt); 632c2a741eeSJunchao Zhang PETSC_EXTERN void PetscSignalSegvCheckPointerOrMpi(void); 633c2a741eeSJunchao Zhang PETSC_DEPRECATED_FUNCTION("Use PetscSignalSegvCheckPointerOrMpi() (since version 3.13)") PETSC_STATIC_INLINE void PetscSignalSegvCheckPointer(void) {PetscSignalSegvCheckPointerOrMpi();} 634329f5518SBarry Smith 635639ff905SBarry Smith /*MC 636639ff905SBarry Smith PetscErrorPrintf - Prints error messages. 637639ff905SBarry Smith 638639ff905SBarry Smith Synopsis: 639aaa7dc30SBarry Smith #include <petscsys.h> 640639ff905SBarry Smith PetscErrorCode (*PetscErrorPrintf)(const char format[],...); 641639ff905SBarry Smith 642639ff905SBarry Smith Not Collective 643639ff905SBarry Smith 644639ff905SBarry Smith Input Parameters: 645639ff905SBarry Smith . format - the usual printf() format string 646639ff905SBarry Smith 647639ff905SBarry Smith Options Database Keys: 6481957e957SBarry Smith + -error_output_stdout - cause error messages to be printed to stdout instead of the (default) stderr 649e1bc860dSBarry Smith - -error_output_none - to turn off all printing of error messages (does not change the way the error is handled.) 650639ff905SBarry Smith 65195452b02SPatrick Sanan Notes: 65295452b02SPatrick Sanan Use 653639ff905SBarry Smith $ PetscErrorPrintf = PetscErrorPrintfNone; to turn off all printing of error messages (does not change the way the 654639ff905SBarry Smith $ error is handled.) and 6551957e957SBarry Smith $ PetscErrorPrintf = PetscErrorPrintfDefault; to turn it back on or you can use your own function 656639ff905SBarry Smith 657639ff905SBarry Smith Use 658639ff905SBarry Smith PETSC_STDERR = FILE* obtained from a file open etc. to have stderr printed to the file. 659639ff905SBarry Smith PETSC_STDOUT = FILE* obtained from a file open etc. to have stdout printed to the file. 660639ff905SBarry Smith 661639ff905SBarry Smith Use 662639ff905SBarry Smith PetscPushErrorHandler() to provide your own error handler that determines what kind of messages to print 663639ff905SBarry Smith 664639ff905SBarry Smith Level: developer 665639ff905SBarry Smith 666639ff905SBarry Smith Fortran Note: 667639ff905SBarry Smith This routine is not supported in Fortran. 668639ff905SBarry Smith 669639ff905SBarry Smith 6702b60790dSJed Brown .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf(), PetscPrintf(), PetscPushErrorHandler(), PetscVFPrintf(), PetscHelpPrintf() 671639ff905SBarry Smith M*/ 672639ff905SBarry Smith PETSC_EXTERN PetscErrorCode (*PetscErrorPrintf)(const char[],...); 673639ff905SBarry Smith 674329f5518SBarry Smith typedef enum {PETSC_FP_TRAP_OFF=0,PETSC_FP_TRAP_ON=1} PetscFPTrap; 675014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscSetFPTrap(PetscFPTrap); 676014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscFPTrapPush(PetscFPTrap); 677014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscFPTrapPop(void); 678aba4c478SBarry Smith PETSC_EXTERN PetscErrorCode PetscDetermineInitialFPTrap(void); 67954a8ef01SBarry Smith 6803a40ed3dSBarry Smith /* 6813a40ed3dSBarry Smith Allows the code to build a stack frame as it runs 6823a40ed3dSBarry Smith */ 6833a40ed3dSBarry Smith 68499cd645aSJed Brown #define PETSCSTACKSIZE 64 685184914b5SBarry Smith 6863a40ed3dSBarry Smith typedef struct { 6870e33f6ddSBarry Smith const char *function[PETSCSTACKSIZE]; 6880e33f6ddSBarry Smith const char *file[PETSCSTACKSIZE]; 689184914b5SBarry Smith int line[PETSCSTACKSIZE]; 690a8d2bbe5SBarry Smith PetscBool petscroutine[PETSCSTACKSIZE]; 691184914b5SBarry Smith int currentsize; 692a2f94806SJed Brown int hotdepth; 6933a40ed3dSBarry Smith } PetscStack; 6943a40ed3dSBarry Smith 6951f46d60fSShri Abhyankar PETSC_EXTERN PetscStack *petscstack; 696184914b5SBarry Smith 6976f5c2d7aSBarry Smith PetscErrorCode PetscStackCopy(PetscStack*,PetscStack*); 6986f5c2d7aSBarry Smith PetscErrorCode PetscStackPrint(PetscStack *,FILE*); 6995d12eec7SSatish Balay #if defined(PETSC_SERIALIZE_FUNCTIONS) 7005d12eec7SSatish Balay #include <petsc/private/petscfptimpl.h> 7015d12eec7SSatish Balay /* 7025d12eec7SSatish Balay Registers the current function into the global function pointer to function name table 7035d12eec7SSatish Balay 7045d12eec7SSatish Balay Have to fix this to handle errors but cannot return error since used in PETSC_VIEWER_DRAW_() etc 7055d12eec7SSatish Balay */ 7065d12eec7SSatish Balay #define PetscRegister__FUNCT__() do { \ 7075d12eec7SSatish Balay static PetscBool __chked = PETSC_FALSE; \ 7085d12eec7SSatish Balay if (!__chked) {\ 7095d12eec7SSatish Balay void *ptr; PetscDLSym(NULL,PETSC_FUNCTION_NAME,&ptr);\ 7105d12eec7SSatish Balay __chked = PETSC_TRUE;\ 7115d12eec7SSatish Balay }} while (0) 7125d12eec7SSatish Balay #else 7135d12eec7SSatish Balay #define PetscRegister__FUNCT__() 7145d12eec7SSatish Balay #endif 7155d12eec7SSatish Balay 7162d7c6352SJed Brown #if defined(PETSC_USE_DEBUG) 717dbf62e16SBarry Smith PETSC_STATIC_INLINE PetscBool PetscStackActive(void) 718dbf62e16SBarry Smith { 7195c25fcd7SBarry Smith return(petscstack ? PETSC_TRUE : PETSC_FALSE); 720dbf62e16SBarry Smith } 7213a40ed3dSBarry Smith 722441dd030SJed Brown /* Stack handling is based on the following two "NoCheck" macros. These should only be called directly by other error 723441dd030SJed Brown * handling macros. We record the line of the call, which may or may not be the location of the definition. But is at 724441dd030SJed Brown * least more useful than "unknown" because it can distinguish multiple calls from the same function. 725441dd030SJed Brown */ 726441dd030SJed Brown 727a2f94806SJed Brown #define PetscStackPushNoCheck(funct,petsc_routine,hot) \ 728441dd030SJed Brown do { \ 729e04113cfSBarry Smith PetscStackSAWsTakeAccess(); \ 7305c25fcd7SBarry Smith if (petscstack && (petscstack->currentsize < PETSCSTACKSIZE)) { \ 7315c25fcd7SBarry Smith petscstack->function[petscstack->currentsize] = funct; \ 7325c25fcd7SBarry Smith petscstack->file[petscstack->currentsize] = __FILE__; \ 7335c25fcd7SBarry Smith petscstack->line[petscstack->currentsize] = __LINE__; \ 7345c25fcd7SBarry Smith petscstack->petscroutine[petscstack->currentsize] = petsc_routine; \ 7355c25fcd7SBarry Smith petscstack->currentsize++; \ 736441dd030SJed Brown } \ 7375c25fcd7SBarry Smith if (petscstack) { \ 7385c25fcd7SBarry Smith petscstack->hotdepth += (hot || petscstack->hotdepth); \ 739a2f94806SJed Brown } \ 740e04113cfSBarry Smith PetscStackSAWsGrantAccess(); \ 741441dd030SJed Brown } while (0) 742441dd030SJed Brown 743441dd030SJed Brown #define PetscStackPopNoCheck \ 7445c25fcd7SBarry Smith do { \ 745e04113cfSBarry Smith PetscStackSAWsTakeAccess(); \ 7465c25fcd7SBarry Smith if (petscstack && petscstack->currentsize > 0) { \ 7475c25fcd7SBarry Smith petscstack->currentsize--; \ 748ffc31a0eSLisandro Dalcin petscstack->function[petscstack->currentsize] = NULL; \ 749ffc31a0eSLisandro Dalcin petscstack->file[petscstack->currentsize] = NULL; \ 7505c25fcd7SBarry Smith petscstack->line[petscstack->currentsize] = 0; \ 7515c25fcd7SBarry Smith petscstack->petscroutine[petscstack->currentsize] = PETSC_FALSE;\ 752441dd030SJed Brown } \ 7535c25fcd7SBarry Smith if (petscstack) { \ 7545c25fcd7SBarry Smith petscstack->hotdepth = PetscMax(petscstack->hotdepth-1,0); \ 755a2f94806SJed Brown } \ 756e04113cfSBarry Smith PetscStackSAWsGrantAccess(); \ 757441dd030SJed Brown } while (0) 758441dd030SJed Brown 75930de9b25SBarry Smith /*MC 7601957e957SBarry Smith PetscFunctionBegin - First executable line of each PETSc function, used for error handling. Final 7611957e957SBarry Smith line of PETSc functions should be PetscFunctionReturn(0); 76230de9b25SBarry Smith 76330de9b25SBarry Smith Synopsis: 764aaa7dc30SBarry Smith #include <petscsys.h> 76530de9b25SBarry Smith void PetscFunctionBegin; 76630de9b25SBarry Smith 767eca87e8dSBarry Smith Not Collective 768eca87e8dSBarry Smith 76930de9b25SBarry Smith Usage: 77030de9b25SBarry Smith .vb 77130de9b25SBarry Smith int something; 77230de9b25SBarry Smith 77330de9b25SBarry Smith PetscFunctionBegin; 77430de9b25SBarry Smith .ve 77530de9b25SBarry Smith 77630de9b25SBarry Smith Notes: 7771957e957SBarry Smith Use PetscFunctionBeginUser for application codes. 7781957e957SBarry Smith 77930de9b25SBarry Smith Not available in Fortran 78030de9b25SBarry Smith 78130de9b25SBarry Smith Level: developer 78230de9b25SBarry Smith 7831957e957SBarry Smith .seealso: PetscFunctionReturn(), PetscFunctionBeginHot(), PetscFunctionBeginUser() 78430de9b25SBarry Smith 78530de9b25SBarry Smith M*/ 786441dd030SJed Brown #define PetscFunctionBegin do { \ 787a2f94806SJed Brown PetscStackPushNoCheck(PETSC_FUNCTION_NAME,PETSC_TRUE,PETSC_FALSE); \ 788a2f94806SJed Brown PetscRegister__FUNCT__(); \ 789a2f94806SJed Brown } while (0) 790a2f94806SJed Brown 791a2f94806SJed Brown /*MC 792a2f94806SJed Brown PetscFunctionBeginHot - Substitute for PetscFunctionBegin to be used in functions that are called in 793a2f94806SJed Brown performance-critical circumstances. Use of this function allows for lighter profiling by default. 794a2f94806SJed Brown 795a2f94806SJed Brown Synopsis: 796aaa7dc30SBarry Smith #include <petscsys.h> 797a2f94806SJed Brown void PetscFunctionBeginHot; 798a2f94806SJed Brown 799a2f94806SJed Brown Not Collective 800a2f94806SJed Brown 801a2f94806SJed Brown Usage: 802a2f94806SJed Brown .vb 803a2f94806SJed Brown int something; 804a2f94806SJed Brown 805a2f94806SJed Brown PetscFunctionBeginHot; 806a2f94806SJed Brown .ve 807a2f94806SJed Brown 808a2f94806SJed Brown Notes: 809a2f94806SJed Brown Not available in Fortran 810a2f94806SJed Brown 811a2f94806SJed Brown Level: developer 812a2f94806SJed Brown 813a2f94806SJed Brown .seealso: PetscFunctionBegin, PetscFunctionReturn() 814a2f94806SJed Brown 815a2f94806SJed Brown M*/ 816a2f94806SJed Brown #define PetscFunctionBeginHot do { \ 817a2f94806SJed Brown PetscStackPushNoCheck(PETSC_FUNCTION_NAME,PETSC_TRUE,PETSC_TRUE); \ 8182d53ad75SBarry Smith PetscRegister__FUNCT__(); \ 81953c77d0aSJed Brown } while (0) 82053c77d0aSJed Brown 821a8d2bbe5SBarry Smith /*MC 822a8d2bbe5SBarry Smith PetscFunctionBeginUser - First executable line of user provided PETSc routine 823a8d2bbe5SBarry Smith 824a8d2bbe5SBarry Smith Synopsis: 825aaa7dc30SBarry Smith #include <petscsys.h> 826a8d2bbe5SBarry Smith void PetscFunctionBeginUser; 827a8d2bbe5SBarry Smith 828a8d2bbe5SBarry Smith Not Collective 829a8d2bbe5SBarry Smith 830a8d2bbe5SBarry Smith Usage: 831a8d2bbe5SBarry Smith .vb 832a8d2bbe5SBarry Smith int something; 833a8d2bbe5SBarry Smith 834ac285190SBarry Smith PetscFunctionBeginUser; 835a8d2bbe5SBarry Smith .ve 836a8d2bbe5SBarry Smith 837a8d2bbe5SBarry Smith Notes: 8381957e957SBarry Smith Final line of PETSc functions should be PetscFunctionReturn(0) except for main(). 8391957e957SBarry Smith 840a8d2bbe5SBarry Smith Not available in Fortran 841a8d2bbe5SBarry Smith 842ac285190SBarry Smith This is identical to PetscFunctionBegin except it labels the routine as a user 843ac285190SBarry Smith routine instead of as a PETSc library routine. 844ac285190SBarry Smith 845a2f94806SJed Brown Level: intermediate 846a8d2bbe5SBarry Smith 847a2f94806SJed Brown .seealso: PetscFunctionReturn(), PetscFunctionBegin, PetscFunctionBeginHot 848a8d2bbe5SBarry Smith 849a8d2bbe5SBarry Smith M*/ 850a8d2bbe5SBarry Smith #define PetscFunctionBeginUser \ 851a8d2bbe5SBarry Smith do { \ 852a2f94806SJed Brown PetscStackPushNoCheck(PETSC_FUNCTION_NAME,PETSC_FALSE,PETSC_FALSE); \ 853a8d2bbe5SBarry Smith PetscRegister__FUNCT__(); \ 854a8d2bbe5SBarry Smith } while (0) 855a8d2bbe5SBarry Smith 856a8d2bbe5SBarry Smith 8575cd90555SBarry Smith #define PetscStackPush(n) \ 85861d886c9SShri Abhyankar do { \ 859a2f94806SJed Brown PetscStackPushNoCheck(n,PETSC_FALSE,PETSC_FALSE); \ 86015681b3cSBarry Smith CHKMEMQ; \ 86115681b3cSBarry Smith } while (0) 8623a40ed3dSBarry Smith 863d64ed03dSBarry Smith #define PetscStackPop \ 864441dd030SJed Brown do { \ 865441dd030SJed Brown CHKMEMQ; \ 866441dd030SJed Brown PetscStackPopNoCheck; \ 86715681b3cSBarry Smith } while (0) 868d64ed03dSBarry Smith 86930de9b25SBarry Smith /*MC 87030de9b25SBarry Smith PetscFunctionReturn - Last executable line of each PETSc function 87130de9b25SBarry Smith used for error handling. Replaces return() 87230de9b25SBarry Smith 87330de9b25SBarry Smith Synopsis: 874aaa7dc30SBarry Smith #include <petscsys.h> 87530de9b25SBarry Smith void PetscFunctionReturn(0); 87630de9b25SBarry Smith 877eca87e8dSBarry Smith Not Collective 878eca87e8dSBarry Smith 87930de9b25SBarry Smith Usage: 88030de9b25SBarry Smith .vb 88130de9b25SBarry Smith .... 88230de9b25SBarry Smith PetscFunctionReturn(0); 88330de9b25SBarry Smith } 88430de9b25SBarry Smith .ve 88530de9b25SBarry Smith 88630de9b25SBarry Smith Notes: 88730de9b25SBarry Smith Not available in Fortran 88830de9b25SBarry Smith 88930de9b25SBarry Smith Level: developer 89030de9b25SBarry Smith 89130de9b25SBarry Smith .seealso: PetscFunctionBegin() 89230de9b25SBarry Smith 89330de9b25SBarry Smith M*/ 8945cd90555SBarry Smith #define PetscFunctionReturn(a) \ 8958246ba0dSJed Brown do { \ 896441dd030SJed Brown PetscStackPopNoCheck; \ 8978246ba0dSJed Brown return(a);} while (0) 898d64ed03dSBarry Smith 899ff94ddecSSatish Balay #define PetscFunctionReturnVoid() \ 9008246ba0dSJed Brown do { \ 901441dd030SJed Brown PetscStackPopNoCheck; \ 9028246ba0dSJed Brown return;} while (0) 90376386721SLisandro Dalcin 9046d385327SIbrahima Ba #else 9056d385327SIbrahima Ba 906c82b4e47SJed Brown PETSC_STATIC_INLINE PetscBool PetscStackActive(void) {return PETSC_FALSE;} 907a2f94806SJed Brown #define PetscStackPushNoCheck(funct,petsc_routine,hot) do {} while (0) 908441dd030SJed Brown #define PetscStackPopNoCheck do {} while (0) 9093a40ed3dSBarry Smith #define PetscFunctionBegin 9100bdf7c52SPeter Brune #define PetscFunctionBeginUser 911a2f94806SJed Brown #define PetscFunctionBeginHot 9123a40ed3dSBarry Smith #define PetscFunctionReturn(a) return(a) 9135665465eSBarry Smith #define PetscFunctionReturnVoid() return 914812af9f3SBarry Smith #define PetscStackPop CHKMEMQ 915812af9f3SBarry Smith #define PetscStackPush(f) CHKMEMQ 9163a40ed3dSBarry Smith 9173a40ed3dSBarry Smith #endif 9183a40ed3dSBarry Smith 919eb6b5d47SBarry Smith /* 920eb6b5d47SBarry Smith PetscStackCall - Calls an external library routine or user function after pushing the name of the routine on the stack. 921eb6b5d47SBarry Smith 922eb6b5d47SBarry Smith Input Parameters: 923eb6b5d47SBarry Smith + name - string that gives the name of the function being called 924fd3f9acdSBarry Smith - routine - actual call to the routine, including ierr = and CHKERRQ(ierr); 925fd3f9acdSBarry Smith 926dbf62e16SBarry Smith Note: Often one should use PetscStackCallStandard() instead. This routine is intended for external library routines that DO NOT return error codes 927eb6b5d47SBarry Smith 928eb6b5d47SBarry Smith Developer Note: this is so that when a user or external library routine results in a crash or corrupts memory, they get blamed instead of PETSc. 929eb6b5d47SBarry Smith 930fd3f9acdSBarry Smith 931fd3f9acdSBarry Smith 932eb6b5d47SBarry Smith */ 93330ecc5abSKarl Rupp #define PetscStackCall(name,routine) do { PetscStackPush(name);routine;PetscStackPop; } while (0) 934eb6b5d47SBarry Smith 935fd3f9acdSBarry Smith /* 936fd3f9acdSBarry Smith PetscStackCallStandard - Calls an external library routine after pushing the name of the routine on the stack. 937fd3f9acdSBarry Smith 938fd3f9acdSBarry Smith Input Parameters: 939fd3f9acdSBarry Smith + func- name of the routine 940fd3f9acdSBarry Smith - args - arguments to the routine surrounded by () 941fd3f9acdSBarry Smith 94295452b02SPatrick Sanan Notes: 94395452b02SPatrick Sanan This is intended for external package routines that return error codes. Use PetscStackCall() for those that do not. 944dbf62e16SBarry Smith 945dbf62e16SBarry Smith Developer Note: this is so that when an external packge routine results in a crash or corrupts memory, they get blamed instead of PETSc. 946fd3f9acdSBarry Smith 947fd3f9acdSBarry Smith */ 948fd3f9acdSBarry Smith #define PetscStackCallStandard(func,args) do { \ 9491d4906efSStefano Zampini PetscErrorCode __ierr; \ 9501d4906efSStefano Zampini PetscStackPush(#func); \ 9511d4906efSStefano Zampini __ierr = func args; \ 9521d4906efSStefano Zampini PetscStackPop; \ 9531d4906efSStefano Zampini if (__ierr) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in %s(): error code %d",#func,(int)__ierr); \ 954fd3f9acdSBarry Smith } while (0) 955fd3f9acdSBarry Smith 956014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscStackCreate(void); 957639ff905SBarry Smith PETSC_EXTERN PetscErrorCode PetscStackView(FILE*); 958014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscStackDestroy(void); 95906d1fe2cSBarry Smith 96006d1fe2cSBarry Smith #endif 961