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