1 |
|
|
! |
2 |
|
|
! $Id: ran1.F 2239 2015-03-23 07:27:30Z emillour $ |
3 |
|
|
! |
4 |
|
5379 |
FUNCTION RAN1(IDUM) |
5 |
|
|
IMPLICIT NONE |
6 |
|
|
REAL RAN1 |
7 |
|
|
REAL,SAVE :: R(97) |
8 |
|
|
REAL,PARAMETER :: RM1=3.8580247E-6,RM2=7.4373773E-6 |
9 |
|
|
INTEGER,SAVE :: IFF=0 |
10 |
|
|
integer,save :: ix1,ix2,ix3 |
11 |
|
|
INTEGER,PARAMETER :: M1=259200,IA1=7141,IC1=54773 |
12 |
|
|
INTEGER,PARAMETER :: M2=134456,IA2=8121,IC2=28411 |
13 |
|
|
INTEGER,PARAMETER :: M3=243000,IA3=4561,IC3=51349 |
14 |
|
|
INTEGER :: IDUM,J |
15 |
|
|
|
16 |
✓✓✗✓
|
5379 |
IF (IDUM.LT.0.OR.IFF.EQ.0) THEN |
17 |
|
1 |
IFF=1 |
18 |
|
1 |
IX1=MOD(IC1-IDUM,M1) |
19 |
|
1 |
IX1=MOD(IA1*IX1+IC1,M1) |
20 |
|
1 |
IX2=MOD(IX1,M2) |
21 |
|
1 |
IX1=MOD(IA1*IX1+IC1,M1) |
22 |
|
1 |
IX3=MOD(IX1,M3) |
23 |
✓✓ |
98 |
DO 11 J=1,97 |
24 |
|
97 |
IX1=MOD(IA1*IX1+IC1,M1) |
25 |
|
97 |
IX2=MOD(IA2*IX2+IC2,M2) |
26 |
|
97 |
R(J)=(REAL(IX1)+REAL(IX2)*RM2)*RM1 |
27 |
|
1 |
11 CONTINUE |
28 |
|
1 |
IDUM=1 |
29 |
|
|
ENDIF |
30 |
|
5379 |
IX1=MOD(IA1*IX1+IC1,M1) |
31 |
|
5379 |
IX2=MOD(IA2*IX2+IC2,M2) |
32 |
|
5379 |
IX3=MOD(IA3*IX3+IC3,M3) |
33 |
|
5379 |
J=1+(97*IX3)/M3 |
34 |
✗✓ |
5379 |
IF(J.GT.97.OR.J.LT.1) stop 1 |
35 |
|
5379 |
RAN1=R(J) |
36 |
|
5379 |
R(J)=(REAL(IX1)+REAL(IX2)*RM2)*RM1 |
37 |
|
|
RETURN |
38 |
|
|
END |