Libraries |
The PRANF Portable Parallel Random Number GeneratorPRANF is a portable parallel pseudorandom number generator. It is designed to duplicate the Cray PRNG named "ranf" in a portable and wordlength independent manner. It can also generate multiple streams of random 48-bit floating point values between zero and one, noninclusive. Each stream is autonomous, independent, and requires its own seed, in each call. The method for generating multiple streams by partitioning the sequence generated by ranf was provided by Dr. Mark J. Durst. The original version of PRANF was written in SISAL, a parallel functional language. The fortran version was written as part of a comparative performance study, by T. M. DeBoni, John Feo, and David Cann. At the time this work was done, all involved were employed at Lawrence Livermore National Laboratory. This code is provided on an "as-is" basis. How to use PRANF:Initialization
integer N, M, StartVal, Seeds
dimension Seeds(M, 4)
call Rans( N, StartVal, Seeds )
This returns an array of M seeds, where M = N, if N is odd, or N+1 otherwise; the returned seeds have values that partition the basic ranf cycle of 2**46 pseudorandom reals in [0,1] into independent subsequences. The subsequence seeds returned in the array Seeds have a special representation particular to PRANF: each seed is stored as one row of the array, and is represented as four integers. The second argument, StartVal, is a cycle-starting value for the full-period generator; if it is zero, a special seed will be used that will produce the same basic sequence as Cray's generator ranf. If a different sequence of random numbers is desired, a nonzero value provided in StartVal will produce it. Use
integer Seed
dimension Seed(4)
real*8 RandNum
call Ranf( Seed, RandNum )
This returns a pseudorandom real and a seed to be passed back in the next invocation of this subsequence. The argument Seed is one element of the array Seeds returned by Rans, and is both an input and an output parameter in the call to Ranf. The returned value of Seed carries the state normally hidden in non-reentrant generators. Care must be taken that the individual subsequences of PRANF are used consistently. Each subsequence is intended for use by a single computational process needing an independent sequence of pseudo-random values. Since the total length of the basic sequence is very long (2**26), a very large number of subsequences can be used, with little chance of them overlapping. If the using processes trade seeds, undesirable statistical behavior may result. Note that a special data structure is needed for this generator; each seed returned by the generator is really an array of four integers. These are intended to be the four digits of a radix-4096 number. All calculations internal to the generator and partitioner are carried out in piecewise fashion, using these numbers. This allows the generator to be easily duplicated on machines of varying word length. The random number returned is calculated as if a 48-bit mantissa were the desired representation. This is consistent with Cray numerics. On machines with shorter words, the number's low-order bits will be lost. However, it should be possible to reprogram this generator to produce a different final representation for the random number, if desired. The important consideration is that the sequence of values generated will be the same on any platform, and consistent with those generated by the Cray generator. The source code for PRANF must be compiled and linked in with the rest of the using program. PRANF is provided in two pieces: a Fortran source program, pranf.F, and an include file, pranf.parm, containing the values of parameters used by the pranf code. Source Code
|
![]() |
Page last modified: Tue, 11 May 2004 16:27:22 GMT Page URL: http://www.nersc.gov/nusers/resources/software/libs/math/random/pranf/ Web contact: webmaster@nersc.gov Computing questions: consult@nersc.gov Privacy and Security Notice |
![]() |