------- Comment #4 from kargl at gcc dot gnu dot org 2009-02-22 16:53 ------- (In reply to comment #3) > On Debian 5.0 they return: > > mrich...@msc3035298w:~$ gfortran duh.f90 > mrich...@msc3035298w:~$ ./a.out > 12 > mrich...@msc3035298w:~$ gfortran doh.f90 > mrich...@msc3035298w:~$ ./a.out > 33 > > I overwrote Debian 4.0 when I built 5.0.
This system has a 113-bit significand floating point type. The random number generator requires 12 integers to seed the 3 internal and independent KISS generators (each KISS requires 4 seeds). The first KISS generator produces the first 32-bits of the significand, the 2nd KISS prng gives the next set of 32 bits, and the last KISS prng provides the remaining bits. The only portable way to seed random_number is to do something like integer, allocatable :: seeds(:) call random_seed(size=i) allocate(seeds(i)) ! ! Set seeds(i) here ! seeds = (/ (j, j=1, i) /) ! Obviously, there are better choices! call random_seed(put=seeds) deallocate(seeds) A few other points. gfortran will mix your seeds with some system entropy to try to limit/prevent a bad choice of seeds. Additionally, if you harvest a real(4), reseed the generator, and then harvest a real(8). The first 24 bits of the real(8) will match the 24 bits of the real(4). If you have other questions about random_seed or random_harvest, it may be best to ask on the fort...@gcc.gnu.org list. -- kargl at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39266