! D01GCF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE d01gcfe_mod ! D01GCF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. USE nag_library, ONLY : nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: ndim = 4, nout = 6 CONTAINS SUBROUTINE region(ndim,x,j,c,d) ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. REAL (KIND=nag_wp), INTENT (OUT) :: c, d INTEGER, INTENT (IN) :: j, ndim ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (IN) :: x(ndim) ! .. Executable Statements .. c = 0.0E0_nag_wp d = 1.0E0_nag_wp RETURN END SUBROUTINE region FUNCTION f(ndim,x) ! .. Implicit None Statement .. IMPLICIT NONE ! .. Function Return Value .. REAL (KIND=nag_wp) :: f ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: ndim ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (IN) :: x(ndim) ! .. Intrinsic Functions .. INTRINSIC cos, real, sum ! .. Executable Statements .. f = cos(0.5E0_nag_wp+2.0E0_nag_wp*sum(x(1:ndim))-real(ndim,kind= & nag_wp)) RETURN END FUNCTION f END MODULE d01gcfe_mod PROGRAM d01gcfe ! D01GCF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : d01gcf, nag_wp USE d01gcfe_mod, ONLY : f, ndim, nout, region ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. REAL (KIND=nag_wp) :: err, res INTEGER :: ifail, itrans, npts, nrand ! .. Local Arrays .. REAL (KIND=nag_wp) :: vk(ndim) ! .. Executable Statements .. WRITE (nout,*) 'D01GCF Example Program Results' npts = 2 itrans = 0 nrand = 4 ifail = 0 CALL d01gcf(ndim,f,region,npts,vk,nrand,itrans,res,err,ifail) WRITE (nout,*) WRITE (nout,99999) 'Result =', res, ' Standard error =', err 99999 FORMAT (1X,A,F13.5,A,E10.2) END PROGRAM d01gcfe