      SUBROUTINE CALCME(JDIM,KDIM,XY,XIT,ETT,XYJ)
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
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 XY(JDIM,KDIM,4),XYJ(JDIM,KDIM)
      DIMENSION XIT(JDIM,KDIM),ETT(JDIM,KDIM)
C
C  FORM JACOBIAN
C
      DO 30 K=KBEGIN,KEND
      DO 30 J=JBEGIN,JEND
         DINV = 1./ ( XY(J,K,4) * XY(J,K,1) - XY(J,K,3) * XY(J,K,2) )
         IF(DINV .LE. 0.0)PRINT *,'JACOBIAN( ',J,K,' )= ',DINV
         XYJ(J,K) = DINV
   30 CONTINUE
C
C  CALCULATE METRICS
C
      DO 32 K=KBEGIN,KEND
      DO 32 J=JBEGIN,JEND
         DINV = XYJ(J,K)
C
C XIX = XY1, XIY=XY2,ETAX=XY3, ETAY = XY4
C
         XY(J,K,1) =   XY(J,K,1)*DINV
         XY(J,K,2) = - XY(J,K,2)*DINV
         XY(J,K,3) = - XY(J,K,3)*DINV
         XY(J,K,4) =   XY(J,K,4)*DINV
32    CONTINUE
C
      RETURN
      END
