source: trunk/MagicSoft/Simulation/Corsika/Mmcs/grndm.f@ 10099

Last change on this file since 10099 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: 2.0 KB
Line 
1 SUBROUTINE GRNDM(RVEC,LENV)
2
3C-----------------------------------------------------------------------
4C G(ENERATOR OF) R(A)ND(O)M (NUMBERS)
5C
6C THIS ROUTINE IS IDENTICAL TO RMMAR
7C DESCRIPTION OF ALGORITHM SEE SUBROUTINE RMMAR
8C THIS SUBROUTINE IS CALLED FROM GHEISHA ROUTINES
9C ARGUMENTS:
10C RVEC = VECTOR FIELD TO BE FILLED WITH RANDOM NUMBERS
11C LENV = LENGTH OF VECTOR (# OF RANDNUMBERS TO BE GENERATED)
12C
13C CERN PROGLIB# V113 RMMAR .VERSION KERNFOR 1.0
14C ORIG. 01/03/89 FCA + FJ
15C-----------------------------------------------------------------------
16
17 REAL RVEC(*)
18 COMMON /RANMA2/ IU(1030),JSEQ
19 COMMON /RANMA3/ TWOM24,TWOM48,CD,CM,CINT,MODCNS
20 INTEGER I97(0:1030),J97(0:1030),NTOT(0:1030),NTOT2(0:1030),
21 * IJKL(0:1030)
22 REAL U(1030),C(0:1030)
23 EQUIVALENCE (IJKL(0),IU(1)),(NTOT(0),IU(2)),(NTOT2(0),IU(3))
24 EQUIVALENCE (U(1),IU(4)),(C(0),IU(101)),(I97(0),IU(102))
25 EQUIVALENCE (J97(0),IU(103))
26C-----------------------------------------------------------------------
27
28 ISEQ = 1
29 IF ( ISEQ .GT. 0 ) JSEQ = ISEQ
30 IBASE = (JSEQ-1)*103
31
32 DO 100 IVEC = 1,LENV
33 UNI = U(IBASE+I97(IBASE))-U(IBASE+J97(IBASE))
34 IF ( UNI .LT. 0. ) UNI = UNI+1.
35 U(IBASE+I97(IBASE)) = UNI
36 I97(IBASE) = I97(IBASE)-1
37 IF ( I97(IBASE) .EQ. 0 ) I97(IBASE) = 97
38 J97(IBASE) = J97(IBASE)-1
39 IF ( J97(IBASE) .EQ. 0 ) J97(IBASE) = 97
40 C(IBASE) = C(IBASE) - CD
41 IF ( C(IBASE) .LT. 0. ) C(IBASE) = C(IBASE)+CM
42 UNI = UNI-C(IBASE)
43 IF ( UNI .LT. 0. ) UNI = UNI+1.
44C REPLACE EXACT ZEROES BY UNIFORM DISTR. *2**-24
45 IF ( UNI .EQ. 0. ) THEN
46 UNI = TWOM24*U(2)
47C AN EXACT ZERO HERE IS VERY UNLIKELY, BUT LET'S BE SAFE.
48 IF ( UNI .EQ. 0. ) UNI = TWOM48
49 ENDIF
50 RVEC(IVEC) = UNI
51 100 CONTINUE
52
53 NTOT(IBASE) = NTOT(IBASE) + LENV
54 IF ( NTOT(IBASE) .GE. MODCNS ) THEN
55 NTOT2(IBASE) = NTOT2(IBASE) + 1
56 NTOT(IBASE) = NTOT(IBASE) - MODCNS
57 ENDIF
58
59 RETURN
60 END
Note: See TracBrowser for help on using the repository browser.