C                                                            <HTML><PRE>
      FUNCTION RAN2 (IDUM)
C------------------------------------------------------------------------
C Function to generate a uniform random number between 0.0 and 1.0.
C Set idum to any negative number to initialize or reinitialize the
C sequence.  This routine is taken from Numerical Recipes, W.H. Press,
C B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling, Cambridge U Press,
C 1986.  See pp. 196-197 for notes about this routine.  Note that the
C principal limitation of this routine is that it returns only 714025
C possible values equally spaced between 0.0 and 1.0.
C
C------------------------

      PARAMETER (M=714025, IA=1366, IC=150889, RM=1./M)
      DIMENSION IR(97)
      SAVE IR,IY
      DATA IFF /0/
      IF (IDUM .LT. 0 .OR. IFF .EQ. 0) THEN
        IFF = 1
        IDUM = MOD(IC-IDUM,M)
C initialize the shuffle table
        DO 11 J = 1, 97
          IDUM = MOD(IA*IDUM+IC, M)
          IR(J) = IDUM
   11     CONTINUE
        IDUM = MOD(IA*IDUM+IC, M)
        IY = IDUM
      END IF
C
C start here except on initialization
      J = 1 + (97*IY) / M
      IF (J .GT. 97 .OR. J .LT. 1) STOP 'RAN2 ERROR'
      IY = IR(J)
      RAN2 = IY * RM
      IDUM = MOD (IA*IDUM+IC, M)
      IR(J) = IDUM
      RETURN
      END
C
C=======================================================================
C                                                                 </PRE>
