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 378 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
Revision 436 by chuckv, Fri Mar 28 21:45:03 2003 UTC

# Line 4 | Line 4
4  
5   #ifdef IS_MPI
6   #include <mpi.h>
7 + #include <mpi++.h>
8   #include "mpiSimulation.hpp"
9 < #define TAKE_THIS_TAG 0
9 > #define TAKE_THIS_TAG_CHAR 1
10 > #define TAKE_THIS_TAG_INT 2
11   #endif //is_mpi
12  
13   #include "ReadWrite.hpp"
14   #include "simError.h"
15  
14
15
16
17
16   DumpWriter::DumpWriter( SimInfo* the_entry_plug ){
17  
18    entry_plug = the_entry_plug;
# Line 68 | Line 66 | void DumpWriter::writeDump( double currentTime ){
66    char tempBuffer[BUFFERSIZE];
67    char writeLine[BUFFERSIZE];
68  
69 <  int i;
69 >  int i, j, which_node, done, game_over, which_atom, local_index;
70    double q[4];
71    DirectionalAtom* dAtom;
72    int nAtoms = entry_plug->n_atoms;
# Line 123 | Line 121 | void DumpWriter::writeDump( double currentTime ){
121  
122   #else // is_mpi
123  
124 <  int masterIndex;
125 <  int nodeAtomsStart;
126 <  int nodeAtomsEnd;
129 <  int mpiErr;
130 <  int sendError;
131 <  int procIndex;
132 <    
133 <  MPI_Status istatus[MPI_STATUS_SIZE];
134 <
135 <    
124 >  MPI::Status istatus;
125 >  int *AtomToProcMap = mpiSim->getAtomToProcMap();
126 >  
127    // write out header and node 0's coordinates
128 <
128 >  
129    if( worldRank == 0 ){
130      outFile << mpiSim->getTotAtoms() << "\n";
131 <      
131 >    
132      outFile << currentTime << "\t"
133              << entry_plug->box_x << "\t"
134              << entry_plug->box_y << "\t"
135              << entry_plug->box_z << "\n";
136 <
137 <    masterIndex = 0;
138 <    for( i=0; i<nAtoms; i++ ){
136 >    outFile.flush();
137 >    for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) {
138 >      // Get the Node number which has this atom;
139        
140 <      sprintf( tempBuffer,
141 <               "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
142 <               atoms[i]->getType(),
152 <               atoms[i]->getX(),
153 <               atoms[i]->getY(),
154 <               atoms[i]->getZ(),
155 <               atoms[i]->get_vx(),
156 <               atoms[i]->get_vy(),
157 <               atoms[i]->get_vz());
158 <      strcpy( writeLine, tempBuffer );
140 >      which_node = AtomToProcMap[i];    
141 >      
142 >      if (which_node == 0 ) {
143          
144 <      if( atoms[i]->isDirectional() ){
144 >        which_atom = i;
145 >        local_index=-1;        
146 >        for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) {
147 >          if (atoms[j]->getGlobalIndex() == which_atom) local_index = j;
148 >        }
149 >        if (local_index != -1) {
150 >          //format the line
151 >          sprintf( tempBuffer,
152 >                   "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
153 >                   atoms[local_index]->getType(),
154 >                   atoms[local_index]->getX(),
155 >                   atoms[local_index]->getY(),
156 >                   atoms[local_index]->getZ(),
157 >                   atoms[local_index]->get_vx(),
158 >                   atoms[local_index]->get_vy(),
159 >                   atoms[local_index]->get_vz()); // check here.
160 >          strcpy( writeLine, tempBuffer );
161            
162 <        dAtom = (DirectionalAtom *)atoms[i];
163 <        dAtom->getQ( q );
164 <          
165 <        sprintf( tempBuffer,
166 <                 "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
167 <                 q[0],
168 <                 q[1],
169 <                 q[2],
170 <                 q[3],
171 <                 dAtom->getJx(),
172 <                 dAtom->getJy(),
173 <                 dAtom->getJz());
174 <        strcat( writeLine, tempBuffer );
162 >          if( atoms[local_index]->isDirectional() ){
163 >            
164 >            dAtom = (DirectionalAtom *)atoms[local_index];
165 >            dAtom->getQ( q );
166 >            
167 >            sprintf( tempBuffer,
168 >                     "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
169 >                     q[0],
170 >                     q[1],
171 >                     q[2],
172 >                     q[3],
173 >                     dAtom->getJx(),
174 >                     dAtom->getJy(),
175 >                     dAtom->getJz());
176 >            strcat( writeLine, tempBuffer );
177 >            
178 >          }
179 >          else
180 >            strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );      
181 >        }
182 >        else {
183 >          strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR");
184 >        }
185 >      }
186 >      else {
187 >        
188 >        //std::cerr << "node 0: sending node " << which_node << " request for atom " << i << "\n";
189 >        MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT);
190 >        //std::cerr << "node 0: sent!\n";
191 >        MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node,
192 >                             TAKE_THIS_TAG_CHAR, istatus);
193 >        //std::cerr << "node 0: got this line: " << writeLine;
194        }
195 <      else
177 <        strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
178 <        
195 >      
196        outFile << writeLine;
197 <      masterIndex++;
197 >      outFile.flush();
198      }
182    outFile.flush();
183  }
184
185  sprintf( checkPointMsg,
186           "Sucessfully wrote node 0's dump configuration.\n");
187  MPIcheckPoint();
199      
200 <  for (procIndex = 1; procIndex < mpiSim->getNumberProcessors();
201 <       procIndex++){
202 <
203 <    if( worldRank == 0 ){
193 <      
194 <      mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex,
195 <                        TAKE_THIS_TAG,MPI_COMM_WORLD,istatus);
196 <      
197 <      mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex,
198 <                        TAKE_THIS_TAG,MPI_COMM_WORLD, istatus);
199 <      
200 <      // Make sure where node 0 is writing to, matches where the
201 <      // receiving node expects it to be.
202 <      
203 <      if (masterIndex != nodeAtomsStart){
204 <        sendError = 1;
205 <        mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,
206 <                          MPI_COMM_WORLD);
207 <        sprintf(painCave.errMsg,
208 <                "DumpWriter error: atoms start index (%d) for "
209 <                "node %d not equal to master index (%d)",
210 <                nodeAtomsStart,procIndex,masterIndex );
211 <        painCave.isFatal = 1;
212 <        simError();
213 <      }
214 <      
215 <      sendError = 0;
216 <      mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,
217 <                        MPI_COMM_WORLD);
218 <      
219 <      // recieve the nodes writeLines
220 <      
221 <      for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){
222 <        
223 <        mpiErr = MPI_Recv(writeLine,BUFFERSIZE,MPI_CHAR,procIndex,
224 <                          TAKE_THIS_TAG,MPI_COMM_WORLD,istatus );
225 <        
226 <        outFile << writeLine;
227 <        masterIndex++;
228 <      }
200 >    // kill everyone off:
201 >    game_over = -1;
202 >    for (j = 0; j < mpiSim->getNumberProcessors(); j++) {      
203 >      MPI::COMM_WORLD.Send(&game_over, 1, MPI_INT, j, TAKE_THIS_TAG_INT);
204      }
205  
206 <    else if( worldRank == procIndex ){
207 <
208 <      nodeAtomsStart = mpiSim->getMyAtomStart();
209 <      nodeAtomsEnd = mpiSim->getMyAtomEnd();
210 <
211 <      mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,TAKE_THIS_TAG,
212 <                        MPI_COMM_WORLD);
213 <      mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,TAKE_THIS_TAG,
214 <                        MPI_COMM_WORLD);
215 <        
216 <      sendError = -1;
217 <      mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,TAKE_THIS_TAG,
218 <                        MPI_COMM_WORLD, istatus);
219 <
220 <      if (sendError) MPIcheckPoint();
221 <
222 <      // send current node's configuration line by line.
223 <
224 <      for( i=0; i<nAtoms; i++ ){
225 <
226 <        sprintf( tempBuffer,
227 <                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
228 <                 atoms[i]->getType(),
229 <                 atoms[i]->getX(),
230 <                 atoms[i]->getY(),
231 <                 atoms[i]->getZ(),
232 <                 atoms[i]->get_vx(),
233 <                 atoms[i]->get_vy(),
259 <                 atoms[i]->get_vz()); // check here.
260 <        strcpy( writeLine, tempBuffer );
206 >  } else {
207 >    
208 >    done = 0;
209 >    while (!done) {
210 >      //std::cerr << "node: " << mpiSim->getMyNode() << " Waiting for receive \n";
211 >      MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0,
212 >                           TAKE_THIS_TAG_INT, istatus);
213 >      //std::cerr << "node: " << mpiSim->getMyNode() << " got request for atom " << which_atom << "\n";
214 >      if (which_atom == -1) {
215 >        done=1;
216 >        continue;
217 >      } else {
218 >        local_index=-1;        
219 >        for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) {
220 >          if (atoms[j]->getGlobalIndex() == which_atom) local_index = j;
221 >        }
222 >        if (local_index != -1) {
223 >          //format the line
224 >          sprintf( tempBuffer,
225 >                   "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
226 >                   atoms[local_index]->getType(),
227 >                   atoms[local_index]->getX(),
228 >                   atoms[local_index]->getY(),
229 >                   atoms[local_index]->getZ(),
230 >                   atoms[local_index]->get_vx(),
231 >                   atoms[local_index]->get_vy(),
232 >                   atoms[local_index]->get_vz()); // check here.
233 >          strcpy( writeLine, tempBuffer );
234            
235 <        if( atoms[i]->isDirectional() ){
236 <            
237 <          dAtom = (DirectionalAtom *)atoms[i];
238 <          dAtom->getQ( q );
239 <            
240 <          sprintf( tempBuffer,
241 <                   "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
242 <                   q[0],
243 <                   q[1],
244 <                   q[2],
245 <                   q[3],
246 <                   dAtom->getJx(),
247 <                   dAtom->getJy(),
248 <                   dAtom->getJz());
249 <          strcat( writeLine, tempBuffer );
250 <        }
251 <        else
252 <          strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
253 <          
254 <        mpiErr = MPI_Send(writeLine,BUFFERSIZE,MPI_CHAR,0,TAKE_THIS_TAG,
255 <                          MPI_COMM_WORLD);
235 >          if( atoms[local_index]->isDirectional() ){
236 >            
237 >            dAtom = (DirectionalAtom *)atoms[local_index];
238 >            dAtom->getQ( q );
239 >            
240 >            sprintf( tempBuffer,
241 >                     "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
242 >                     q[0],
243 >                     q[1],
244 >                     q[2],
245 >                     q[3],
246 >                     dAtom->getJx(),
247 >                     dAtom->getJy(),
248 >                     dAtom->getJz());
249 >            strcat( writeLine, tempBuffer );
250 >          }
251 >          else
252 >            strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
253 >          // std::cerr << "node: " << mpiSim->getMyNode() << " sending this line" << writeLine;
254 >          MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,
255 >                               TAKE_THIS_TAG_CHAR);
256 >        } else {
257 >          strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR");
258 >          MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,
259 >                               TAKE_THIS_TAG_CHAR);
260 >        }
261        }
262      }
263 <      
264 <    sprintf(checkPointMsg,"Node %d sent dump configuration.",
265 <            procIndex);
266 <    MPIcheckPoint();
267 <  }
290 <    
263 >  }  
264 >  outFile.flush();
265 >  sprintf( checkPointMsg,
266 >           "Sucessfully took a dump.\n");
267 >  MPIcheckPoint();
268   #endif // is_mpi
269   }
270  
294
295
271   void DumpWriter::writeFinal(){
272  
273 +  char finalName[500];
274 +  ofstream finalOut;
275  
276    const int BUFFERSIZE = 2000;
277 <  char tempBuffer[500];
278 <  char writeLine[BUFFERSIZE];
302 <  
303 <  char finalName[500];
277 >  char tempBuffer[BUFFERSIZE];
278 >  char writeLine[BUFFERSIZE];  
279  
305  int i;
280    double q[4];
281    DirectionalAtom* dAtom;
282    int nAtoms = entry_plug->n_atoms;
283    Atom** atoms = entry_plug->atoms;
284 +  int i, j, which_node, done, game_over, which_atom, local_index;
285    
311  ofstream finalOut;
286    
287   #ifdef IS_MPI
288    if(worldRank == 0 ){
# Line 335 | Line 309 | void DumpWriter::writeFinal(){
309    
310   #endif //is_mpi
311  
312 <    
339 <
312 >  
313   #ifndef IS_MPI
314      
315    finalOut << nAtoms << "\n";
# Line 344 | Line 317 | void DumpWriter::writeFinal(){
317    finalOut << entry_plug->box_x << "\t"
318             << entry_plug->box_y << "\t"
319             << entry_plug->box_z << "\n";
320 <    
320 >  
321    for( i=0; i<nAtoms; i++ ){
322        
323      sprintf( tempBuffer,
# Line 380 | Line 353 | void DumpWriter::writeFinal(){
353      finalOut << writeLine;
354    }
355    finalOut.flush();
356 +  finalOut.close();
357  
358   #else // is_mpi
359 +  
360 +  MPI::Status istatus;
361 +  int *AtomToProcMap = mpiSim->getAtomToProcMap();
362  
386  int masterIndex;
387  int nodeAtomsStart;
388  int nodeAtomsEnd;
389  int mpiErr;
390  int sendError;
391  int procIndex;
392    
393  MPI_Status istatus[MPI_STATUS_SIZE];
394
395    
363    // write out header and node 0's coordinates
364 <
364 >  
365    if( worldRank == 0 ){
366      finalOut << mpiSim->getTotAtoms() << "\n";
367 <      
367 >    
368      finalOut << entry_plug->box_x << "\t"
369 <             << entry_plug->box_y << "\t"
370 <             << entry_plug->box_z << "\n";
369 >            << entry_plug->box_y << "\t"
370 >            << entry_plug->box_z << "\n";
371      
372 <    masterIndex = 0;
373 <    
407 <    for( i=0; i<nAtoms; i++ ){
372 >    for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) {
373 >      // Get the Node number which has this molecule:
374        
375 <      sprintf( tempBuffer,
376 <               "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
377 <               atoms[i]->getType(),
378 <               atoms[i]->getX(),
379 <               atoms[i]->getY(),
380 <               atoms[i]->getZ(),
381 <               atoms[i]->get_vx(),
382 <               atoms[i]->get_vy(),
383 <               atoms[i]->get_vz());
384 <      strcpy( writeLine, tempBuffer );
375 >      which_node = AtomToProcMap[i];    
376 >      
377 >      if (which_node == mpiSim->getMyNode()) {
378 >        
379 >        sprintf( tempBuffer,
380 >                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
381 >                 atoms[i]->getType(),
382 >                 atoms[i]->getX(),
383 >                 atoms[i]->getY(),
384 >                 atoms[i]->getZ(),
385 >                 atoms[i]->get_vx(),
386 >                 atoms[i]->get_vy(),
387 >                 atoms[i]->get_vz());
388 >        strcpy( writeLine, tempBuffer );
389          
390 <      if( atoms[i]->isDirectional() ){
390 >        if( atoms[i]->isDirectional() ){
391            
392 <        dAtom = (DirectionalAtom *)atoms[i];
393 <        dAtom->getQ( q );
392 >          dAtom = (DirectionalAtom *)atoms[i];
393 >          dAtom->getQ( q );
394            
395 <        sprintf( tempBuffer,
396 <                 "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
397 <                 q[0],
398 <                 q[1],
399 <                 q[2],
400 <                 q[3],
401 <                 dAtom->getJx(),
402 <                 dAtom->getJy(),
403 <                 dAtom->getJz());
404 <        strcat( writeLine, tempBuffer );
395 >          sprintf( tempBuffer,
396 >                   "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
397 >                   q[0],
398 >                   q[1],
399 >                   q[2],
400 >                   q[3],
401 >                   dAtom->getJx(),
402 >                   dAtom->getJy(),
403 >                   dAtom->getJz());
404 >          strcat( writeLine, tempBuffer );
405 >        }
406 >        else
407 >          strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );      
408 >        
409 >      } else {
410 >        
411 >        MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT);
412 >        MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node,
413 >                                TAKE_THIS_TAG_CHAR, istatus);
414        }
415 <      else
437 <        strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
438 <        
415 >      
416        finalOut << writeLine;
440      masterIndex++;
417      }
442    finalOut.flush();
443  }
418      
419 <  for (procIndex = 1; procIndex < mpiSim->getNumberProcessors();
420 <       procIndex++){
421 <
422 <    if( worldRank == 0 ){
449 <        
450 <      mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex,
451 <                        TAKE_THIS_TAG,MPI_COMM_WORLD,istatus);
452 <
453 <      mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex,
454 <                        TAKE_THIS_TAG,MPI_COMM_WORLD, istatus);
455 <        
456 <      // Make sure where node 0 is writing to, matches where the
457 <      // receiving node expects it to be.
458 <        
459 <      if (masterIndex != nodeAtomsStart){
460 <        sendError = 1;
461 <        mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,
462 <                          MPI_COMM_WORLD);
463 <        sprintf(painCave.errMsg,
464 <                "DumpWriter error: atoms start index (%d) for "
465 <                "node %d not equal to master index (%d)",
466 <                nodeAtomsStart,procIndex,masterIndex );
467 <        painCave.isFatal = 1;
468 <        simError();
469 <      }
470 <        
471 <      sendError = 0;
472 <      mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,
473 <                        MPI_COMM_WORLD);
474 <
475 <      // recieve the nodes writeLines
476 <
477 <      for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){
478 <          
479 <        mpiErr = MPI_Recv(writeLine,BUFFERSIZE,MPI_CHAR,procIndex,
480 <                          TAKE_THIS_TAG,MPI_COMM_WORLD,istatus );
481 <
482 <        finalOut << writeLine;
483 <        masterIndex++;
484 <      }
485 <
486 <      finalOut.flush();
419 >    // kill everyone off:
420 >    game_over = -1;
421 >    for (j = 0; j < mpiSim->getNumberProcessors(); j++) {
422 >      MPI::COMM_WORLD.Send(&game_over, 1, MPI_INT, j, TAKE_THIS_TAG_INT);
423      }
424  
425 <    else if( worldRank == procIndex ){
425 >  } else {
426 >    
427 >    done = 0;
428 >    while (!done) {
429 >      MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0,
430 >                           TAKE_THIS_TAG_INT, istatus);
431  
432 <      nodeAtomsStart = mpiSim->getMyAtomStart();
433 <      nodeAtomsEnd = mpiSim->getMyAtomEnd();
434 <        
435 <      mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,TAKE_THIS_TAG,
495 <                        MPI_COMM_WORLD);
496 <      mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,TAKE_THIS_TAG,
497 <                        MPI_COMM_WORLD);
498 <        
499 <      mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,TAKE_THIS_TAG,
500 <                        MPI_COMM_WORLD, istatus);
501 <      if (sendError) MPIcheckPoint();
432 >      if (which_atom == -1) {
433 >        done=1;
434 >        continue;
435 >      } else {
436  
437 <      // send current node's configuration line by line.
437 >        local_index=-1;        
438 >        for (j=0; j < mpiSim->getMyNlocal(); j++) {
439 >          if (atoms[j]->getGlobalIndex() == which_atom) local_index = j;
440 >        }
441 >        if (local_index != -1) {
442  
443 <      for( i=0; i<nAtoms; i++ ){
443 >          //format the line
444 >          sprintf( tempBuffer,
445 >                   "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
446 >                   atoms[local_index]->getType(),
447 >                   atoms[local_index]->getX(),
448 >                   atoms[local_index]->getY(),
449 >                   atoms[local_index]->getZ(),
450 >                   atoms[local_index]->get_vx(),
451 >                   atoms[local_index]->get_vy(),
452 >                   atoms[local_index]->get_vz()); // check here.
453 >          strcpy( writeLine, tempBuffer );
454            
455 <        sprintf( tempBuffer,
456 <                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
457 <                 atoms[i]->getType(),
458 <                 atoms[i]->getX(),
511 <                 atoms[i]->getY(),
512 <                 atoms[i]->getZ(),
513 <                 atoms[i]->get_vx(),
514 <                 atoms[i]->get_vy(),
515 <                 atoms[i]->get_vz());
516 <        strcpy( writeLine, tempBuffer );
517 <          
518 <        if( atoms[i]->isDirectional() ){
455 >          if( atoms[local_index]->isDirectional() ){
456 >            
457 >            dAtom = (DirectionalAtom *)atoms[local_index];
458 >            dAtom->getQ( q );
459              
460 <          dAtom = (DirectionalAtom *)atoms[i];
461 <          dAtom->getQ( q );
462 <            
463 <          sprintf( tempBuffer,
464 <                   "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
465 <                   q[0],
466 <                   q[1],
467 <                   q[2],
468 <                   q[3],
469 <                   dAtom->getJx(),
470 <                   dAtom->getJy(),
471 <                   dAtom->getJz());
472 <          strcat( writeLine, tempBuffer );
473 <        }
474 <        else
475 <          strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
476 <          
477 <        mpiErr = MPI_Send(writeLine,BUFFERSIZE,MPI_CHAR,0,TAKE_THIS_TAG,
478 <                          MPI_COMM_WORLD);
460 >            sprintf( tempBuffer,
461 >                     "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
462 >                     q[0],
463 >                     q[1],
464 >                     q[2],
465 >                     q[3],
466 >                     dAtom->getJx(),
467 >                     dAtom->getJy(),
468 >                     dAtom->getJz());
469 >            strcat( writeLine, tempBuffer );
470 >          }
471 >          else
472 >            strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
473 >          
474 >          MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,
475 >                               TAKE_THIS_TAG_CHAR);
476 >        } else {
477 >          strcpy( writeLine, "ATOM NOT FOUND ON THIS PROCESSOR");
478 >          MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,
479 >                               TAKE_THIS_TAG_CHAR);
480 >        }
481        }
482      }
541      
542    sprintf(checkPointMsg,"Node %d sent dump configuration.",
543            procIndex);
544    MPIcheckPoint();
483    }
484 +  finalOut.flush();
485 +  sprintf( checkPointMsg,
486 +           "Sucessfully took a dump.\n");
487 +  MPIcheckPoint();
488  
489 <  if( worldRank == 0 ) finalOut.close();
548 <
549 <    
489 >  if( worldRank == 0 ) finalOut.close();    
490   #endif // is_mpi
491   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines