[PATCH, fortran/52879] RANDOM_SEED revisited

N.M. Maclaren nmm1@cam.ac.uk
Sun Feb 9 10:28:00 GMT 2014


On Feb 9 2014, Steve Kargl wrote:
>
>Here is a potentially contentious patch for PR fortran/52879.
>
>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

Patches removed, as this is a separate point.

>As demonstrated in that PR, it is possible to provide RANDOM_SEED
>with sets of seeds that result in a very poor sequences of PRN.

That should be fixed, I agree.

>Gfortran's RANDOM_NUMBER uses 3 independent KISS PRNG to generate
>the bits of the significands of the real PRN.

I am extremely rusty, but this used to be my area.

Unless it has been changed since 4.5.1, they are not independent;
they are merely separate.  Using 3 copies of them probably does not
make any significant difference - if you want to get a benefit from
combining generators, then you must use ones based on very distinct
mathematical properties, or where they have known independence.

As far as I know, there is only one known method of achieving the
last, which is something I developed some decades back, though it
can easily be extended to other algebras.  I tend to favour ones
based on different principles - which is PRECISELY the technique
used inside Marsaglias's KISS!

>Each KISS PRNG
>requires 4 seeds.  This patch removes the need for a user to
>specify 12 seeds.  It uses a Lehmer linear congruent generator
>to generate the 12 KISS seeds.  This LCG requires a single seed.
>I have selected to have seed(1)=0 correspond to the current
>default set of KISS seeds.  Internally, the LCG declares the 
>seed as a GFC_UINTEGER_8 (ie., uint64_t) type, so for gfortran's
>default integer kind one has 2**31-1 possible seeds and if one
>use -fdefault-integer-8 then one has 2**32 possible seeds.

That's certainly a plausible solution.

>It is possible to extend the patch to allow a skip count such that
>for example seed(2)=10 would use every tenth value in the LCG
>sequence. I haven't pursued this as it appears to be an unneeded
>complication.

Not just that - an undesirable complication.  The ONLY point of seeds
should be to select between sequences - all of the randomisation should
be internal.


Regards,
Nick Maclaren.



More information about the Fortran mailing list