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

NAG AD Library Introduction
Example description
    Program e01aa_p0w_fe

!     E01AA_P0W_F Example Program Text

!     Mark 30.3 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use iso_c_binding, Only: c_ptr
      Use nagad_library, Only: e01aa_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
      Real (Kind=nag_wp)               :: x
      Integer                          :: i, ifail, n, n1, n2
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:), b(:), c(:)
!     .. Executable Statements ..
      Write (nout,*) 'E01AA_P0W_F Example Program Results'

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

      n1 = n + 1
      n2 = n*(n+1)/2
      Allocate (a(n1),b(n1),c(n2))

      Read (nin,*)(a(i),i=1,n1)
      Read (nin,*)(b(i),i=1,n1)

      ifail = 0
!     Call passive routine
      ifail = 0
      Call e01aa_p0w_f(ad_handle,a,b,c,n,x,ifail)

      Write (nout,*)
      Write (nout,99999) 'Interpolation point = ', x
      Write (nout,*)
      Write (nout,99999) 'Function value at interpolation point = ', c(n2)

99999 Format (1X,A,F12.5)
    End Program e01aa_p0w_fe