! D01AHF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE d01ahfe_mod ! D01AHF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. USE nag_library, ONLY : nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 CONTAINS FUNCTION f(x) ! .. Implicit None Statement .. IMPLICIT NONE ! .. Function Return Value .. REAL (KIND=nag_wp) :: f ! .. Scalar Arguments .. REAL (KIND=nag_wp), INTENT (IN) :: x ! .. Executable Statements .. f = 4.0E0_nag_wp/(1.0E0_nag_wp+x*x) RETURN END FUNCTION f END MODULE d01ahfe_mod PROGRAM d01ahfe ! D01AHF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : d01ahf, nag_wp USE d01ahfe_mod, ONLY : f, nin, nout ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. REAL (KIND=nag_wp) :: a, ans, b, epsr, relerr INTEGER :: ifail, nlimit, npts ! .. Executable Statements .. WRITE (nout,*) 'D01AHF Example Program Results' READ (nin,*) READ (nin,*) a, b READ (nin,*) nlimit READ (nin,*) epsr ifail = -1 ans = d01ahf(a,b,epsr,npts,relerr,f,nlimit,ifail) SELECT CASE (ifail) CASE (0:2) WRITE (nout,*) WRITE (nout,99999) 'Integral = ', ans WRITE (nout,*) WRITE (nout,99998) 'Estimated relative error = ', relerr WRITE (nout,*) WRITE (nout,99997) 'Number of function evaluations = ', npts END SELECT 99999 FORMAT (1X,A,F8.5) 99998 FORMAT (1X,A,E10.2) 99997 FORMAT (1X,A,I5) END PROGRAM d01ahfe