--- trunk/mdtools/mpi_implementation/mpiSimulation.cpp 2002/12/05 18:53:40 195 +++ trunk/mdtools/mpi_implementation/mpiSimulation.cpp 2002/12/10 21:41:26 202 @@ -26,8 +26,12 @@ mpiSimulation::~mpiSimulation(){ } -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; @@ -35,12 +39,23 @@ void mpiSimulation::divideLabor(int nComponents, Molec int nTarget; int molIndex, atomIndex, compIndex, compStart; int done; - int nLocal; + int nLocal, molLocal; int i; int smallDiff, bigDiff; int testSum; + nComponents = entryPlug->nComponents; + compStamps = entryPlug->compStamps; + componentsNmol = entryPlug->componentsNmol; + + simTotAtoms = entryPlug->n_atoms; + simTotBonds = entryPlug->n_bonds; + simTotBends = entryPlug->n_bends; + simTotTorsions = entryPlug->n_torsions; + simTotSRI = entryPlug->n_SRI; + simTotNmol = entryPlug->n_nmol; + numerator = (double) entryPlug->n_atoms; denominator = (double) numberProcessors; precast = numerator / denominator; @@ -54,6 +69,7 @@ void mpiSimulation::divideLabor(int nComponents, Molec done = 0; nLocal = 0; + molLocal = 0; if( i == myNode ){ myMolStart = molIndex; @@ -71,6 +87,7 @@ void mpiSimulation::divideLabor(int nComponents, Molec nLocal += compStamps[compIndex]->getNAtoms(); atomIndex += compStamps[compIndex]->getNAtoms(); molIndex++; + molLocal++; if ( nLocal == nTarget ) done = 1; @@ -83,6 +100,7 @@ void mpiSimulation::divideLabor(int nComponents, Molec if( bigDiff < smallDiff ) done = 1; else{ molIndex--; + molLocal--; atomIndex -= compStamps[compIndex]->getNAtoms(); nLocal -= compStamps[compIndex]->getNAtoms(); done = 1; @@ -94,6 +112,7 @@ void mpiSimulation::divideLabor(int nComponents, Molec myMolEnd = (molIndex - 1); myAtomEnd = (atomIndex - 1); myNlocal = nLocal; + myMol = molLocal; } numerator = (double)( entryPlug->n_atoms - atomIndex ); @@ -107,6 +126,7 @@ void mpiSimulation::divideLabor(int nComponents, Molec myAtomStart = atomIndex; nLocal = 0; + molLocal = 0; while( compIndex < nComponents ){ if( (molIndex-compStart) >= componentsNmol[compIndex] ){ @@ -118,11 +138,13 @@ void mpiSimulation::divideLabor(int nComponents, Molec nLocal += compStamps[compIndex]->getNAtoms(); atomIndex += compStamps[compIndex]->getNAtoms(); molIndex++; + molLocal++; } myMolEnd = (molIndex - 1); myAtomEnd = (atomIndex - 1); - myNlocal = nLocal; + myNlocal = nLocal; + myMol = molLocal; } @@ -141,4 +163,6 @@ void mpiSimulation::divideLabor(int nComponents, Molec sprintf( checkPointMsg, "Successfully divided the molecules among the processors.\n" ); MPIcheckPoint(); + + // lets create the identity array }