35 integer :: rand_inst = 0
36 integer,
parameter :: krand = kind(1.d0)
37 integer :: rand_feedback = 1
41 subroutine initrandom(i, i2)
43 integer,
optional,
intent(in) :: i
44 integer,
optional,
intent(in) :: i2
46 character(len=10) :: fred
54 if (seed_in /=-1)
then
57 if (i2 > 30081) stop
'initRandom:second seed too large'
63 call system_clock(count=ij)
64 ij = mod(ij + rand_inst*100, 31328)
65 call date_and_time(time=fred)
66 read (fred,
'(e10.3)') klr
67 kl = mod(int(klr*1000), 30081)
70 if (rand_feedback > 0 )
write(*,
'(" Random seeds:",1I6,",",1I6," rand_inst:",1I4)') ij,kl,rand_inst
73 end subroutine initrandom
83 real(dl),
intent(in) :: a
84 real(dl),
intent(in) :: b
100 real(dl) :: R, V1, V2, FAC
101 integer ,
save :: iset = 0
102 real(dl),
save :: gset
106 do while (r >= 1._dl)
111 fac = sqrt(-2.d0*log(r)/r)
131 real(dl),
intent(in) :: mu
132 real(dl),
intent(in) :: sigma
189 subroutine rmarin(IJ,KL)
208 double precision U(97), C, CD, CM, S, T
209 integer I97, J97,i,j,k,l,m
216 common /raset1/ u, c, cd, cm, i97, j97
217 if( ij < 0 .or. ij > 31328 .or. &
218 kl < 0 .or. kl > 30081 )
then
219 print
'(A)',
' The first random number seed must have a value between 0 and 31328'
220 print
'(A)',
' The second seed must have a value between 0 and 30081'
223 i = mod(ij/177, 177) + 2
224 j = mod(ij , 177) + 2
225 k = mod(kl/169, 178) + 1
231 m = mod(mod(i*j, 179)*k, 179)
236 if (mod(l*m, 64) >= 32)
then
245 c = 362436.0 / 16777216.0
246 cd = 7654321.0 / 16777216.0
247 cm = 16777213.0 /16777216.0
251 end subroutine rmarin
259 double precision function ranmar()
261 double precision U(97), C, CD, CM
265 common /raset1/ u, c, cd, cm, i97, j97
267 uni = u(i97) - u(j97)
268 if( uni < 0.0 ) uni = uni + 1.0
271 if(i97 == 0) i97 = 97
273 if(j97 == 0) j97 = 97
275 if( c < 0.d0 ) c = c + cm
277 if( uni < 0.d0 ) uni = uni + 1.0
This module contains the subroutine and functions to generate random numbers from different distribut...
real(dl) function random_uniform(a, b)
This function returns a random number generated from the uniform distribution in [a,b(. To improve performances no check is done in order to ensure that the random number generator is initialised.
real(dl) function random_gaussian(mu, sigma)
This function returns a random number generated from the gaussian distribution with mean mu and varia...
double precision function ranmar()
This function returns a random number generated from the uniform distribution in [0,1( This is the random number generator proposed by George Marsaglia in Florida State University Report: FSU-SCRI-87-50 It was slightly modified by F. James to produce an array of pseudorandom numbers.
real(dl) function gaussian_1()
This function returns a random number generated from the gaussian distribution with mean zero and var...