    PROGRAM s21dafe

!      S21DAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s21daf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       COMPLEX (KIND=nag_wp)           :: y, z
       REAL (KIND=nag_wp)              :: a, akp, b
       INTEGER                         :: ifail
!      .. Executable Statements ..
       WRITE (nout,*) 'S21DAF Example Program Results'

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

       WRITE (nout,*)
       WRITE (nout,*) '     Z          AKP     A', '      B                 Y'
       WRITE (nout,*)

       READ (nin,*) z, akp, a, b

       ifail = -1
       y = s21daf(z,akp,a,b,ifail)

       IF (ifail>=0) THEN
          WRITE (nout,99999) z, akp, a, b, y
       END IF

99999  FORMAT (1X,'(',F4.1,',',F4.1,' )',3F7.1,3X,'(',1P,E12.4,',',E12.4,' )')
    END PROGRAM s21dafe
