returns a scalar random number, the initial seed idum must be negative usage: idum = -k !(set idum < 0 to initialise) do i=1,nvals my_rand(i) = random(idum) end do
23 integer(k4b),
intent(inout) :: idum
26 integer(k4b),
save :: ix=-1,iy=-1,k
28 if (idum <=0 .or. iy < 0)
then 29 am = nearest(1.0,-1.0)/im
30 iy=ior(ieor(888889999,abs(idum)),1)
31 ix=ieor(777755555,abs(idum))
34 ix = ieor(ix,ishft(ix,13))
35 ix = ieor(ix,ishft(ix,-17))
36 ix = ieor(ix,ishft(ix,5))
39 if(iy < 0) iy = iy + im
40 random = am*ior(iand(im,ieor(ix,iy)),1)