ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/simError.c
Revision: 378
Committed: Fri Mar 21 17:42:12 2003 UTC (21 years, 3 months ago) by mmeineke
Content type: text/plain
File size: 1713 byte(s)
Log Message:
This commit was generated by cvs2svn to compensate for changes in r377,
which included commits to RCS files with non-trunk default branches.

File Contents

# User Rev Content
1 mmeineke 377 #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    
13     void initSimError( void ){
14     painCave.errMsg[0] = '\0';
15     painCave.isFatal = 0;
16     #ifdef IS_MPI
17     painCave.isEventLoop = 0;
18     nChecks = 0;
19     MPI_Comm_rank( MPI_COMM_WORLD, &worldRank );
20     #endif
21     }
22    
23     int simError( void ) {
24    
25     #ifdef IS_MPI
26     int myError = 1;
27     int isError;
28     int isFatal;
29    
30     if( painCave.isEventLoop ){
31     fprintf( stderr,
32     "MPI Event Error on node %d: %s\n",
33     worldRank,
34     painCave.errMsg );
35     return 1;
36     }
37     else{
38     if( painCave.isFatal ){
39     fprintf( stderr,
40     "MPI Fatal Error on node %d: %s\n",
41     worldRank,
42     painCave.errMsg );
43     MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
44    
45     MPI_Finalize();
46     exit(0);
47     }
48     else{
49     fprintf( stderr,
50     "MPI Non-Fatal Error on node %d: %s\n",
51     worldRank,
52     painCave.errMsg );
53     }
54     return 1;
55     }
56    
57     #else
58    
59     if( painCave.isFatal ){
60     fprintf( stderr,
61     "Fatal Error: %s\n",
62     painCave.errMsg );
63     exit(0);
64     }
65     else{
66     fprintf( stderr,
67     "Warning: %s\n",
68     painCave.errMsg );
69     }
70     return 1;
71    
72     #endif // IS_MPI
73    
74     return 0; // in case nobody caught that.
75    
76     }
77    
78    
79     #ifdef IS_MPI
80    
81     void MPIcheckPoint( void ){
82    
83     int myError = 0;
84     int isError;
85    
86     MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
87     if( isError ){
88     MPI_Finalize();
89     exit(0);
90     }
91    
92     #ifdef CHECKPOINT_VERBOSE
93     nChecks++;
94     if( worldRank == 0 ){
95     fprintf(stderr,
96     "Checkpoint #%d reached: %s\n",
97     nChecks,
98     checkPointMsg );
99     }
100     #endif // CHECKPOINT_VERBOSE
101    
102     }
103    
104     #endif // IS_MPI