--- trunk/OOPSE/libmdtools/mpiSimulation.cpp 2003/03/26 19:34:49 406 +++ trunk/OOPSE/libmdtools/mpiSimulation.cpp 2003/03/26 23:14:02 416 @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -10,6 +11,7 @@ #include "fortranWrappers.hpp" #include "randomSPRNG.hpp" +#define BASE_SEED 123456789 mpiSimulation* mpiSim; @@ -44,7 +46,7 @@ int* mpiSimulation::divideLabor( void ){ int nComponents; MoleculeStamp** compStamps; - randomSPRNG myRandom; + randomSPRNG *myRandom; int* componentsNmol; int* AtomsPerProc; @@ -58,8 +60,11 @@ int* mpiSimulation::divideLabor( void ){ int molIndex, atomIndex, compIndex, compStart; int done; int nLocal, molLocal; - int i, index; + int i, j, loops, which_proc, nmol_local, natoms_local; + int nmol_global, natoms_global; + int local_index, index; int smallDiff, bigDiff; + int baseSeed = BASE_SEED; int testSum; @@ -75,7 +80,7 @@ int* mpiSimulation::divideLabor( void ){ mpiPlug->nSRIGlobal = entryPlug->n_SRI; mpiPlug->nMolGlobal = entryPlug->n_mol; - myRandom = new randomSPRNG(); + myRandom = new randomSPRNG( baseSeed ); a = (double)mpiPlug->nMolGlobal / (double)mpiPlug->nAtomsGlobal; @@ -120,7 +125,7 @@ int* mpiSimulation::divideLabor( void ){ // Pick a processor at random - which_proc = (int) (myRandom.getRandom() * mpiPlug->numberProcessors); + which_proc = (int) (myRandom->getRandom() * mpiPlug->numberProcessors); // How many atoms does this processor have? @@ -131,7 +136,7 @@ int* mpiSimulation::divideLabor( void ){ if (old_atoms >= nTarget) continue; - add_atoms = compStamps[MolComponentType[i]]->getNatoms(); + add_atoms = compStamps[MolComponentType[i]]->getNAtoms(); new_atoms = old_atoms + add_atoms; // If we can add this molecule to this processor without sending @@ -180,7 +185,7 @@ int* mpiSimulation::divideLabor( void ){ // where a = 1 / (average atoms per molecule) x = (double) (new_atoms - nTarget); - y = myRandom.getRandom(); + y = myRandom->getRandom(); if (exp(- a * x) > y) { MolToProcMap[i] = which_proc; @@ -281,17 +286,8 @@ int* mpiSimulation::divideLabor( void ){ globalIndex[local_index] = i; } } - - - - - index = mpiPlug->myAtomStart; -// for( i=0; imyNlocal; i++){ -// globalIndex[i] = index; -// index++; -// } - -// return globalIndex; + + return globalIndex; }