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

      subroutine anhess( elvar, elptr, varin, ptrel,
     +                   iss,  kj,  kp, naibs, xst )

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

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

*     The variable KJ belongs to the independent set KP.
*     This routine determines all the variables, say TT,
*     that are linked to variable KJ by the Hessian matrix.
*     These variables TT and their independent sets are
*     then included in the independent set KP.

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

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

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

*     kj      ( int )

*       input  : the indice of the variable for which we search
*                all its dependencies.
*       output : unmodified.

*     kp      ( int )

*       input  : the indice of the independent set including
*                variable KJ.
*       output : unmodified.

*     naibs   ( int )

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

*     xst     ( int )

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

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

*     gxsu, snxdej.

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

*     D. Tuyttens

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

*     Routine parameters

      integer  elvar(*), elptr(*), varin(*), ptrel(*),
     +         iss(*),   kj,   kp,  naibs(*),  xst(*)

*     Internal variables

      integer  i, j, tt, k1, ii, ist
      logical  gxsu

*     Common specifications

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

*
*     We visit all the elements II including variable KJ.
*
      do 20 i = ptrel(kj) , ptrel(kj+1)-1
         ii = varin(i)
*
*       We visit all the variables TT included in element II.
*
        do 30 j = elptr(ii) , elptr(ii+1)-1
          tt  = elvar(j)
          ist = iss(tt)
*
*         We test if the variable TT is already included in
*         one independent set different from KP.
*
          if( ist.ne.kp .and. ist.ne.0 ) then
*
*           We include in independent set KP all the variables
*           that are in the same independent set as variable TT.
*
            do 10 k1 = 1 , arcs
              if( k1.ne.tt .and. iss(k1).eq.ist ) then
                iss(k1) = kp
                if( gxsu(xst(k1)) ) naibs(kp) = naibs(kp) + 1
              endif
 10         continue
*
*           The independent set IST vanishes.
*
            naibs(ist) = 0
            call snxdej(xst(ist))
            if( gxsu(xst(tt)) ) naibs(kp) = naibs(kp) + 1
            iss(tt) = kp
*
          endif
*
*         We visit next variable included in element II.
*
 30     continue
*
*       We visit next element including variable KJ.
*
 20   continue
*
      return
      end