ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/simError.c
Revision: 790
Committed: Mon Sep 29 21:16:11 2003 UTC (20 years, 9 months ago) by mmeineke
Content type: text/plain
File size: 1754 byte(s)
Log Message:
fixed a lot of warnings and errors found with SUN's SUNWspro.s1s7

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 "MPI Fatal Error on node %d: %s\n",
49 worldRank,
50 painCave.errMsg );
51 MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
52
53 MPI_Finalize();
54 exit(0);
55 }
56 else{
57 fprintf( stderr,
58 "MPI Warning on node %d: %s\n",
59 worldRank,
60 painCave.errMsg );
61 }
62 return 1;
63 }
64
65 #else
66
67 if( painCave.isFatal ){
68 fprintf( stderr,
69 "Fatal Error: %s\n",
70 painCave.errMsg );
71 exit(0);
72 }
73 else{
74 fprintf( stderr,
75 "Warning: %s\n",
76 painCave.errMsg );
77 }
78 return 1;
79
80 #endif // IS_MPI
81
82 }
83
84
85 #ifdef IS_MPI
86
87 void MPIcheckPoint( void ){
88
89 int myError = 0;
90 int isError;
91
92 MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
93 if( isError ){
94 MPI_Finalize();
95 exit(0);
96 }
97
98 #ifdef CHECKPOINT_VERBOSE
99 nChecks++;
100 if( worldRank == 0 ){
101 fprintf(stderr,
102 "Checkpoint #%d reached: %s\n",
103 nChecks,
104 checkPointMsg );
105 }
106 #endif // CHECKPOINT_VERBOSE
107
108 }
109
110 #endif // IS_MPI