10 |
|
|
11 |
|
|
12 |
|
|
13 |
< |
mpiEventInit() |
13 |
> |
void mpiEventInit(void) |
14 |
|
{ |
15 |
< |
int blockCounts[4] = {1,3,4,120} |
15 |
> |
int blockCounts[4] = {1,3,4,120}; |
16 |
|
MPI_Aint dspls[4]; |
17 |
|
MPI_Datatype types[4]; |
18 |
|
mBEvent protoEvent; |
19 |
|
|
20 |
|
int i; |
21 |
|
|
22 |
< |
MPI_Address(&protoEvent.type, dspls[0]); |
23 |
< |
MPI_Address(&protoEvent.d1, dspls[1]); |
24 |
< |
MPI_Address(&protoEvent.i1, dspls[2]); |
25 |
< |
MPI_Address(&protoEvent.cArray, dspls[3]); |
22 |
> |
MPI_Address(&protoEvent.type, &dspls[0]); |
23 |
> |
MPI_Address(&protoEvent.d1, &dspls[1]); |
24 |
> |
MPI_Address(&protoEvent.i1, &dspls[2]); |
25 |
> |
MPI_Address(&protoEvent.cArray, &dspls[3]); |
26 |
|
|
27 |
|
|
28 |
|
types[0] = MPI_INT; |
38 |
|
} |
39 |
|
|
40 |
|
|
41 |
< |
throwMPIEvent(event* the_event) |
41 |
> |
void throwMPIEvent(event* the_event) |
42 |
|
{ |
43 |
< |
mBEvent mpiBEventContainer; |
43 |
> |
mBEvent mpiEventContainer; |
44 |
|
int mpiStatus; |
45 |
|
int mpiError; |
46 |
|
|
50 |
|
mpiError = MPI_Bcast(&mpiStatus,1,MPI_INT,0,MPI_COMM_WORLD); |
51 |
|
if (mpiError != MPI_SUCCESS){ |
52 |
|
mpiError = MPI_Finalize(); |
53 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
53 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
54 |
|
exit (0); |
55 |
|
} |
56 |
|
|
58 |
|
switch (the_event->event_type){ |
59 |
|
case MOLECULE: |
60 |
|
mpiEventContainer.type = mpiMOLECULE; |
61 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
61 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
62 |
|
break; |
63 |
|
|
64 |
|
case ATOM: |
65 |
|
mpiEventContainer.type = mpiATOM; |
66 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
66 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
67 |
|
break; |
68 |
|
|
69 |
|
case BOND: |
70 |
|
mpiEventContainer.type = mpiBOND; |
71 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
71 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
72 |
|
break; |
73 |
|
|
74 |
|
case BEND: |
75 |
|
mpiEventContainer.type = mpiBEND; |
76 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
76 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
77 |
|
break; |
78 |
|
|
79 |
|
case TORSION: |
80 |
|
mpiEventContainer.type = mpiTORSION; |
81 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
81 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
82 |
|
break; |
83 |
|
|
84 |
|
case COMPONENT: |
85 |
|
mpiEventContainer.type = mpiCOMPONENT; |
86 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
86 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
87 |
|
break; |
88 |
|
|
89 |
|
case POSITION: |
117 |
|
switch (the_event->evt.asmt.asmt_type){ |
118 |
|
case STRING: |
119 |
|
mpiEventContainer.type = mpiASSIGNMENT_s; |
120 |
< |
strcpy(mpiEventContainer.cArray,the_event->evt.asmt.sval); |
120 |
> |
strcpy(mpiEventContainer.cArray,the_event->evt.asmt.rhs.sval); |
121 |
|
break; |
122 |
|
|
123 |
|
case INT: |
124 |
|
mpiEventContainer.type = mpiASSIGNMENT_i; |
125 |
< |
mpiEventContainer.i1 = the_event->evt.asmt.ival; |
125 |
> |
mpiEventContainer.i1 = the_event->evt.asmt.rhs.ival; |
126 |
|
break; |
127 |
|
|
128 |
|
case DOUBLE: |
129 |
|
mpiEventContainer.type = mpiASSIGNMENT_d; |
130 |
< |
mpiEventContainer.d1 = the_event->evt.asmt.dval; |
130 |
> |
mpiEventContainer.d1 = the_event->evt.asmt.rhs.dval; |
131 |
|
break; |
132 |
|
} |
133 |
|
break; |
142 |
|
|
143 |
|
if (mpiError != MPI_SUCCESS){ |
144 |
|
mpiError = MPI_Finalize(); |
145 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
145 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
146 |
|
exit (0); |
147 |
|
} |
148 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
// Everybody but node 0 runs this |
153 |
< |
mpiEventLoop() |
153 |
> |
void mpiEventLoop(void) |
154 |
|
{ |
155 |
|
int mpiError; |
156 |
|
int mpiContinue; |
158 |
|
mpiError = MPI_Bcast(&mpiContinue,1,MPI_INT,0,MPI_COMM_WORLD); |
159 |
|
if (mpiError != MPI_SUCCESS){ |
160 |
|
mpiError = MPI_Finalize(); |
161 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
161 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
162 |
|
exit (0); |
163 |
|
} |
164 |
|
|
170 |
|
mpiError = MPI_Bcast(&mpiContinue,1,MPI_INT,0,MPI_COMM_WORLD); |
171 |
|
if (mpiError != MPI_SUCCESS){ |
172 |
|
mpiError = MPI_Finalize(); |
173 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
173 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
174 |
|
exit (0); |
175 |
|
} |
176 |
|
} |
177 |
|
|
178 |
|
if (mpiContinue == MPI_INTERFACE_ABORT){ |
179 |
|
mpiError = MPI_Finalize(); |
180 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
180 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
181 |
|
exit (0); |
182 |
|
} |
183 |
|
} |
184 |
|
|
185 |
< |
mpiCatchEvent() |
185 |
> |
void mpiCatchEvent(void) |
186 |
|
{ |
187 |
|
event the_event; |
188 |
< |
mBEvent mpiBEventContainer; |
188 |
> |
mBEvent mpiEventContainer; |
189 |
|
int mpiError; |
190 |
|
|
191 |
|
|
193 |
|
|
194 |
|
if (mpiError != MPI_SUCCESS){ |
195 |
|
mpiError = MPI_Finalize(); |
196 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
196 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
197 |
|
exit (0); |
198 |
|
} |
199 |
|
|
201 |
|
switch (mpiEventContainer.type){ |
202 |
|
case mpiMOLECULE: |
203 |
|
the_event.event_type = MOLECULE; |
204 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
204 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
205 |
|
break; |
206 |
|
|
207 |
|
case mpiATOM: |
208 |
|
the_event.event_type = ATOM; |
209 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
209 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
210 |
|
break; |
211 |
|
|
212 |
|
case mpiBOND: |
213 |
|
the_event.event_type = BOND; |
214 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
214 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
215 |
|
break; |
216 |
|
|
217 |
|
case mpiBEND: |
218 |
|
the_event.event_type = BEND; |
219 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
219 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
220 |
|
break; |
221 |
|
|
222 |
|
case mpiTORSION: |
223 |
|
the_event.event_type = TORSION; |
224 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
224 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
225 |
|
break; |
226 |
|
|
227 |
|
case mpiCOMPONENT: |
228 |
|
the_event.event_type = COMPONENT; |
229 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
229 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
230 |
|
break; |
231 |
|
|
232 |
|
|
260 |
|
case mpiASSIGNMENT_s: |
261 |
|
the_event.event_type = ASSIGNMENT; |
262 |
|
the_event.evt.asmt.asmt_type = STRING; |
263 |
< |
strcpy(the_event.evt.asmt.sval,mpiEventContainer.cArray); |
263 |
> |
strcpy(the_event.evt.asmt.rhs.sval,mpiEventContainer.cArray); |
264 |
|
break; |
265 |
|
|
266 |
|
case mpiASSIGNMENT_i: |
267 |
|
the_event.event_type = ASSIGNMENT; |
268 |
|
the_event.evt.asmt.asmt_type = INT; |
269 |
< |
the_event.evt.asmt.ival = mpiEventContainer.i1; |
269 |
> |
the_event.evt.asmt.rhs.ival = mpiEventContainer.i1; |
270 |
|
break; |
271 |
|
|
272 |
|
case mpiASSIGNMENT_d: |
273 |
|
the_event.event_type = ASSIGNMENT; |
274 |
|
the_event.evt.asmt.asmt_type = DOUBLE; |
275 |
< |
the_event.evt.asmt.dval = mpiEventContainer.d1; |
275 |
> |
the_event.evt.asmt.rhs.dval = mpiEventContainer.d1; |
276 |
|
break; |
277 |
|
|
278 |
|
case mpiBLOCK_END: |
282 |
|
|
283 |
|
|
284 |
|
if (!event_handler(&the_event)){ |
285 |
< |
sprintf(stderr,"MPI event handling error => %s\n",the_event.err_msg); |
285 |
> |
fprintf(stderr,"MPI event handling error => %s\n",the_event.err_msg); |
286 |
|
mpiError = MPI_Finalize(); |
287 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
287 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
288 |
|
exit (0); |
289 |
|
} |
290 |
|
} |
291 |
+ |
|
292 |
+ |
|
293 |
+ |
void mpiInterfaceExit(void){ |
294 |
+ |
int mpiError; |
295 |
+ |
int mpiStatus = MPI_INTERFACE_ABORT; |
296 |
+ |
|
297 |
+ |
mpiError = MPI_Bcast(&mpiStatus,1,MPI_INT,0,MPI_COMM_WORLD); |
298 |
+ |
if (mpiError != MPI_SUCCESS){ |
299 |
+ |
mpiError = MPI_Finalize(); |
300 |
+ |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
301 |
+ |
exit (0); |
302 |
+ |
} |
303 |
+ |
|
304 |
+ |
mpiError = MPI_Finalize(); |
305 |
+ |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
306 |
+ |
exit (0); |
307 |
+ |
|
308 |
+ |
} |