    PROGRAM s14aefe

!      S14AEF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s14aef
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: x, y
       INTEGER                         :: ifail, ioerr, k
!      .. Executable Statements ..
       WRITE (nout,*) 'S14AEF Example Program Results'

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

       WRITE (nout,*)
       WRITE (nout,*) '   X     K    (d^K/dx^K)psi(X)'
       WRITE (nout,*)

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

          IF (ioerr<0) THEN
             EXIT DATA
          END IF

          ifail = -1
          y = s14aef(x,k,ifail)

          IF (ifail<0) THEN
             EXIT DATA
          END IF

          WRITE (nout,99999) x, k, y
       END DO DATA

99999  FORMAT (1X,F5.1,I5,5X,1P,E12.4)
    END PROGRAM s14aefe
