      SUBROUTINE SOLVE(M,U,F,MAXN,NDOFS,LO,IDIAG,UP)
                              
      INTEGER MAXN,NDOFS,I,J,K,LO,UP,IDIAG,IMAX,JMAX
      DOUBLE PRECISION M(2*MAXN,*),U(*),F(*),AMUL


        DO 1200 I=1,NDOFS                             
1200      U(I)=F(I)
          

        DO 1250 K=1,NDOFS-1

          IF((K+LO).GT.NDOFS) THEN
            IMAX=NDOFS
          ELSE
            IMAX=K+LO
          ENDIF

          DO 1240 I=K+1,IMAX
            AMUL=-M(I,IDIAG+K-I)/M(K,IDIAG)
            M(I,IDIAG+K-I)=0.0

            IF((K+UP).GT.NDOFS) THEN
              JMAX=NDOFS
            ELSE
              JMAX=K+UP
            ENDIF

            DO 1230 J=K+1,JMAX 
              M(I,IDIAG+J-I)=M(I,IDIAG+J-I)+AMUL*M(K,IDIAG+J-K)
1230        CONTINUE
            U(I)=U(I)+AMUL*U(K)
1240      CONTINUE
1250    CONTINUE
      

        U(NDOFS)=U(NDOFS)/M(NDOFS,IDIAG)
      
        DO 1270 K=NDOFS-1,1,-1
          IF((K+UP).GT.NDOFS) THEN
            JMAX=NDOFS
          ELSE
            JMAX=K+UP
          ENDIF
          DO 1260 J=K+1,JMAX
            U(K)=U(K)-M(K,IDIAG+J-K)*U(J)
1260      CONTINUE
          U(K)=U(K)/M(K,IDIAG)
1270    CONTINUE

      RETURN         
      END 
