NAG Library Manual, Mark 30.1
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program e01tmfe

!     E01TMF Example Program Text

!     Mark 30.1 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: e01tmf, e01tnf, 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,*) 'E01TMF Example Program Results'

!     Skip heading in data file
      Read (nin,*)

!     Input the number of nodes.
      Read (nin,*) m
      liq = 2*m + 1
      lrq = 21*m + 11
      Allocate (x(5,m),f(m),iq(liq),rq(lrq))

!     Input the data points X and F.
      Do i = 1, m
        Read (nin,*) x(1:5,i), f(i)
      End Do

!     Generate the interpolant.
      nq = 0
      nw = 0

      ifail = 0
      Call e01tmf(m,x,f,nw,nq,iq,rq,ifail)

!     Input the number of evaluation points.
      Read (nin,*) n
      Allocate (xe(5,n),q(n),qx(5,n))

!     Input the evaluation points.
      Do i = 1, n
        Read (nin,*) xe(1:5,i)
      End Do

!     Evaluate the interpolant using E01TNF.
      ifail = 0
      Call e01tnf(m,x,f,iq,rq,n,xe,q,qx,ifail)

      Write (nout,99998) 'Interpolated Evaluation Points', 'Values'
      Write (nout,99997)
      Write (nout,99996)(i,i=1,5)
      Write (nout,99997)
      Write (nout,99999)(i,xe(1:5,i),q(i),i=1,n)

99999 Format (1X,I4,1X,6F10.4)
99998 Format (/,4X,'   |',10X,A31,10X,'|',A7)
99997 Format (4X,'---|',51('-'),'+',7('-'))
99996 Format (4X,'I  |',5(2X,'XE(',I1,',I)',1X),1X,'|',3X,'Q(I)')
    End Program e01tmfe