Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rlu.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file rlu.f
1 
2 C*********************************************************************
3 
4  FUNCTION rlu(IDUM)
5 
6 C...Purpose: to generate random numbers uniformly distributed between
7 C...0 and 1, excluding the endpoints.
8  common/ludatr/mrlu(6),rrlu(100)
9  SAVE /ludatr/
10  equivalence(mrlu1,mrlu(1)),(mrlu2,mrlu(2)),(mrlu3,mrlu(3)),
11  &(mrlu4,mrlu(4)),(mrlu5,mrlu(5)),(mrlu6,mrlu(6)),
12  &(rrlu98,rrlu(98)),(rrlu99,rrlu(99)),(rrlu00,rrlu(100))
13 
14 C...Initialize generation from given seed.
15  IF(mrlu2.EQ.0) THEN
16  ij=mod(mrlu1/30082,31329)
17  kl=mod(mrlu1,30082)
18  i=mod(ij/177,177)+2
19  j=mod(ij,177)+2
20  k=mod(kl/169,178)+1
21  l=mod(kl,169)
22  DO 110 ii=1,97
23  s=0.
24  t=0.5
25  DO 100 jj=1,24
26  m=mod(mod(i*j,179)*k,179)
27  i=j
28  j=k
29  k=m
30  l=mod(53*l+1,169)
31  IF(mod(l*m,64).GE.32) s=s+t
32  100 t=0.5*t
33  110 rrlu(ii)=s
34  twom24=1.
35  DO 120 i24=1,24
36  120 twom24=0.5*twom24
37  rrlu98=362436.*twom24
38  rrlu99=7654321.*twom24
39  rrlu00=16777213.*twom24
40  mrlu2=1
41  mrlu3=0
42  mrlu4=97
43  mrlu5=33
44  ENDIF
45 
46 C...Generate next random number.
47  130 runi=rrlu(mrlu4)-rrlu(mrlu5)
48  IF(runi.LT.0.) runi=runi+1.
49  rrlu(mrlu4)=runi
50  mrlu4=mrlu4-1
51  IF(mrlu4.EQ.0) mrlu4=97
52  mrlu5=mrlu5-1
53  IF(mrlu5.EQ.0) mrlu5=97
54  rrlu98=rrlu98-rrlu99
55  IF(rrlu98.LT.0.) rrlu98=rrlu98+rrlu00
56  runi=runi-rrlu98
57  IF(runi.LT.0.) runi=runi+1.
58  IF(runi.LE.0.OR.runi.GE.1.) goto 130
59 
60 C...Update counters. Random number to output.
61  mrlu3=mrlu3+1
62  IF(mrlu3.EQ.1000000000) THEN
63  mrlu2=mrlu2+1
64  mrlu3=0
65  ENDIF
66  rlu=runi
67 
68  RETURN
69  END