--- trunk/mdtools/mpi_implementation/mpiSimulation.cpp 2002/12/05 21:37:51 196 +++ trunk/mdtools/mpi_implementation/mpiSimulation.cpp 2002/12/19 21:59:51 215 @@ -5,29 +5,34 @@ i#include #include "mpiSimulation.hpp" #include "simError.h" +mpiSimulation* mpiSim; - mpiSimulation::mpiSimulation(SimInfo* the_entryPlug) { entryPlug = the_entryPlug; + mpiPlug = new MpiSimData; - numberProcessors = MPI::COMM_WORLD.Get_size(); - myNode = worldRank; + mpiPlug->numberProcessors = MPI::COMM_WORLD.Get_size(); + mpiPlug->myNode = worldRank; - // let the simulation know were there. - entryPlug->mpiSim = this; + } mpiSimulation::~mpiSimulation(){ - // empty for now + delete mpiPlug; + // perhaps we should let fortran know the party is over. } -void mpiSimulation::divideLabor(int nComponents, MoleculeStamp** compStamps, int* componentsNmol ){ - +void mpiSimulation::divideLabor( void ){ + + int nComponents; + MoleculeStamp** compStamps; + int* componentsNmol; + double numerator; double denominator; double precast; @@ -41,8 +46,19 @@ void mpiSimulation::divideLabor(int nComponents, Molec int testSum; + nComponents = entryPlug->nComponents; + compStamps = entryPlug->compStamps; + componentsNmol = entryPlug->componentsNmol; + + mpiPlug->nAtomsGlobal = entryPlug->n_atoms; + mpiPlug->nBondsGlobal = entryPlug->n_bonds; + mpiPlug->nBendsGlobal = entryPlug->n_bends; + mpiPlug->nTorsionsGlobal = entryPlug->n_torsions; + mpiPlug->nSRIGlobal = entryPlug->n_SRI; + mpiPlug->nMolGlobal = entryPlug->n_nmol; + numerator = (double) entryPlug->n_atoms; - denominator = (double) numberProcessors; + denominator = (double) mpiPlug->numberProcessors; precast = numerator / denominator; nTarget = (int)( precast + 0.5 ); @@ -50,15 +66,15 @@ void mpiSimulation::divideLabor(int nComponents, Molec atomIndex = 0; compIndex = 0; compStart = 0; - for( i=0; i<(numberProcessors-1); i++){ + for( i=0; i<(mpiPlug->numberProcessors-1); i++){ done = 0; nLocal = 0; molLocal = 0; - if( i == myNode ){ - myMolStart = molIndex; - myAtomStart = atomIndex; + if( i == mpiPlug->myNode ){ + mpiPlug->myMolStart = molIndex; + mpiPlug->myAtomStart = atomIndex; } while( !done ){ @@ -93,22 +109,22 @@ void mpiSimulation::divideLabor(int nComponents, Molec } } - if( i == myNode ){ - myMolEnd = (molIndex - 1); - myAtomEnd = (atomIndex - 1); - myNlocal = nLocal; - myMol = molLocal; + if( i == mpiPlug->myNode ){ + mpiPlug->myMolEnd = (molIndex - 1); + mpiPlug->myAtomEnd = (atomIndex - 1); + mpiPlug->myNlocal = nLocal; + mpiPlug->myMol = molLocal; } numerator = (double)( entryPlug->n_atoms - atomIndex ); - denominator = (double)( numberProcessors - (i+1) ); + denominator = (double)( mpiPlug->numberProcessors - (i+1) ); precast = numerator / denominator; nTarget = (int)( precast + 0.5 ); } - if( myNode == numberProcessors-1 ){ - myMolStart = molIndex; - myAtomStart = atomIndex; + if( mpiPlug->myNode == mpiPlug->numberProcessors-1 ){ + mpiPlug->myMolStart = molIndex; + mpiPlug->myAtomStart = atomIndex; nLocal = 0; molLocal = 0; @@ -126,16 +142,16 @@ void mpiSimulation::divideLabor(int nComponents, Molec molLocal++; } - myMolEnd = (molIndex - 1); - myAtomEnd = (atomIndex - 1); - myNlocal = nLocal; - myMol = molLocal; + mpiPlug->myMolEnd = (molIndex - 1); + mpiPlug->myAtomEnd = (atomIndex - 1); + mpiPlug->myNlocal = nLocal; + mpiPlug->myMol = molLocal; } - MPI_Allreduce( &Nlocal, &testSum, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); + MPI_Allreduce( &nLocal, &testSum, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); - if( myNode == 0 ){ + if( mpiPlug->myNode == 0 ){ if( testSum != entryPlug->n_atoms ){ sprintf( painCave.errMsg, "The summ of all nLocals, %d, did not equal the total number of atoms, %d.\n",