      SUBROUTINE CMPROD(M, N, L, A, KA, B, KB, C, KC, ROW)
C     ******************************************************************
C     PRODUCT OF COMPLEX MATRICES
C     ******************************************************************
      COMPLEX A(KA,N), B(KB,L), C(KC,L), ROW(1), W
      LOGICAL CLOC
      W = C(1,1)
      C(1,1) = (1.0,0.0)
      IF (CLOC(C,A)) GO TO 20
      IF (CLOC(C,B)) GO TO 30
C
      DO 12 J = 1,L
         DO 11 I = 1,M
         W = (0.0,0.0)
            DO 10 K = 1,N
   10       W = W + A(I,K)*B(K,J)
   11    C(I,J) = W
   12 CONTINUE
      RETURN
C
C     HERE C BEGINS IN THE SAME LOCATION AS A. THE DIMENSION OF ROW
C     MUST BE GREATER THAN OR EQUAL TO L. IT IS ASSUMED THAT KC=KA.
C
   20 A(1,1) = W
      DO 24 I = 1,M
         DO 22 J = 1,L
         W = (0.0,0.0)
            DO 21 K = 1,N
   21       W = W + A(I,K)*B(K,J)
   22    ROW(J) = W
         DO 23 J = 1,L
   23    A(I,J) = ROW(J)
   24 CONTINUE
      RETURN
C
C     HERE C BEGINS IN THE SAME LOCATION AS B. THE DIMENSION OF ROW
C     MUST BE GREATER THAN OR EQUAL TO M. IT IS ASSUMED THAT KC=KB.
C
   30 B(1,1) = W
      DO 34 J = 1,L
         DO 32 I = 1,M
         W = (0.0,0.0)
            DO 31 K = 1,N
   31       W = W + A(I,K)*B(K,J)
   32    ROW(I) = W
         DO 33 I = 1,M
   33    B(I,J) = ROW(I)
   34 CONTINUE
      RETURN
      END
