Actual source code: errstop.c
1: /*$Id: errstop.c,v 1.17 2001/04/10 19:34:27 bsmith Exp $*/
3: #include petsc.h
5: /*@C
6: PetscStopErrorHandler - Calls MPI_abort() and exists.
8: Not Collective
10: Input Parameters:
11: + line - the line number of the error (indicated by __LINE__)
12: . file - the file in which the error was detected (indicated by __FILE__)
13: . dir - the directory of the file (indicated by __SDIR__)
14: . mess - an error text string, usually just printed to the screen
15: . n - the generic error number
16: . p - the specific error number
17: - ctx - error handler context
19: Level: developer
21: Notes:
22: Most users need not directly employ this routine and the other error
23: handlers, but can instead use the simplified interface SETERRQ, which has
24: the calling sequence
25: $ SETERRQ(n,p,mess)
27: Notes for experienced users:
28: Use PetscPushErrorHandler() to set the desired error handler. The
29: currently available PETSc error handlers include PetscTraceBackErrorHandler(),
30: PetscStopErrorHandler(), PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler().
32: Concepts: error handler^stopping
34: .seealso: PetscPushErrorHandler(), PetscAttachDebuggerErrorHandler(),
35: PetscAbortErrorHandler(), PetscTraceBackErrorHandler()
36: @*/
37: int PetscStopErrorHandler(int line,char *fun,char *file,char *dir,int n,int p,char *mess,void *ctx)
38: {
39: int rank;
40: PetscTruth flg1,flg2;
41: PetscLogDouble mem,rss;
44: if (!mess) mess = " ";
46: MPI_Comm_rank(MPI_COMM_WORLD,&rank);
47: if (n == PETSC_ERR_MEM) {
48: (*PetscErrorPrintf)("[%d]PETSC ERROR: %s() line %d in %s%sn",rank,fun,line,dir,file);
49: (*PetscErrorPrintf)("[%d]PETSC ERROR: Out of memory. This could be due to allocatingn",rank);
50: (*PetscErrorPrintf)("[%d]PETSC ERROR: too large an object or bleeding by not properlyn",rank);
51: (*PetscErrorPrintf)("[%d]PETSC ERROR: destroying unneeded objects.n",rank);
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 if (flg1) {
58: (*PetscErrorPrintf)("[%d]PETSC ERROR: Memory allocated %d Memory used by process %dn",rank,(int)mem,(int)rss);
59: PetscTrDump(stdout);
60: } else {
61: (*PetscErrorPrintf)("[%d]PETSC ERROR: Memory allocated %d Memory used by process %dn",rank,(int)mem,(int)rss);
62: (*PetscErrorPrintf)("[%d]PETSC ERROR: Try running with -trdump or -trmalloc_log for info.n",rank);
63: }
64: } else if (n == PETSC_ERR_SUP) {
65: (*PetscErrorPrintf)("[%d]PETSC ERROR: %s() line %d in %s%sn",rank,fun,line,dir,file);
66: (*PetscErrorPrintf)("[%d]PETSC ERROR: No support for this operation for this object type!n",rank);
67: (*PetscErrorPrintf)("[%d]PETSC ERROR: %sn",rank,mess);
68: } else if (n == PETSC_ERR_SIG) {
69: (*PetscErrorPrintf)("[%d]PETSC ERROR: %s() line %d in %s%s %sn",rank,fun,line,dir,file,mess);
70: } else {
71: (*PetscErrorPrintf)("[%d]PETSC ERROR: %s() line %d in %s%sn %sn",rank,fun,line,dir,file,mess);
72: }
73: MPI_Abort(PETSC_COMM_WORLD,n);
74: return(0);
75: }