    PROGRAM s21cafe

!      S21CAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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

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

       WRITE (nout,*)
       WRITE (nout,*) &
          '          U            M           SN           CN           DN'

DATA:  DO
          READ (nin,*,IOSTAT=ioerr) u, m

          IF (ioerr<0) THEN
             EXIT DATA
          END IF

          ifail = 0
          CALL s21caf(u,m,sn,cn,dn,ifail)

          WRITE (nout,99999) u, m, sn, cn, dn
       END DO DATA

99999  FORMAT (3X,5E13.4)
    END PROGRAM s21cafe
