51 |
|
ParallelRandNumGen::ParallelRandNumGen(const uint32& oneSeed) { |
52 |
|
|
53 |
|
const int masterNode = 0; |
54 |
< |
int seed = oneSeed; |
54 |
> |
unsigned long seed = oneSeed; |
55 |
> |
|
56 |
|
#ifdef IS_MPI |
57 |
|
MPI_Bcast(&seed, 1, MPI_UNSIGNED_LONG, masterNode, MPI_COMM_WORLD); |
58 |
|
#endif |
59 |
+ |
|
60 |
|
if (seed != oneSeed) { |
61 |
|
sprintf(painCave.errMsg, |
62 |
|
"Using different seed to initialize ParallelRandNumGen.\n"); |
66 |
|
|
67 |
|
int nProcessors; |
68 |
|
#ifdef IS_MPI |
69 |
< |
MPI_Comm_size(MPI_COMM_WORLD, &nProcessors); |
69 |
> |
MPI_Comm_size( MPI_COMM_WORLD, &nProcessors); |
70 |
|
MPI_Comm_rank( MPI_COMM_WORLD, &myRank_); |
71 |
|
#else |
72 |
|
nProcessors = 1; |
76 |
|
//actual seed used by random number generator is the seed passed |
77 |
|
//to the constructor plus the number of random number generators |
78 |
|
//which are already created. |
79 |
< |
int newSeed = oneSeed + nCreatedRNG_; |
79 |
> |
unsigned long newSeed = oneSeed + nCreatedRNG_; |
80 |
|
mtRand_ = new MTRand(newSeed, nProcessors, myRank_); |
81 |
|
|
82 |
|
++nCreatedRNG_; |
88 |
|
const int masterNode = 0; |
89 |
|
int nProcessors; |
90 |
|
#ifdef IS_MPI |
91 |
< |
MPI_Comm_size(MPI_COMM_WORLD, &nProcessors); |
91 |
> |
MPI_Comm_size( MPI_COMM_WORLD, &nProcessors); |
92 |
|
MPI_Comm_rank( MPI_COMM_WORLD, &myRank_); |
93 |
|
#else |
94 |
|
nProcessors = 1; |
104 |
|
void ParallelRandNumGen::seed( const uint32 oneSeed ) { |
105 |
|
|
106 |
|
const int masterNode = 0; |
107 |
< |
int seed = oneSeed; |
107 |
> |
unsigned long seed = oneSeed; |
108 |
|
#ifdef IS_MPI |
109 |
|
MPI_Bcast(&seed, 1, MPI_UNSIGNED_LONG, masterNode, MPI_COMM_WORLD); |
110 |
|
#endif |
115 |
|
simError(); |
116 |
|
} |
117 |
|
|
118 |
< |
int newSeed = oneSeed +nCreatedRNG_; |
118 |
> |
unsigned long newSeed = oneSeed +nCreatedRNG_; |
119 |
|
mtRand_->seed(newSeed); |
120 |
|
|
121 |
|
++nCreatedRNG_; |