Program e01tkfe
! E01TKF Example Program Text
! Mark 26.1 Release. NAG Copyright 2016.
! .. Use Statements ..
Use nag_library, Only: e01tkf, e01tlf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, liq, lrq, m, n, nq, nw
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: f(:), q(:), qx(:,:), rq(:), x(:,:), &
xe(:,:)
Integer, Allocatable :: iq(:)
! .. Executable Statements ..
Write (nout,*) 'E01TKF Example Program Results'
! Skip heading in data file
Read (nin,*)
! Input the number of nodes.
Read (nin,*) m
liq = 2*m + 1
lrq = 15*m + 9
Allocate (x(4,m),f(m),iq(liq),rq(lrq))
! Input the data points X and F.
Do i = 1, m
Read (nin,*) x(1:4,i), f(i)
End Do
! Generate the interpolant.
nq = 0
nw = 0
ifail = 0
Call e01tkf(m,x,f,nw,nq,iq,rq,ifail)
! Input the number of evaluation points.
Read (nin,*) n
Allocate (xe(4,n),q(n),qx(4,n))
! Input the evaluation points.
Do i = 1, n
Read (nin,*) xe(1:4,i)
End Do
! Evaluate the interpolant using E01TLF.
ifail = 1
Call e01tlf(m,x,f,iq,rq,n,xe,q,qx,ifail)
If (ifail==0 .Or. ifail==3) Then
If (ifail==3) Then
Write (nout,*) 'Some values below have been extrapolated'
Write (nout,*)
End If
Write (nout,99998) 'Interpolated Evaluation Points', 'Values'
Write (nout,99997)
Write (nout,99996)(i,i=1,4)
Write (nout,99997)
Do i = 1, n
Write (nout,99999) i, xe(1:4,i), q(i)
End Do
Else
Write (nout,99995) 'Evaluation routine returned with IFAIL = ', ifail
End If
99999 Format (1X,I4,1X,4F10.4,1X,F10.4)
99998 Format (/,4X,' |',5X,A31,5X,'|',A7)
99997 Format (4X,'---|',41('-'),'+',8('-'))
99996 Format (4X,'I |',4(2X,'XE(I,',I1,')',1X),1X,'|',2X,'Q(I)')
99995 Format (1X,A,I4)
End Program e01tkfe