    PROGRAM s21bffe

!      S21BFF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s21bff, x01aaf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: dm, f, phi, pi
       INTEGER                         :: ifail, ix
!      .. Intrinsic Functions ..
       INTRINSIC                          real
!      .. Executable Statements ..
       WRITE (nout,*) 'S21BFF Example Program Results'

       WRITE (nout,*)
       WRITE (nout,*) '    PHI    DM      S21BFF'
       WRITE (nout,*)

       pi = x01aaf(pi)

DATA:  DO ix = 1, 3
          phi = real(ix,kind=nag_wp)*pi/6.0E0_nag_wp
          dm = real(ix,kind=nag_wp)*0.25E0_nag_wp

          ifail = -1
          f = s21bff(phi,dm,ifail)

          IF (ifail<0) THEN
             EXIT DATA
          END IF

          WRITE (nout,99999) phi, dm, f
       END DO DATA

99999  FORMAT (1X,2F7.2,F12.4)
    END PROGRAM s21bffe
