      SUBROUTINE ABAT(A,B,R,W,M,N)
C
C  FORM THE MATRIX PRODUCT R=ABA'
C  THE MATRICES A AND B ARE RETURNED UNCHANGED
C  W IS A SCRATCH VECTOR
C
      IMPLICIT REAL*8 (A-H,O-Z)
      DIMENSION A(M,N),B(N,N),R(M,M),W(N)
      DO 15 I=1,M
      DO 5 K=1,N
      W(K)=0
      DO 5 L=1,N
    5 W(K)=W(K)+A(I,L)*B(L,K)
      DO 15 J=I,M
      R(I,J)=0
      DO 10 L=1,N
   10 R(I,J)=R(I,J)+W(L)*A(J,L)
   15 R(J,I)=R(I,J)
      RETURN    
      END
