* D01GCF Example Program Text * Mark 14 Revised. NAG Copyright 1989. * .. Parameters .. INTEGER NDIM PARAMETER (NDIM=4) INTEGER NOUT PARAMETER (NOUT=6) * .. Local Scalars .. DOUBLE PRECISION ERR, RES INTEGER IFAIL, ITRANS, NPTS, NRAND * .. Local Arrays .. DOUBLE PRECISION VK(NDIM) * .. External Functions .. DOUBLE PRECISION F EXTERNAL F * .. External Subroutines .. EXTERNAL D01GCF, REGION * .. Executable Statements .. WRITE (NOUT,*) 'D01GCF Example Program Results' NPTS = 2 ITRANS = 0 NRAND = 4 IFAIL = 1 * CALL D01GCF(NDIM,F,REGION,NPTS,VK,NRAND,ITRANS,RES,ERR,IFAIL) * IF (IFAIL.EQ.0) THEN WRITE (NOUT,*) WRITE (NOUT,99999) 'Result =', RES, ' Standard error =', ERR ELSE WRITE (NOUT,*) WRITE (NOUT,99998) ' ** D01GBF returned with IFAIL = ', IFAIL END IF * 99999 FORMAT (1X,A,F13.5,A,E10.2) 99998 FORMAT (1X,A,I5) END * SUBROUTINE REGION(N,X,J,A,B) * .. Scalar Arguments .. DOUBLE PRECISION A, B INTEGER J, N * .. Array Arguments .. DOUBLE PRECISION X(N) * .. Executable Statements .. A = 0.0D0 B = 1.0D0 RETURN END * DOUBLE PRECISION FUNCTION F(NDIM,X) * .. Scalar Arguments .. INTEGER NDIM * .. Array Arguments .. DOUBLE PRECISION X(NDIM) * .. Local Scalars .. DOUBLE PRECISION SUM INTEGER J * .. Intrinsic Functions .. INTRINSIC COS, DBLE * .. Executable Statements .. SUM = 0.0D0 DO 20 J = 1, NDIM SUM = SUM + X(J) 20 CONTINUE F = COS(0.5D0+2.0D0*SUM-DBLE(NDIM)) RETURN END