! D01JAF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE d01jafe_mod ! D01JAF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. USE nag_library, ONLY : nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nout = 6 CONTAINS 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) ! .. Local Scalars .. REAL (KIND=nag_wp) :: a, rho ! .. Intrinsic Functions .. INTRINSIC sqrt ! .. Executable Statements .. rho = x(1) a = (1.0E0_nag_wp-rho)*(1.0E0_nag_wp+rho) IF (a/=0.0E0_nag_wp) THEN f = 1.0E0_nag_wp/sqrt(a) ELSE f = 0.0E0_nag_wp END IF RETURN END FUNCTION f END MODULE d01jafe_mod PROGRAM d01jafe ! D01JAF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : d01jaf, nag_wp USE d01jafe_mod, ONLY : f, nout ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. REAL (KIND=nag_wp) :: epsa, epsr, esterr, radius, & relest, result INTEGER :: icoord, ifail, method, ndim, & nevals ! .. Executable Statements .. WRITE (nout,*) 'D01JAF Example Program Results' radius = 1.0E0_nag_wp method = 0 icoord = 1 epsa = 0.0E0_nag_wp epsr = 0.5E-4_nag_wp TEST: DO ndim = 2, 4, 2 ifail = -1 CALL d01jaf(f,ndim,radius,epsa,epsr,method,icoord,result,esterr, & nevals,ifail) SELECT CASE (ifail) CASE (:-1) EXIT TEST CASE (0:3) relest = esterr/result WRITE (nout,*) WRITE (nout,99999) 'Dimension of the sphere =', ndim WRITE (nout,99998) 'Requested relative tolerance =', epsr WRITE (nout,99997) 'Approximation to the integral =', result WRITE (nout,99999) 'No. of function evaluations =', nevals WRITE (nout,99998) 'Estimated relative error =', relest END SELECT END DO TEST 99999 FORMAT (1X,A,I5) 99998 FORMAT (1X,A,E9.2) 99997 FORMAT (1X,A,F9.5) END PROGRAM d01jafe