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