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 1129 by tim, Thu Apr 22 03:29:30 2004 UTC vs.
Revision 1231 by tim, Thu Jun 3 21:06:51 2004 UTC

# Line 216 | Line 216 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
216  
217    int nProc;
218    int j, which_node, done, which_atom, local_index, currentIndex;
219 <  double atomData6[6];
220 <  double atomData13[13];
219 >  double atomData[13];
220    int isDirectional;
221    char* atomTypeString;
222    char MPIatomTypeString[MINIBUFFERSIZE];
223    int nObjects;
224 +  int msgLen; // the length of message actually recieved at master nodes
225   #endif //is_mpi
226  
227    double q[4], ji[3];
# Line 294 | Line 294 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
294        }
295        else
296          strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
297 +    
298 +      for(k = 0; k < outFile.size(); k++)
299 +        *outFile[k] << writeLine;      
300      }
301  
299    
300    for(k = 0; k < outFile.size(); k++)
301      *outFile[k] << writeLine;
302   }
303  
304   #else // is_mpi
# Line 325 | Line 325 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
325  
326      // Node 0 needs a list of the magic potatoes for each processor;
327  
328 <    nProc = mpiSim->getNumberProcessors();
328 >    nProc = mpiSim->getNProcessors();
329      potatoes = new int[nProc];
330  
331      //write out the comment lines
# Line 353 | Line 353 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
353  
354      currentIndex = 0;
355  
356 <    for (i = 0 ; i < mpiSim->getTotNmol(); i++ ) {
356 >    for (i = 0 ; i < mpiSim->getNMolGlobal(); i++ ) {
357        
358        // Get the Node number which has this atom;
359        
# Line 379 | Line 379 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
379          
380          for(int l = 0; l < nCurObj; l++){
381  
382 <          if (potatoes[which_node] + 3 >= MAXTAG) {
382 >          if (potatoes[which_node] + 2 >= MAXTAG) {
383              // The potato was going to exceed the maximum value,
384              // so wrap this processor potato back to 0:        
385  
# Line 395 | Line 395 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
395  
396            myPotato++;
397  
398 <          MPI_Recv(&isDirectional, 1, MPI_INT, which_node,
399 <          myPotato, MPI_COMM_WORLD, &istatus);
400 <              
398 >          MPI_Recv(atomData, 13, MPI_DOUBLE, which_node, myPotato, MPI_COMM_WORLD, &istatus);
399            myPotato++;
400  
401 <          if (isDirectional) {          
402 <          MPI_Recv(atomData13, 13, MPI_DOUBLE, which_node,
403 <                   myPotato, MPI_COMM_WORLD, &istatus);
404 <          } else {
405 <          MPI_Recv(atomData6, 6, MPI_DOUBLE, which_node,
406 <                   myPotato, MPI_COMM_WORLD, &istatus);          
401 >          MPI_Get_count(&istatus, MPI_DOUBLE, &msgLen);
402 >
403 >          if(msgLen  == 13)
404 >            isDirectional = 1;
405 >          else
406 >            isDirectional = 0;
407 >          
408 >          // If we've survived to here, format the line:
409 >            
410 >          if (!isDirectional) {
411 >        
412 >            sprintf( writeLine,
413 >                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
414 >                 atomTypeString,
415 >                 atomData[0],
416 >                 atomData[1],
417 >                 atomData[2],
418 >                 atomData[3],
419 >                 atomData[4],
420 >                 atomData[5]);
421 >        
422 >           strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
423 >        
424 >          }
425 >          else {
426 >        
427 >                sprintf( writeLine,
428 >                         "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
429 >                         atomTypeString,
430 >                         atomData[0],
431 >                         atomData[1],
432 >                         atomData[2],
433 >                         atomData[3],
434 >                         atomData[4],
435 >                         atomData[5],
436 >                         atomData[6],
437 >                         atomData[7],
438 >                         atomData[8],
439 >                         atomData[9],
440 >                         atomData[10],
441 >                         atomData[11],
442 >                         atomData[12]);
443 >            
444            }
445 +          
446 +          for(k = 0; k < outFile.size(); k++)
447 +            *outFile[k] << writeLine;            
448  
449 <          myPotato++;
412 <        }
449 >        }// end for(int l =0)
450          potatoes[which_node] = myPotato;
451  
452 <      } else {
452 >      }
453 >      else {
454          
455          haveError = 0;
456          
# Line 427 | Line 465 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
465              sd->getPos(pos);
466              sd->getVel(vel);          
467            
468 <            atomData6[0] = pos[0];
469 <            atomData6[1] = pos[1];
470 <            atomData6[2] = pos[2];
468 >            atomData[0] = pos[0];
469 >            atomData[1] = pos[1];
470 >            atomData[2] = pos[2];
471  
472 <            atomData6[3] = vel[0];
473 <            atomData6[4] = vel[1];
474 <            atomData6[5] = vel[2];
472 >            atomData[3] = vel[0];
473 >            atomData[4] = vel[1];
474 >            atomData[5] = vel[2];
475                
476              isDirectional = 0;
477  
# Line 445 | Line 483 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
483                sd->getJ( ji );
484  
485                for (int j = 0; j < 6 ; j++)
486 <                atomData13[j] = atomData6[j];            
486 >                atomData[j] = atomData[j];            
487                
488 <              atomData13[6] = q[0];
489 <              atomData13[7] = q[1];
490 <              atomData13[8] = q[2];
491 <              atomData13[9] = q[3];
488 >              atomData[6] = q[0];
489 >              atomData[7] = q[1];
490 >              atomData[8] = q[2];
491 >              atomData[9] = q[3];
492                
493 <              atomData13[10] = ji[0];
494 <              atomData13[11] = ji[1];
495 <              atomData13[12] = ji[2];
493 >              atomData[10] = ji[0];
494 >              atomData[11] = ji[1];
495 >              atomData[12] = ji[2];
496              }
497              
498 <        }
498 >            // If we've survived to here, format the line:
499 >            
500 >            if (!isDirectional) {
501 >        
502 >              sprintf( writeLine,
503 >                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
504 >                 atomTypeString,
505 >                 atomData[0],
506 >                 atomData[1],
507 >                 atomData[2],
508 >                 atomData[3],
509 >                 atomData[4],
510 >                 atomData[5]);
511 >        
512 >             strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
513 >        
514 >            }
515 >            else {
516 >        
517 >                sprintf( writeLine,
518 >                         "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
519 >                         atomTypeString,
520 >                         atomData[0],
521 >                         atomData[1],
522 >                         atomData[2],
523 >                         atomData[3],
524 >                         atomData[4],
525 >                         atomData[5],
526 >                         atomData[6],
527 >                         atomData[7],
528 >                         atomData[8],
529 >                         atomData[9],
530 >                         atomData[10],
531 >                         atomData[11],
532 >                         atomData[12]);
533 >              
534 >            }
535 >            
536 >            for(k = 0; k < outFile.size(); k++)
537 >              *outFile[k] << writeLine;
538 >            
539 >            
540 >        }//end for(iter = integrableObject.begin())
541          
542        currentIndex++;
543        }
544 <      // If we've survived to here, format the line:
545 <      
466 <      if (!isDirectional) {
467 <        
468 <        sprintf( writeLine,
469 <                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t",
470 <                 atomTypeString,
471 <                 atomData6[0],
472 <                 atomData6[1],
473 <                 atomData6[2],
474 <                 atomData6[3],
475 <                 atomData6[4],
476 <                 atomData6[5]);
477 <        
478 <        strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" );
479 <        
480 <      } else {
481 <        
482 <        sprintf( writeLine,
483 <                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",
484 <                 atomTypeString,
485 <                 atomData13[0],
486 <                 atomData13[1],
487 <                 atomData13[2],
488 <                 atomData13[3],
489 <                 atomData13[4],
490 <                 atomData13[5],
491 <                 atomData13[6],
492 <                 atomData13[7],
493 <                 atomData13[8],
494 <                 atomData13[9],
495 <                 atomData13[10],
496 <                 atomData13[11],
497 <                 atomData13[12]);
498 <        
499 <      }
500 <      
501 <      for(k = 0; k < outFile.size(); k++)
502 <        *outFile[k] << writeLine;
503 <    }
544 >
545 >    }//end for(i = 0; i < mpiSim->getNmol())
546      
547      for(k = 0; k < outFile.size(); k++)
548        outFile[k]->flush();
# Line 521 | Line 563 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
563      myPotato = 0;
564      currentIndex = 0;
565      
566 <    for (i = 0 ; i < mpiSim->getTotNmol(); i++ ) {
566 >    for (i = 0 ; i < mpiSim->getNMolGlobal(); i++ ) {
567        
568        // Am I the node which has this integrableObject?
569        
# Line 549 | Line 591 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
591  
592            for( iter = integrableObjects.begin(); iter  != integrableObjects.end(); iter++){
593  
594 <            if (myPotato + 3 >= MAXTAG) {
594 >            if (myPotato + 2 >= MAXTAG) {
595            
596                // The potato was going to exceed the maximum value,
597                // so wrap this processor potato back to 0 (and block until
# Line 566 | Line 608 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
608              sd->getPos(pos);
609              sd->getVel(vel);
610  
611 <            atomData6[0] = pos[0];
612 <            atomData6[1] = pos[1];
613 <            atomData6[2] = pos[2];
611 >            atomData[0] = pos[0];
612 >            atomData[1] = pos[1];
613 >            atomData[2] = pos[2];
614  
615 <            atomData6[3] = vel[0];
616 <            atomData6[4] = vel[1];
617 <            atomData6[5] = vel[2];
615 >            atomData[3] = vel[0];
616 >            atomData[4] = vel[1];
617 >            atomData[5] = vel[2];
618                
619              isDirectional = 0;
620  
# Line 583 | Line 625 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
625                  sd->getQ( q );
626                  sd->getJ( ji );
627                  
586                for (int j = 0; j < 6 ; j++)
587                  atomData13[j] = atomData6[j];
628                  
629 <                atomData13[6] = q[0];
630 <                atomData13[7] = q[1];
631 <                atomData13[8] = q[2];
632 <                atomData13[9] = q[3];
629 >                atomData[6] = q[0];
630 >                atomData[7] = q[1];
631 >                atomData[8] = q[2];
632 >                atomData[9] = q[3];
633        
634 <                atomData13[10] = ji[0];
635 <                atomData13[11] = ji[1];
636 <                atomData13[12] = ji[2];
634 >                atomData[10] = ji[0];
635 >                atomData[11] = ji[1];
636 >                atomData[12] = ji[2];
637                }
638  
639              
# Line 606 | Line 646 | void DumpWriter::writeFrame( vector<ofstream*>& outFil
646                               myPotato, MPI_COMM_WORLD);
647              
648              myPotato++;
609
610            MPI_Send(&isDirectional, 1, MPI_INT, 0,
611                             myPotato, MPI_COMM_WORLD);
649              
613            myPotato++;
614            
650              if (isDirectional) {
651  
652 <              MPI_Send(atomData13, 13, MPI_DOUBLE, 0,
652 >              MPI_Send(atomData, 13, MPI_DOUBLE, 0,
653                         myPotato, MPI_COMM_WORLD);
654                
655              } else {
656  
657 <              MPI_Send(atomData6, 6, MPI_DOUBLE, 0,
657 >              MPI_Send(atomData, 6, MPI_DOUBLE, 0,
658                         myPotato, MPI_COMM_WORLD);
659              }
660  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines