ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/simError.c
Revision: 796
Committed: Fri Oct 3 22:01:46 2003 UTC (20 years, 9 months ago) by mmeineke
Content type: text/plain
File size: 1802 byte(s)
Log Message:
changed the formating ogf the error statements in simError

File Contents

# Content
1 #include <stdlib.h>
2 #include <stdio.h>
3
4 #ifdef IS_MPI
5 #include <mpi.h>
6
7 int nChecks;
8 #endif // IS_MPI
9
10 #include "simError.h"
11
12 errorStruct painCave;
13
14 #ifdef IS_MPI
15
16 char checkPointMsg[MAX_SIM_ERROR_MSG_LENGTH];
17 int worldRank;
18
19 #endif
20
21
22 void initSimError( void ){
23 painCave.errMsg[0] = '\0';
24 painCave.isFatal = 0;
25 #ifdef IS_MPI
26 painCave.isEventLoop = 0;
27 nChecks = 0;
28 MPI_Comm_rank( MPI_COMM_WORLD, &worldRank );
29 #endif
30 }
31
32 int simError( void ) {
33
34 #ifdef IS_MPI
35 int myError = 1;
36 int isError;
37
38 if( painCave.isEventLoop ){
39 fprintf( stderr,
40 "MPI Event Error on node %d: %s\n",
41 worldRank,
42 painCave.errMsg );
43 return 1;
44 }
45 else{
46 if( painCave.isFatal ){
47 fprintf( stderr,
48 "\n"
49 "MPI Fatal Error on node %d: %s\n",
50 worldRank,
51 painCave.errMsg );
52 MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
53
54 MPI_Finalize();
55 exit(0);
56 }
57 else{
58 fprintf( stderr,
59 "\n"
60 "MPI Warning on node %d: %s\n",
61 worldRank,
62 painCave.errMsg );
63 }
64 return 1;
65 }
66
67 #else
68
69 if( painCave.isFatal ){
70 fprintf( stderr,
71 "\n"
72 "Fatal Error: %s\n",
73 painCave.errMsg );
74 exit(0);
75 }
76 else{
77 fprintf( stderr,
78 "\n"
79 "Warning: %s\n",
80 painCave.errMsg );
81 }
82 return 1;
83
84 #endif // IS_MPI
85
86 }
87
88
89 #ifdef IS_MPI
90
91 void MPIcheckPoint( void ){
92
93 int myError = 0;
94 int isError;
95
96 MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
97 if( isError ){
98 MPI_Finalize();
99 exit(0);
100 }
101
102 #ifdef CHECKPOINT_VERBOSE
103 nChecks++;
104 if( worldRank == 0 ){
105 fprintf(stderr,
106 "Checkpoint #%d reached: %s\n",
107 nChecks,
108 checkPointMsg );
109 }
110 #endif // CHECKPOINT_VERBOSE
111
112 }
113
114 #endif // IS_MPI