ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/DumpWriter.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/DumpWriter.cpp (file contents):
Revision 417 by gezelter, Thu Mar 27 01:49:45 2003 UTC vs.
Revision 590 by mmeineke, Thu Jul 10 22:15:53 2003 UTC

# 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 0
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 20 | Line 27 | DumpWriter::DumpWriter( SimInfo* the_entry_plug ){
27    if(worldRank == 0 ){
28   #endif // is_mpi
29      
23
24    
30      strcpy( outName, entry_plug->sampleName );
31      
32      outFile.open(outName, ios::out | ios::trunc );
# Line 34 | 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 65 | 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;
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 76 | Line 81 | void DumpWriter::writeDump( double currentTime ){
81      
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";
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        
# Line 120 | 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";
154 <    
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;
166        
167        which_node = AtomToProcMap[i];    
168        
169 <      if (which_node == mpiSim->getMyNode()) {
142 <        
143 <        sprintf( tempBuffer,
144 <                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
145 <                 atoms[i]->getType(),
146 <                 atoms[i]->getX(),
147 <                 atoms[i]->getY(),
148 <                 atoms[i]->getZ(),
149 <                 atoms[i]->get_vx(),
150 <                 atoms[i]->get_vy(),
151 <                 atoms[i]->get_vz());
152 <        strcpy( writeLine, tempBuffer );
169 >      if (which_node == 0 ) {
170          
171 <        if( atoms[i]->isDirectional() ){
172 <          
173 <          dAtom = (DirectionalAtom *)atoms[i];
174 <          dAtom->getQ( q );
175 <          
159 <          sprintf( tempBuffer,
160 <                   "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
161 <                   q[0],
162 <                   q[1],
163 <                   q[2],
164 <                   q[3],
165 <                   dAtom->getJx(),
166 <                   dAtom->getJy(),
167 <                   dAtom->getJz());
168 <          strcat( writeLine, tempBuffer );
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 <        else
178 <          strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );      
179 <        
180 <      } else {
181 <        
182 <        MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG);
183 <        MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node,
184 <                                TAKE_THIS_TAG, istatus);
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 <    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);
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 <      MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0,
252 <                              TAKE_THIS_TAG, istatus);
251 >      
252 >      MPI_Recv(&myStatus, 1, MPI_INT, 0,
253 >               TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus);
254  
255 <      if (which_atom == -1) {
256 <        done=1;
257 <        continue;
199 <      } else {
255 >      if(!myStatus) anonymousNodeDie();
256 >      
257 >      if(myStatus < 0) break;
258  
259 <        //format the line
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[which_atom]->getType(),
272 <                 atoms[which_atom]->getX(),
273 <                 atoms[which_atom]->getY(),
274 <                 atoms[which_atom]->getZ(),
275 <                 atoms[which_atom]->get_vx(),
276 <                 atoms[which_atom]->get_vy(),
277 <                 atoms[which_atom]->get_vz()); // check here.
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[which_atom]->isDirectional() ){
214 <            
215 <          dAtom = (DirectionalAtom *)atoms[which_atom];
282 >          dAtom = (DirectionalAtom *)atoms[local_index];
283            dAtom->getQ( q );
284 <            
284 >          
285            sprintf( tempBuffer,
286                     "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
287                     q[0],
# Line 226 | Line 293 | void DumpWriter::writeDump( double currentTime ){
293                     dAtom->getJz());
294            strcat( writeLine, tempBuffer );
295          }
296 <        else
296 >        else{
297            strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
298 <        
299 <        MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,
300 <                             TAKE_THIS_TAG);
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 254 | Line 337 | void DumpWriter::writeFinal(){
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;
340 >  int i, j, which_node, done, game_over, which_atom, local_index;
341    
342    
343   #ifdef IS_MPI
# Line 287 | 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][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        
# Line 330 | 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 348 | Line 456 | void DumpWriter::writeFinal(){
456        which_node = AtomToProcMap[i];    
457        
458        if (which_node == mpiSim->getMyNode()) {
459 <        
460 <        sprintf( tempBuffer,
461 <                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
462 <                 atoms[i]->getType(),
463 <                 atoms[i]->getX(),
356 <                 atoms[i]->getY(),
357 <                 atoms[i]->getZ(),
358 <                 atoms[i]->get_vx(),
359 <                 atoms[i]->get_vy(),
360 <                 atoms[i]->get_vz());
361 <        strcpy( writeLine, tempBuffer );
362 <        
363 <        if( atoms[i]->isDirectional() ){
364 <          
365 <          dAtom = (DirectionalAtom *)atoms[i];
366 <          dAtom->getQ( q );
367 <          
368 <          sprintf( tempBuffer,
369 <                   "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
370 <                   q[0],
371 <                   q[1],
372 <                   q[2],
373 <                   q[3],
374 <                   dAtom->getJx(),
375 <                   dAtom->getJy(),
376 <                   dAtom->getJz());
377 <          strcat( writeLine, tempBuffer );
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 <        else
466 <          strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );      
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 <      } else {
510 <        
511 <        MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG);
512 <        MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node,
513 <                                TAKE_THIS_TAG, 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);
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) {
402      MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0,
403                           TAKE_THIS_TAG, 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 <        //format the line
554 >        //format the line
555          sprintf( tempBuffer,
556                   "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
557 <                 atoms[which_atom]->getType(),
558 <                 atoms[which_atom]->getX(),
559 <                 atoms[which_atom]->getY(),
560 <                 atoms[which_atom]->getZ(),
561 <                 atoms[which_atom]->get_vx(),
562 <                 atoms[which_atom]->get_vy(),
563 <                 atoms[which_atom]->get_vz()); // check here.
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[which_atom]->isDirectional() ){
423 <            
424 <          dAtom = (DirectionalAtom *)atoms[which_atom];
568 >          dAtom = (DirectionalAtom *)atoms[local_index];
569            dAtom->getQ( q );
570 <            
570 >          
571            sprintf( tempBuffer,
572                     "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
573                     q[0],
# Line 435 | Line 579 | void DumpWriter::writeFinal(){
579                     dAtom->getJz());
580            strcat( writeLine, tempBuffer );
581          }
582 <        else
582 >        else{
583            strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
584 <        
585 <        MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,
586 <                             TAKE_THIS_TAG);
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 <  }  
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines