      SUBROUTINE CALCPS(JDIM,KDIM,Q,PRESS,SNDSP)
      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 Q(JDIM,KDIM,4),PRESS(JDIM,KDIM),SNDSP(JDIM,KDIM)
C
C  CALCULATE PRESSURE AND SOUND SPEED AND STORE
C
C  NOTE PRESSURE HAS JACOBIAN
C       SOUND SPEED DOES NOT HAVE JACOBIAN
C       CALL AFTER BC ROUTINE SO THAT BOUNDARY VALUES ARE CORRECT
C
        DO 1 K = KBEGIN,KEND
        DO 1 J = JBEGIN,JEND
C
        PRESS(J,K) = GAMI*(Q(J,K,4) - 
     *               0.5*(Q(J,K,2)**2 + Q(J,K,3)**2)/Q(J,K,1))
        SNDSP(J,K) = SQRT(GAMMA*PRESS(J,K)/Q(J,K,1))
C
1       CONTINUE
C
        RETURN
        END
