! D01AUF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE d01aufe_mod ! D01AUF 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 SUBROUTINE f(x,fv,n) ! .. Implicit None Statement .. IMPLICIT NONE ! .. Scalar Arguments .. INTEGER, INTENT (IN) :: n ! .. Array Arguments .. REAL (KIND=nag_wp), INTENT (OUT) :: fv(n) REAL (KIND=nag_wp), INTENT (IN) :: x(n) ! .. Intrinsic Functions .. INTRINSIC cos, sin ! .. Executable Statements .. fv(1:n) = x(1:n)*(sin(30.0E0_nag_wp*x(1:n)))*cos(x(1:n)) RETURN END SUBROUTINE f END MODULE d01aufe_mod PROGRAM d01aufe ! D01AUF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : d01auf, nag_wp, x01aaf USE d01aufe_mod, ONLY : f, liw, lw, nout ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. REAL (KIND=nag_wp) :: a, abserr, b, epsabs, epsrel, & pi, result INTEGER :: ifail, key ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: w(:) INTEGER, ALLOCATABLE :: iw(:) ! .. Executable Statements .. WRITE (nout,*) 'D01AUF Example Program Results' ALLOCATE (w(lw),iw(liw)) pi = x01aaf(pi) epsabs = 0.0E0_nag_wp epsrel = 1.0E-03_nag_wp a = 0.0E0_nag_wp b = 2.0E0_nag_wp*pi key = 6 ifail = -1 CALL d01auf(f,a,b,key,epsabs,epsrel,result,abserr,w,lw,iw,liw,ifail) IF (ifail>=0) THEN WRITE (nout,*) WRITE (nout,99999) 'A ', 'lower limit of integration', a WRITE (nout,99999) 'B ', 'upper limit of integration', b WRITE (nout,99998) 'EPSABS', 'absolute accuracy requested', epsabs WRITE (nout,99998) 'EPSREL', 'relative accuracy requested', epsrel END IF IF (ifail>=0 .AND. ifail<=3) 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,' - ',A30,' = ',F10.4) 99998 FORMAT (1X,A6,' - ',A30,' = ',E9.2) 99997 FORMAT (1X,A6,' - ',A30,' = ',F9.5) 99996 FORMAT (1X,A6,' - ',A30,' = ',I4) END PROGRAM d01aufe