1 | DOUBLE PRECISION FUNCTION RANNOR( A,B )
|
---|
2 |
|
---|
3 | C-----------------------------------------------------------------------
|
---|
4 | C RAN(DOM NUMBER) NOR(MALLY DISTRIBUTED)
|
---|
5 | C
|
---|
6 | C GENERATES NORMAL DISTRIBUTED RANDOM NUMBER
|
---|
7 | C DELIVERS 2 UNCORRELATED RANDOM NUMBERS,
|
---|
8 | C THEREFORE RANDOM CALLS ARE ONLY NECESSARY EVERY SECOND TIME.
|
---|
9 | C REFERENCE : NUMERICAL RECIPES, W.H. PRESS ET AL.,
|
---|
10 | C CAMBRIDGE UNIVERSITY PRESS, 1992 ISBN 0 521 43064 X
|
---|
11 | C THIS FUNCTION IS CALLED FROM HDPM, LEADDF, NIHILA, PARRAP, QGSTOR,
|
---|
12 | C UPDATE, AND VAPOR
|
---|
13 | C ARGUMENTS:
|
---|
14 | C A = MEAN VALUE
|
---|
15 | C B = STANDARD DEVIATION
|
---|
16 | C-----------------------------------------------------------------------
|
---|
17 |
|
---|
18 | IMPLICIT NONE
|
---|
19 | *KEEP,CONST.
|
---|
20 | COMMON /CONST/ PI,PI2,OB3,TB3,ENEPER
|
---|
21 | DOUBLE PRECISION PI,PI2,OB3,TB3,ENEPER
|
---|
22 | *KEEP,RANDPA.
|
---|
23 | COMMON /RANDPA/ FAC,U1,U2,RD,NSEQ,ISEED,KNOR
|
---|
24 | DOUBLE PRECISION FAC,U1,U2
|
---|
25 | REAL RD(3000)
|
---|
26 | INTEGER ISEED(103,10),NSEQ
|
---|
27 | LOGICAL KNOR
|
---|
28 | *KEEP,RUNPAR.
|
---|
29 | COMMON /RUNPAR/ FIXHEI,THICK0,HILOECM,HILOELB,
|
---|
30 | * STEPFC,NRRUN,NSHOW,PATAPE,MONIIN,
|
---|
31 | * MONIOU,MDEBUG,NUCNUC,
|
---|
32 | * CETAPE,
|
---|
33 | * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
|
---|
34 | * N1STTR,MDBASE,
|
---|
35 | * DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
|
---|
36 | * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
|
---|
37 | * ,GHEISH,GHESIG
|
---|
38 | COMMON /RUNPAC/ DSN,HOST,USER
|
---|
39 | DOUBLE PRECISION FIXHEI,THICK0,HILOECM,HILOELB
|
---|
40 | REAL STEPFC
|
---|
41 | INTEGER NRRUN,NSHOW,PATAPE,MONIIN,MONIOU,MDEBUG,NUCNUC,
|
---|
42 | * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
|
---|
43 | * N1STTR,MDBASE
|
---|
44 | INTEGER CETAPE
|
---|
45 | CHARACTER*79 DSN
|
---|
46 | CHARACTER*20 HOST,USER
|
---|
47 |
|
---|
48 | LOGICAL DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
|
---|
49 | * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
|
---|
50 | * ,GHEISH,GHESIG
|
---|
51 | *KEND.
|
---|
52 |
|
---|
53 | DOUBLE PRECISION A,B,RR
|
---|
54 | C-----------------------------------------------------------------------
|
---|
55 |
|
---|
56 | CC IF ( DEBUG ) WRITE(MDEBUG,100) SNGL(A),SNGL(B)
|
---|
57 | CC100 FORMAT(' RANNOR: A,B=',1P,2E10.3)
|
---|
58 | IF ( KNOR ) THEN
|
---|
59 | 1 CONTINUE
|
---|
60 | CALL RMMAR( RD,2,1 )
|
---|
61 | U1 = 2.D0*RD(1) - 1.D0
|
---|
62 | U2 = 2.D0*RD(2) - 1.D0
|
---|
63 | RR = U1**2 + U2**2
|
---|
64 | IF ( RR .GE. 1.D0 .OR. RR .EQ. 0.D0 ) GOTO 1
|
---|
65 | FAC = SQRT( -2.D0 * LOG(RR) / RR )
|
---|
66 |
|
---|
67 | RANNOR = FAC * U1 * B + A
|
---|
68 | KNOR = .FALSE.
|
---|
69 | ELSE
|
---|
70 | RANNOR = FAC * U2 * B + A
|
---|
71 | KNOR = .TRUE.
|
---|
72 | ENDIF
|
---|
73 | CC IF ( DEBUG ) WRITE(MDEBUG,101) RANNOR
|
---|
74 | CC101 FORMAT('+',34X,' RANNOR =',1P,E12.5)
|
---|
75 |
|
---|
76 | RETURN
|
---|
77 | END
|
---|