RANL_SKIP64(3dxml) — Subroutines
Name
ranl_skip64 − Routine to skip forward a given number, d, of seeds for the RANL and RANL_NORMAL random number generators
FORMAT
RANL_SKIP64 (d, s1, s2, s1_new, s2_new)
Arguments
dinteger∗8
On entry, an integer d>0 specifying the number d of seeds to skip starting at (s1,s2) in the L’Ecuyer algorithm.
s1integer∗4
On entry, a starting seed s1>=1.
s2integer∗4
On entry, a starting seed s2>=1.
s1_newinteger∗4
On exit, a new starting seed d iterations away from s1.
s2_newinteger∗4
On exit, a new starting seed d iterations away from s2.
Description
The RANL_SKIP64 routine is used to get starting seeds for parallel, independent streams of random numbers. The new starting seeds are computed using the following algorithms:
s1_new = a1∗∗d∗s1 mod m1
s2_new = a2∗∗d∗s2 mod m2
where a1,a2,m1,m2 are the constants defining the L’Ecuyer method.
This example calls RANL_SKIP64 to set up separate seeds for 4 streams, (nprocs=4), from RANL_NORMAL. It computes the averages per stream.
Example
integer nprocs,n
integer∗8 hop
parameter (nprocs=4)
parameter (n=16384,hop=1000000)
integer∗4 j,k,nsum
real∗4 v(n,nprocs)
integer∗4 s1val(nprocs),s2val(nprocs)
real∗4 sum1(nprocs)
c get seeds (hop apart) for separate streams
s1val(1)=1
s2val(1)=1
nsum=12
do j=2,nprocs
call ranl_skip64(hop,s1val(j-1),s2val(j-1),s1val(j),s2val(j))
end do
c parallel calls to ranl_normal can be done with KAP directives:
C∗$∗ ASSERT CONCURRENT CALL
C∗$∗ ASSERT DO (CONCURRENT)
do j=1,nprocs
call ranl_normal(s1val(j),s2val(j),nsum,v(1,j),n)
sum1(j)=0.0
do k=1,n
sum1(j)=sum1(j)+v(k,j)
end do
end do
print∗,’ per-stream averages’
do j=1,nprocs
print∗,sum1(j)/n
end do
end