C***********************************************************************
C***********************************************************************
C      
c     Call EMATpreMULT(EMAT,Zetanew,R,LRVS,NN,NHBW,NR,NBWE)

      SUBROUTINE EMATpreMULT(A,X,R,JX,NN,NB,NX,NB2DIM)
C DRL 22 Nov 1998
C From EMATMULT, same day. This routine performs premultiplication.
C    It also pre-zeros the result vector, (unlike EMATMULT which adds
C    the multiplication to the pre-established result vector).
C
C Performs the matrix algebra r=x*A for known A and x
C
C Conventions for A storage are the same as for EMATMULT and RHS MULT
C
C A and x are undisturbed; r is first zeroed, then overwritten. 
C r is a n-length vector
C A is a matrix in column-banded, column-condensed form:
C     A(row, column) is A((2*nb+1), nx)
C x is a n-length vector
C
C Column condensation:
C   JX(k) is a pointer from local to global node number
C   JX(k) is the global column number of column k in A
C       A(*,j) multiplies x(jx(j))
C
C Column-banding:
C   Columns stored have total band height 2NB+1
C   The column is stored beginning in row 1
C   The main diagonal is at row NB+1
C
C NB is the half-bandheight (Full BW=2*NB+1)
C NX is the number of columns in A (Number of Type I BC's)
C NN is the length of the r and x vectors (Number of nodes globally)
C NB2DIM is the first physical dimension of A in the main program
C    --- NB2DIM.ge.(2*NB+1) ---
C
C      DIMENSION A(NB2DIM,*), R(*), X(*),JX(*)
       REAL      A(NB2DIM,*), R(*), X(*)
       INTEGER   JX(*)
       INTEGER   NN,NB,NX,NB2DIM
C
c local variables
       INTEGER   NB2 
       INTEGER   J, JG, I1, I2, IG, I
      

C Check dimensions passed
C
      NB2=2*NB+1
      IF (NB2DIM.LT.NB2) THEN
         WRITE(*,*) ' INSUFFICIENT DIMENSION FOR MATRIX A IN'//
     &              ' SUBROUTINE EMATpreMULT'
         WRITE(*,*) ' NB2DIM =', NB2DIM, ' NB2 =', NB2
         WRITE(*,*) ' EXECUTION TERMINATED'
         STOP
      ENDIF
C
      DO J=1,NX
      	JG=JX(J)
      	R(J)=0.0
      	I1=Min0(NB,  (JG-1))
      	I2=Min0(NB, (NN-JG))
      	IG=JG-I1
      	DO I=NB+1-I1, NB+1+I2
      	   R(J)=R(J)+X(IG)*A(I,J)
      	   IG=IG+1
      	ENDDO
      ENDDO
C
      RETURN
      END
C
C*********************************************************************
C*********************************************************************
