*     ------------------------------------------------------------------
*     File minosm.for
*     This is a main program to test subroutine mimps, which is
*     part of MINOS 5.5.  It uses mimps to read the MPS file
*     associated with problem t4manne, then asks minoss to solve it.
*
*     
*     19 Apr 1992: First version, derived from minost.for.
*     24 Oct 1996: Test mpsout also.
*     ------------------------------------------------------------------

      program            minosm

      implicit           double precision (a-h,o-z)

      parameter        ( maxm   = 1000,
     $                   maxn   = 2000,
     $                   maxnb  = maxm + maxn,
     $                   maxne  = 20000,
     $                   maxnam = maxnb )

      character*8        names(5)
      integer*4          ha(maxne) , hint(maxn)   , hs(maxnb)
      integer            ka(maxn+1), name1(maxnam), name2(maxnam)
      double precision   a(maxne)  , bl(maxnb)    , bu(maxnb),
     $                   xn(maxnb) , pi(maxm)     , rc(maxnb)

      parameter          ( nwcore = 100000 )
      double precision   z(nwcore)
*     ------------------------------------------------------------------

*     Specify some of the MINOS files.
*     ispecs  is the Specs file.
*     iprint  is the Print file.
*     isumm   is the Summary file.
*     (mispec opens these files via mifile and m1open.)
*     nout    is an output file to be used here by mitest.

      ispecs = 4
      iprint = 9
      isumm  = 6
      nout   = 6

*     ------------------------------------------------------------------
*     Set options to default values.
*     Read a Specs file (if ispecs > 0).
*     ------------------------------------------------------------------
      call mispec( ispecs, iprint, isumm, nwcore, inform )

      if (inform .ge. 2) then
         write(nout, *) 'ispecs > 0 but no Specs file found'
         stop
      end if

*     ------------------------------------------------------------------
*     Read an MPS file from unit imps.
*     File imps should be opened here if necessary.
*
*     nncon, nnjac and nnobj can be hardwired here, or specified in the
*     SPECS file as
*        Nonlinear constraints
*        Nonlinear Jacobian  variables
*        Nonlinear objective variables
*     respectively.  For linear programs they would all be zero.
*     ------------------------------------------------------------------
      imps   = 10
      nncon  = 10
      nnjac  = 10
      nnobj  = 20

*     mimps will load names(1) with the problem name from the MPS file.
*     Here we can load names(2)-names(5) with the desired 8-character
*     Objective, Rhs, Ranges and Bounds names.
*     Blank means grab the first names encountered in the MPS file.

      names(2) = 'funobj'
      names(3) = ' '
      names(4) = ' '
      names(5) = ' '

      call mimps ( imps, maxm, maxn, maxnb, maxne,
     $             nncon, nnjac, nnobj,
     $             m, n, nb, ne, nint,
     $             iobj, objadd, names,
     $             a, ha, ka, bl, bu, name1, name2,
     $             hint, hs, xn, pi,
     $             inform, ns, z, nwcore )

      if (inform .ge. 1) then
         write(nout, *) 'Error while reading MPS file from unit', imps
         stop
      end if             

      if (nint   .gt. 0) then
         write(nout, *) 'No. of integer variables:', nint
      end if

*     ------------------------------------------------------------------
*     Go for it, using a Cold start.
*     mimps has already initialized hs(*) and xn(*).
*     Also, the MPS file may have initialized them via an INITIAL
*     bounds set.  If necessary, they can be further modified here.
*
*     For cold starts, the first n entries of hs should be
*     0, 1, 2, 3, 4, or 5.  The values are used by the Crash procedure
*     to choose an initial basis B.
*     If hs(j) = 0 or 1, column j is eligible for B.
*     If hs(j) = 2,      column j is initially superbasic (not in B).
*     If hs(j) = 3,      column j is eligible for B and is given
*                        preference over columns with hs(j) = 0 or 1.
*     If hs(j) = 4 or 5, column j is initially nonbasic.
*     ------------------------------------------------------------------
      nname  = nb
      call minoss( 'Cold', m, n, nb, ne, nname,
     $             nncon, nnobj, nnjac,
     $             iobj, objadd, names,
     $             a, ha, ka, bl, bu, name1, name2,
     $             hs, xn, pi, rc, 
     $             inform, mincor, ns, ninf, sinf, obj,
     $             z, nwcore )

      write(nout, *) ' '
      write(nout, *) 'minoss finished.'
      write(nout, *) 'inform =', inform
      write(nout, *) 'ninf   =', ninf
      write(nout, *) 'sinf   =', sinf
      write(nout, *) 'obj    =', obj

*     ------------------------------------------------------------------
*     Test mpsout by outputting the current problem.
*     ------------------------------------------------------------------
      mps = 30
      write(nout, *) ' '
      write(nout, *) 'Writing MPS file to unit', mps

      call mpsout( mps, m, n, nb, ne, nname, names,
     $             a, ha, ka, bl, bu, name1, name2 )

      write(nout, *) 'MPS file written'

*     end of main program to test subroutine mimps
      end
