    PROGRAM h02bbfe

!      H02BBF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : h02bbf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: bigbnd, objmip, tolfes, toliv
       INTEGER                         :: i, ifail, intfst, itmax, j, lda,     &
                                          liwork, lrwork, m, maxdpt, maxnod,   &
                                          msglvl, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:), bl(:), bu(:), cvec(:),       &
                                          rwork(:), x(:)
       INTEGER, ALLOCATABLE            :: intvar(:), iwork(:)
!      .. Intrinsic Functions ..
       INTRINSIC                          min
!      .. Executable Statements ..
       WRITE (nout,*) 'H02BBF Example Program Results'
       FLUSH (nout)

!      Skip heading in data file
       READ (nin,*)

       READ (nin,*) n, m
       lda = m
       ALLOCATE (a(lda,n),bl(m+n),bu(m+n),cvec(n),x(n),intvar(n))

       READ (nin,*) itmax, msglvl
       READ (nin,*) maxnod
       READ (nin,*) intfst, maxdpt
       READ (nin,*) tolfes, toliv
       READ (nin,*) (cvec(i),i=1,n)
       READ (nin,*) ((a(i,j),j=1,n),i=1,m)
       READ (nin,*) bigbnd
       READ (nin,*) (bl(i),i=1,n+m)
       READ (nin,*) (bu(i),i=1,n+m)
       READ (nin,*) (intvar(i),i=1,n)
       READ (nin,*) (x(i),i=1,n)

       liwork = (25+n+m)*maxdpt + 5*n + m + 4
       lrwork = maxdpt*(n+1) + 2*min(n,m+1)**2 + 14*n + 12*m
       ALLOCATE (iwork(liwork),rwork(lrwork))

!      Solve the IP problem

       ifail = 0
       CALL h02bbf(itmax,msglvl,n,m,a,lda,bl,bu,intvar,cvec,maxnod,intfst, &
          maxdpt,toliv,tolfes,bigbnd,x,objmip,iwork,liwork,rwork,lrwork,ifail)

    END PROGRAM h02bbfe
