57 |
|
#include "UseTheForce/ForceFieldFactory.hpp" |
58 |
|
#include "utils/simError.h" |
59 |
|
#include "utils/StringUtils.hpp" |
60 |
+ |
|
61 |
|
#ifdef IS_MPI |
62 |
|
#include "io/mpiBASS.h" |
63 |
< |
#include "math/randomSPRNG.hpp" |
63 |
> |
#include "math/ParallelRandNumGen.hpp" |
64 |
|
#endif |
65 |
|
|
66 |
|
namespace oopse { |
189 |
|
} |
190 |
|
|
191 |
|
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 |
– |
|
192 |
|
|
193 |
|
//figure out the ouput file names |
194 |
|
std::string prefix; |
197 |
|
|
198 |
|
if (worldRank == 0) { |
199 |
|
#endif // is_mpi |
200 |
< |
|
200 |
> |
Globals * simParams = info->getSimParams(); |
201 |
|
if (simParams->haveFinalConfig()) { |
202 |
|
prefix = getPrefix(simParams->getFinalConfig()); |
203 |
|
} else { |
253 |
|
simError(); |
254 |
|
} |
255 |
|
|
256 |
< |
MTRand myRandom(info->getSeed(), nProcessors, worldRank); |
256 |
> |
int seedValue; |
257 |
> |
Globals * simParams = info->getSimParams(); |
258 |
> |
SeqRandNumGen* myRandom; //divide labor does not need Parallel random number generator |
259 |
> |
if (simParams->haveSeed()) { |
260 |
> |
seedValue = simParams->getSeed(); |
261 |
> |
myRandom = new MTRand(seedValue); |
262 |
> |
}else { |
263 |
> |
myRandom = new MTRand(); |
264 |
> |
} |
265 |
|
|
266 |
|
|
267 |
|
a = 3.0 * nGlobalMols / info->getNGlobalAtoms(); |
284 |
|
|
285 |
|
// Pick a processor at random |
286 |
|
|
287 |
< |
which_proc = (int) (myRandom.rand() * nProcessors); |
287 |
> |
which_proc = (int) (myRandom->rand() * nProcessors); |
288 |
|
|
289 |
|
//get the molecule stamp first |
290 |
|
int stampId = info->getMoleculeStampId(i); |
336 |
|
// where a = penalty / (average atoms per molecule) |
337 |
|
|
338 |
|
x = (double)(new_atoms - nTarget); |
339 |
< |
y = myRandom.getRandom(); |
339 |
> |
y = myRandom->rand(); |
340 |
|
|
341 |
|
if (y < exp(- a * x)) { |
342 |
|
molToProcMap[i] = which_proc; |
350 |
|
} |
351 |
|
} |
352 |
|
|
353 |
+ |
delete myRandom; |
354 |
+ |
|
355 |
|
// Spray out this nonsense to all other processors: |
356 |
|
|
357 |
|
MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD); |