    PROGRAM s18gkfe

!      S18GKF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s18gkf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       COMPLEX (KIND=nag_wp)           :: z
       REAL (KIND=nag_wp)              :: a, alpha
       INTEGER                         :: i, ifail, nl
!      .. Local Arrays ..
       COMPLEX (KIND=nag_wp), ALLOCATABLE :: b(:)
!      .. Intrinsic Functions ..
       INTRINSIC                          abs, real, sign
!      .. Executable Statements ..
       WRITE (nout,*) 'S18GKF Example Program Results'

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

       READ (nin,*) z, a, nl
       ALLOCATE (b(abs(nl)+1))

       ifail = 0
       CALL s18gkf(z,a,nl,b,ifail)

       WRITE (nout,*)
       WRITE (nout,*) '      Z           A     NL'
       WRITE (nout,*)
       WRITE (nout,99999) z, a, nl

       WRITE (nout,*)
       WRITE (nout,*) ' Requested values of J_alpha(Z)'
       WRITE (nout,*)
       WRITE (nout,*) '     alpha              J_alpha(Z)'

       alpha = a

       DO i = 1, abs(nl) + 1
          WRITE (nout,99998) alpha, b(i)
          alpha = alpha + sign(1.0E0_nag_wp,real(nl,kind=nag_wp))
       END DO

99999  FORMAT (1X,'( ',F4.1,', ',F4.1,' )',2X,F4.1,I6)
99998  FORMAT (1X,1P,E12.4,3X,'(',E12.4,',',E12.4,' )')
    END PROGRAM s18gkfe
