! D01GDF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE d01gdfe_mod ! D01GDF 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 vecfun(ndim,x,fv,m) ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: m, ndim ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (OUT) :: fv(m) REAL (KIND=nag_wp), INTENT (IN) :: x(m,ndim) ! .. Local Scalars .. INTEGER :: i ! .. Intrinsic Functions .. INTRINSIC cos, real, sum ! .. Executable Statements .. DO i = 1, m fv(i) = cos(0.5E0_nag_wp+2.0E0_nag_wp*sum(x(i, & 1:ndim))-real(ndim,kind=nag_wp)) END DO RETURN END SUBROUTINE vecfun SUBROUTINE vecreg(ndim,x,j,c,d,m) ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: j, m, ndim ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (OUT) :: c(m), d(m) REAL (KIND=nag_wp), INTENT (IN) :: x(m,ndim) ! .. Executable Statements .. c(1:m) = 0.0E0_nag_wp d(1:m) = 1.0E0_nag_wp RETURN END SUBROUTINE vecreg END MODULE d01gdfe_mod PROGRAM d01gdfe ! D01GDF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : d01gdf, nag_wp USE d01gdfe_mod, ONLY : ndim, nout, vecfun, vecreg ! .. 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,*) 'D01GDF Example Program Results' npts = 2 itrans = 0 nrand = 4 ifail = 0 CALL d01gdf(ndim,vecfun,vecreg,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 d01gdfe