! D01FCF Example Program Text
! Mark 30.0 Release. NAG Copyright 2024.
Module d01fcfe_mod
! D01FCF Example Program Module:
! Parameters and User-defined Routines
! .. Use Statements ..
Use nag_library, Only: nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Accessibility Statements ..
Private
Public :: f
! .. Parameters ..
Integer, Parameter, Public :: ndim = 4, nout = 6
Integer, Parameter, Public :: maxpts = 1000*ndim
Integer, Parameter, Public :: lenwrk = (ndim+2)*(1+maxpts/(2**ndim &
+2*ndim*ndim+2*ndim+1))
Contains
Function f(ndim,z)
! .. Function Return Value ..
Real (Kind=nag_wp) :: f
! .. Scalar Arguments ..
Integer, Intent (In) :: ndim
! .. Array Arguments ..
Real (Kind=nag_wp), Intent (In) :: z(ndim)
! .. Intrinsic Procedures ..
Intrinsic :: exp
! .. Executable Statements ..
f = 4.0E0_nag_wp*z(1)*z(3)*z(3)*exp(2.0E0_nag_wp*z(1)*z(3))/ &
(1.0E0_nag_wp+z(2)+z(4))**2
Return
End Function f
End Module d01fcfe_mod
Program d01fcfe
! D01FCF Example Main Program
! .. Use Statements ..
Use d01fcfe_mod, Only: f, lenwrk, maxpts, ndim, nout
Use nag_library, Only: d01fcf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Local Scalars ..
Real (Kind=nag_wp) :: acc, eps, finval
Integer :: ifail, minpts
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: a(:), b(:), wrkstr(:)
! .. Executable Statements ..
Write (nout,*) 'D01FCF Example Program Results'
Allocate (a(ndim),b(ndim),wrkstr(lenwrk))
a(1:ndim) = 0.0E0_nag_wp
b(1:ndim) = 1.0E0_nag_wp
eps = 0.0001E0_nag_wp
minpts = 0
ifail = -1
Call d01fcf(ndim,a,b,minpts,maxpts,f,eps,acc,lenwrk,wrkstr,finval,ifail)
Select Case (ifail)
Case (0,2:)
Write (nout,*)
Write (nout,99999) 'Requested accuracy = ', eps
Write (nout,99998) 'Estimated value = ', finval
Write (nout,99999) 'Estimated accuracy = ', acc
End Select
99999 Format (1X,A,E12.2)
99998 Format (1X,A,F12.4)
End Program d01fcfe