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

NAG FL Interface Introduction
Example description
    Program e01befe

!     E01BEF Example Program Text

!     Mark 28.5 Release. NAG Copyright 2022.

!     .. Use Statements ..
      Use nag_library, Only: e01bef, e01bff, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: step
      Integer                          :: i, ifail, m, n, r
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: d(:), f(:), pf(:), px(:), x(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: min, real
!     .. Executable Statements ..
      Write (nout,*) 'E01BEF Example Program Results'

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

      Read (nin,*) n
      Allocate (d(n),f(n),x(n))

      Do r = 1, n
        Read (nin,*) x(r), f(r)
      End Do

      ifail = 0
      Call e01bef(n,x,f,d,ifail)

      Read (nin,*) m
      Allocate (pf(m),px(m))

!     Compute M equally spaced points from X(1) to X(N).

      step = (x(n)-x(1))/real(m-1,kind=nag_wp)

      Do i = 1, m
        px(i) = min(x(1)+real(i-1,kind=nag_wp)*step,x(n))
      End Do

      ifail = 0
      Call e01bff(n,x,f,d,m,px,pf,ifail)

      Write (nout,*)
      Write (nout,*) '                Interpolated'
      Write (nout,*) '     Abscissa          Value'

      Do i = 1, m
        Write (nout,99999) px(i), pf(i)
      End Do

99999 Format (1X,F13.4,2X,F13.4)
    End Program e01befe