    PROGRAM h03abfe

!      H03ABF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : h03abf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: z
       INTEGER                         :: i, ifail, j, ldkost, m, ma, maxit,   &
                                          mb, numit
!      .. Local Arrays ..
       INTEGER, ALLOCATABLE            :: k11(:), k12(:), k15(:), k6(:),       &
                                          k7(:), k8(:), k9(:), kost(:,:)
!      .. Executable Statements ..
       WRITE (nout,*) 'H03ABF Example Program Results'

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

       READ (nin,*) ma, mb
       m = ma + mb
       ldkost = ma
       ALLOCATE (kost(ldkost,mb),k15(m),k7(m),k9(m),k6(m),k8(m),k11(m),k12(m))

       READ (nin,*) (k15(i),i=1,m)

       DO i = 1, ma
          READ (nin,*) (kost(i,j),j=1,mb)
       END DO

       maxit = 200

       ifail = 0
       CALL h03abf(kost,ldkost,ma,mb,m,k15,maxit,k7,k9,numit,k6,k8,k11,k12,z, &
          ifail)

       WRITE (nout,*)
       WRITE (nout,99999) 'Total cost = ', z
       WRITE (nout,*)
       WRITE (nout,*) 'Goods from  to'
       WRITE (nout,*)
       WRITE (nout,99998) (k11(i),k6(i),k8(i),i=1,m-1)

99999  FORMAT (1X,A,F5.1)
99998  FORMAT (1X,I3,I6,I5)
    END PROGRAM h03abfe
