1
subroutine ntuple(x,a,b,ii,jconfig)
2
c-------------------------------------------------------
3
c Front to ranmar which allows user to easily
5
c------------------------------------------------------
10
double precision x,a,b
16
integer ij, kl, iseed1,iseed2
33
call get_offset(ioffset)
34
if (iseed .eq. 0) call get_base(iseed)
37
c Modified to allow for more sequences
38
c iseed can be between 0 and 31328*30081
39
c before pattern repeats
41
ij=1802+jconfig + mod(iseed,30081)
42
kl=9373+(iseed/31328)+ioffset
43
write(*,'(a,i6,a3,i6)') 'Using random seed offsets',jconfig," : ",ioffset
44
write(*,*) ' with seed', iseed
45
do while (ij .gt. 31328)
48
do while (kl .gt. 30081)
54
do while (x .lt. 1d-16)
60
subroutine get_base(iseed)
61
c-------------------------------------------------------
62
c Looks for file iproc.dat to offset random number gen
63
c------------------------------------------------------
87
do while(.not. done .and. level .lt. 5)
88
open(unit=lun,file=fname,status='old',err=15)
91
fname = '../' // fname
93
if (i .gt. 0) fname=fname(1:i-1)
96
read(lun,'(a)',end=24,err=24) fname
98
if (i .gt. 0) fname=fname(i+1:)
99
read(fname,*,err=26,end=26) iseed
101
c write(*,*) 'Read iseed from randinit ',iseed
106
c write(*,*) 'No base found using iseed=0'
109
subroutine get_offset(iseed)
110
c-------------------------------------------------------
111
c Looks for file iproc.dat to offset random number gen
112
c------------------------------------------------------
130
open(unit=lun,file='./iproc.dat',status='old',err=15)
131
read(lun,*,err=14) iseed
135
15 open(unit=lun,file='../iproc.dat',status='old',err=25)
136
read(lun,*,err=24) iseed
143
subroutine ranmar(rvec)
145
* universal random number generator proposed by marsaglia and zaman
146
* in report fsu-scri-87-50
147
* in this version rvec is a double precision variable.
148
implicit real*8(a-h,o-z)
149
common/ raset1 / ranu(97),ranc,rancd,rancm
150
common/ raset2 / iranmr,jranmr
151
save /raset1/,/raset2/
152
uni = ranu(iranmr) - ranu(jranmr)
153
if(uni .lt. 0d0) uni = uni + 1d0
157
if(iranmr .eq. 0) iranmr = 97
158
if(jranmr .eq. 0) jranmr = 97
160
if(ranc .lt. 0d0) ranc = ranc + rancm
162
if(uni .lt. 0d0) uni = uni + 1d0
166
subroutine rmarin(ij,kl)
168
* initializing routine for ranmar, must be called before generating
169
* any pseudorandom numbers with ranmar. the input values should be in
170
* the ranges 0<=ij<=31328 ; 0<=kl<=30081
171
implicit real*8(a-h,o-z)
172
common/ raset1 / ranu(97),ranc,rancd,rancm
173
common/ raset2 / iranmr,jranmr
174
save /raset1/,/raset2/
175
* this shows correspondence between the simplified input seeds ij, kl
176
* and the original marsaglia-zaman seeds i,j,k,l.
177
* to get the standard values in the marsaglia-zaman paper (i=12,j=34
178
* k=56,l=78) put ij=1802, kl=9373
179
write(*,*) "Ranmar initialization seeds",ij,kl
180
i = mod( ij/177 , 177 ) + 2
181
j = mod( ij , 177 ) + 2
182
k = mod( kl/169 , 178 ) + 1
188
m = mod( mod(i*j,179)*k , 179 )
192
l = mod( 53*l+1 , 169 )
193
if(mod(l*m,64) .ge. 32) s = s + t
198
ranc = 362436d0 / 16777216d0
199
rancd = 7654321d0 / 16777216d0
200
rancm = 16777213d0 / 16777216d0