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

NAG AD Library Introduction
Example description
    Program e01bg_p0w_fe

!     E01BG_P0W_F Example Program Text
!     Mark 29.3 Release. NAG Copyright 2023.

!     .. Use Statements ..
      Use iso_c_binding, Only: c_ptr
      Use nagad_library, Only: e01be_p0w_f, e01bg_p0w_f
      Use nag_library, Only: nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Type (c_ptr)                     :: ad_handle
      Integer                          :: ifail, m, n, r
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: d(:), df(:), dx(:), f(:), pd(:),     &
                                          pf(:), px(:), x(:)
!     .. Executable Statements ..

      Write (nout,*) 'E01BG_P0W_F Example Program Results'

!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n
      m = 1
      Allocate (d(n),f(n),x(n),dx(n),df(n),px(m),pf(m),pd(m))

!     Initialize x and f arrays using data
      Read (nin,*)(x(r),f(r),r=1,n)

!     Call the passive routine
      ifail = 0
      Call e01be_p0w_f(ad_handle,n,x,f,d,ifail)

      px(1) = 0.5_nag_wp*(x(n/2)+x(n/2+1))
      Call e01bg_p0w_f(ad_handle,n,x,f,d,m,px,pf,pd,ifail)

      Write (nout,*)
      Write (nout,99999) 'Interpolated value at x = ', px(1), ' is: ', pf(1)
99999 Format (1X,A,F7.3,A,E12.5)

    End Program e01bg_p0w_fe