    Program s14aefe

!     S14AEF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. 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
