1 | SUBROUTINE RMMAR( RVEC,LENV,ISEQ )
|
---|
2 |
|
---|
3 | C-----------------------------------------------------------------------
|
---|
4 | C R(ANDO)M (NUMBER GENERATOR OF) MAR(SAGLIA TYPE)
|
---|
5 | C
|
---|
6 | C THESE ROUTINES (RMMAR,RMMAQ) ARE TAKEN FROM THE CERN LIBRARIES
|
---|
7 | C DESCRIPTION OF ALGORITHM SEE THERE
|
---|
8 | C THIS SUBROUTINE IS CALLED FROM MANY ROUTINES
|
---|
9 | C ARGUMENTS:
|
---|
10 | C RVEC = VECTOR FIELD TO BE FILLED WITH RANDOM NUMBERS
|
---|
11 | C LENV = LENGTH OF VECTOR (# OF RANDNUMBERS TO BE GENERATED)
|
---|
12 | C ISEQ = # OF RANDOM SEQUENCE
|
---|
13 | C
|
---|
14 | C CERN PROGLIB# V113 RMMAR .VERSION KERNFOR 1.0
|
---|
15 | C ORIG. 01/03/89 FCA + FJ
|
---|
16 | C-----------------------------------------------------------------------
|
---|
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))
|
---|
27 | C-----------------------------------------------------------------------
|
---|
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.
|
---|
44 | C REPLACE EXACT ZEROES BY UNIFORM DISTR. *2**-24
|
---|
45 | IF ( UNI .EQ. 0. ) THEN
|
---|
46 | UNI = TWOM24*U(2)
|
---|
47 | C 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
|
---|