1      DOUBLE PRECISION FUNCTION gennor(av,sd)
2C**********************************************************************
3C
4C     DOUBLE PRECISION FUNCTION GENNOR( AV, SD )
5C
6C         GENerate random deviate from a NORmal distribution
7C
8C
9C                              Function
10C
11C
12C     Generates a single random deviate from a normal distribution
13C     with mean, AV, and standard deviation, SD.
14C
15C
16C                              Arguments
17C
18C
19C     AV --> Mean of the normal distribution.
20C                              REAL AV
21C
22C     SD --> Standard deviation of the normal distribution.
23C                              REAL SD
24C     JJV                      (SD >= 0)
25C
26C     GENNOR <-- Generated normal deviate.
27C                              REAL GENNOR
28C
29C
30C                              Method
31C
32C
33C     Renames SNORM from TOMS as slightly modified by BWB to use RANF
34C     instead of SUNIF.
35C
36C     For details see:
37C               Ahrens, J.H. and Dieter, U.
38C               Extensions of Forsythe's Method for Random
39C               Sampling from the Normal Distribution.
40C               Math. Comput., 27,124 (Oct. 1973), 927 - 937.
41C
42C
43C**********************************************************************
44C     .. Scalar Arguments ..
45      DOUBLE PRECISION av,sd
46C     ..
47C     .. External Functions ..
48      DOUBLE PRECISION snorm
49      EXTERNAL snorm
50C     ..
51C     .. Executable Statements ..
52C     JJV added check to ensure SD >= 0.0
53      IF (sd.GE.0.0) GO TO 10
54      WRITE (*,*) 'SD < 0.0 in GENNOR - ABORT'
55      WRITE (*,*) 'Value of SD: ',sd
56      STOP 'SD < 0.0 in GENNOR - ABORT'
57
58 10   gennor = sd*snorm() + av
59      RETURN
60
61      END
62