      SUBROUTINE BLKORD(N,IA,JA,R,C,IB,NUM,IWK,IERR)
C     ******************************************************************
C     REORDERING A SPARSE MATRIX INTO BLOCK TRIANGULAR FORM
C     ******************************************************************
      INTEGER IA(1),JA(1),R(N),C(N),IB(N)
C     INTEGER IWK(5*N)
      INTEGER IWK(1)
C
      LENGTH = IA(N+1) - IA(1)
      DO 10 I = 1,N
   10 IWK(I) = IA(I+1) - IA(I)
      CALL MC21A(N,JA,LENGTH,IA,IWK(1),R,NUM,IWK(N+1))
      IERR = N - NUM
      IF (IERR .NE. 0) RETURN
C
      DO 20 I = 1,N
      LI = R(I)
      IWK(I) = IA(LI)
      NPI = N + I
   20 IWK(NPI) = IA(LI+1) - IA(LI)
      CALL MC13D(N,JA,LENGTH,IWK(1),IWK(N+1),C,IB,NUM,IWK(2*N+1))
C
      DO 30 I = 1,N
      LI = C(I)
   30 IWK(I) = R(LI)
      DO 31 I = 1,N
   31 R(I) = IWK(I)
      RETURN
      END
