      SUBROUTINE TK(JDIM,KDIM,Q,SNDSP,S,XYJ,XY,IX,IY)
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C
C  IX = 1, IY = 2  XI  METRICS
C  IX = 3, IY = 4  ETA METRICS
C
      COMMON/BASE/
     1  JMAX,       KMAX,     JM,          KM,          JBEGIN,   JEND,
     1  KBEGIN,     KEND,     JPLUS(999),  JMINU (999), JLOW,     JUP,
     1  KLOW,       KUP,      PERIDC  ,    NP,          DT,   CP2TIM,
     1  FSMACH,     ALPHA,    GAMMA,       GAMI,        PI,
     1  DIS2X,      DIS2Y,    DIS4X,       DIS4Y,       PHIDT,    
     1  THETAD ,    RESID,    JACDT,       IPRINT,      NPCP,
     1  JTAIL1,     JTAIL2,   NUMITE ,     ISTART,      NSTEPS
      LOGICAL PERIDC  
      COMMON/GRID/DYM,YMAX,XMIN,XMAX,THICK
C
      DIMENSION Q(JDIM,KDIM,4),S(JDIM,KDIM,4),SNDSP(JDIM,KDIM)
      DIMENSION XY(JDIM,KDIM,4),XYJ(JDIM,KDIM)
C
      BT = 1./SQRT(2.)
      RGAMI = 1./GAMI
C
C  T  MATRIX MULTIPLY FOR DIAGONAL ALGORITHM
C   K
C
      DO 1 K = KLOW, KUP
       DO 1 J = JLOW,JUP
          RX      = XY(J,K,IX)
          RY      = XY(J,K,IY)
          RRXY    = 1./SQRT(RX**2+RY**2)
          RX      = RX*RRXY
          RY      = RY*RRXY
             RHO    = Q(J,K,1)*XYJ(J,K)
             RHOINV = 1./Q(J,K,1)
             U = Q(J,K,2)*RHOINV
             V = Q(J,K,3)*RHOINV
             ALP0 = RHO*BT/SNDSP(J,K)
                 S1 = S(J,K,1)
                 S2 = S(J,K,2)
                 SA = (S(J,K,3) + S(J,K,4))*ALP0
                 SM = (S(J,K,3) - S(J,K,4))*RHO*BT
                 UV2 = 0.5*(U**2 + V**2)
                 RRX = RHO*RX
                 RRY = RHO*RY
C
                    S(J,K,1) = S1 + SA
                    S(J,K,2) = U*S1 + RRY*S2 + U*SA + RX*SM
                    S(J,K,3) = V*S1 - RRX*S2 + V*SA + RY*SM
                    S(J,K,4) = UV2*S1 + (RRY*U - RRX*V)*S2 + 
     +                         (UV2+SNDSP(J,K)**2*RGAMI)*SA + 
     +                         (RX*U + RY*V)*SM
C
1       CONTINUE
C
          RETURN
          END
