1 #define PETSC_DLL 2 3 #include "petscsys.h" /*I "petscsys.h" I*/ 4 5 #undef __FUNCT__ 6 #define __FUNCT__ "PetscMPIAbortErrorHandler" 7 /*@C 8 PetscMPIAbortErrorHandler - Calls MPI_abort() and exits. 9 10 Not Collective 11 12 Input Parameters: 13 + comm - communicator over which error occurred 14 . line - the line number of the error (indicated by __LINE__) 15 . fun - the function where the error occurred (indicated by __FUNCT__) 16 . file - the file in which the error was detected (indicated by __FILE__) 17 . dir - the directory of the file (indicated by __SDIR__) 18 . mess - an error text string, usually just printed to the screen 19 . n - the generic error number 20 . p - the specific error number 21 - ctx - error handler context 22 23 Level: developer 24 25 Notes: 26 Most users need not directly employ this routine and the other error 27 handlers, but can instead use the simplified interface SETERRQ, which has 28 the calling sequence 29 $ SETERRQ(comm,n,p,mess) 30 31 Notes for experienced users: 32 Use PetscPushErrorHandler() to set the desired error handler. The 33 currently available PETSc error handlers include PetscTraceBackErrorHandler(), 34 PetscMPIAbortErrorHandler(), PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler(). 35 36 Concepts: error handler^stopping 37 38 .seealso: PetscPushErrorHandler(), PetscAttachDebuggerErrorHandler(), 39 PetscAbortErrorHandler(), PetscTraceBackErrorHandler() 40 @*/ 41 PetscErrorCode PETSC_DLLEXPORT PetscMPIAbortErrorHandler(MPI_Comm comm,int line,const char *fun,const char *file,const char *dir,PetscErrorCode n,int p,const char *mess,void *ctx) 42 { 43 PetscTruth flg1 = PETSC_FALSE,flg2 = PETSC_FALSE; 44 PetscLogDouble mem,rss; 45 46 PetscFunctionBegin; 47 if (!mess) mess = " "; 48 49 if (n == PETSC_ERR_MEM) { 50 (*PetscErrorPrintf)("%s() line %d in %s%s\n",fun,line,dir,file); 51 (*PetscErrorPrintf)("Out of memory. This could be due to allocating\n"); 52 (*PetscErrorPrintf)("too large an object or bleeding by not properly\n"); 53 (*PetscErrorPrintf)("destroying unneeded objects.\n"); 54 PetscMallocGetCurrentUsage(&mem); PetscMemoryGetCurrentUsage(&rss); 55 PetscOptionsGetTruth(PETSC_NULL,"-malloc_dump",&flg1,PETSC_NULL); 56 PetscOptionsGetTruth(PETSC_NULL,"-malloc_log",&flg2,PETSC_NULL); 57 if (flg2) { 58 PetscMallocDumpLog(stdout); 59 } else { 60 (*PetscErrorPrintf)("Memory allocated %D Memory used by process %D\n",(PetscInt)mem,(PetscInt)rss); 61 if (flg1) { 62 PetscMallocDump(stdout); 63 } else { 64 (*PetscErrorPrintf)("Try running with -malloc_dump or -malloc_log for info.\n"); 65 } 66 } 67 } else if (n == PETSC_ERR_SUP) { 68 (*PetscErrorPrintf)("%s() line %d in %s%s\n",fun,line,dir,file); 69 (*PetscErrorPrintf)("No support for this operation for this object type!\n"); 70 (*PetscErrorPrintf)("%s\n",mess); 71 } else if (n == PETSC_ERR_SIG) { 72 (*PetscErrorPrintf)("%s() line %d in %s%s %s\n",fun,line,dir,file,mess); 73 } else { 74 (*PetscErrorPrintf)("%s() line %d in %s%s\n %s\n",fun,line,dir,file,mess); 75 } 76 MPI_Abort(PETSC_COMM_WORLD,n); 77 PetscFunctionReturn(0); 78 } 79 80