    PROGRAM s14adfe

!      S14ADF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s14adf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: m = 4, nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: x
       INTEGER                         :: i, ifail, ioerr, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp)              :: ans(m)
!      .. Executable Statements ..
       WRITE (nout,*) 'S14ADF Example Program Results'

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

       WRITE (nout,*)
       WRITE (nout,*) '      X           ANS(1)        ANS(2)        ', &
          'ANS(3)        ANS(4)'
       WRITE (nout,*)

       n = 0

DATA:  DO
          READ (nin,*,IOSTAT=ioerr) x

          IF (ioerr<0) THEN
             EXIT DATA
          END IF

          ifail = 0
          CALL s14adf(x,n,m,ans,ifail)

          WRITE (nout,99999) x, (ans(i),i=1,m)
       END DO DATA

99999  FORMAT (1X,1P,5(E12.4,2X))
    END PROGRAM s14adfe
