1 |
nikolas |
1.1 |
* |
2 |
|
|
* $Id: gpgaus.F,v 3.1.1.1 2002/07/11 16:02:00 cafagna Exp $ |
3 |
|
|
* |
4 |
|
|
* $Log: gpgaus.F,v $ |
5 |
|
|
* Revision 3.1.1.1 2002/07/11 16:02:00 cafagna |
6 |
|
|
* First GPAMELA release on CVS |
7 |
|
|
* |
8 |
|
|
* |
9 |
|
|
*CMZ : 2.01/00 05/04/2000 14.35.18 by Marialuigia Ambriola |
10 |
|
|
*CMZ : 2.00/00 03/03/2000 15.39.05 by Francesco Cafagna |
11 |
|
|
*CMZ : 1.01/00 06/05/96 12.57.18 by Francesco Cafagna |
12 |
|
|
*-- Author : Francesco Cafagna 03/05/96 |
13 |
|
|
REAL FUNCTION GPGAUS(XDUMMY) |
14 |
|
|
************************************************************************ |
15 |
|
|
* * |
16 |
|
|
* To generate a normally distribute deviate with zero mean and unit variance * |
17 |
|
|
* From GASDEV, Numerical recepies $7.3. * |
18 |
|
|
* Variables definition: * |
19 |
|
|
* IN: * |
20 |
|
|
* XDUMMY, dummy argument * |
21 |
|
|
* * |
22 |
|
|
* Called by:<USER> * |
23 |
|
|
* Author: Francesco Cafagna, 03/05/96 17.11.14 * |
24 |
|
|
* * |
25 |
|
|
************************************************************************ |
26 |
|
|
INTEGER ISET |
27 |
|
|
REAL V1,V2,GAS1,RVAL(2),R |
28 |
|
|
* |
29 |
|
|
DATA ISET/0/ |
30 |
|
|
* |
31 |
|
|
* Generate a random number in the circle of radius 1 |
32 |
|
|
* |
33 |
|
|
IF (ISET.EQ.0) THEN |
34 |
|
|
10 CALL GRNDM(RVAL,2) |
35 |
|
|
V1 = 2.*RVAL(1) -1. |
36 |
|
|
V2 = 2.*RVAL(2) -1. |
37 |
|
|
R = V1**2 + V2**2 |
38 |
|
|
IF(R.GE.1.) GO TO 10 |
39 |
|
|
GAS1 = V1 * SQRT(-2.*LOG(R)/R) |
40 |
|
|
GPGAUS = V2 * SQRT(-2.*LOG(R)/R) |
41 |
|
|
ISET = 1 |
42 |
|
|
ELSE |
43 |
|
|
GPGAUS = GAS1 |
44 |
|
|
ISET = 0 |
45 |
|
|
ENDIF |
46 |
|
|
* |
47 |
|
|
RETURN |
48 |
|
|
END |