    Program s21cafe

!     S21CAF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. 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
