# | Line 4 | Line 4 | |
---|---|---|
4 | ||
5 | #ifdef IS_MPI | |
6 | #include <mpi.h> | |
7 | – | #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" | |
# | Line 21 | Line 27 | DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ | |
27 | if(worldRank == 0 ){ | |
28 | #endif // is_mpi | |
29 | ||
24 | – | |
25 | – | |
30 | strcpy( outName, entry_plug->sampleName ); | |
31 | ||
32 | outFile.open(outName, ios::out | ios::trunc ); | |
# | Line 35 | Line 39 | DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ | |
39 | painCave.isFatal = 1; | |
40 | simError(); | |
41 | } | |
42 | < | |
42 | > | |
43 | //outFile.setf( ios::scientific ); | |
44 | ||
45 | #ifdef IS_MPI | |
# | Line 66 | Line 70 | void DumpWriter::writeDump( double currentTime ){ | |
70 | char tempBuffer[BUFFERSIZE]; | |
71 | char writeLine[BUFFERSIZE]; | |
72 | ||
73 | < | int i, j, which_node, done, game_over, which_atom, local_index; |
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; | |
# | Line 78 | Line 82 | void DumpWriter::writeDump( double currentTime ){ | |
82 | outFile << nAtoms << "\n"; | |
83 | ||
84 | outFile << currentTime << "\t" | |
85 | < | << entry_plug->box_x << "\t" |
86 | < | << entry_plug->box_y << "\t" |
87 | < | << entry_plug->box_z << "\n"; |
85 | > | << entry_plug->Hmat[0] << "\t" |
86 | > | << entry_plug->Hmat[1] << "\t" |
87 | > | << entry_plug->Hmat[2] << "\t" |
88 | > | |
89 | > | << entry_plug->Hmat[3] << "\t" |
90 | > | << entry_plug->Hmat[4] << "\t" |
91 | > | << entry_plug->Hmat[5] << "\t" |
92 | > | |
93 | > | << entry_plug->Hmat[6] << "\t" |
94 | > | << entry_plug->Hmat[7] << "\t" |
95 | > | << entry_plug->Hmat[8] << "\n"; |
96 | ||
97 | for( i=0; i<nAtoms; i++ ){ | |
98 | ||
# | Line 121 | Line 133 | void DumpWriter::writeDump( double currentTime ){ | |
133 | ||
134 | #else // is_mpi | |
135 | ||
136 | < | MPI::Status istatus; |
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 | < | |
149 | > | |
150 | outFile << currentTime << "\t" | |
151 | < | << entry_plug->box_x << "\t" |
152 | < | << entry_plug->box_y << "\t" |
153 | < | << entry_plug->box_z << "\n"; |
151 | > | << entry_plug->Hmat[0] << "\t" |
152 | > | << entry_plug->Hmat[1] << "\t" |
153 | > | << entry_plug->Hmat[2] << "\t" |
154 | > | |
155 | > | << entry_plug->Hmat[3] << "\t" |
156 | > | << entry_plug->Hmat[4] << "\t" |
157 | > | << entry_plug->Hmat[5] << "\t" |
158 | > | |
159 | > | << entry_plug->Hmat[6] << "\t" |
160 | > | << entry_plug->Hmat[7] << "\t" |
161 | > | << entry_plug->Hmat[8] << "\n"; |
162 | > | ; |
163 | outFile.flush(); | |
164 | for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | |
165 | // Get the Node number which has this atom; | |
# | Line 141 | Line 168 | void DumpWriter::writeDump( double currentTime ){ | |
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++) { | |
# | Line 180 | Line 208 | void DumpWriter::writeDump( double currentTime ){ | |
208 | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); | |
209 | } | |
210 | else { | |
211 | < | strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR"); |
211 | > | sprintf(painCave.errMsg, |
212 | > | "Atom %d not found on processor %d\n", |
213 | > | i, worldRank ); |
214 | > | haveError= 1; |
215 | > | simError(); |
216 | } | |
217 | < | } |
217 | > | |
218 | > | if(haveError) nodeZeroError(); |
219 | > | |
220 | > | } |
221 | else { | |
222 | < | |
223 | < | //std::cerr << "node 0: sending node " << which_node << " request for atom " << i << "\n"; |
224 | < | MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT); |
225 | < | //std::cerr << "node 0: sent!\n"; |
226 | < | MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, |
227 | < | TAKE_THIS_TAG_CHAR, istatus); |
228 | < | //std::cerr << "node 0: got this line: " << writeLine; |
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; | |
# | Line 198 | Line 238 | void DumpWriter::writeDump( double currentTime ){ | |
238 | } | |
239 | ||
240 | // kill everyone off: | |
241 | < | game_over = -1; |
241 | > | myStatus = -1; |
242 | for (j = 0; j < mpiSim->getNumberProcessors(); j++) { | |
243 | < | MPI::COMM_WORLD.Send(&game_over, 1, MPI_INT, j, TAKE_THIS_TAG_INT); |
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 | < | //std::cerr << "node: " << mpiSim->getMyNode() << " Waiting for receive \n"; |
252 | < | MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0, |
253 | < | TAKE_THIS_TAG_INT, istatus); |
254 | < | //std::cerr << "node: " << mpiSim->getMyNode() << " got request for atom " << which_atom << "\n"; |
255 | < | if (which_atom == -1) { |
256 | < | done=1; |
257 | < | continue; |
258 | < | } else { |
259 | < | local_index=-1; |
260 | < | for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) { |
261 | < | if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; |
262 | < | } |
263 | < | if (local_index != -1) { |
264 | < | //format the line |
265 | < | sprintf( tempBuffer, |
266 | < | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
267 | < | atoms[local_index]->getType(), |
268 | < | atoms[local_index]->getX(), |
269 | < | atoms[local_index]->getY(), |
270 | < | atoms[local_index]->getZ(), |
271 | < | atoms[local_index]->get_vx(), |
272 | < | atoms[local_index]->get_vy(), |
273 | < | atoms[local_index]->get_vz()); // check here. |
274 | < | strcpy( writeLine, tempBuffer ); |
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 | < | if( atoms[local_index]->isDirectional() ){ |
283 | < | |
284 | < | dAtom = (DirectionalAtom *)atoms[local_index]; |
285 | < | dAtom->getQ( q ); |
286 | < | |
287 | < | sprintf( tempBuffer, |
288 | < | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
289 | < | q[0], |
290 | < | q[1], |
291 | < | q[2], |
292 | < | q[3], |
293 | < | dAtom->getJx(), |
294 | < | dAtom->getJy(), |
295 | < | dAtom->getJz()); |
296 | < | strcat( writeLine, tempBuffer ); |
297 | < | } |
298 | < | else |
299 | < | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
300 | < | // std::cerr << "node: " << mpiSim->getMyNode() << " sending this line" << writeLine; |
301 | < | MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
302 | < | TAKE_THIS_TAG_CHAR); |
303 | < | } else { |
304 | < | strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR"); |
305 | < | MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
306 | < | TAKE_THIS_TAG_CHAR); |
307 | < | } |
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(){ |
327 | > | void DumpWriter::writeFinal(double finalTime){ |
328 | ||
329 | char finalName[500]; | |
330 | ofstream finalOut; | |
# | Line 314 | Line 370 | void DumpWriter::writeFinal(){ | |
370 | ||
371 | finalOut << nAtoms << "\n"; | |
372 | ||
373 | < | finalOut << entry_plug->box_x << "\t" |
374 | < | << entry_plug->box_y << "\t" |
375 | < | << entry_plug->box_z << "\n"; |
373 | > | finalOut << finalTime << "\t" |
374 | > | << entry_plug->Hmat[0] << "\t" |
375 | > | << entry_plug->Hmat[1] << "\t" |
376 | > | << entry_plug->Hmat[2] << "\t" |
377 | > | |
378 | > | << entry_plug->Hmat[3] << "\t" |
379 | > | << entry_plug->Hmat[4] << "\t" |
380 | > | << entry_plug->Hmat[5] << "\t" |
381 | > | |
382 | > | << entry_plug->Hmat[6] << "\t" |
383 | > | << entry_plug->Hmat[7] << "\t" |
384 | > | << entry_plug->Hmat[8] << "\n"; |
385 | ||
386 | for( i=0; i<nAtoms; i++ ){ | |
387 | ||
# | Line 357 | Line 422 | void DumpWriter::writeFinal(){ | |
422 | ||
423 | #else // is_mpi | |
424 | ||
425 | < | MPI::Status istatus; |
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 << entry_plug->box_x << "\t" |
441 | < | << entry_plug->box_y << "\t" |
442 | < | << entry_plug->box_z << "\n"; |
440 | > | finalOut << finalTime << "\t" |
441 | > | << entry_plug->Hmat[0] << "\t" |
442 | > | << entry_plug->Hmat[1] << "\t" |
443 | > | << entry_plug->Hmat[2] << "\t" |
444 | > | |
445 | > | << entry_plug->Hmat[3] << "\t" |
446 | > | << entry_plug->Hmat[4] << "\t" |
447 | > | << entry_plug->Hmat[5] << "\t" |
448 | > | |
449 | > | << entry_plug->Hmat[6] << "\t" |
450 | > | << entry_plug->Hmat[7] << "\t" |
451 | > | << entry_plug->Hmat[8] << "\n"; |
452 | ||
453 | for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | |
454 | // Get the Node number which has this molecule: | |
# | Line 413 | Line 494 | void DumpWriter::writeFinal(){ | |
494 | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); | |
495 | } | |
496 | else { | |
497 | < | strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR"); |
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 | < | } else { |
506 | > | } |
507 | > | else { |
508 | ||
509 | < | MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT); |
510 | < | MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, |
511 | < | TAKE_THIS_TAG_CHAR, istatus); |
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 | < | game_over = -1; |
527 | < | for (j = 0; j < mpiSim->getNumberProcessors(); j++) { |
528 | < | MPI::COMM_WORLD.Send(&game_over, 1, MPI_INT, j, TAKE_THIS_TAG_INT); |
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) { | |
439 | – | MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0, |
440 | – | TAKE_THIS_TAG_INT, istatus); |
536 | ||
537 | < | if (which_atom == -1) { |
538 | < | done=1; |
539 | < | continue; |
540 | < | } else { |
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 | < | local_index=-1; |
555 | < | for (j=0; j < mpiSim->getMyNlocal(); j++) { |
556 | < | if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; |
557 | < | } |
558 | < | if (local_index != -1) { |
559 | < | |
560 | < | //format the line |
561 | < | sprintf( tempBuffer, |
562 | < | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
563 | < | atoms[local_index]->getType(), |
564 | < | atoms[local_index]->getX(), |
565 | < | atoms[local_index]->getY(), |
566 | < | atoms[local_index]->getZ(), |
460 | < | atoms[local_index]->get_vx(), |
461 | < | atoms[local_index]->get_vy(), |
462 | < | atoms[local_index]->get_vz()); // check here. |
463 | < | strcpy( writeLine, tempBuffer ); |
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 | < | if( atoms[local_index]->isDirectional() ){ |
569 | < | |
570 | < | dAtom = (DirectionalAtom *)atoms[local_index]; |
571 | < | dAtom->getQ( q ); |
572 | < | |
573 | < | sprintf( tempBuffer, |
574 | < | "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", |
575 | < | q[0], |
576 | < | q[1], |
577 | < | q[2], |
578 | < | q[3], |
579 | < | dAtom->getJx(), |
580 | < | dAtom->getJy(), |
581 | < | dAtom->getJz()); |
582 | < | strcat( writeLine, tempBuffer ); |
583 | < | } |
584 | < | else |
585 | < | strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); |
586 | < | |
587 | < | MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
588 | < | TAKE_THIS_TAG_CHAR); |
589 | < | } else { |
590 | < | strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR"); |
591 | < | MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0, |
592 | < | TAKE_THIS_TAG_CHAR); |
593 | < | } |
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 | < | |
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 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |