    Program h02bffe

!     H02BFF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

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