! D01AMF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE d01amfe_mod ! D01AMF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. USE nag_library, ONLY : nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: lw = 800, nout = 6 INTEGER, PARAMETER :: liw = lw/4 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 ! .. Intrinsic Functions .. INTRINSIC sqrt ! .. Executable Statements .. f = 1.0E0_nag_wp/((x+1.0E0_nag_wp)*sqrt(x)) RETURN END FUNCTION f END MODULE d01amfe_mod PROGRAM d01amfe ! D01AMF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : d01amf, nag_wp USE d01amfe_mod, ONLY : f, liw, lw, nout ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. REAL (KIND=nag_wp) :: abserr, bound, epsabs, epsrel, & result INTEGER :: ifail, inf ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: w(:) INTEGER, ALLOCATABLE :: iw(:) ! .. Executable Statements .. WRITE (nout,*) 'D01AMF Example Program Results' ALLOCATE (w(lw),iw(liw)) epsabs = 0.0E0_nag_wp epsrel = 1.0E-04_nag_wp bound = 0.0E0_nag_wp inf = 1 ifail = -1 CALL d01amf(f,bound,inf,epsabs,epsrel,result,abserr,w,lw,iw,liw,ifail) IF (ifail>=0) THEN WRITE (nout,*) WRITE (nout,99999) 'A ', 'lower limit of integration', bound WRITE (nout,99995) 'B ', 'upper limit of integration', & 'infinity' WRITE (nout,99998) 'EPSABS', 'absolute accuracy requested', epsabs WRITE (nout,99998) 'EPSREL', 'relative accuracy requested', epsrel END IF IF (ifail>=0 .AND. ifail<=5) THEN WRITE (nout,*) WRITE (nout,99997) 'RESULT', 'approximation to the integral', result WRITE (nout,99998) 'ABSERR', 'estimate of the absolute error', & abserr WRITE (nout,99996) 'IW(1) ', 'number of subintervals used', iw(1) END IF 99999 FORMAT (1X,A6,' - ',A32,' = ',F10.4) 99998 FORMAT (1X,A6,' - ',A32,' = ',E9.2) 99997 FORMAT (1X,A6,' - ',A32,' = ',F9.5) 99996 FORMAT (1X,A6,' - ',A32,' = ',I4) 99995 FORMAT (1X,A6,' - ',A32,' = ',A8) END PROGRAM d01amfe