    PROGRAM s17dgfe

!      S17DGF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s17dgf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       COMPLEX (KIND=nag_wp)           :: ai, z
       INTEGER                         :: ifail, ioerr, nz
       CHARACTER (1)                   :: deriv, scal
!      .. Executable Statements ..
       WRITE (nout,*) 'S17DGF Example Program Results'

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

       WRITE (nout,*)
       WRITE (nout,*) &
          'DERIV           Z         SCAL           AI          NZ'
       WRITE (nout,*)

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

          IF (ioerr<0) THEN
             EXIT DATA
          END IF

          ifail = 0
          CALL s17dgf(deriv,z,scal,ai,nz,ifail)

          WRITE (nout,99999) deriv, z, scal, ai, nz
       END DO DATA

99999  FORMAT (3X,A,'   (',F8.4,',',F8.4,')   ',A,'   (',F8.4,',',F8.4,')',I4)
    END PROGRAM s17dgfe
