randomizing the seed - unintuitive behaviour
Steve Kargl
sgk@troutmask.apl.washington.edu
Sun Feb 27 06:35:00 GMT 2005
On Sun, Feb 27, 2005 at 01:07:59AM -0500, Kamaraju Kusumanchi wrote:
(snip)
>
> I agree that this behaviour is standard conforming. But it is counter
> intuitive. I tried intel compiler (ifort 8.1). It does what I want to
> do.
(snip)
>
> Do the experts consider this as a bug or is it a feature?
>
You answered your own question! gfortran's implementation
of random_number and random_seed conform to the standard.
The "experts" (whatever that means) will agree to disagree.
If you want a different sequence with each invocation,
then learn to seed random_number.
integer nrand, val(8)
integer, allocatable, dimension(:) :: put
call date_and_time(values=val)
call random_seed(size=nrand)
allocate(put(nrand))
if (nrand > 8) put = 1
put = val(1:nrand)
call random_seed(put=put)
There are better ways to do this.
--
Steve
More information about the Fortran
mailing list