This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] PATCH -- Fix for PR 15619

On Wednesday 26 May 2004 23:12, Steve Kargl wrote:
> There were 2 problems that led to PR 15619.  First, a global
> index was used where a local index should have been used.
> This caused the global index to either retain a wrong value
> or reset to new value when RANDOM_SEED(GET=) was called.
> The second problem was the global index needs to be reset
> to N on each call to RANDOM_SEED(PUT=).  This then causes
> the sequence to be regenerated.
> 2004-05-26  Steven G. Kargl  <>
>         * random.c (random_seed): Use local index.  Reset global index.

No, still wrong. Fails the test appended to this mail.

Possible solution: add an extra word to the seed which contains the current 
position. Obviously you'll need to cope with arbitary values when the user 
specifies PUT=, but curent_index=abs(current_index) % N should do the trick.

Oh, and while you're at it, please rename the global variable "i" to something 
more sane ;)


program prog
  integer, allocatable :: a(:)
  integer n
  real w, x, y, z
  call random_seed(size=n)
  call random_number (x)
  call random_seed(get=a)
  call random_number(x)
  call random_seed(put=a)
  call random_number(y)
  if (x .ne. y) call abort ()
end program

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]