1 |
#include <cstring> |
2 |
#include <iostream> |
3 |
#include <fstream> |
4 |
|
5 |
#ifdef IS_MPI |
6 |
#include <mpi.h> |
7 |
#include "mpiSimulation.hpp" |
8 |
#define TAKE_THIS_TAG_CHAR 1 |
9 |
#define TAKE_THIS_TAG_INT 2 |
10 |
|
11 |
namespace dWrite{ |
12 |
void nodeZeroError( void ); |
13 |
void anonymousNodeDie( void ); |
14 |
} |
15 |
|
16 |
using namespace dWrite; |
17 |
#endif //is_mpi |
18 |
|
19 |
#include "ReadWrite.hpp" |
20 |
#include "simError.h" |
21 |
|
22 |
DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ |
23 |
|
24 |
entry_plug = the_entry_plug; |
25 |
|
26 |
#ifdef IS_MPI |
27 |
if(worldRank == 0 ){ |
28 |
#endif // is_mpi |
29 |
|
30 |
strcpy( outName, entry_plug->sampleName ); |
31 |
|
32 |
outFile.open(outName, ios::out | ios::trunc ); |
33 |
|
34 |
if( !outFile ){ |
35 |
|
36 |
sprintf( painCave.errMsg, |
37 |
"Could not open \"%s\" for dump output.\n", |
38 |
outName); |
39 |
painCave.isFatal = 1; |
40 |
simError(); |
41 |
} |
42 |
|
43 |
//outFile.setf( ios::scientific ); |
44 |
|
45 |
#ifdef IS_MPI |
46 |
} |
47 |
|
48 |
sprintf( checkPointMsg, |
49 |
"Sucessfully opened output file for dumping.\n"); |
50 |
MPIcheckPoint(); |
51 |
#endif // is_mpi |
52 |
} |
53 |
|
54 |
DumpWriter::~DumpWriter( ){ |
55 |
|
56 |
#ifdef IS_MPI |
57 |
if(worldRank == 0 ){ |
58 |
#endif // is_mpi |
59 |
|
60 |
outFile.close(); |
61 |
|
62 |
#ifdef IS_MPI |
63 |
} |
64 |
#endif // is_mpi |
65 |
} |
66 |
|
67 |
void DumpWriter::writeDump( double currentTime ){ |
68 |
|
69 |
const int BUFFERSIZE = 2000; |
70 |
char tempBuffer[BUFFERSIZE]; |
71 |
char writeLine[BUFFERSIZE]; |
72 |
|
73 |
int i, j, which_node, done, which_atom, local_index; |
74 |
double q[4]; |
75 |
DirectionalAtom* dAtom; |
76 |
int nAtoms = entry_plug->n_atoms; |
77 |
Atom** atoms = entry_plug->atoms; |
78 |
|
79 |
|
80 |
#ifndef IS_MPI |
81 |
|
82 |
outFile << nAtoms << "\n"; |
83 |
|
84 |
outFile << currentTime << ";\t" |
85 |
<< entry_plug->Hmat[0][0] << "\t" |
86 |
<< entry_plug->Hmat[1][0] << "\t" |
87 |
<< entry_plug->Hmat[2][0] << ";\t" |
88 |
|
89 |
<< entry_plug->Hmat[0][1] << "\t" |
90 |
<< entry_plug->Hmat[1][1] << "\t" |
91 |
<< entry_plug->Hmat[2][1] << ";\t" |
92 |
|
93 |
<< entry_plug->Hmat[0][2] << "\t" |
94 |
<< entry_plug->Hmat[1][2] << "\t" |
95 |
<< entry_plug->Hmat[2][2] << ";\n"; |
96 |
|
97 |
for( i=0; i<nAtoms; i++ ){ |
98 |
|
99 |
|
100 |
sprintf( tempBuffer, |
101 |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
102 |
atoms[i]->getType(), |
103 |
atoms[i]->getX(), |
104 |
atoms[i]->getY(), |
105 |
atoms[i]->getZ(), |
106 |
atoms[i]->get_vx(), |
107 |
atoms[i]->get_vy(), |
108 |
atoms[i]->get_vz()); |
109 |
strcpy( writeLine, tempBuffer ); |
110 |
|
111 |
if( atoms[i]->isDirectional() ){ |
112 |
|
113 |
dAtom = (DirectionalAtom *)atoms[i]; |
114 |
dAtom->getQ( q ); |
115 |
|
116 |
sprintf( tempBuffer, |
117 |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
118 |
q[0], |
119 |
q[1], |
120 |
q[2], |
121 |
q[3], |
122 |
dAtom->getJx(), |
123 |
dAtom->getJy(), |
124 |
dAtom->getJz()); |
125 |
strcat( writeLine, tempBuffer ); |
126 |
} |
127 |
else |
128 |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
129 |
|
130 |
outFile << writeLine; |
131 |
} |
132 |
outFile.flush(); |
133 |
|
134 |
#else // is_mpi |
135 |
|
136 |
// first thing first, suspend fatalities. |
137 |
painCave.isEventLoop = 1; |
138 |
|
139 |
int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone |
140 |
int haveError; |
141 |
|
142 |
MPI_Status istatus; |
143 |
int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
144 |
|
145 |
// write out header and node 0's coordinates |
146 |
|
147 |
if( worldRank == 0 ){ |
148 |
outFile << mpiSim->getTotAtoms() << "\n"; |
149 |
|
150 |
outFile << currentTime << ";\t" |
151 |
<< entry_plug->Hmat[0][0] << "\t" |
152 |
<< entry_plug->Hmat[1][0] << "\t" |
153 |
<< entry_plug->Hmat[2][0] << ";\t" |
154 |
|
155 |
<< entry_plug->Hmat[0][1] << "\t" |
156 |
<< entry_plug->Hmat[1][1] << "\t" |
157 |
<< entry_plug->Hmat[2][1] << ";\t" |
158 |
|
159 |
<< entry_plug->Hmat[0][2] << "\t" |
160 |
<< entry_plug->Hmat[1][2] << "\t" |
161 |
<< entry_plug->Hmat[2][2] << ";\n"; |
162 |
|
163 |
outFile.flush(); |
164 |
for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { |
165 |
// Get the Node number which has this atom; |
166 |
|
167 |
which_node = AtomToProcMap[i]; |
168 |
|
169 |
if (which_node == 0 ) { |
170 |
|
171 |
haveError = 0; |
172 |
which_atom = i; |
173 |
local_index=-1; |
174 |
for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) { |
175 |
if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; |
176 |
} |
177 |
if (local_index != -1) { |
178 |
//format the line |
179 |
sprintf( tempBuffer, |
180 |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
181 |
atoms[local_index]->getType(), |
182 |
atoms[local_index]->getX(), |
183 |
atoms[local_index]->getY(), |
184 |
atoms[local_index]->getZ(), |
185 |
atoms[local_index]->get_vx(), |
186 |
atoms[local_index]->get_vy(), |
187 |
atoms[local_index]->get_vz()); // check here. |
188 |
strcpy( writeLine, tempBuffer ); |
189 |
|
190 |
if( atoms[local_index]->isDirectional() ){ |
191 |
|
192 |
dAtom = (DirectionalAtom *)atoms[local_index]; |
193 |
dAtom->getQ( q ); |
194 |
|
195 |
sprintf( tempBuffer, |
196 |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
197 |
q[0], |
198 |
q[1], |
199 |
q[2], |
200 |
q[3], |
201 |
dAtom->getJx(), |
202 |
dAtom->getJy(), |
203 |
dAtom->getJz()); |
204 |
strcat( writeLine, tempBuffer ); |
205 |
|
206 |
} |
207 |
else |
208 |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
209 |
} |
210 |
else { |
211 |
sprintf(painCave.errMsg, |
212 |
"Atom %d not found on processor %d\n", |
213 |
i, worldRank ); |
214 |
haveError= 1; |
215 |
simError(); |
216 |
} |
217 |
|
218 |
if(haveError) nodeZeroError(); |
219 |
|
220 |
} |
221 |
else { |
222 |
myStatus = 1; |
223 |
MPI_Send(&myStatus, 1, MPI_INT, which_node, |
224 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
225 |
MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
226 |
MPI_COMM_WORLD); |
227 |
MPI_Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, |
228 |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
229 |
MPI_Recv(&myStatus, 1, MPI_INT, which_node, |
230 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
231 |
|
232 |
if(!myStatus) nodeZeroError(); |
233 |
|
234 |
} |
235 |
|
236 |
outFile << writeLine; |
237 |
outFile.flush(); |
238 |
} |
239 |
|
240 |
// kill everyone off: |
241 |
myStatus = -1; |
242 |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
243 |
MPI_Send(&myStatus, 1, MPI_INT, j, |
244 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
245 |
} |
246 |
|
247 |
} else { |
248 |
|
249 |
done = 0; |
250 |
while (!done) { |
251 |
|
252 |
MPI_Recv(&myStatus, 1, MPI_INT, 0, |
253 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
254 |
|
255 |
if(!myStatus) anonymousNodeDie(); |
256 |
|
257 |
if(myStatus < 0) break; |
258 |
|
259 |
MPI_Recv(&which_atom, 1, MPI_INT, 0, |
260 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
261 |
|
262 |
myStatus = 1; |
263 |
local_index=-1; |
264 |
for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) { |
265 |
if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; |
266 |
} |
267 |
if (local_index != -1) { |
268 |
//format the line |
269 |
sprintf( tempBuffer, |
270 |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
271 |
atoms[local_index]->getType(), |
272 |
atoms[local_index]->getX(), |
273 |
atoms[local_index]->getY(), |
274 |
atoms[local_index]->getZ(), |
275 |
atoms[local_index]->get_vx(), |
276 |
atoms[local_index]->get_vy(), |
277 |
atoms[local_index]->get_vz()); // check here. |
278 |
strcpy( writeLine, tempBuffer ); |
279 |
|
280 |
if( atoms[local_index]->isDirectional() ){ |
281 |
|
282 |
dAtom = (DirectionalAtom *)atoms[local_index]; |
283 |
dAtom->getQ( q ); |
284 |
|
285 |
sprintf( tempBuffer, |
286 |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
287 |
q[0], |
288 |
q[1], |
289 |
q[2], |
290 |
q[3], |
291 |
dAtom->getJx(), |
292 |
dAtom->getJy(), |
293 |
dAtom->getJz()); |
294 |
strcat( writeLine, tempBuffer ); |
295 |
} |
296 |
else{ |
297 |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
298 |
} |
299 |
} |
300 |
else { |
301 |
sprintf(painCave.errMsg, |
302 |
"Atom %d not found on processor %d\n", |
303 |
which_atom, worldRank ); |
304 |
myStatus = 0; |
305 |
simError(); |
306 |
|
307 |
strcpy( writeLine, "Hello, I'm an error.\n"); |
308 |
} |
309 |
|
310 |
MPI_Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
311 |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
312 |
MPI_Send( &myStatus, 1, MPI_INT, 0, |
313 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
314 |
} |
315 |
} |
316 |
outFile.flush(); |
317 |
sprintf( checkPointMsg, |
318 |
"Sucessfully took a dump.\n"); |
319 |
MPIcheckPoint(); |
320 |
|
321 |
// last thing last, enable fatalities. |
322 |
painCave.isEventLoop = 0; |
323 |
|
324 |
#endif // is_mpi |
325 |
} |
326 |
|
327 |
void DumpWriter::writeFinal(double finalTime){ |
328 |
|
329 |
char finalName[500]; |
330 |
ofstream finalOut; |
331 |
|
332 |
const int BUFFERSIZE = 2000; |
333 |
char tempBuffer[BUFFERSIZE]; |
334 |
char writeLine[BUFFERSIZE]; |
335 |
|
336 |
double q[4]; |
337 |
DirectionalAtom* dAtom; |
338 |
int nAtoms = entry_plug->n_atoms; |
339 |
Atom** atoms = entry_plug->atoms; |
340 |
int i, j, which_node, done, game_over, which_atom, local_index; |
341 |
|
342 |
|
343 |
#ifdef IS_MPI |
344 |
if(worldRank == 0 ){ |
345 |
#endif // is_mpi |
346 |
|
347 |
strcpy( finalName, entry_plug->finalName ); |
348 |
|
349 |
finalOut.open( finalName, ios::out | ios::trunc ); |
350 |
if( !finalOut ){ |
351 |
sprintf( painCave.errMsg, |
352 |
"Could not open \"%s\" for final dump output.\n", |
353 |
finalName ); |
354 |
painCave.isFatal = 1; |
355 |
simError(); |
356 |
} |
357 |
|
358 |
// finalOut.setf( ios::scientific ); |
359 |
|
360 |
#ifdef IS_MPI |
361 |
} |
362 |
|
363 |
sprintf(checkPointMsg,"Opened file for final configuration\n"); |
364 |
MPIcheckPoint(); |
365 |
|
366 |
#endif //is_mpi |
367 |
|
368 |
|
369 |
#ifndef IS_MPI |
370 |
|
371 |
finalOut << nAtoms << "\n"; |
372 |
|
373 |
finalOut << finalTime << ";\t" |
374 |
<< entry_plug->Hmat[0][0] << "\t" |
375 |
<< entry_plug->Hmat[1][0] << "\t" |
376 |
<< entry_plug->Hmat[2][0] << ";\t" |
377 |
|
378 |
<< entry_plug->Hmat[0][1] << "\t" |
379 |
<< entry_plug->Hmat[1][1] << "\t" |
380 |
<< entry_plug->Hmat[2][1] << ";\t" |
381 |
|
382 |
<< entry_plug->Hmat[0][2] << "\t" |
383 |
<< entry_plug->Hmat[1][2] << "\t" |
384 |
<< entry_plug->Hmat[2][2] << ";\n"; |
385 |
|
386 |
for( i=0; i<nAtoms; i++ ){ |
387 |
|
388 |
sprintf( tempBuffer, |
389 |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
390 |
atoms[i]->getType(), |
391 |
atoms[i]->getX(), |
392 |
atoms[i]->getY(), |
393 |
atoms[i]->getZ(), |
394 |
atoms[i]->get_vx(), |
395 |
atoms[i]->get_vy(), |
396 |
atoms[i]->get_vz()); |
397 |
strcpy( writeLine, tempBuffer ); |
398 |
|
399 |
if( atoms[i]->isDirectional() ){ |
400 |
|
401 |
dAtom = (DirectionalAtom *)atoms[i]; |
402 |
dAtom->getQ( q ); |
403 |
|
404 |
sprintf( tempBuffer, |
405 |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
406 |
q[0], |
407 |
q[1], |
408 |
q[2], |
409 |
q[3], |
410 |
dAtom->getJx(), |
411 |
dAtom->getJy(), |
412 |
dAtom->getJz()); |
413 |
strcat( writeLine, tempBuffer ); |
414 |
} |
415 |
else |
416 |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
417 |
|
418 |
finalOut << writeLine; |
419 |
} |
420 |
finalOut.flush(); |
421 |
finalOut.close(); |
422 |
|
423 |
#else // is_mpi |
424 |
|
425 |
// first thing first, suspend fatalities. |
426 |
painCave.isEventLoop = 1; |
427 |
|
428 |
int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone |
429 |
int haveError; |
430 |
|
431 |
MPI_Status istatus; |
432 |
int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
433 |
|
434 |
// write out header and node 0's coordinates |
435 |
|
436 |
haveError = 0; |
437 |
if( worldRank == 0 ){ |
438 |
finalOut << mpiSim->getTotAtoms() << "\n"; |
439 |
|
440 |
finalOut << finalTime << ";\t" |
441 |
<< entry_plug->Hmat[0][0] << "\t" |
442 |
<< entry_plug->Hmat[1][0] << "\t" |
443 |
<< entry_plug->Hmat[2][0] << ";\t" |
444 |
|
445 |
<< entry_plug->Hmat[0][1] << "\t" |
446 |
<< entry_plug->Hmat[1][1] << "\t" |
447 |
<< entry_plug->Hmat[2][1] << ";\t" |
448 |
|
449 |
<< entry_plug->Hmat[0][2] << "\t" |
450 |
<< entry_plug->Hmat[1][2] << "\t" |
451 |
<< entry_plug->Hmat[2][2] << ";\n"; |
452 |
|
453 |
for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { |
454 |
// Get the Node number which has this molecule: |
455 |
|
456 |
which_node = AtomToProcMap[i]; |
457 |
|
458 |
if (which_node == mpiSim->getMyNode()) { |
459 |
|
460 |
which_atom = i; |
461 |
local_index=-1; |
462 |
for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) { |
463 |
if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; |
464 |
} |
465 |
if (local_index != -1) { |
466 |
sprintf( tempBuffer, |
467 |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
468 |
atoms[local_index]->getType(), |
469 |
atoms[local_index]->getX(), |
470 |
atoms[local_index]->getY(), |
471 |
atoms[local_index]->getZ(), |
472 |
atoms[local_index]->get_vx(), |
473 |
atoms[local_index]->get_vy(), |
474 |
atoms[local_index]->get_vz()); |
475 |
strcpy( writeLine, tempBuffer ); |
476 |
|
477 |
if( atoms[local_index]->isDirectional() ){ |
478 |
|
479 |
dAtom = (DirectionalAtom *)atoms[local_index]; |
480 |
dAtom->getQ( q ); |
481 |
|
482 |
sprintf( tempBuffer, |
483 |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
484 |
q[0], |
485 |
q[1], |
486 |
q[2], |
487 |
q[3], |
488 |
dAtom->getJx(), |
489 |
dAtom->getJy(), |
490 |
dAtom->getJz()); |
491 |
strcat( writeLine, tempBuffer ); |
492 |
} |
493 |
else |
494 |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
495 |
} |
496 |
else { |
497 |
sprintf(painCave.errMsg, |
498 |
"Atom %d not found on processor %d\n", |
499 |
i, worldRank ); |
500 |
haveError= 1; |
501 |
simError(); |
502 |
} |
503 |
|
504 |
if(haveError) nodeZeroError(); |
505 |
|
506 |
} |
507 |
else { |
508 |
|
509 |
myStatus = 1; |
510 |
MPI_Send(&myStatus, 1, MPI_INT, which_node, |
511 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
512 |
MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
513 |
MPI_COMM_WORLD); |
514 |
MPI_Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, |
515 |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
516 |
MPI_Recv(&myStatus, 1, MPI_INT, which_node, |
517 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
518 |
|
519 |
if(!myStatus) nodeZeroError(); |
520 |
} |
521 |
|
522 |
finalOut << writeLine; |
523 |
} |
524 |
|
525 |
// kill everyone off: |
526 |
myStatus = -1; |
527 |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
528 |
MPI_Send(&myStatus, 1, MPI_INT, j, |
529 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
530 |
} |
531 |
|
532 |
} else { |
533 |
|
534 |
done = 0; |
535 |
while (!done) { |
536 |
|
537 |
MPI_Recv(&myStatus, 1, MPI_INT, 0, |
538 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
539 |
|
540 |
if(!myStatus) anonymousNodeDie(); |
541 |
|
542 |
if(myStatus < 0) break; |
543 |
|
544 |
MPI_Recv(&which_atom, 1, MPI_INT, 0, |
545 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
546 |
|
547 |
myStatus = 1; |
548 |
local_index=-1; |
549 |
for (j=0; j < mpiSim->getMyNlocal(); j++) { |
550 |
if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; |
551 |
} |
552 |
if (local_index != -1) { |
553 |
|
554 |
//format the line |
555 |
sprintf( tempBuffer, |
556 |
"%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
557 |
atoms[local_index]->getType(), |
558 |
atoms[local_index]->getX(), |
559 |
atoms[local_index]->getY(), |
560 |
atoms[local_index]->getZ(), |
561 |
atoms[local_index]->get_vx(), |
562 |
atoms[local_index]->get_vy(), |
563 |
atoms[local_index]->get_vz()); // check here. |
564 |
strcpy( writeLine, tempBuffer ); |
565 |
|
566 |
if( atoms[local_index]->isDirectional() ){ |
567 |
|
568 |
dAtom = (DirectionalAtom *)atoms[local_index]; |
569 |
dAtom->getQ( q ); |
570 |
|
571 |
sprintf( tempBuffer, |
572 |
"%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
573 |
q[0], |
574 |
q[1], |
575 |
q[2], |
576 |
q[3], |
577 |
dAtom->getJx(), |
578 |
dAtom->getJy(), |
579 |
dAtom->getJz()); |
580 |
strcat( writeLine, tempBuffer ); |
581 |
} |
582 |
else{ |
583 |
strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
584 |
} |
585 |
} |
586 |
else { |
587 |
sprintf(painCave.errMsg, |
588 |
"Atom %d not found on processor %d\n", |
589 |
which_atom, worldRank ); |
590 |
myStatus = 0; |
591 |
simError(); |
592 |
|
593 |
strcpy( writeLine, "Hello, I'm an error.\n"); |
594 |
} |
595 |
|
596 |
MPI_Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
597 |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
598 |
MPI_Send( &myStatus, 1, MPI_INT, 0, |
599 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
600 |
} |
601 |
} |
602 |
finalOut.flush(); |
603 |
sprintf( checkPointMsg, |
604 |
"Sucessfully took a dump.\n"); |
605 |
MPIcheckPoint(); |
606 |
|
607 |
if( worldRank == 0 ) finalOut.close(); |
608 |
#endif // is_mpi |
609 |
} |
610 |
|
611 |
|
612 |
|
613 |
#ifdef IS_MPI |
614 |
|
615 |
// a couple of functions to let us escape the write loop |
616 |
|
617 |
void dWrite::nodeZeroError( void ){ |
618 |
int j, myStatus; |
619 |
|
620 |
myStatus = 0; |
621 |
for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
622 |
MPI_Send( &myStatus, 1, MPI_INT, j, |
623 |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
624 |
} |
625 |
|
626 |
|
627 |
MPI_Finalize(); |
628 |
exit (0); |
629 |
|
630 |
} |
631 |
|
632 |
void dWrite::anonymousNodeDie( void ){ |
633 |
|
634 |
MPI_Finalize(); |
635 |
exit (0); |
636 |
} |
637 |
|
638 |
#endif //is_mpi |