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 440 by mmeineke, Tue Apr 1 16:49:17 2003 UTC vs.
Revision 572 by mmeineke, Wed Jul 2 21:26:55 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_CHAR 1
9   #define TAKE_THIS_TAG_INT 2
# Line 28 | Line 27 | DumpWriter::DumpWriter( SimInfo* the_entry_plug ){
27    if(worldRank == 0 ){
28   #endif // is_mpi
29      
31
32    
30      strcpy( outName, entry_plug->sampleName );
31      
32      outFile.open(outName, ios::out | ios::trunc );
# Line 42 | 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 73 | 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 85 | 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 134 | Line 139 | void DumpWriter::writeDump( double currentTime ){
139    int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone
140    int haveError;
141  
142 <  MPI::Status istatus;
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 206 | Line 220 | void DumpWriter::writeDump( double currentTime ){
220        }
221        else {
222          myStatus = 1;
223 <        MPI::COMM_WORLD.Send(&myStatus, 1, MPI_INT, which_node,
224 <                             TAKE_THIS_TAG_INT);
225 <        MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT);
226 <        MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node,
227 <                             TAKE_THIS_TAG_CHAR, istatus);
228 <        MPI::COMM_WORLD.Recv(&myStatus, 1, MPI_INT, which_node,
229 <                             TAKE_THIS_TAG_INT, istatus);
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  
# Line 225 | Line 240 | void DumpWriter::writeDump( double currentTime ){
240      // kill everyone off:
241      myStatus = -1;
242      for (j = 0; j < mpiSim->getNumberProcessors(); j++) {      
243 <      MPI::COMM_WORLD.Send(&myStatus, 1, MPI_INT, j,
244 <                           TAKE_THIS_TAG_INT);
243 >      MPI_Send(&myStatus, 1, MPI_INT, j,
244 >               TAKE_THIS_TAG_INT, MPI_COMM_WORLD);
245      }
246  
247    } else {
# Line 234 | Line 249 | void DumpWriter::writeDump( double currentTime ){
249      done = 0;
250      while (!done) {
251        
252 <      MPI::COMM_WORLD.Recv(&myStatus, 1, MPI_INT, 0,
253 <                           TAKE_THIS_TAG_INT, istatus);
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::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0,
260 <                           TAKE_THIS_TAG_INT, istatus);
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;        
# Line 292 | Line 307 | void DumpWriter::writeDump( double currentTime ){
307          strcpy( writeLine, "Hello, I'm an error.\n");
308        }
309  
310 <      MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,
311 <                           TAKE_THIS_TAG_CHAR);
312 <      MPI::COMM_WORLD.Send( &myStatus, 1, MPI_INT, 0,
313 <                            TAKE_THIS_TAG_INT);
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();
# Line 309 | Line 324 | void DumpWriter::writeFinal(){
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 355 | 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 404 | Line 428 | void DumpWriter::writeFinal(){
428    int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone
429    int haveError;
430  
431 <  MPI::Status istatus;
431 >  MPI_Status istatus;
432    int *AtomToProcMap = mpiSim->getAtomToProcMap();
433  
434    // write out header and node 0's coordinates
# Line 413 | Line 437 | void DumpWriter::writeFinal(){
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 474 | Line 507 | void DumpWriter::writeFinal(){
507        else {
508          
509          myStatus = 1;
510 <        MPI::COMM_WORLD.Send(&myStatus, 1, MPI_INT, which_node,
511 <                             TAKE_THIS_TAG_INT);
512 <        MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT);
513 <        MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node,
514 <                             TAKE_THIS_TAG_CHAR, istatus);
515 <        MPI::COMM_WORLD.Recv(&myStatus, 1, MPI_INT, which_node,
516 <                             TAKE_THIS_TAG_INT, istatus);
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        }
# Line 491 | Line 525 | void DumpWriter::writeFinal(){
525      // kill everyone off:
526      myStatus = -1;
527      for (j = 0; j < mpiSim->getNumberProcessors(); j++) {      
528 <      MPI::COMM_WORLD.Send(&myStatus, 1, MPI_INT, j,
529 <                           TAKE_THIS_TAG_INT);
528 >      MPI_Send(&myStatus, 1, MPI_INT, j,
529 >               TAKE_THIS_TAG_INT, MPI_COMM_WORLD);
530      }
531  
532    } else {
# Line 500 | Line 534 | void DumpWriter::writeFinal(){
534      done = 0;
535      while (!done) {
536  
537 <      MPI::COMM_WORLD.Recv(&myStatus, 1, MPI_INT, 0,
538 <                           TAKE_THIS_TAG_INT, istatus);
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::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0,
545 <                           TAKE_THIS_TAG_INT, istatus);
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;        
# Line 559 | Line 593 | void DumpWriter::writeFinal(){
593          strcpy( writeLine, "Hello, I'm an error.\n");
594        }
595  
596 <      MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,
597 <                           TAKE_THIS_TAG_CHAR);
598 <      MPI::COMM_WORLD.Send( &myStatus, 1, MPI_INT, 0,
599 <                            TAKE_THIS_TAG_INT);
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();
# Line 585 | Line 619 | void dWrite::nodeZeroError( void ){
619    
620    myStatus = 0;
621    for (j = 0; j < mpiSim->getNumberProcessors(); j++) {      
622 <    MPI::COMM_WORLD.Send( &myStatus, 1, MPI_INT, j,
623 <                          TAKE_THIS_TAG_INT);
622 >    MPI_Send( &myStatus, 1, MPI_INT, j,
623 >              TAKE_THIS_TAG_INT, MPI_COMM_WORLD);
624    }  
625    
626  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines