C$TEST PRS3
C TO RUN AS A MAIN PROGRAM REMOVE NEXT LINE
      SUBROUTINE PRS3
C***********************************************************************
C
C  EXAMPLE OF USE OF THE PORT PROGRAM SPMNF
C
C***********************************************************************
      INTEGER IROW(301), JCOL(2500), ISTAK(23000), I1MACH, IWRITE
      INTEGER MRP(300), MCP(300), ITEMP, INMCP(300), N
      INTEGER ILAPSZ, IT, IT2, IT3, IT4, IT5, IT6, I, NUMBER
      INTEGER NUM, IPOINT, NP1
      REAL RSTAK(23000), A(2500), GROWTH
      DOUBLE PRECISION DSTAK(11500)
      COMMON /CSTAK/DSTAK
      EQUIVALENCE(ISTAK(1), RSTAK(1), DSTAK(1))
      IWRITE = I1MACH(2)
      CALL ISTKIN(23000,2)
      DO 40 N=100,300,100
         CALL SETUP(N, IROW, JCOL, A)
         NUMBER = IROW(N+1)-1
         WRITE(IWRITE,11)N,NUMBER
  11     FORMAT(/5H N = ,I4,22H NUMBER OF NONZEROS = ,I7)
C
C ORDER THE ROWS AND COLUMNS OF THE MATRIX
C TO DECREASE FILL-IN
C
         CALL SPMOR(N, IROW, JCOL, MRP, INMCP)
C
C ALLOCATE THE AVAILABLE SPACE FOR THE WORK VECTOR IN SPMSF
C BUT MAKE SURE THERE IS ENOUGH FOR SPMSF'S ALLOCATIONS
C
         MAXIW = ISTKQU(2)-3*N-5
         IW = ISTKGT(MAXIW,2)
C
C TIME THE SYMBOLIC FACTORIZATION
C
         IT = ILAPSZ(0)
         CALL SPMSF(N, MRP, INMCP, IROW, JCOL, ISTAK(IW), MAXIW, ISIZE)
         IT2=ILAPSZ(0)-IT
         WRITE(IWRITE, 12)ISIZE
  12     FORMAT(37H NUMBER OF NONZEROS IN DECOMPOSITION=,I5)
         WRITE(IWRITE,13)IT2
  13     FORMAT(23H ELAPSED TIME FOR SPMSF,I7)
C
C MODIFY THE WORK STACK TO REFLECT THE AMOUNT NEEDED BY SPMSF
C AND ALLOCATE SPACE FOR THE NUMERICAL FACTORIZATION
C
         ISPAC= 2*N+2+ISIZE
         IW = ISTKMD(ISPAC,2)
         IUL = ISTKGT(ISIZE, 3)
C
C COMPUTE THE TIME NEEDED TO INSERT THE NUMERICAL ELEMENTS
C IN THEIR PROPER PLACES
C
         IT3 = ILAPSZ(0)
         DO 20 I=1, N
            MCP(I) = MRP(I)
            IR = MRP(I)
            NUM = IROW(IR+1)-IROW(IR)
            IPOINT = IROW(IR)
            CALL SPMIN(N, INMCP, ISTAK(IW), I, A(IPOINT),
     1        JCOL(IPOINT), NUM, I, RSTAK(IUL))
  20     CONTINUE
         IT4 = ILAPSZ(0)-IT3
         WRITE(IWRITE,21)IT4
  21     FORMAT(23H ELAPSED TIME FOR SPMIN,I7)
C
C TIME THE SUBROUTINE WHICH COMPUTES THE NUMERICAL
C FACTORIZATION
C
         IT5 =ILAPSZ(0)
         CALL SPMNF(N, ISTAK(IW), RSTAK(IUL), 0.0, GROWTH)
         IT6 =ILAPSZ(0)-IT5
         WRITE(IWRITE, 22)IT6
  22     FORMAT(23H ELAPSED TIME FOR SPMNF,I7)
         IT6 = IT2 + IT4 +IT6
         WRITE(6,23)IT6
  23     FORMAT(26H ELAPSED TIME FOR SF-IN-NF,I7)
C
C REDO THE FACTORIZATION WITH THE SUBROUTINE THAT PERMITS
C PIVOTING FOR STABILITY AND TIME IT
C
         CALL MOVEFR(NUMBER,A,RSTAK(IUL))
         CALL MOVEFI(NUMBER,JCOL,ISTAK(IW))
         IL = ISTKGT(N+1,2)
         IT5 =ILAPSZ(0)
         CALL SPMLU(N, MRP, MCP, IROW, ISTAK(IW), RSTAK(IUL), ISPAC,
     1   ISTAK(IL), 0.0, 0.0, ISIZE, GROWTH)
         IT6 = ILAPSZ(0)-IT5
         WRITE(IWRITE, 31)IT6
  31     FORMAT(23H ELAPSED TIME FOR SPMLU, I7)
         CALL ISTKRL(3)
  40  CONTINUE
      STOP
      END
