! D01BD_P0W_F Example Program Text
! Mark 30.0 Release. NAG Copyright 2024.
Module d01bd_p0w_fe_mod
! .. Use Statements ..
Use iso_c_binding, Only: c_ptr
Use nag_library, Only: nag_wp, x01aaf
! .. Implicit None Statement ..
Implicit None
! .. Accessibility Statements ..
Private
Public :: f
! .. Parameters ..
Integer, Parameter, Public :: nout = 6
Contains
Subroutine f(ad_handle,x,ret,iuser,ruser)
! .. Scalar Arguments ..
Type (c_ptr), Intent (Inout) :: ad_handle
Real (Kind=nag_wp), Intent (Out) :: ret
Real (Kind=nag_wp), Intent (In) :: x
! .. Array Arguments ..
Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
Integer, Intent (Inout) :: iuser(*)
! .. Local Scalars ..
Real (Kind=nag_wp) :: pi, xx
! .. Intrinsic Procedures ..
Intrinsic :: sin
! .. Executable Statements ..
pi = x01aaf(xx)
ret = (x**2)*sin(pi*ruser(1)*x)
Return
End Subroutine f
End Module d01bd_p0w_fe_mod
Program d01bd_p0w_fe
! D01BD_P0W_F Example Main Program
! .. Use Statements ..
Use d01bd_p0w_fe_mod, Only: f, nout
Use iso_c_binding, Only: c_ptr
Use nagad_library, Only: d01bd_p0w_f
Use nag_library, Only: nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Local Scalars ..
Type (c_ptr) :: ad_handle
Real (Kind=nag_wp) :: a, abserr, b, epsabs, epsrel, result
Integer :: ifail
! .. Local Arrays ..
Real (Kind=nag_wp) :: ruser(1)
Integer :: iuser(1)
! .. Intrinsic Procedures ..
Intrinsic :: abs, max
! .. Executable Statements ..
Write (nout,*) 'D01BD_P0W_F Example Program Results'
epsabs = 0.0_nag_wp
epsrel = 1.0E-4_nag_wp
a = 0.0_nag_wp
b = 1.0_nag_wp
ruser(1) = 10.0_nag_wp
ifail = 0
Call d01bd_p0w_f(ad_handle,f,a,b,epsabs,epsrel,result,abserr,iuser, &
ruser,ifail)
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
Write (nout,*)
Write (nout,99997) 'result - approximation to the integral = ', result
Write (nout,99998) 'abserr - estimate to the absolute error = ', abserr
If (abserr>max(epsabs,(epsrel)*abs(result))) Then
Write (nout,*)
Write (nout,*) &
'Warning - requested accuracy may not have been achieved'
End If
99999 Format (1X,A,F10.4)
99998 Format (1X,A,E9.2)
99997 Format (1X,A,F9.5)
End Program d01bd_p0w_fe