    PROGRAM e01abfe

!      E01ABF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : e01abf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: p
       INTEGER                         :: i, ifail, n, n1, n2, r
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:), g(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'E01ABF Example Program Results'

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

       READ (nin,*) n, p
       n1 = 2*n
       n2 = n1 + 1
       ALLOCATE (a(n1),g(n2))

       READ (nin,*) (a(i),i=1,n1)

       ifail = 0
       CALL e01abf(n,p,a,g,n1,n2,ifail)

       WRITE (nout,*)

       DO r = 0, n - 1
          WRITE (nout,99999) 'Central differences order ', r, ' of Y0 =', &
             g(2*r+1)
          WRITE (nout,99998) '                               Y1 =', g(2*r+2)
       END DO

       WRITE (nout,*)
       WRITE (nout,99998) 'Function value at interpolation point =', g(n2)

99999  FORMAT (1X,A,I1,A,F12.5)
99998  FORMAT (1X,A,F12.5)
    END PROGRAM e01abfe
