    PROGRAM s21bcfe

!      S21BCF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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

       WRITE (nout,*)
       WRITE (nout,*) '    X      Y      Z        S21BCF'
       WRITE (nout,*)

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

          DO iy = ix, 3
             y = real(iy,kind=nag_wp)*0.5E0_nag_wp
             z = 1.0E0_nag_wp

             ifail = -1
             rd = s21bcf(x,y,z,ifail)

             IF (ifail<0) THEN
                EXIT DATA
             END IF

             WRITE (nout,99999) x, y, z, rd
          END DO

       END DO DATA

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