[FLASH-USERS] Random Number Generators in FLASH

Carlo Graziani carlo at oddjob.uchicago.edu
Wed Feb 24 15:27:25 EST 2016


On 02/24/2016 01:56 PM, Jason Galyardt wrote:
> Dear FLASH Users,
>
> In FLASH 4.3, there is a random number generator (RNG) unit, located at source/flashUtilities/rng. There are two implementations: the default is located at source/flashUtilities/rng, and the other is located at source/flashUtilities/rng/mt_rng. The default implementation seems to use the Fortran 90 intrinsic RNG facilities (random_seed() and random_number()), while the mt_rng implementation uses the 32-bit Mersenne Twister.
>
> Has anyone used the Mersenne Twister implementation before? Is there a recommended prescription for setting the seed on each processor of an MPI job? The latter is complicated by the fact that mt_rng seems to want an integer array of length 624 instead of a single integer seed which can be constructed from the processor ID and a global, user-provided seed.
>
> Thanks,
> Jason
>
> ----
> Jason Galyardt
> Department of Physics and Astronomy
> University of Georgia
>

Hi Jason.

As I recall, this functionality was introduced in order to obtain
cross-platform reproducibility of results.  The Fortan 90 intrinsics
random_seed() and random_number() produce platform-dependent results, so in
cases where it is important that pseudorandomness should be repeatable across
platforms, it is desirable to have a portable high-quality RNG, such as
the Mersenne twister.

I don't know whether a recommended seeding prescription was ever articulated.
It should be obvious, though, that if RNG initialization is bound to MPI rank
rather than to a stable in-application computational structure (e.g. hashed
coordinates of local block center, or Morton ordering of a block) the advantage
of reproducibility is promptly lost, since one has now tied RNG initialization
to the system-level details of MPI process allocation, so that the same
simulation performed with different number of MPI processes necessarily
produces different results.

Bit-for-bit simulation reproducibility, even despite RNG calls, is important
for regression testing.  It is also (I would argue) very valuable in general
scientific simulation, particularly in cases of flows where small differences
can be amplified by irreducible instabilities.  However, it is not obtainable
without some effort, so the effort involved had better pass some cost/benefit
analysis for you. If you feel it is more trouble than it is worth, the standard
F90 intrinsics should probably produces adequate randomness.

Carlo

-- 
Carlo Graziani                                 (773) 702-7973 (Voice)
University of Chicago Flash Center             (773) 702-6645 (FAX)
5747 South Ellis Avenue     -------------------------------------
Jones 314                  | The less a statesman amounts to, the
Chicago, IL 60637          | more he loves the flag.
carlo at oddjob.uchicago.edu  | 		   --- Kin Hubbard





More information about the flash-users mailing list