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

NAG AD Library Introduction
Example description
    Program e01ea_p0w_fe

!     E01EA_P0W_F Example Program Text
!     Mark 30.0 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use iso_c_binding, Only: c_ptr
      Use nagad_library, Only: e01ea_p0w_f, e01eb_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  :: f(:), pf(:), px(:), py(:), x(:),     &
                                          y(:)
      Integer, Allocatable             :: triang(:)
!     .. Executable Statements ..
      Write (nout,*) 'E01EA_P0W_F Example Program Results'

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

      Read (nin,*) n
      m = 1
      Allocate (f(n),x(n),y(n),px(m),py(m),pf(m),triang(7*n))

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

!     Call the passive routine
      ifail = 0
      Call e01ea_p0w_f(n,x,y,triang,ifail)

      px(1) = 0.5_nag_wp*(x(n/2)+x(n/2+1))
      py(1) = 0.5_nag_wp*(y(n/2)+y(n/2+1))

      ifail = 0
      Call e01eb_p0w_f(ad_handle,m,n,x,y,f,triang,px,py,pf,ifail)

      Write (nout,*)
      Write (nout,99999) 'Interpolation point: x = ', px(1), ' y = ', py(1)
      Write (nout,99999) 'Interpolated value = ', pf(1)
99999 Format (1X,A,F7.4,A,F7.4)

    End Program e01ea_p0w_fe