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

      subroutine inschk( nip, niptot, naibs, nsu, info, iflag )

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

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

*     This routine counts the total number of non empty independent 
*     superbasic sets created and checks if all the superbasic variables
*     have been partitioned in these independent superbasic sets.

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

*     nip     ( int )

*       input  : the maximum number of independent superbasic
*                sets created. Some of them may be empty, it
*                is the case when two independent sets become
*                dependent during the partition. In this case 
*                these two sets must be joined and one of them 
*                becomes empty.
*       output : unmodified.

*     niptot  ( int )

*       input  : meaningless.
*       output : the total number of non empty independent
*                superbasic sets created.

*     naibs   ( int )

*       input  : array of length NIP, storing the number of
*                superbasic variables contained in each independent
*                superbasic set.
*       output : unmodified.

*     nsu     ( int )

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

*     info    ( int )

*       input  : meaningless.
*       output : it is set to the number of superbasic variables
*                partitioned in the different insets if the
*                partition is incorrect. Otherwise, it is left
*                unchanged.

*     iflag   ( int )

*       input  : meaningless.
*       output : if the partition into independent superbasic 
*                sets is incorrect, it is set to the corresponding 
*                error code. Otherwise, it is left unchanged.

*     Routines used :
*     ---------------

*     None.

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

*     D. Tuyttens

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

*     Routine parameters

      integer  nip, niptot, naibs(*), nsu, info, iflag

*     Internal variables

      integer  i, nipsu

      niptot = 0
      nipsu  = 0
*
      do 10 i = 1 , nip
        if( naibs(i).ne.0 ) then
          niptot = niptot + 1
          nipsu  = nipsu + naibs(i)
        endif
 10   continue
*
      if( nipsu.ne.nsu ) then
        info  = nipsu
        iflag = 17
      endif
*
      return
      end
