    PROGRAM s21bafe

!      S21BAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : nag_wp, s21baf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: rc, x, y
       INTEGER                         :: ifail, ix
!      .. Intrinsic Functions ..
       INTRINSIC                          real
!      .. Executable Statements ..
       WRITE (nout,*) 'S21BAF Example Program Results'

       WRITE (nout,*)
       WRITE (nout,*) '    X      Y        S21BAF'
       WRITE (nout,*)

DATA:  DO ix = 1, 3
          x = real(ix,kind=nag_wp)*0.5E0_nag_wp
          y = 1.0E0_nag_wp

          ifail = -1
          rc = s21baf(x,y,ifail)

          IF (ifail<0) THEN
             EXIT DATA
          END IF

          WRITE (nout,99999) x, y, rc
       END DO DATA

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