This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: randomizing the seed - unintuitive behaviour
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Kamaraju Kusumanchi <kamaraju at gmail dot com>
- Cc: gfortran <fortran at gcc dot gnu dot org>
- Date: Sat, 26 Feb 2005 22:35:26 -0800
- Subject: Re: randomizing the seed - unintuitive behaviour
- References: <ba49751505022622071ba59950@mail.gmail.com>
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