source: branches/start/MagicSoft/Simulation/Corsika/Mmcs/rmmar.f@ 18569

Last change on this file since 18569 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.1 KB
Line 
1 SUBROUTINE RMMAR( RVEC,LENV,ISEQ )
2
3C-----------------------------------------------------------------------
4C R(ANDO)M (NUMBER GENERATOR OF) MAR(SAGLIA TYPE)
5C
6C THESE ROUTINES (RMMAR,RMMAQ) ARE TAKEN FROM THE CERN LIBRARIES
7C DESCRIPTION OF ALGORITHM SEE THERE
8C THIS SUBROUTINE IS CALLED FROM MANY ROUTINES
9C ARGUMENTS:
10C RVEC = VECTOR FIELD TO BE FILLED WITH RANDOM NUMBERS
11C LENV = LENGTH OF VECTOR (# OF RANDNUMBERS TO BE GENERATED)
12C ISEQ = # OF RANDOM SEQUENCE
13C
14C CERN PROGLIB# V113 RMMAR .VERSION KERNFOR 1.0
15C ORIG. 01/03/89 FCA + FJ
16C-----------------------------------------------------------------------
17
18 REAL RVEC(*)
19 COMMON /RANMA2/ IU(1030),JSEQ
20 COMMON /RANMA3/ TWOM24,TWOM48,CD,CM,CINT,MODCNS
21 INTEGER I97(0:1030),J97(0:1030),NTOT(0:1030),NTOT2(0:1030),
22 * IJKL(0:1030)
23 REAL U(1030),C(0:1030)
24 EQUIVALENCE (IJKL(0),IU(1)),(NTOT(0),IU(2)),(NTOT2(0),IU(3))
25 EQUIVALENCE (U(1),IU(4)),(C(0),IU(101)),(I97(0),IU(102))
26 EQUIVALENCE (J97(0),IU(103))
27C-----------------------------------------------------------------------
28
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.