    PROGRAM h02bffe

!      H02BFF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : h02bff, nag_wp, x04acf, x04baf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       REAL (KIND=nag_wp), PARAMETER   :: xbl_default = 0.0E0_nag_wp
       REAL (KIND=nag_wp), PARAMETER   :: xbu_default = 1.0E+20_nag_wp
       INTEGER, PARAMETER              :: maxm = 50, maxn = 50, msglvl = 5,    &
                                          nindat = 7, nout = 6
       INTEGER, PARAMETER              :: maxdpt = 3*maxn/2
       INTEGER, PARAMETER              ::                                      &
                            liwork = (25+maxn+maxm)*maxdpt + 2*maxm + 7*maxn+ 4
       INTEGER, PARAMETER              :: lrwork = maxdpt*(maxn + 1) +         &
                                          2*maxn**2 + maxm*maxn + 19*maxn +    &
                                          15*maxm
       CHARACTER (*), PARAMETER        :: fname = 'h02bffe.opt'
       CHARACTER (3), PARAMETER        :: optim = 'MIN'
!      .. Local Scalars ..
       INTEGER                         :: ifail, infile, m, mode, n
       CHARACTER (80)                  :: rec
!      .. Local Arrays ..
       REAL (KIND=nag_wp)              :: rwork(lrwork), x(maxn)
       INTEGER                         :: iwork(liwork)
       CHARACTER (8)                   :: crname(maxn+maxm)
!      .. Executable Statements ..
       WRITE (rec,99999) 'H02BFF Example Program Results'
       CALL x04baf(nout,rec)

!      Open the data file for reading

       mode = 0

       ifail = 0
       CALL x04acf(nindat,fname,mode,ifail)

!      Solve the problem

       infile = nindat

       ifail = 0
       CALL h02bff(infile,maxn,maxm,optim,xbl_default,xbu_default,maxdpt, &
          msglvl,n,m,x,crname,iwork,liwork,rwork,lrwork,ifail)

99999  FORMAT (1X,A)
    END PROGRAM h02bffe
