--- trunk/src/brains/SimCreator.cpp 2005/03/01 15:44:45 383 +++ trunk/src/brains/SimCreator.cpp 2005/03/01 19:11:47 384 @@ -57,9 +57,10 @@ #include "UseTheForce/ForceFieldFactory.hpp" #include "utils/simError.h" #include "utils/StringUtils.hpp" +#include "math/OOPSERandNumGen.hpp" #ifdef IS_MPI #include "io/mpiBASS.h" -#include "math/randomSPRNG.hpp" + #endif namespace oopse { @@ -188,59 +189,6 @@ void SimCreator::gatherParameters(SimInfo *info, const } void SimCreator::gatherParameters(SimInfo *info, const std::string& mdfile) { - - //setup seed for random number generator - int seedValue; - Globals * simParams = info->getSimParams(); - - if (simParams->haveSeed()) { - seedValue = simParams->getSeed(); - - if (seedValue < 100000000 ) { - sprintf(painCave.errMsg, - "Seed for sprng library should contain at least 9 digits\n" - "OOPSE will generate a seed for user\n"); - - painCave.isFatal = 0; - simError(); - - //using seed generated by system instead of invalid seed set by user - -#ifndef IS_MPI - - seedValue = make_sprng_seed(); - -#else - - if (worldRank == 0) { - seedValue = make_sprng_seed(); - } - - MPI_Bcast(&seedValue, 1, MPI_INT, 0, MPI_COMM_WORLD); - -#endif - - } //end if (seedValue /1000000000 == 0) - } else { - -#ifndef IS_MPI - - seedValue = make_sprng_seed(); - -#else - - if (worldRank == 0) { - seedValue = make_sprng_seed(); - } - - MPI_Bcast(&seedValue, 1, MPI_INT, 0, MPI_COMM_WORLD); - -#endif - - } //end of simParams->haveSeed() - - info->setSeed(seedValue); - //figure out the ouput file names std::string prefix; @@ -249,7 +197,7 @@ void SimCreator::gatherParameters(SimInfo *info, const if (worldRank == 0) { #endif // is_mpi - + Globals * simParams = info->getSimParams(); if (simParams->haveFinalConfig()) { prefix = getPrefix(simParams->getFinalConfig()); } else { @@ -305,7 +253,15 @@ void SimCreator::divideMolecules(SimInfo *info) { simError(); } - MTRand myRandom(info->getSeed(), nProcessors, worldRank); + int seedValue; + Globals * simParams = info->getSimParams(); + OOPSERandNumGen* myRandom; + if (simParams->haveSeed()) { + seedValue = simParams->getSeed(); + myRandom = new OOPSERandNumGen(seedValue); + }else { + myRandom = new OOPSERandNumGen(); + } a = 3.0 * nGlobalMols / info->getNGlobalAtoms(); @@ -328,7 +284,7 @@ void SimCreator::divideMolecules(SimInfo *info) { // Pick a processor at random - which_proc = (int) (myRandom.rand() * nProcessors); + which_proc = (int) (myRandom->rand() * nProcessors); //get the molecule stamp first int stampId = info->getMoleculeStampId(i); @@ -380,7 +336,7 @@ void SimCreator::divideMolecules(SimInfo *info) { // where a = penalty / (average atoms per molecule) x = (double)(new_atoms - nTarget); - y = myRandom.getRandom(); + y = myRandom->rand(); if (y < exp(- a * x)) { molToProcMap[i] = which_proc; @@ -394,6 +350,8 @@ void SimCreator::divideMolecules(SimInfo *info) { } } + delete myRandom; + // Spray out this nonsense to all other processors: MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD);