      PROGRAM PIG
C     (c) Riccardo Fazio, January 14, 1999  rfazio@dipmat.unime.it      
C     VALORE DI PI
      DATA PI /3.141592653589793238462643383280/
C
      AREA=0
      L=79
      DO 50 K=1,1000000
         X=RANDOM(L)
         Y=RANDOM(L)
c         PRINT*, X, Y
         IF(Y.LE.SQRT(1.-X*X))  AREA=AREA+4
         PICAL=AREA/FLOAT(K)
         ERELA=ABS(PICAL-PI)/PI
C         PRINT*, K,PICAL,ERELA
         IF (MOD(K,100000).EQ.0) PRINT*, K, PICAL, ERELA
50    CONTINUE
      PRINT*, PI   
      STOP
      END

      FUNCTION RANDOM(L)
      L = MOD(16807*L,2147483647)
      RANDOM = ABS(REAL(L)*4.6566128752458E-10)      
      RETURN
      END 
