C   23/07/74 712221307  MEMBER NAME  NVERT    (S)           FORTRAN
C
C     PRODUCE NORMALLY DISTRIBUTED NUMBERS WITH SD S AROUND
C     MEAN VALUE AM
C     THE RESULT IS RETURNED IN V
C
C     GENERATE NORMAL DEVIATE BY COMPOSITION METHOD
C     OF AHRENS AND DIETER
C     THE AREA UNDER THE NORMAL CURVE IS DIVIDED INTO 5
C     DIFFERENT AREAS.
C
C     SOURCE FROM BOOK ' A GUIDE TO SIMULATION BY P. BRATLEY,
C     B.L. FOX AND L.E. SCHRAGE, SPRINGER-VERLAG, P. 318 '
C
C     INPUT : IX ( DUMMY )
C
C     AUXILIARY ROUTINE : UNIF(IX) FOR UNIFORM RANDOM NUMBERS
C
      SUBROUTINE NVERT(S,AM,V)
C
      UNIF(IX) = RN(DUM)
C
      U =  UNIF(IX)
      U0 = UNIF(IX)
      IF (U .GE. 0.919544) GOTO 160
C
C     AREA A , THE TRAPEZOID IN THE MIDDLE
C
      TRPNRM = 2.40376*( U0 + U*0.825339 ) - 2.11403
      V = AM + S*TRPNRM
      RETURN
C
  160 CONTINUE
      IF (U .LT. 0.965487) GOTO 210
C
C     AREA B
C
  180 CONTINUE
      TRPTMP = SQRT(4.46911 - 2.0*ALOG( UNIF(IX) ) )
      IF ( TRPTMP*UNIF(IX) .GT. 2.11403 ) GOTO 180
      GOTO 340
  210 CONTINUE
      IF (U .LT. 0.949991 ) GOTO 260
C
C     AREA C
C
  230 CONTINUE
      TRPTMP = 1.8404 + UNIF(IX) *0.273629
      IF ( 0.398942*EXP( -0.5*TRPTMP*TRPTMP) - 0.443299
     &     + TRPTMP*0.209694 .LT. UNIF(IX) * 4.27026E-2 ) GOTO 230
      GOTO 340
  260 CONTINUE
      IF (U .LT. 0.925852 ) GOTO 310
C
C     AREA D
C
  280 CONTINUE
      TRPTMP = 0.28973 + UNIF(IX)*1.55067
      IF ( 0.398942*EXP( -0.5*TRPTMP*TRPTMP) - 0.443299
     &     + TRPTMP*0.209694 .LT. UNIF(IX) * 1.59745E-2 ) GOTO 280
      GOTO 340
  310 CONTINUE
      TRPTMP = UNIF(IX)*0.28973
C
C     AREA E
C
      IF ( 0.398942*EXP( -0.5*TRPTMP*TRPTMP) - 0.382545
     &     .LT. UNIF(IX) * 1.63977E-2 ) GOTO 310
C
  340 IF (U0 .LE. 0.5) TRPTMP = -TRPTMP
      TRPNRM = TRPTMP
      V = AM + S*TRPNRM
      RETURN
      END
