*     G05YFF Example Program Text
*     Mark 21 Release. NAG Copyright 2004.
*     .. Parameters ..
      INTEGER          NOUT
      PARAMETER        (NOUT=6)
*     .. Local Scalars ..
      DOUBLE PRECISION SUM, VSBL
      INTEGER          I, IDIM, IFAIL, ISKIP, NTIMES
*     .. Local Arrays ..
      DOUBLE PRECISION QUASI(2,16)
      INTEGER          IREF(2000)
*     .. External Functions ..
      DOUBLE PRECISION FUN
      EXTERNAL         FUN
*     .. External Subroutines ..
      EXTERNAL         G05YEF, G05YFF
*     .. Intrinsic Functions ..
      INTRINSIC        DBLE
*     .. Executable Statements ..
      WRITE (NOUT,99999) 'G05YFF Example Program Results'
      IDIM = 15
      NTIMES = 5000
      IFAIL = 0
      ISKIP = 20
*
      CALL G05YEF(IDIM,IREF,ISKIP,IFAIL)
*
      SUM = 0.0D0
      DO 20 I = 1, NTIMES
*
         CALL G05YFF(2,QUASI,IREF,IFAIL)
*
         SUM = SUM + FUN(IDIM,QUASI,2)
   20 CONTINUE
      VSBL = SUM/DBLE(2*NTIMES)
      WRITE (NOUT,99999)
      WRITE (NOUT,99999) 'Value of integral = ', VSBL
      STOP
*
99999 FORMAT (A,F8.4)
      END
*
      DOUBLE PRECISION FUNCTION FUN(IDIM,X,N)
*     .. Scalar Arguments ..
      INTEGER                       IDIM, N
*     .. Array Arguments ..
      DOUBLE PRECISION              X(N,IDIM)
*     .. Local Scalars ..
      DOUBLE PRECISION              TMP, TMP1
      INTEGER                       J
*     .. Intrinsic Functions ..
      INTRINSIC                     ABS
*     .. Executable Statements ..
      TMP = 1.0D0
      TMP1 = 1.0D0
      DO 20 J = 1, IDIM
         TMP = TMP*ABS(4.0D0*X(1,J)-2.0D0)
         TMP1 = TMP1*ABS(4.0D0*X(2,J)-2.0D0)
   20 CONTINUE
      FUN = TMP + TMP1
      RETURN
      END
