C
C *** TRANSMISSION BOUNDARY ***
C
      SUBROUTINE TMB2(OM,MMD,SZ4,SZ5,ND4,CC,NMODE,DV,DP,WK,IWK,DK)
C
C ** INPUT DATA **
C OM    : OMEGA
C MMD   : MAX MODE NUMBER IN MAIN DIMENSION
C SZ4(I): Z LOCATION OF Ith NODE ON BOUNDARY 4 (THE UPPER LAYER)
C SZ5(I): Z LOCATION OF Ith NODE ON BOUNDARY 5 (THE BOTTOM BEDROCK)
C ND4   : DIMENSION NUMBER OF TOTAL NODE OF B4 AND B5
C ** OUTPUT DATA **
C CC(J)  : PHASE VELOCITY OF THE Jth LOVE MODE
C NMODE  : OUTPUT HIGHEST MODE
C DV(I,J): MATRIX DV
C DP(I,J): MATRIX DP
C WK(I)  : WORK MATRIX
C IWK(I) : WORK MATRIX
C DK(I,J): MATRIX DK (STIFFNESS MATRIX DUE TO TRANSMISSION BOUNDARY)
C
      IMPLICIT REAL*8(A-H,O-Z)
      COMMON /NS/NS1,NS2,NS3,NS4,NS5
      DIMENSION CC(0:MMD),SZ4(ND4),SZ5(ND4),WK(ND4),IWK(ND4) 
      COMPLEX*16 DV(ND4,ND4),DP(ND4,ND4),DK(ND4,ND4)
C
C *** PHASE VELOCITY ***
C
      NDC=100
      CALL PHAS2(OM,NDC,MMD,CC,NMODE)
C
C *** DV AND DP ***
C
      CALL LVVP(OM,CC,NMODE,MMD,SZ4,SZ5,ND4,DV,DP)
C
C *** DK ***
C
      ESP=1.D-10
      CALL $ZIF1M(DV,NS4+NS5,ND4,ESP,RDET,IDET,WK,IWK,IER)
      IF(IER.NE.0)THEN
        WRITE(*,*)'FROM TMB; IER.NE.0, THUS STOP'
        WRITE(*,*)'IER=',IER
        STOP
      END IF
C
      DO 100 I=1,ND4
        DO 110 J=1,ND4
          DK(I,J)=(0.D0,0.D0)
  110   CONTINUE
  100 CONTINUE
C
      DO 200 I=1,ND4
        DO 210 J=1,ND4
          DO 220 K=1,ND4
            DK(I,J)=DK(I,J)-DV(I,K)*DP(K,J)
  220     CONTINUE
  210   CONTINUE
  200 CONTINUE
C
      RETURN
      END
