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 397 by gezelter, Fri Mar 4 15:29:03 2005 UTC

# Line 47 | Line 47
47   * @version 1.0
48   */
49  
50 #include <sprng.h>
51
50   #include "brains/MoleculeCreator.hpp"
51   #include "brains/SimCreator.hpp"
52   #include "brains/SimSnapshotManager.hpp"
# Line 57 | Line 55
55   #include "UseTheForce/ForceFieldFactory.hpp"
56   #include "utils/simError.h"
57   #include "utils/StringUtils.hpp"
58 + #include "math/SeqRandNumGen.hpp"
59   #ifdef IS_MPI
60   #include "io/mpiBASS.h"
61 < #include "math/randomSPRNG.hpp"
61 > #include "math/ParallelRandNumGen.hpp"
62   #endif
63  
64   namespace oopse {
# Line 188 | Line 187 | void SimCreator::gatherParameters(SimInfo *info, const
187   }
188  
189   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 {
190  
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
191      //figure out the ouput file names
192      std::string prefix;
193  
# Line 249 | Line 195 | void SimCreator::gatherParameters(SimInfo *info, const
195  
196      if (worldRank == 0) {
197   #endif // is_mpi
198 <
198 >        Globals * simParams = info->getSimParams();
199          if (simParams->haveFinalConfig()) {
200              prefix = getPrefix(simParams->getFinalConfig());
201          } else {
# Line 305 | Line 251 | void SimCreator::divideMolecules(SimInfo *info) {
251          simError();
252      }
253  
254 <    MTRand myRandom(info->getSeed(), nProcessors, worldRank);
254 >    int seedValue;
255 >    Globals * simParams = info->getSimParams();
256 >    SeqRandNumGen* myRandom; //divide labor does not need Parallel random number generator
257 >    if (simParams->haveSeed()) {
258 >        seedValue = simParams->getSeed();
259 >        myRandom = new SeqRandNumGen(seedValue);
260 >    }else {
261 >        myRandom = new SeqRandNumGen();
262 >    }  
263  
264  
265      a = 3.0 * nGlobalMols / info->getNGlobalAtoms();
# Line 328 | Line 282 | void SimCreator::divideMolecules(SimInfo *info) {
282  
283                  // Pick a processor at random
284  
285 <                which_proc = (int) (myRandom.rand() * nProcessors);
285 >                which_proc = (int) (myRandom->rand() * nProcessors);
286  
287                  //get the molecule stamp first
288                  int stampId = info->getMoleculeStampId(i);
# Line 380 | Line 334 | void SimCreator::divideMolecules(SimInfo *info) {
334                  // where a = penalty / (average atoms per molecule)
335  
336                  x = (double)(new_atoms - nTarget);
337 <                y = myRandom.getRandom();
337 >                y = myRandom->rand();
338  
339                  if (y < exp(- a * x)) {
340                      molToProcMap[i] = which_proc;
# Line 394 | Line 348 | void SimCreator::divideMolecules(SimInfo *info) {
348              }
349          }
350  
351 +        delete myRandom;
352 +        
353          // Spray out this nonsense to all other processors:
354  
355          MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines