source: trunk/MagicSoft/Simulation/Corsika/Mmcs/rmmaq.f@ 502

Last change on this file since 502 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: 3.7 KB
Line 
1 SUBROUTINE RMMAQ( ISEED,ISEQ,CHOPT )
2
3C-----------------------------------------------------------------------
4C R(ANDO)M (NUMBER GENERATOR OF) MA(RSAGLIA TYPE INITIALISATION)
5C
6C ROUTINE FOR INITIALIZATION OF RMMAR
7C THIS SUBROUTINE IS CALLED FROM MAIN AND START
8C ARGUMENTS:
9C ISEED = SEED TO INITIALIZE A SEQUENCE
10C ISEQ = # OF RANDOM SEQUENCE
11C CHOPT = CHARACTER TO STEER INITIALIZATION OPTIONS
12C
13C CERN PROGLIB# V113 RMMAQ .VERSION KERNFOR 1.0
14C ORIG. 01/03/89 FCA + FJ
15C-----------------------------------------------------------------------
16
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),NTOT2(0:1030),
20 * IJKL(0:1030)
21 REAL U(1030),C(0:1030),UU(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))
25 INTEGER ISEED(*)
26 CHARACTER CHOPT*(*), CCHOPT*12
27 LOGICAL FIRST
28 DATA FIRST / .TRUE. /
29C-----------------------------------------------------------------------
30
31 IF ( FIRST ) THEN
32 TWOM24 = 2.**(-24)
33 TWOM48 = 2.**(-48)
34 CD = 7654321.*TWOM24
35 CM = 16777213.*TWOM24
36 CINT = 362436.*TWOM24
37 MODCNS = 1000000000
38 FIRST = .FALSE.
39 ENDIF
40
41 CCHOPT = CHOPT
42 IF ( CCHOPT .EQ. ' ' ) THEN
43 ISEED(1) = 54217137
44 ISEED(2) = 0
45 ISEED(3) = 0
46 CCHOPT = 'S'
47 JSEQ = 1
48 ENDIF
49
50 IF ( INDEX(CCHOPT,'S') .NE. 0 ) THEN
51 IF ( ISEQ .GT. 0 ) JSEQ = ISEQ
52 IBASE = (JSEQ-1)*103
53 IF ( INDEX(CCHOPT,'V') .NE. 0 ) THEN
54 DO 10 JJ = 1,103
55 IU(IBASE+JJ) = ISEED(JJ)
56 10 CONTINUE
57 ELSE
58 IJKL(IBASE) = ISEED(1)
59 NTOT(IBASE) = ISEED(2)
60 NTOT2(IBASE) = ISEED(3)
61 IJ = IJKL(IBASE) / 30082
62 KL = IJKL(IBASE) - 30082*IJ
63 I = MOD(IJ/177, 177) + 2
64 J = MOD(IJ, 177) + 2
65 K = MOD(KL/169, 178) + 1
66 L = MOD(KL, 169)
67 DO 30 II = 1,97
68 S = 0.
69 T = .5
70 DO 20 JJ = 1,24
71 M = MOD(MOD(I*J,179)*K, 179)
72 I = J
73 J = K
74 K = M
75 L = MOD(53*L+1, 169)
76 IF ( MOD(L*M,64) .GE. 32 ) S = S+T
77 T = 0.5*T
78 20 CONTINUE
79 UU(II) = S
80 30 CONTINUE
81 CC = CINT
82 II97 = 97
83 IJ97 = 33
84C COMPLETE INITIALIZATION BY SKIPPING (NTOT2*MODCNS+NTOT) RANDOMNUMBERS
85 NITER = MODCNS
86 DO 50 LOOP2 = 1,NTOT2(IBASE)+1
87 IF ( LOOP2 .GT.N TOT2(IBASE) ) NITER = NTOT(IBASE)
88 DO 40 IDUM = 1,NITER
89 UNI = UU(II97)-UU(IJ97)
90 IF ( UNI .LT. 0. ) UNI = UNI+1.
91 UU(II97) = UNI
92 II97 = II97-1
93 IF ( II97 .EQ. 0 ) II97 = 97
94 IJ97 = IJ97-1
95 IF ( IJ97 .EQ. 0 ) IJ97 = 97
96 CC = CC - CD
97 IF ( CC .LT. 0. ) CC = CC+CM
98 40 CONTINUE
99 50 CONTINUE
100 I97(IBASE) = II97
101 J97(IBASE) = IJ97
102 C(IBASE) = CC
103 DO 60 JJ = 1,97
104 U(IBASE+JJ) = UU(JJ)
105 60 CONTINUE
106 ENDIF
107 ELSEIF ( INDEX(CCHOPT,'R') .NE. 0 ) THEN
108 IF ( ISEQ .GT. 0 ) THEN
109 JSEQ = ISEQ
110 ELSE
111 ISEQ = JSEQ
112 ENDIF
113 IBASE = (JSEQ-1)*103
114 IF ( INDEX(CCHOPT,'V') .NE. 0 ) THEN
115 NCOPY = 103
116 ELSE
117 NCOPY = 3
118 ENDIF
119 DO 70 JJ = 1,NCOPY
120 ISEED(JJ) = IU(IBASE+JJ)
121 70 CONTINUE
122 ENDIF
123 RETURN
124 END
Note: See TracBrowser for help on using the repository browser.