    PROGRAM s17dcfe

!      S17DCF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s17dcf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: n = 2, nin = 5, nout = 6
!      .. Local Scalars ..
       COMPLEX (KIND=nag_wp)           :: z
       REAL (KIND=nag_wp)              :: fnu
       INTEGER                         :: ifail, ioerr, nz
       CHARACTER (1)                   :: scal
!      .. Local Arrays ..
       COMPLEX (KIND=nag_wp)           :: cwrk(n), cy(n)
!      .. Executable Statements ..
       WRITE (nout,*) 'S17DCF Example Program Results'

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

       WRITE (nout,*)
       WRITE (nout,99999) 'Calling with N =', n
       WRITE (nout,*)
       WRITE (nout,*) &
          '   FNU            Z        SCAL       CY(1)              CY(2)', &
          '        NZ'
       WRITE (nout,*)

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

          IF (ioerr<0) THEN
             EXIT DATA
          END IF

          ifail = 0
          CALL s17dcf(fnu,z,n,scal,cy,nz,cwrk,ifail)

          WRITE (nout,99998) fnu, z, scal, cy(1), cy(2), nz
       END DO DATA

99999  FORMAT (1X,A,I2)
99998  FORMAT (1X,F7.4,'  (',F7.3,',',F7.3,')   ',A, &
          2('  (',F7.3,',',F7.3,')'),I4)
    END PROGRAM s17dcfe
