    PROGRAM s21cbfe

!      S21CBF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s21cbf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       COMPLEX (KIND=nag_wp)           :: cn, dn, sn, z
       REAL (KIND=nag_wp)              :: ak2
       INTEGER                         :: ifail
!      .. Executable Statements ..
       WRITE (nout,*) 'S21CBF Example Program Results'

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

       WRITE (nout,*)

       READ (nin,*) z, ak2

       ifail = 0
       CALL s21cbf(z,ak2,sn,cn,dn,ifail)

       WRITE (nout,*) '          Z                    AK2'
       WRITE (nout,99999) z, ak2
       WRITE (nout,*)
       WRITE (nout,*) '         SN                     CN', &
          '                     DN'
       WRITE (nout,99998) sn, cn, dn

99999  FORMAT (1X,'(',F8.4,',',F8.4,')',5X,F10.2)
99998  FORMAT (3(' (',F8.4,',',F8.4,')',3X))
    END PROGRAM s21cbfe
