This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] PATCH -- random.c: fix infinite loop and make sequences consistent
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Tobias Schl?ter <tobias dot schlueter at physik dot uni-muenchen dot de>
- Cc: kargls at comcast dot net, fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sun, 13 Jun 2004 11:02:40 -0700
- Subject: Re: [gfortran] PATCH -- random.c: fix infinite loop and make sequences consistent
- References: <20040613101605.764109fa.kargls@comcast.net> <40CC9427.5070503@physik.uni-muenchen.de>
On Sun, Jun 13, 2004 at 07:51:35PM +0200, Tobias Schl?ter wrote:
> Steven G. Kargl wrote:
> >2004-06-13 Steven G. Kargl <kargls@comcast.net>
> > * random.c (random_r4): Burn a random number
> > (random_r8): fix infinite loop.
> >
>
> I committed this under the obviously correct rule. Your burning of a
> random number also makes sense if one uses it to generate both REAL*4
> and REAL*8 random numbers, as now in a sequence REAL*8, REAL*4, REAL*8
> the third number will be the same as in a series of REAL*8 numbers.
>
Thanks. Yes, the burning of the number allows one to
change a program from REAL*4 to REAL*8 for testing
with the expectation that the PRN sequences are consistent.
program s
integer i
real(4) x4(4)
real(8) x8(4)
call random_seed
call random_number(x4)
call random_seed
call random_number(x8)
do i = 1, 4
print '(I2,2X,E15.6,E22.15)', i, x4(i), x8(i)
end do
end program s
kargl[334] ./uuu
1 0.126499E+00 0.126499085373039E+00
2 0.827013E-01 0.827013909818962E-01
3 0.330153E+00 0.330153673957584E+00
4 0.401973E+00 0.401973397956495E+00
--
Steve