ccccccccccccccccccccccccc     Program 2.14     ccccccccccccccccccccccccc
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c                                                                      c
c Please Note:                                                         c
c                                                                      c
c (1) This computer program is part of the book, "An Introduction to   c
c     Computational Physics," written by Tao Pang and published and    c
c     copyrighted by Cambridge University Press in 1997.               c
c                                                                      c
c (2) No warranties, express or implied, are made for this program.    c
c                                                                      c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
      SUBROUTINE PERCOLATION (L,N,M,P)
      LOGICAL L(N,M)
      COMMON/CSEED/ ISEED
      DO      200  I = 1, N
        DO    100  J = 1, M
          R = RANF()
          IF(R.LT.P) THEN
            L(I,J) = .TRUE.
          ELSE
            L(I,J) = .FALSE.
          END IF
  100   CONTINUE
  200 CONTINUE
      RETURN
      END
C
      FUNCTION RANF()
      DATA IA/16807/,IC/2147483647/,IQ/127773/,IR/2836/
      COMMON /CSEED/ ISEED
        IH = ISEED/IQ
        IL = MOD(ISEED,IQ)
        IT = IA*IL-IR*IH
        IF(IT.GT.0) THEN
          ISEED = IT
        ELSE
          ISEED = IC+IT
        END IF
        RANF() = ISEED/FLOAT(IC)
      RETURN
      END
