      SUBROUTINE BANSLV ( W, NROWW, NROW, NBANDL, NBANDU, B )
C  FROM  * A PRACTICAL GUIDE TO SPLINES *  BY C. DE BOOR
C  COMPANION ROUTINE TO  BANFAC . IT RETURNS THE SOLUTION  X  OF THE
C  LINEAR SYSTEM  A*X = B  IN PLACE OF  B , GIVEN THE LU-FACTORIZATION
C  FOR  A  IN THE WORKARRAY  W .
C
C******  I N P U T  ******
C  W, NROWW,NROW,NBANDL,NBANDU.....DESCRIBE THE LU-FACTORIZATION OF A
C        BANDED MATRIX  A  OF RODER  NROW  AS CONSTRUCTED IN  BANFAC .
C        FOR DETAILS, SEE  BANFAC .
C  B.....RIGHT SIDE OF THE SYSTEM TO BE SOLVED .
C
C******  O U T P U T  ******
C  B.....CONTAINS THE SOLUTION  X , OF ORDER  NROW .
C
C******  M E T H O D  ******
C     (WITH  A = L*U, AS STORED IN  W,) THE UNIT LOWER TRIANGULAR SYSTEM
C  L(U*X) = B  IS SOLVED FOR  Y = U*X, AND  Y  STORED IN  B . THEN THE
C  UPPER TRIANGULAR SYSTEM  U*X = Y  IS SOLVED FOR  X  . THE CALCUL-
C  ATIONS ARE SO ARRANGED THAT THE INNERMOST LOOPS STAY WITHIN COLUMNS.
C
      REAL W(NROWW,NROW),B(NROW)
      MIDDLE = NBANDU + 1
      IF (NROW .EQ. 1)                  GO TO 49
      NROWM1 = NROW - 1
      IF (NBANDL .EQ. 0)                GO TO 30
C                                 FORWARD PASS
C            FOR I=1,2,...,NROW-1, SUBTRACT  RIGHT SIDE(I)*(I-TH COLUMN
C            OF  L )  FROM RIGHT SIDE  (BELOW I-TH ROW) .
      DO 21 I=1,NROWM1
         JMAX = MIN0(NBANDL, NROW-I)
         DO 21 J=1,JMAX
            IPJ = I + J
            MPJ = MIDDLE + J
   21       B(IPJ) = B(IPJ) - B(I)*W(MPJ,I)
C                                 BACKWARD PASS
C            FOR I=NROW,NROW-1,...,1, DIVIDE RIGHT SIDE(I) BY I-TH DIAG-
C            ONAL ENTRY OF  U, THEN SUBTRACT  RIGHT SIDE(I)*(I-TH COLUMN
C            OF  U)  FROM RIGHT SIDE  (ABOVE I-TH ROW).
   30 IF (NBANDU .GT. 0)                GO TO 40
C                                A  IS LOWER TRIANGULAR .
      DO 31 I=1,NROW
   31    B(I) = B(I)/W(1,I)
                                        RETURN
   40 I = NROW
   41    B(I) = B(I)/W(MIDDLE,I)
         JMAX = MIN0(NBANDU,I-1)
         DO 45 J=1,JMAX
            IMJ = I - J
            MMJ = MIDDLE - J
   45       B(IMJ) = B(IMJ) - B(I)*W(MMJ,I)
         I = I - 1
         IF (I .GT. 1)                  GO TO 41
   49 B(1) = B(1)/W(MIDDLE,1)
                                        RETURN
      END
