    PROGRAM e02akfe

!      E02AKF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : e02akf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       REAL (KIND=nag_wp), PARAMETER   :: xmax = 2.5E0_nag_wp
       REAL (KIND=nag_wp), PARAMETER   :: xmin = -0.5E0_nag_wp
       INTEGER, PARAMETER              :: nout = 6, np1 = 7
       INTEGER, PARAMETER              :: la = np1
       REAL (KIND=nag_wp), PARAMETER   :: a(la) = (/ 2.53213E0_nag_wp,         &
                                          1.13032E0_nag_wp, 0.27150E0_nag_wp,  &
                                          0.04434E0_nag_wp, 0.00547E0_nag_wp,  &
                                          0.00054E0_nag_wp, 0.00004E0_nag_wp/)
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: res, x
       INTEGER                         :: i, ifail, m
!      .. Intrinsic Functions ..
       INTRINSIC                          real
!      .. Executable Statements ..
       WRITE (nout,*) 'E02AKF Example Program Results'

       m = 4

       DO i = 1, m
          x = (xmin*real(m-i,kind=nag_wp)+xmax*real(i-1,kind=nag_wp))/ &
             real(m-1,kind=nag_wp)

          ifail = 0
          CALL e02akf(np1,xmin,xmax,a,1,la,x,res,ifail)

          IF (i==1) THEN
             WRITE (nout,*)
             WRITE (nout,*) '   I   Argument  Value of polynomial'
          END IF

          WRITE (nout,99999) i, x, res
       END DO

99999  FORMAT (1X,I4,F10.4,4X,F9.4)
    END PROGRAM e02akfe
