      SUBROUTINE RSUB1(A,IA,JA,B,IB,JB,C,IC,JC,M,N,X,IX,NUM,IERR)
      REAL A(1),B(1),C(1),X(N)
      INTEGER IA(1),JA(1),IB(1),JB(1),IC(1),JC(1),IX(N)
C     --------------------
      IP = 1
      DO 10 J=1,N
   10 IX(J) = 0
C
C        COMPUTE THE I-TH ROW OF C
C
      DO 42 I=1,M
      IC(I) = IP
      JPMIN = IA(I)
      JPMAX = IA(I+1)-1
      IF (JPMIN.GT.JPMAX) GO TO 30
      DO 20 JP=JPMIN,JPMAX
      J = JA(JP)
      IF (IP.GT.NUM) GO TO 50
      JC(IP) = J
      IP = IP+1
      IX(J) = I
   20 X(J) = A(JP)
C
   30 JPMIN = IB(I)
      JPMAX = IB(I+1)-1
      IF (JPMIN.GT.JPMAX) GO TO 40
      DO 32 JP=JPMIN,JPMAX
      J = JB(JP)
      IF (IX(J).EQ.I) GO TO 31
      IF (IP.GT.NUM) GO TO 50
      JC(IP) = J
      IP = IP+1
      IX(J) = I
      X(J) = -B(JP)
      GO TO 32
   31 X(J) = X(J)-B(JP)
   32 CONTINUE
C
   40 JPMIN = IC(I)
      JPMAX = IP-1
      IF (JPMIN.GT.JPMAX) GO TO 42
      DO 41 JP=JPMIN,JPMAX
      J = JC(JP)
   41 C(JP) = X(J)
   42 CONTINUE
C
C        COMPLETE COMPUTATION
C
      IC(M+1) = IP
      IERR = 0
      RETURN
C
C           ERROR RETURN
C
   50 IERR = I
      RETURN
      END
