source: trunk/MagicSoft/Simulation/Corsika/Mmcs/rannor.f

Last change on this file 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.7 KB
Line 
1 DOUBLE PRECISION FUNCTION RANNOR( A,B )
2
3C-----------------------------------------------------------------------
4C RAN(DOM NUMBER) NOR(MALLY DISTRIBUTED)
5C
6C GENERATES NORMAL DISTRIBUTED RANDOM NUMBER
7C DELIVERS 2 UNCORRELATED RANDOM NUMBERS,
8C THEREFORE RANDOM CALLS ARE ONLY NECESSARY EVERY SECOND TIME.
9C REFERENCE : NUMERICAL RECIPES, W.H. PRESS ET AL.,
10C CAMBRIDGE UNIVERSITY PRESS, 1992 ISBN 0 521 43064 X
11C THIS FUNCTION IS CALLED FROM HDPM, LEADDF, NIHILA, PARRAP, QGSTOR,
12C UPDATE, AND VAPOR
13C ARGUMENTS:
14C A = MEAN VALUE
15C B = STANDARD DEVIATION
16C-----------------------------------------------------------------------
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
54C-----------------------------------------------------------------------
55
56CC IF ( DEBUG ) WRITE(MDEBUG,100) SNGL(A),SNGL(B)
57CC100 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
73CC IF ( DEBUG ) WRITE(MDEBUG,101) RANNOR
74CC101 FORMAT('+',34X,' RANNOR =',1P,E12.5)
75
76 RETURN
77 END
Note: See TracBrowser for help on using the repository browser.