
      SUBROUTINE EOSALL(S,T,P0,THET,SIGTHE,ALFNEW,BETNEW,GAMNEW,SOUNDV)
C *********************************************************************
C THIS PROGRAMME WRITTEN 8 JULY 1985 BY TREVOR J. McDOUGALL
C EOSALL STANDS FOR "EQUATION OF STATE ALL"
C THIS SUBROUTINE USES THE FOLLOWING FUNCTIONS WRITEN BY BOB MILLARD,
C  - THETA(S,T,P0,PR) ; SVAN(S,T,P0,SIGTHE) ; EOS8D(S,T,P0,DRV)
C THE NEW EXPANSION COEFFICIENT , ALFNEW , DUE TO HEAT , AND THE
C CORRESPONDING SALINE CONTRACTION COEFFICIENT ARE DEFINED IN
C TERMS OF THE TWO CONSERVATIVE PROPERTIES OF SEA WATER,
C NAMELY POTENTIAL TEMPERATURE (REFERED TO ANY REFERENCE LEVEL)
C AND SALINITY. THESE COEFFICIENTS ARE DEFINED IN GILL(1982)
C AND HE LABELS THEM WITH DASHES, SEE HIS SECTION 3.7.4
C ********************************************************************
C
      IMPLICIT DOUBLE PRECISION (A-Z)
      DOUBLE PRECISION DRV(3,8)
C ******* THE REFERENCE PRESSURE PR IS KEPT GENERAL BUT WILL BE
C ******* EQUAL TO ZERO FOR ALL PERCIEVED APPLICATIONS OF NEUTRAL
C ******* SURFACES.
      PR=0.0
      THET=THETA(S,T,P0,PR)
      EDUM=EOS8D(S,T,P0,DRV)
C ******* CALCULATE THE ORDINARY EXPANSION COEFFICIENTS, ALFOLD
C ******* BETOLD AND THE OLD COMPRESSIBILITY, GAMOLD.
      ALFOLD=-DRV(2,3)/(DRV(1,3)+1000.0)
      BETOLD=DRV(1,8)/(DRV(1,3)+1000.0)
      GAMOLD=DRV(1,7)/(DRV(1,3)+1000.0)
C ******* CALCULATE THE SPECIFIC VOLUME ANOMALY, SVAN, AND THE
C ******* SIGMA THETA, SIGTHE, BY THE FUNCTION SVAN.
      SDUM=SVAN(S,THET,PR,SIGTHE)
      CALL DERTHE(S,T,P0,DTHEDT,DTHEDS,DTHEDP)
      ALFNEW=ALFOLD/DTHEDT
      BETNEW=BETOLD+ALFNEW*DTHEDS
      GAMNEW=GAMOLD+ALFNEW*DTHEDP
C ******* CHECK VALUES OF THESE NEW 'EXPANSION COEFFICIENTS'
C ******* AT S=40.0,T=40.0,THET=36.8907,P0=10000.0 DBARS,
C ******* ALFNEW=4395.6E-7 ; (ALFOLD=4181.1E-7)
C ******* BETNEW=6646.9E-7 ; (BETOLD=6653.1E-7)
C ******* GAMNEW=31.4E-7   ; (GAMOLD=32.7E-7)
C *******
C ******* NOW FOR FUN WE CALCULATE THE SPEED OF SOUND.
C ******* THE IN SITU DENSITY IS (DRV(1,3)+1000.0)
      SOUNDV=SQRT(ABS(1.0E+4/(GAMNEW*(DRV(1,3)+1000.0))))
C ******* CHECK VALUE OF THE SPEED OF SOUND IS
C ******* AT S=40.0,T=40.0,THET=36.8907,P0=10000.0 DBARS,
C ******* IS SOUNDV=1734.8 M/S.
      RETURN
      END

