next up previous contents
Next: Monte Carlo Processing: An Up: Monte Carlo Previous: Monte Carlo   Contents

Random Numbers

All random numbers for SNOMAN come from the routine SNORAN(I). This routine acts only as a level of indirection for whatever random number generator is in use, which is currently a lagged-Fibonacci pseudo-RNG (see the specific description elsewhere in this manual). If a different random number generator is desired, it should be substituted in SNORAN, this will simultaneously change it for all calls in SNOMAN (including the Numerical Recipes routines GASDEV and POIDEV). The argument I is a dummy in the current implementation, however it is used to avoid a possible subtle compiler bug. We have been told that some optimizing compilers will assume that a function called twice in the same line with the same arguments (or multiple times in a loop) will return the same value, thus if SNORAN(I) is called twice in the same line the value of I should be changed, and if called in a loop I should be a function of the loop variable. We have not actually encountered this problem, however better safe than sorry.

SNORAN is initialized by the routine SNORAN_INI.FOR which loads titles bank SEED. This bank contains two integer seeds which determine which random number sequence will be generated, and a third integer which is the point in the sequence to start from. The first integer must be in the range 1 - 31328, and the second 1 - 30081; each pair of such integers generates a different random number sequence of length 2$^{144}$. . At the beginning of each event the routine MCMAIN writes the current event number, these two integers, and the number of random numbers used so far to a file called `rseed.dat'. This can be overridden using a FILE command (see section 3.9.2) e.g.:-

file mco 1 my_seeds.dat checkpoint=10
The checkpoint option can be used to decrease the frequency with which the file is updated; in this case it is output every 10th. event. If the program crashes for some reason it can be restarted at the same point by using the same two seeds and copying the number of random numbers used to the 3rd entry in the SEED bank. Otherwise this number should be set to 0 so that the random number sequence starts at the beginning.

There was one change made to the algorithm as published. As published the routine would produce a true zero once every 4.2 billion numbers. This would then crash those routines that take log(SNORAN). Rather than trap all of these routines and pay a price in speed we decided to make a different change that would accomplish the same thing. The routine actually implemented in SNORAN substitutes 1.0 whenever the original routine would have produced 0.0 without altering the subsequent sequence (we think). This avoids the crashes without increasing the run time.

For further information see the Companion:-

The Random Number Generator.


next up previous contents
Next: Monte Carlo Processing: An Up: Monte Carlo Previous: Monte Carlo   Contents
sno Guest Acct 2009-09-09