      SUBROUTINE RPOSE1(P,A,IA,JA,B,IB,JB,M,N)
      INTEGER P(M)
      DIMENSION A(1),IA(1),JA(1),B(1),IB(1),JB(1)
C
C        COMPUTE THE NUMBER OF ELEMENTS IN EACH COLUMN
C              OF A AND STORE THE RESULTS IN IB
C
      IPMIN = IA(1)
      IPMAX = IA(M+1)-1
      IF (IPMIN.GT.IPMAX) GO TO 40
      DO 10 J=1,N
   10 IB(J) = 0
      DO 11 IP=IPMIN,IPMAX
      J = JA(IP)
   11 IB(J) = IB(J)+1
C
C       COMPUTE THE ROW POINTERS OF THE TRANSPOSE MATRIX
C             AND STORE THEM IN IB(2),...,IB(M+1)
C
      NUM = IA(M+1)-IA(1)+1
      J = N
      DO 20 JJ=1,N
      NUM = NUM-IB(J)
      IB(J+1) = NUM
   20 J = J-1
C
C             STORE THE I-TH ROW OF A IN B AND JB
C               AND UPDATE THE POINTERS IN IB
C
      DO 31 I=1,M
      II = P(I)
      IPMIN = IA(II)
      IPMAX = IA(II+1)-1
      IF (IPMIN.GT.IPMAX) GO TO 31
      DO 30 IP=IPMIN,IPMAX
      J = JA(IP)
      JP = IB(J+1)
      JB(JP) = I
      B(JP) = A(IP)
   30 IB(J+1) = JP+1
   31 CONTINUE
C
C                   COMPLETE COMPUTATION
C
      IB(1) = 1
      RETURN
C
C                 TRANSPOSE A ZERO MATRIX A
C
   40 NP1 = N+1
      DO 41 J=1,NP1
   41 IB(J) = 1
      RETURN
      END
