*     *************************************************************************

      subroutine inset( nipst, nip, naibs, iss, itmaj, ndacti,
     +                  elvar,  elptr,   varin,  ptrel,   xst,
     +                  ftstem,  pr,  bep,  fr,  to,  ba, nba,
     +                  su,  nsu,  info,  iflag )

*     *************************************************************************

*     Purpose :
*     ---------

*     When ITMAJ  =  0 : It is the first time that the partition
*                        of the variables into independent sets
*                        is done. The routine builds the independent
*                        superbasic sets from the just deactivated
*                        set of variables.
*                        The superbasic set corresponding to the 
*                        initial solution was empty.

*                < > 0 : The routine includes the just-deactivated 
*                        set of variables in the old independent 
*                        sets, and joins independent sets if necessary.

*     Parameters :
*     ------------

*     nipst   ( log )

*       input  : .true.  if the user whishes to use the concept
*                        of independent superbasic sets in order
*                        to exploit the parrallelism in both the
*                        constraints and the cost function structure.
*                .false. if no decomposition is achieved.
*       output : unmodified.

*     nip     ( int )

*       input  : the number of independent sets before the
*                routine is called.
*       output : the number of independent sets after the
*                the routine is called.

*     naibs   ( int )

*       input  : vector containing the number of superbasic
*                variables in each independent set.
*       output : this vector is updated following the new partition.

*     iss     ( int )

*       input  : vector containing for each variable, the indice
*                of the independent set in which it is included.
*                It is equal to zero when the variable does not
*                belongs to any independent set.
*       output : this vector is updated following the new partition.

*     itmaj   ( int )

*       input  : =  0, when it is the first time that the partition
*                      of the variables into independent sets is done
*                      The superbasic set corresponding to the
*                      initial solution was empty.
*                <> 0, when we include the just deactivated set of
*                      variables in the old independent sets.
*       output : unmodified.

*     ndacti  ( int )

*       input  : the number of just deactivated variables.
*       output : unmodified.

*     elvar   ( int )

*       input  : array containing the indices of the variables in 
*                the first element, followed by those in the second 
*                element, etc.
*       output : unmodified.

*     elptr   ( int )

*       input  : array whose kth value is the position of the first
*                variable of element k, in the list ELVAR.
*       output : unmodified.

*     varin   ( int )

*       input  : meaningless.
*       output : array containing the indices of the element including
*                the first variable, followed by those including the
*                second variable, etc.

*     ptrel   ( int )

*       input  : meaningless.
*       output : array whose kth value is the position of the first
*                element including variable k, in the list VARIN.

*     xst     ( int )

*       input  : vector containing the status of the variables.
*       output : this vector is updated following the new partition.

*     ftstem  ( int )

*       input  : vector containing for each superbasic variable,
*                the length from its origine node to the stem
*                node, and the length of its flow augmenting path.
*       output : unmodified.

*     pr      ( int )

*       input  : the predecessor vector.
*       output : unmodified.

*     bep     ( int )

*       input  : array used as workspace.
*       output : meaningless.

*     fr      ( int )

*       input  : vector containing the origine nodes of the arcs.
*       output : unmodified.

*     to      ( int )

*       input  : vector containing the end nodes of the arcs.
*       output : unmodified.

*     ba      ( int )

*       input  : vector containing the indices of the basic
*                variables.
*       output : unmodified.

*     nba     ( int )

*       input  : the number of basic variables.
*       output : unmodified.

*     su      ( int )

*       input  : vector containing the indices of the superbasic
*                variables.
*       output : unmodified.

*     nsu     ( int )

*       input  : the number of superbasic variables.
*       output : unmodified.

*     info    ( int )

*       input  : meaningless.
*       output : when IFLAG = 11, it contains the number of independent
*                sets created.
*                Otherwise, it is meaningless.

*     iflag   ( int )

*       input  : should be equal to zero when the routine is called.
*       output : = 11, if the maximum number of independent sets
*                      is reached.
*                Otherwise, it remains unmodified.

*     Routine used :
*     --------------

*     Invpss, isetvl, analys.

*     Programming :
*     -------------

*     D. Tuyttens 

*     =========================================================================

*     Routine parameters

      integer  nip, naibs(*), iss(*),  itmaj, ndacti, elvar(*),
     +         elptr(*), varin(*), ptrel(*), xst(*), ftstem(*),
     +         pr(*), bep(*),  fr(*), to(*), ba(*), nba, su(*),
     +         nsu, info, iflag
      logical  nipst

*     Internal variables

      integer  ik, k

*     Common specifications

      integer           arcs, nodes, elem
      common / prbdim / arcs, nodes, elem

*     Parameters definition

      integer  maxins
      parameter(  maxins = 100 )

*
*     We build the inverse partially separable structure.
*
      call invpss( elvar, elptr, varin, ptrel )
*
*     We test if it is the first time that the partition
*     of the variables into independent sets is done.
*
      if( itmaj.eq.0 ) then
*
*       It is the first time that the partition of the
*       variables into independent sets is done. We
*       initialize the vectors NAIBS and ISS.
*
        call isetvl( maxins, naibs, 1, 0 )
        call isetvl( arcs, iss, 1, 0 )
        nip = 1
      endif
*
*     We include the just deactivated set of variables
*     in the old independent sets and we join independent
*     sets if necessary.
*
      do 10 ik = nsu-ndacti+1 , nsu
        k = su(ik)
*
*       We include the superbasic variable K in a new
*       independent set and we analyse all its dependencies.
*
        call analys( k,  nip, nipst,  iss, naibs, ftstem,
     +               pr, bep, elvar, elptr, varin, ptrel,
     +               xst, fr, to,  ba, nba, iflag, info )
 10   continue
*
      return
      end