source: trunk/MagicSoft/Simulation/Corsika/Mmcs/rangen.f@ 526

Last change on this file since 526 was 286, checked in by harald, 25 years ago
This is the start point for further developments of the Magic Monte Carlo Simulation written by Jose Carlos Gonzales. Now it is under control of one CVS repository for the whole collaboration. Everyone should use this CVS repository for further developments.
File size: 1.9 KB
Line 
1 FUNCTION RANGEN()
2
3C-----------------------------------------------------------------------
4C RAN(DOM NUMBER) GEN(ERATOR)
5C
6C SEE SUBROUTINE RMMAR
7C THIS FUNCTION IS CALLED FROM MANY VENUS ROUTINES
8C
9C CERN PROGLIB# V113 RMMAR .VERSION KERNFOR 1.0
10C ORIG. 01/03/89 FCA + FJ
11C
12C CHANGES : D. HECK IK3 FZK KARLSRUHE
13C DATE : FEB 02, 1994
14C-----------------------------------------------------------------------
15
16C REAL RVEC(1)
17 COMMON /RANMA2/ IU(1030),JSEQ
18 COMMON /RANMA3/ TWOM24,TWOM48,CD,CM,CINT,MODCNS
19 INTEGER I97(0:1030),J97(0:1030),NTOT(0:1030)
20 INTEGER NTOT2(0:1030),IJKL(0:1030)
21 REAL U(97),C(0:1030)
22 EQUIVALENCE (IJKL(0),IU(1)),(NTOT(0),IU(2)),(NTOT2(0),IU(3))
23 EQUIVALENCE (U(1),IU(4)),(C(0),IU(101)),(I97(0),IU(102))
24 EQUIVALENCE (J97(0),IU(103))
25C-----------------------------------------------------------------------
26
27C ISEQ = 1
28 LENV = 1
29C IF ( ISEQ .GT. 0 ) JSEQ = ISEQ
30C IBASE = (JSEQ-1)*103
31 IBASE = 0
32
33 IVEC = 1
34C DO 100 IVEC = 1,LENV
35 UNI = U( +I97(IBASE))-U( +J97(IBASE))
36 IF ( UNI .LT. 0. ) UNI = UNI+1.
37 U( +I97(IBASE)) = UNI
38 I97(IBASE) = I97(IBASE)-1
39 IF ( I97(IBASE) .EQ. 0 ) I97(IBASE) = 97
40 J97(IBASE) = J97(IBASE)-1
41 IF ( J97(IBASE) .EQ. 0 ) J97(IBASE) = 97
42 C(IBASE) = C(IBASE) - CD
43 IF ( C(IBASE) .LT. 0. ) C(IBASE) = C(IBASE)+CM
44 UNI = UNI-C(IBASE)
45 IF ( UNI .LT. 0. ) UNI = UNI+1.
46C REPLACE EXACT ZEROES BY UNIFORM DISTR. *2**-24
47 IF ( UNI .EQ. 0. ) THEN
48 UNI = TWOM24*U(2)
49C AN EXACT ZERO HERE IS VERY UNLIKELY, BUT LET'S BE SAFE.
50 IF ( UNI .EQ. 0. ) UNI = TWOM48
51 ENDIF
52 RANGEN = UNI
53 100 CONTINUE
54
55 NTOT(IBASE) = NTOT(IBASE) + LENV
56 IF ( NTOT(IBASE) .GE. MODCNS ) THEN
57 NTOT2(IBASE) = NTOT2(IBASE) + 1
58 NTOT(IBASE) = NTOT(IBASE) - MODCNS
59 ENDIF
60
61 RETURN
62 END
Note: See TracBrowser for help on using the repository browser.