void init_random_seed(long seed) { /* initializes the random number generator. You MUST NOT FORGET THIS! */ int j; long k; /* This random generator is bad I know {why, Frank? It's the same as the one in l_random!}, thats why its only {no, in l_random as well!} used for the seed (see Num. Rec. 7.1.) */ if(seed < 1) { fprintf(stderr,"The initial seed of the random number generator must be a positive integer!\n"); fprintf(stderr,"Using 0 will result in a plain 0-sequence, hence it's forbidden (you used: %ld)!\n",seed); fflush(NULL); errexit(); } idumInit = idum = seed; RANDOM_TRACE(fprintf(stderr, "%d: Init random with seed %ld in 'random.c'\n",this_node,idum)); for (j = NTAB_RANDOM + 7;j >= 0; j--) { k = (idum) / IQ; idum = IA * (idum - k * IQ) - IR * k; if (idum < 0) idum += IM; if (j < NTAB_RANDOM) iv[j] = idum; } iy = iv[0]; }
void mpi_random_seed_slave(int pnode, int cnt) { int this_seed; MPI_Scatter(NULL, 1, MPI_INT, &this_seed, 1, MPI_INT, 0, comm_cart); RANDOM_TRACE(printf("%d: Received seed %d\n", this_node, this_seed)); init_random_seed(this_seed); }
void mpi_random_seed(int cnt, vector<int> &seeds) { int this_seed; mpi_call(mpi_random_seed_slave, -1, cnt); MPI_Scatter(&seeds[0], 1, MPI_INT, &this_seed, 1, MPI_INT, 0, comm_cart); RANDOM_TRACE(printf("%d: Received seed %d\n", this_node, this_seed)); init_random_seed(this_seed); }