ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/io/RestraintReader.cpp
(Generate patch)

Comparing trunk/OOPSE-3.0/src/io/RestraintReader.cpp (file contents):
Revision 1772 by chrisfen, Tue Nov 23 22:48:31 2004 UTC vs.
Revision 1778 by chrisfen, Wed Nov 24 18:06:34 2004 UTC

# Line 493 | Line 493 | void RestraintReader::readZangle( const char *in_name
493  
494    int i;
495    unsigned int j;
496 +  int isPresent;
497  
498   #ifdef IS_MPI
499    int done, which_node, which_atom; // loop counter
500 <
501 <  int *potatoes;
501 <  int myPotato;
502 <
503 <  int nProc;
500 >  int nProc;
501 >  MPI_Status istatus;
502   #endif //is_mpi
503  
504    const int BUFFERSIZE = 2000; // size of the read buffer
# Line 517 | Line 515 | void RestraintReader::readZangle( const char *in_name
515   #ifdef IS_MPI
516    if (worldRank == 0) {
517   #endif
518 <
519 <  inAngFile = fopen(in_name, "r");
520 <  if(!inAngFile){
521 <    sprintf(painCave.errMsg,
522 <            "Restraints Warning: %s file is not present\n"
523 <            "\tAll omega values will be initialized to zero. If the\n"
524 <            "\tsimulation is starting from the idealCrystal.in reference\n"
525 <            "\tconfiguration, this is the desired action. If this is not\n"
526 <            "\tthe case, the energy calculations will be incorrect.\n",
527 <            in_name);
528 <    painCave.severity = OOPSE_WARNING;
529 <    painCave.isFatal = 0;
530 <    simError();  
531 <    return;
532 <  }
518 >    isPresent = 1;
519 >    inAngFile = fopen(in_name, "r");
520 >    if(!inAngFile){
521 >      sprintf(painCave.errMsg,
522 >              "Restraints Warning: %s file is not present\n"
523 >              "\tAll omega values will be initialized to zero. If the\n"
524 >              "\tsimulation is starting from the idealCrystal.in reference\n"
525 >              "\tconfiguration, this is the desired action. If this is not\n"
526 >              "\tthe case, the energy calculations will be incorrect.\n",
527 >              in_name);
528 >      painCave.severity = OOPSE_WARNING;
529 >      painCave.isFatal = 0;
530 >      simError();  
531 >      isPresent = 0;
532 >    }
533  
536  inAngFileName = in_name;
534   #ifdef IS_MPI
535 +    // let the other nodes know the status of the file search
536 +    MPI_Bcast(&isPresent, 1, MPI_INT, 0, MPI_COMM_WORLD);
537 + #endif // is_mpi
538 +
539 +    if (!isPresent)
540 +      return;
541 +    
542 +    inAngFileName = in_name;
543 + #ifdef IS_MPI
544    }
545 +
546 +  // listen to node 0 to see if we should exit this function
547 +  if (worldRank != 0) {
548 +    MPI_Bcast(&isPresent, 1, MPI_INT, 0, MPI_COMM_WORLD);
549 +    if (!isPresent)
550 +      return;
551 +  }
552 +  
553    strcpy( checkPointMsg, "zAngle file opened successfully for reading." );
554    MPIcheckPoint();
555   #endif
# Line 586 | Line 600 | void RestraintReader::readZangle( const char *in_name
600    int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone
601    int haveError, index;
602  
589  MPI_Status istatus;
603    int *MolToProcMap = mpiSim->getMolToProcMap();
604    int localIndex;
605    int nCurObj;
# Line 650 | Line 663 | void RestraintReader::readZangle( const char *in_name
663            index++;
664          }      
665          
666 <        // restraints is limited to a single zAngle per molecule
667 <        vecParticles = (simnfo->molecules[localIndex]).getIntegrableObjects();
668 <        for(j=0; j < vecParticles.size(); j++)
669 <          vecParticles[j]->setZangle(tempZangs[i]);
666 > //      // restraints is limited to a single zAngle per molecule
667 > //      vecParticles = (simnfo->molecules[localIndex]).getIntegrableObjects();
668 > //      for(j=0; j < vecParticles.size(); j++)
669 > //        vecParticles[j]->setZangle(tempZangs[i]);
670          
671        } else {
672          // I am MASTER OF THE UNIVERSE, but I don't own this molecule
# Line 700 | Line 713 | void RestraintReader :: zeroZangle(){
713  
714    int i;
715    unsigned int j;
716 +  int nTotObjs; // the number of atoms
717  
718    vector<StuntDouble*> vecParticles;
719  
# Line 718 | Line 732 | void RestraintReader :: zeroZangle(){
732    painCave.isEventLoop = 1;
733  
734    int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone
735 <  int haveError;
735 >  int haveError, index;
736 >  int which_node;
737  
738    MPI_Status istatus;
739    int *MolToProcMap = mpiSim->getMolToProcMap();
740    int localIndex;
741 <  int which_node;
741 >  int nCurObj;
742 >  double angleTranfer;
743  
744 +  nTotObjs = simnfo->getTotIntegrableObjects();
745    haveError = 0;
746  
747    for (i=0 ; i < mpiSim->getNMolGlobal(); i++) {
748 +    // Get the Node number which has this atom
749      which_node = MolToProcMap[i];
750      
751 <    if(which_node == worldRank){
752 <      //molecule with global index i belongs to this processor
753 <      
754 <      localIndex = mpiSim->getGlobalToLocalMol(i);
755 <      
756 <      if(localIndex == -1) {
757 <        sprintf(painCave.errMsg, "Molecule not found on node %d\n", worldRank);
758 <        haveError = 1;
759 <        simError();
751 >    // let's let node 0 pass out constant values to all the processors
752 >    if (worldRank == 0) {
753 >      if (which_node == 0) {
754 >        localIndex = mpiSim->getGlobalToLocalMol(i);
755 >        
756 >        if(localIndex == -1) {
757 >          strcpy(painCave.errMsg, "Molecule not found on node 0!");
758 >          haveError = 1;
759 >          simError();
760 >        }
761 >        
762 >        vecParticles = (simnfo->molecules[localIndex]).getIntegrableObjects();  
763 >        for(j = 0; j < vecParticles.size(); j++){        
764 >          vecParticles[j]->setZangle( 0.0 );
765 >        }      
766 >        
767 >      } else {
768 >        // I am MASTER OF THE UNIVERSE, but I don't own this molecule
769 >        
770 >        MPI_Recv(&nCurObj, 1, MPI_INT, which_node,
771 >                 TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus);
772 >        
773 >        for(j=0; j < nCurObj; j++){              
774 >          angleTransfer = 0.0;
775 >          MPI_Send(&angleTransfer, 1, MPI_DOUBLE, which_node,
776 >                   TAKE_THIS_TAG_DOUBLE, MPI_COMM_WORLD);        
777 >          index++;
778 >        }
779        }
780 +    } else {
781 +      // I am SLAVE TO THE MASTER
782        
783 <      vecParticles = (simnfo->molecules[localIndex]).getIntegrableObjects();
784 <      
785 <      // set zAngle to 0.0 for all integrable objects
786 <      for(j = 0; j < vecParticles.size(); j++){
787 <        vecParticles[j]->setZangle( 0.0 );
783 >      if (which_node == worldRank) {
784 >        
785 >        // BUT I OWN THIS MOLECULE!!!
786 >        
787 >        localIndex = mpiSim->getGlobalToLocalMol(i);
788 >        vecParticles = (simnfo->molecules[localIndex]).getIntegrableObjects();  
789 >        nCurObj = vecParticles.size();
790 >        
791 >        MPI_Send(&nCurObj, 1, MPI_INT, 0,
792 >                 TAKE_THIS_TAG_INT, MPI_COMM_WORLD);
793 >        
794 >        for(j = 0; j < vecParticles.size(); j++){
795 >          
796 >          MPI_Recv(&angleTransfer, 1, MPI_DOUBLE, 0,
797 >                   TAKE_THIS_TAG_DOUBLE, MPI_COMM_WORLD, &istatus);
798 >          vecParticles[j]->setZangle(angleTransfer);
799 >        }      
800        }
801      }
802    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines