ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/brains/SimCreator.cpp
(Generate patch)

Comparing trunk/src/brains/SimCreator.cpp (file contents):
Revision 381 by tim, Tue Mar 1 14:45:45 2005 UTC vs.
Revision 388 by tim, Tue Mar 1 23:02:33 2005 UTC

# Line 57 | Line 57
57   #include "UseTheForce/ForceFieldFactory.hpp"
58   #include "utils/simError.h"
59   #include "utils/StringUtils.hpp"
60 + #include "math/MersenneTwister.hpp"
61   #ifdef IS_MPI
62   #include "io/mpiBASS.h"
62 #include "math/randomSPRNG.hpp"
63   #endif
64  
65   namespace oopse {
# Line 189 | Line 189 | void SimCreator::gatherParameters(SimInfo *info, const
189  
190   void SimCreator::gatherParameters(SimInfo *info, const std::string& mdfile) {
191  
192    //setup seed for random number generator
193    int seedValue;
194    Globals * simParams = info->getSimParams();
195
196    if (simParams->haveSeed()) {
197        seedValue = simParams->getSeed();
198
199        if (seedValue < 100000000 ) {
200            sprintf(painCave.errMsg,
201                    "Seed for sprng library should contain at least 9 digits\n"
202                        "OOPSE will generate a seed for user\n");
203
204            painCave.isFatal = 0;
205            simError();
206
207            //using seed generated by system instead of invalid seed set by user
208
209 #ifndef IS_MPI
210
211            seedValue = make_sprng_seed();
212
213 #else
214
215            if (worldRank == 0) {
216                seedValue = make_sprng_seed();
217            }
218
219            MPI_Bcast(&seedValue, 1, MPI_INT, 0, MPI_COMM_WORLD);
220
221 #endif
222
223        } //end if (seedValue /1000000000 == 0)
224    } else {
225
226 #ifndef IS_MPI
227
228        seedValue = make_sprng_seed();
229
230 #else
231
232        if (worldRank == 0) {
233            seedValue = make_sprng_seed();
234        }
235
236        MPI_Bcast(&seedValue, 1, MPI_INT, 0, MPI_COMM_WORLD);
237
238 #endif
239
240    } //end of simParams->haveSeed()
241
242    info->setSeed(seedValue);
243
244
192      //figure out the ouput file names
193      std::string prefix;
194  
# Line 249 | Line 196 | void SimCreator::gatherParameters(SimInfo *info, const
196  
197      if (worldRank == 0) {
198   #endif // is_mpi
199 <
199 >        Globals * simParams = info->getSimParams();
200          if (simParams->haveFinalConfig()) {
201              prefix = getPrefix(simParams->getFinalConfig());
202          } else {
# Line 305 | Line 252 | void SimCreator::divideMolecules(SimInfo *info) {
252          simError();
253      }
254  
255 <    MTRand myRandom(info->getSeed(), nProcessors, worldRank);
255 >    int seedValue;
256 >    Globals * simParams = info->getSimParams();
257 >    MTRand* myRandom; //divide labor does not need Parallel random number generator
258 >    if (simParams->haveSeed()) {
259 >        seedValue = simParams->getSeed();
260 >        myRandom = new MTRand(seedValue);
261 >    }else {
262 >        myRandom = new MTRand();
263 >    }  
264  
265  
266      a = 3.0 * nGlobalMols / info->getNGlobalAtoms();
# Line 328 | Line 283 | void SimCreator::divideMolecules(SimInfo *info) {
283  
284                  // Pick a processor at random
285  
286 <                which_proc = (int) (myRandom.rand() * nProcessors);
286 >                which_proc = (int) (myRandom->rand() * nProcessors);
287  
288                  //get the molecule stamp first
289                  int stampId = info->getMoleculeStampId(i);
# Line 380 | Line 335 | void SimCreator::divideMolecules(SimInfo *info) {
335                  // where a = penalty / (average atoms per molecule)
336  
337                  x = (double)(new_atoms - nTarget);
338 <                y = myRandom.getRandom();
338 >                y = myRandom->rand();
339  
340                  if (y < exp(- a * x)) {
341                      molToProcMap[i] = which_proc;
# Line 394 | Line 349 | void SimCreator::divideMolecules(SimInfo *info) {
349              }
350          }
351  
352 +        delete myRandom;
353 +        
354          // Spray out this nonsense to all other processors:
355  
356          MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines