    PROGRAM s14affe

!      S14AFF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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

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

       WRITE (nout,*)
       WRITE (nout,*) '       Z           K         (d^K/dz^K)psi(Z)'
       WRITE (nout,*)

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

          IF (ioerr<0) THEN
             EXIT DATA
          END IF

          ifail = -1
          y = s14aff(z,k,ifail)

          IF (ifail<0) THEN
             EXIT DATA
          END IF

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

99999  FORMAT (1X,'(',F5.1,',',F5.1,' )',I6,'   (',1P,E12.4,',',E12.4,' )')
    END PROGRAM s14affe
