
      SUBROUTINE TGAS(E,R,P,A,KFLAG)
C
C     INPUTS FOR SUBROUTINE:
C     E=INTERNAL ENERGY IN (M/SEC)**2
C     R=DENSITY IN KG/M**3
C     KFLAG=0 OR 1 DEPENDING ON OUTPUT VARIABLE DESIRED
C
C     OUTPUTS:
C     FOR KFLAG=0 RETURN P=PRESSURE IN NEWTONS/M**2
C     FOR KFLAG=1 RETURN P=PRESSURE IN NEWTONS/M**2 AND
C                        A=SPEED OF SOUND IN M/SEC
C
      DATA E0,R0/78408.4E00,1.292E00/
      RRATIO=R/R0
      ERATIO=E/E0
      Y=ALOG10(RRATIO)
      Z=ALOG10(ERATIO)
      IF(ABS(Y+4.5E00).LT.2.5E-02) GO TO 20
      IF(ABS(Y+0.5E00).LT.5.0E-03) GO TO 50
      IFLAG=-1
      GO TO 90
10    RETURN
20    IFLAG=0
      RSAVE=R
      YM=Y
      Y=-4.5E00+2.5E-02
      YHIGH=Y
      R=(10.**Y)*R0
      JFLAG=-1
      GO TO 90
30    PHIGH=P
      AHIGH=A
      Y=-4.5E00-2.5E-02
      YLOW=Y
      R=(10.**Y)*R0
      JFLAG=0
      GO TO 90
40    PLOW=P
      ALOW=A
      GO TO 80
50    IFLAG=1
      RSAVE=R
      YM=Y
      Y=-0.5E00+0.5E-02
      YHIGH=Y
      R=(10.**Y)*R0
      JFLAG=-1
      GO TO 90
60    PHIGH=P
      AHIGH=A
      Y=-0.5E00-0.5E-02
      YLOW=Y
      R=(10.**Y)*R0
      JFLAG=0
      GO TO 90
70    PLOW=P
      ALOW=A
80    P=PLOW+(PHIGH-PLOW)/(YHIGH-YLOW)*(YM-YLOW)
      A=ALOW+(AHIGH-ALOW)/(YHIGH-YLOW)*(YM-YLOW)
      R=RSAVE
      RETURN
90    CONTINUE
      IF(Y.GT.-0.5E00) GO TO 180
      IF(Y.GT.-4.5E00) GO TO 140
         IF(Z.LE.0.65E00) GO TO 220
      IF(Z.GT.1.5E00) GO TO 100
      GAS1=1.39037E00-8.21107E-03*Y
      GAS2=(-2.43213E-02+1.24063E-02*Y)*Z
      GAS3=(-7.25748E-04-1.25272E-03*Z-9.10474E-05*Y)*Y*Y
      GAS4=(1.22447E-01-1.89287E-02*Y-1.48369E-01*Z)*Z*Z
      GAS5=-3.75667E00-1.54712E-01*Y
      GAS6=(7.78906E00+2.03385E-01*Y)*Z
      GAS7=(-7.16886E-04+1.90409E-03*Z+6.40147E-05*Y)*Y*Y
      GAS8=(-5.34593E00-4.78112E-02*Y+1.27123E00*Z)*Z*Z
      GAS9=EXP(8.6E01+5.058807E00*Y-8.0E01*Z-4.705882E00*Y*Z)
      DENO=1.-GAS9
      GAMM=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/DENO
      IF(KFLAG.EQ.0) GO TO 230
      GAS1R=-8.21107E-03
      GAS2R=1.24063E-02*Z
      GAS3R=(-1.451496E-03-2.50544E-03*Z-2.731422E-04*Y)*Y
      GAS4R=-1.89287E-02*Z*Z
      GAS5R=-1.54712E-01
      GAS6R=2.03385E-01*Z
      GAS7R=(-1.433772E-03+3.80818E-03*Z+1.920441E-04*Y)*Y
      GAS8R=-4.78112E-02*Z*Z
      GAS9R=5.058807E00-4.705882E00*Z
      GAS2E=GAS2/Z
      GAS3E=-1.25272E-03*Y*Y
      GAS4E=(2.44894E-01-3.78574E-02*Y-4.45107E-01*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=1.90409E-03*Y*Y
      GAS8E=(-1.069186E01-9.56224E-02*Y+3.81369E00*Z)*Z
      GAS9E=-8.0E01-4.705882E00*Y
      GAMMR=GAS1R+GAS2R+GAS3R+GAS4R+(GAS5R+GAS6R+GAS7R+GAS8R)/DENO
     *+(GAS5+GAS6+GAS7+GAS8)*GAS9R*GAS9/(DENO**2)
      GAMME=GAS2E+GAS3E+GAS4E+(GAS6E+GAS7E+GAS8E)/DENO
     *+(GAS5+GAS6+GAS7+GAS8)*GAS9E*GAS9/(DENO**2)
      GO TO 230
100   IF(Z.GT.2.2E00) GO TO 110
      GAS1=-1.70333E01-5.08545E-01*Y
      GAS2=(2.46299E01+4.45617E-01*Y)*Z
      GAS3=(-8.95298E-03+2.29618E-03*Z-2.89186E-04*Y)*Y*Y
      GAS4=(-1.10204E01-9.89727E-02*Y+1.62903E00*Z)*Z*Z
      GAS5=1.86797E01+5.19662E-01*Y
      GAS6=(-2.41338E01-4.34837E-01*Y)*Z
      GAS7=(9.16089E-03-1.52082E-03*Z+3.46482E-04*Y)*Y*Y
      GAS8=(1.02035E01+9.70762E-02*Y-1.39460E00*Z)*Z*Z
      GAS9=(-1.42762E02-1.647088E00*Y+7.660312E01*Z
     *+8.259346E-01*Y*Z)
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=-5.08545E-01
      GAS2R=4.45617E-01*Z
      GAS3R=(-1.790596E-02+4.59236E-03*Z-8.67558E-04*Y)*Y
      GAS4R=-9.89727E-02*Z*Z
      GAS5R=5.19662E-01
      GAS6R=-4.34837E-01*Z
      GAS7R=(1.832178E-02-3.04164E-03*Z+1.039446E-03*Y)*Y
      GAS8R=9.70762E-02*Z*Z
      GAS9R=-1.647088E00+8.259346E-01*Z
      GAS2E=GAS2/Z
      GAS3E=2.29618E-03*Y*Y
      GAS4E=(-2.20408E01-1.979454E-01*Y+4.88709E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=-1.52082E-03*Y*Y
      GAS8E=(2.0407E01+1.941524E-01*Y-4.1838E00*Z)*Z
      GAS9E=7.660312E01+8.259346E-01*Y
      GO TO 210
110   IF (Z.GT.3.05E00) GO TO 120
      GAS1=2.24374E00+1.03073E-01*Y
      GAS2=(-5.32238E-01-5.59852E-02*Y)*Z
      GAS3=(3.56484E-03-1.01359E-04*Z+1.59127E-04*Y)*Y*Y
      GAS4=(-4.80156E-02+1.06794E-02*Y+3.66035E-02*Z)*Z*Z
      GAS5=-5.70378E00-3.10056E-01*Y
      GAS6=(5.01094E00+1.80411E-01*Y)*Z
      GAS7=(-9.49361E-03+1.94839E-03*Z-2.24908E-04*Y)*Y*Y
      GAS8=(-1.40331E00-2.79718E-02*Y+1.20278E-01*Z)*Z*Z
      GAS9=(1.139755E02-4.985467E00*Y-4.223833E01*Z
     *+2.009706E00*Y*Z)
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=1.03073E-01
      GAS2R=-5.59852E-02*Z
      GAS3R=(7.12968E-03-2.0218E-04*Z+4.77381E-04*Y)*Y
      GAS4R=1.06794E-02*Z*Z
      GAS5R=-3.10056E-01
      GAS6R=1.80411E-01*Z
      GAS7R=(-1.898722E-02+3.89678E-03*Z-6.74724E-04*Y)*Y
      GAS8R=-2.79718E-02*Z*Z
      GAS9R=-4.985467E00+2.009706E00*Z
      GAS2E=GAS2/Z
      GAS3E=-1.01359E-04*Y*Y
      GAS4E=(-9.60312E-02+2.13588E-02*Y+1.098105E-01*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=1.94839E-03*Y*Y
      GAS8E=(-2.80662E00-5.59436E-02*Y+3.60834E-01*Z)*Z
      GAS9E=-4.223833E01+2.009706E00*Y
      GO TO 210
120   IF(Z.GT.3.4E00) GO TO 130
      GAS1=-0.20807E02+0.40197E00*Y
      GAS2=(0.22591E02-0.25660E00*Y)*Z
      GAS3=(-0.95833E-03+0.23966E-02*Z+0.33671E-03*Y)*Y*Y
      GAS4=(-0.77174E01+0.4606E-01*Y+0.878E00*Z)*Z*Z
      GAS5=-0.21737E03-0.46927E01*Y
      GAS6=(0.18101E03+0.26621E01*Y)*Z
      GAS7=(-0.34759E-01+0.64681E-02*Z-0.70391E-03*Y)*Y*Y
      GAS8=(-0.50019E02-0.38381E00*Y+0.45795E01*Z)*Z*Z
      GAS9=(0.4544373E03+0.1250133E02*Y-0.1376001E03*Z
     *-0.3641774E01*Y*Z)
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=0.40197E00
      GAS2R=-0.25660E00*Z
      GAS3R=(-1.91666E-03+4.7932E-03*Z+1.01013E-03*Y)*Y
      GAS4R=0.4606E-01*Z*Z
      GAS5R=-0.46927E01
      GAS6R=0.26621E01*Z
      GAS7R=(-6.9518E-02+1.29362E-02*Z-2.11173E-03*Y)*Y
      GAS8R=-0.38381E00*Z*Z
      GAS9R=0.1250133E02-0.3641774E01*Z
      GAS2E=GAS2/Z
      GAS3E=0.23966E-02*Y*Y
      GAS4E=(-1.54348E01+9.212E-02*Y+2.634E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=0.64681E-02*Y*Y
      GAS8E=(-1.00038E02-7.6762E-01*Y+1.37385E01*Z)*Z
      GAS9E=-0.1376001E03-0.3641774E01*Y
      GO TO 210
130   IF(Z.GT.3.69E00) WRITE(6,1000) R,E
      GAS1=-5.22951E01-4.00011E-01*Y
      GAS2=(4.56439E01+2.24484E-01*Y)*Z
      GAS3=(-3.73775E-03+2.43161E-03*Z+2.24755E-04*Y)*Y*Y
      GAS4=(-1.29756E01-2.79517E-02*Y+1.22998E00*Z)*Z*Z
      GAMM=GAS1+GAS2+GAS3+GAS4
      IF(KFLAG.EQ.0) GO TO 230
      GAS1R=-4.00011E-01
      GAS2R=2.24484E-01*Z
      GAS3R=(-7.4755E-03+4.86322E-03*Z+6.74265E-04*Y)*Y
      GAS4R=-2.79517E-02*Z*Z
      GAS2E=GAS2/Z
      GAS3E=2.43161E-03*Y*Y
      GAS4E=(-2.59512E01-5.59034E-02*Y+3.68994E00*Z)*Z
      GAMMR=GAS1R+GAS2R+GAS3R+GAS4R
      GAMME=GAS2E+GAS3E+GAS4E
      GO TO 230
140   IF(Z.LE.0.65E00) GO TO 220
      IF (Z.GT.1.5E00) GO TO 150
      GAS1=1.39123E00-4.08321E-03*Y
      GAS2=(1.42545E-02+1.41769E-02*Y)*Z
      GAS3=(2.57225E-04+6.52912E-04*Z+8.46912E-05*Y)*Y*Y
      GAS4=(6.2555E-02-7.83637E-03*Y-9.78720E-02*Z)*Z*Z
      GAS5=5.80955-1.82302E-01*Y
      GAS6=(-9.62396E00+1.79619E-01*Y)*Z
      GAS7=(-2.30518E-02+1.18720E-02*Z-3.35499E-04*Y)*Y*Y
      GAS8=(5.27047E00-3.65507E-02*Y-9.19897E-01*Z)*Z*Z
      GAS9=(-10.0E00*Z+14.2E00)
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=-4.08321E-03
      GAS2R=1.41769E-02*Z
      GAS3R=(5.1445E-04+1.305824E-03*Z+2.540736E-04*Y)*Y
      GAS4R=-7.83637E-03*Z*Z
      GAS5R=-1.82302E-01
      GAS6R=1.79619E-01*Z
      GAS7R=(-4.61036E-02+2.3744E-02*Z-1.006497E-03*Y)*Y
      GAS8R=-3.65507E-02*Z*Z
      GAS9R=0.0E00
      GAS2E=GAS2/Z
      GAS3E=6.52912E-04*Y*Y
      GAS4E=(1.2511E-01-1.567274E-02*Y-2.93616E-01*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=1.1872E-02*Y*Y
      GAS8E=(1.054094E01-7.31014E-02*Y-2.759691E00*Z)*Z
      GAS9E=-10.0E00
      GO TO 210
150   IF (Z.GT.2.22E00) GO TO 160
      GAS1=-1.20784E00-2.57909E-01*Y
      GAS2=(5.02307E00+2.87201E-01*Y)*Z
      GAS3=(-9.95577E-03+5.23524E-03*Z-1.45574E-04*Y)*Y*Y
      GAS4=(-3.20619E00-7.50405E-02*Y+6.51564E-01*Z)*Z*Z
      GAS5=-6.62841E00+2.77112E-02*Y
      GAS6=(7.30762E00-7.68230E-02*Y)*Z
      GAS7=(7.19421E-03-3.62463E-03*Z+1.62777E-04*Y)*Y*Y
      GAS8=(-2.33161E00+3.04767E-02*Y+1.66856E-01*Z)*Z*Z
      GAS9=(1.255324E02+2.015335E00*Y-6.390747E01*Z-
     *6.515225E-01*Y*Z)
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=-2.57909E-01
      GAS2R=2.87201E-01*Z
      GAS3R=(-1.991154E-02+1.047048E-02*Z-4.36722E-04*Y)*Y
      GAS4R=-7.50405E-02*Z*Z
      GAS5R=2.77112E-02
      GAS6R=-7.6823E-02*Z
      GAS7R=(1.438842E-02-7.24926E-03*Z+4.88331E-04*Y)*Y
      GAS8R=3.04767E-02*Z*Z
      GAS9R=2.015335E00-6.515225E-01*Z
      GAS2E=GAS2/Z
      GAS3E=5.23524E-03*Y*Y
      GAS4E=(-6.41238E00-1.50081E-01*Y+1.954692E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=-3.62463E-03*Y*Y
      GAS8E=(-4.66322E00+6.09534E-02*Y+5.00568E-01*Z)*Z
      GAS9E=-6.390747E01-6.515225E-01*Y
      GO TO 210
160   IF (Z.GT.2.95) GO TO 170
      GAS1=-2.26460E00-7.82263E-02*Y
      GAS2=(4.90497E00+7.18096E-02*Y)*Z
      GAS3=(-3.06443E-03+1.74209E-03*Z+2.84214E-05*Y)*Y*Y
      GAS4=(-2.24750E00-1.31641E-02*Y+3.33658E-01*Z)*Z*Z
      GAS5=-1.47904E01-1.76627E-01*Y
      GAS6=(1.35036E01+8.77280E-02*Y)*Z
      GAS7=(-2.13327E-03+7.15487E-04*Z+7.30928E-05*Y)*Y*Y
      GAS8=(-3.95372E00-8.96151E-03*Y+3.63229E-01*Z)*Z*Z
      GAS9=(1.788542E02+6.317894E00*Y-6.756741E01*Z-
     *2.460060E00*Y*Z)
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=-7.82263E-02
      GAS2R=7.18096E-02*Z
      GAS3R=(-6.12886E-03+3.48418E-03*Z+8.52642E-05*Y)*Y
      GAS4R=-1.31641E-02*Z*Z
      GAS5R=-1.76627E-01
      GAS6R=8.7728E-02*Z
      GAS7R=(-4.26654E-03+1.430974E-03*Z+2.192784E-04*Y)*Y
      GAS8R=-8.96151E-03*Z*Z
      GAS9R=6.317894E00-2.46006E00*Z
      GAS2E=GAS2/Z
      GAS3E=1.74209E-03*Y*Y
      GAS4E=(-4.495E00-2.63282E-02*Y+1.000974E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=7.15487E-04*Y*Y
      GAS8E=(-7.90744E00-1.792302E-02*Y+1.089687E00*Z)*Z
      GAS9E=-6.756741E01-2.46006E00*Y
      GO TO 210
170   IF(Z.GT.3.4E00) WRITE(6,1000) R,E
      GAS1=-1.66904E01-2.58318E-01*Y
      GAS2=(1.78350E01+1.54898E-01*Y)*Z
      GAS3=(-9.71263E-03+3.97740E-03*Z+9.04300E-05*Y)*Y*Y
      GAS4=(-5.94108E00-2.01335E-02*Y+6.60432E-01*Z)*Z*Z
      GAS5=8.54690E01+1.17554E01*Y
      GAS6=(-7.21760E01-7.15723E00*Y)*Z
      GAS7=(-4.16150E-02+1.38147E-02*Z+5.45184E-04*Y)*Y*Y
      GAS8=(2.01758E01+1.08990E00*Y-1.86438E00*Z)*Z*Z
      GAS9=(2.883262E02+1.248536E01*Y-8.816985E01*Z-
     *3.720309E00*Y*Z)
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=-2.58318E-01
      GAS2R=1.54898E-01*Z
      GAS3R=(-1.942526E-02+7.9548E-03*Z+2.7129E-04*Y)*Y
      GAS4R=-2.01335E-02*Z*Z
      GAS5R=1.17554E01
      GAS6R=-7.15723E00*Z
      GAS7R=(-8.323E-02+2.76294E-02*Z+1.635552E-03*Y)*Y
      GAS8R=1.0899E00*Z*Z
      GAS9R=1.248536E01-3.720309E00*Z
      GAS2E=GAS2/Z
      GAS3E=3.9774E-03*Y*Y
      GAS4E=(-1.188216E01-4.0267E-02*Y+1.981296E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=1.38147E-02*Y*Y
      GAS8E=(4.03516E01+2.1798E00*Y-5.59314E00*Z)*Z
      GAS9E=-8.816985E01-3.720309E00*Y
      GO TO 210
180   IF(Z.LE.0.65E00) GO TO 220
      IF(Z.GT.1.7E00) GO TO 190
      GAS1=1.37062E00+1.29673E-02*Y
      GAS2=(1.11418E-01-3.26912E-02*Y)*Z
      GAS3=(1.06869E-03-2.00286E-03*Z+2.38305E-04*Y)*Y*Y
      GAS4=(-1.06133E-01+1.90251E-02*Y+3.02210E-03*Z)*Z*Z
      GAMM=GAS1+GAS2+GAS3+GAS4
      IF(KFLAG.EQ.0) GO TO 230
      GAS1R=1.29673E-02
      GAS2R=-3.26912E-02*Z
      GAS3R=(2.13738E-03-4.00572E-03*Z+7.14915E-04*Y)*Y
      GAS4R=1.90251E-02*Z*Z
      GAS2E=GAS2/Z
      GAS3E=-2.00286E-03*Y*Y
      GAS4E=(-2.12266E-01+3.80502E-02*Y+9.0663E-03*Z)*Z
      GAMMR=GAS1R+GAS2R+GAS3R+GAS4R
      GAMME=GAS2E+GAS3E+GAS4E
      GO TO 230
190   IF(Z.GT.2.35) GO TO 200
      GAS1=3.43846E-02-2.33584E-01*Y
      GAS2=(2.85574E00+2.59787E-01*Y)*Z
      GAS3=(-10.89927E-03+4.23659E-03*Z+3.85712E-04*Y)*Y*Y
      GAS4=(-1.94785E00-6.73865E-02*Y+4.08518E-01*Z)*Z*Z
      GAS5=-4.20569E00+1.33139E-01*Y
      GAS6=(4.51236E00-1.66341E-01*Y)*Z
      GAS7=(1.67787E-03-1.10022E-03*Z+3.06676E-04*Y)*Y*Y
      GAS8=(-1.35516E00+4.91716E-02*Y+7.52509E-02*Z)*Z*Z
      GAS9=(1.757042E02-2.163278E00*Y-8.833702E01*Z+
     *1.897543E00*Y*Z)
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=-2.33584E-01
      GAS2R=2.59787E-01*Z
      GAS3R=(-2.179854E-02+8.47318E-03*Z+1.157136E-03*Y)*Y
      GAS4R=-6.73865E-02*Z*Z
      GAS5R=1.33139E-01
      GAS6R=-1.66341E-01*Z
      GAS7R=(3.35574E-03-2.20044E-03*Z+9.20028E-04*Y)*Y
      GAS8R=4.91716E-02*Z*Z
      GAS9R=-2.163278E00+1.897543E00*Z
      GAS2E=GAS2/Z
      GAS3E=4.23659E-03*Y*Y
      GAS4E=(-3.8957E00-1.34773E-01*Y+1.225554E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=-1.10022E-03*Y*Y
      GAS8E=(-2.71032E00+9.83432E-02*Y+2.257527E-01*Z)*Z
      GAS9E=-8.833702E01+1.897543E00*Y
      GO TO 210
200   IF(Z.GT.2.9E00) WRITE(6,1000) R,E
      GAS1=-1.70633E00-1.48403E-01*Y
      GAS2=(4.23104E00+1.37290E-01*Y)*Z
      GAS3=(-9.10934E-03+3.85707E-03*Z+2.69026E-04*Y)*Y*Y
      GAS4=(-1.97292E00-2.81830E-02*Y+2.95882E-01*Z)*Z*Z
      GAS5=3.41580E01-1.89972E01*Y
      GAS6=(-4.0858E01+1.30321E01*Y)*Z
      GAS7=(-8.01272E-01+2.75121E-01*Z-1.77969E-04*Y)*Y*Y
      GAS8=(1.60826E01-2.23386E00*Y-2.08853E00*Z)*Z*Z
      GAS9=(2.561323E02+1.737089E02*Y-9.058890E01*Z-
     *5.838803E01*Y*Z)
      IF(GAS9.GT.30.E00) GAS9=30.E00
      IF(GAS9.LT.-30.E00) GAS9=-30.E00
      IF(KFLAG.EQ.0) GO TO 210
      GAS1R=-1.48403E-01
      GAS2R=1.3729E-01*Z
      GAS3R=(-1.821868E-02+7.71414E-03*Z+8.07078E-04*Y)*Y
      GAS4R=-2.8183E-02*Z*Z
      GAS5R=-1.89972E01
      GAS6R=1.30321E01*Z
      GAS7R=(-1.602544E00+5.50242E-01*Z-5.33907E-04*Y)*Y
      GAS8R=-2.23386E00*Z*Z
      GAS9R=1.737089E02-5.838803E01*Z
      GAS2E=GAS2/Z
      GAS3E=3.85707E-03*Y*Y
      GAS4E=(-3.94584E00-5.6366E-02*Y+8.87646E-01*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=2.75121E-01*Y*Y
      GAS8E=(3.21652E01-4.46772E00*Y-6.26559E00*Z)*Z
      GAS9E=-9.05889E01-5.838803E01*Y
210   GAS9=EXP(GAS9)
      GAMM=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.+GAS9)
      IF(KFLAG.EQ.0) GO TO 230
      GAMMR=GAS1R+GAS2R+GAS3R+GAS4R+(GAS5R+GAS6R+GAS7R+GAS8R)/
     *(1.+GAS9)-(GAS5+GAS6+GAS7+GAS8)*GAS9R*GAS9/((1.+GAS9)**2)
      GAMME=GAS2E+GAS3E+GAS4E+(GAS6E+GAS7E+GAS8E)/(1.+GAS9)
     *-(GAS5+GAS6+GAS7+GAS8)*GAS9E*GAS9/((1.+GAS9)**2)
      GO TO 230
220   GAMM=1.396E00
      IF(KFLAG.EQ.0) GO TO 230
      GAMMR=0.0E00
      GAMME=0.0E00
230   P=(GAMM-1)*E*R
      IF(KFLAG.EQ.0) GO TO 240
      GAMMR=GAMMR/2.302585E00
      GAMME=GAMME/2.302585E00
      A=E*((GAMM-1.E00)*(GAMM+GAMME)+GAMMR)
240   IF(IFLAG) 10,250,260
250   IF(JFLAG) 30,40,10
260   IF(JFLAG) 60,70,10
1000  FORMAT(/20X,48HWARNING]  OUTSIDE OF VALIDITY RANGE OF CURVE FIT
     *,/,20X,5HRHO =,1PE15.8,5X,3HE =,1PE15.8,/)
      RETURN
      END
C     SUBROUTINE TGAS1(E,R,P,A,T,MFLAG)
C
C     INPUTS FOR SUBROUTINE:
C
C     E= INTERNAL ENERGY, IN (M/SEC)**2 ;
C     R= DENSITY, IN KG/M**3 .
C
C     OUTPUTS:
C
C     P= PRESSURE, IN NEWTONS/M**2 ;
C     A= SPEED OF SOUND, IN M/SEC ;
C     T= TEMPERATURE, IN KELVIN .
C
C     IF MFLAG=0, RETURN P ;
C     IF MFLAG=1, RETURN P AND A ;
C     IF MFLAG=2, RETURN P AND T ;
C     IF MFLAG=3, RETURN P, A AND T .
C
      SUBROUTINE TGAS1 (E,R,P,A,T,MFLAG)
      DATA E0,R0,P0,T0,GASCON/78408.4E00,1.292E00,1.0133E05,
     *273.15E00,287.06E00/
      RRATIO=R/R0
      ERATIO=E/E0
      Y=ALOG10(RRATIO)
      Z=ALOG10(ERATIO)
      LFLAG=0
      KFLAG=0
      IF (MFLAG.GT.1) LFLAG=1
      IF ((MFLAG.EQ.1).OR.(MFLAG.EQ.3)) KFLAG=1
      IF(ABS(Y+4.5E00).LT.2.5E-02) GO TO 20
      IF(ABS(Y+0.5E00).LT.5.0E-03) GO TO 50
      IFLAG=-1
      GO TO 90
10    IF(LFLAG.EQ.1) GO TO 300
      RETURN
20    IFLAG=0
      RSAVE=R
      YM=Y
      Y=-4.5E00+2.5E-02
      YHIGH=Y
      R=(10.**Y)*R0
      JFLAG=-1
      GO TO 90
30    PHIGH=P
      AHIGH=A
      Y=-4.5E00-2.5E-02
      YLOW=Y
      R=(10.**Y)*R0
      JFLAG=0
      GO TO 90
40    PLOW=P
      ALOW=A
      GO TO 80
50    IFLAG=1
      RSAVE=R
      YM=Y
      Y=-0.5E00+0.5E-02
      YHIGH=Y
      R=(10.**Y)*R0
      JFLAG=-1
      GO TO 90
60    PHIGH=P
      AHIGH=A
      Y=-0.5E00-0.5E-02
      YLOW=Y
      R=(10.**Y)*R0
      JFLAG=0
      GO TO 90
70    PLOW=P
      ALOW=A
80    P=PLOW+(PHIGH-PLOW)/(YHIGH-YLOW)*(YM-YLOW)
      A=ALOW+(AHIGH-ALOW)/(YHIGH-YLOW)*(YM-YLOW)
      R=RSAVE
      IF(LFLAG.EQ.1) GO TO 300
      RETURN
90    CONTINUE
      IF(Y.GT.-0.5E00) GO TO 200
      IF(Y.GT.-4.5E00) GO TO 150
      IF(Z.GT.0.65E00) GO TO 100
      GAMM=1.3965E00
      GO TO 250
100   IF(Z.GT.1.5E00) GO TO 110
      GAS1=1.52792E00-1.26953E-02*Y
      GAS2=(-6.13514E-01-5.08262E-02*Y)*Z
      GAS3=(-5.49384E-03+4.75120E-05*Z-3.18468E-04*Y)*Y*Y
      GAS4=(6.31835E-01+3.34012E-02*Y-2.19921E-01*Z)*Z*Z
      GAS5=-4.96286E01-1.17932E+01*Y
      GAS6=(6.91028E01+4.40405E+01*Y)*Z
      GAS7=(5.09249E00-1.40326E00*Z+2.08988E-01*Y)*Y*Y
      GAS8=(1.37308E01-1.78726E01*Y-1.86943E01*Z)*Z*Z
      GAS9=EXP(24.60452E00-2.E00*Y-2.093022E01*Z)
      DENO=1.-GAS9
      GAMM=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/DENO
      IF(KFLAG.EQ.0) GO TO 260
      GAS1R=-1.26953E-02
      GAS2R=-5.08262E-02*Z
      GAS3R=(-1.098768E-02-9.50240E-05*Z-9.554040E-04*Y)*Y
      GAS4R=3.34012E-02*Z*Z
      GAS5R=-1.17932E01
      GAS6R=4.40405E01*Z
      GAS7R=(1.018498E01-2.80652E00*Z+6.269641E-01*Y)*Y
      GAS8R=-1.78726E01*Z*Z
      GAS9R=-2.0E00
      GAS2E=GAS2/Z
      GAS3E=4.75120E-05*Y*Y
      GAS4E=(1.26367E00+6.68024E-02*Y-6.59763E-01*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=-1.40326E00*Y*Y
      GAS8E=(2.74616E01-3.57452E01*Y-5.60829E01*Z)*Z
      GAS9E=-2.093022E01
      GAMMR=GAS1R+GAS2R+GAS3R+GAS4R+(GAS5R+GAS6R+GAS7R+GAS8R)/DENO
     *+(GAS5+GAS6+GAS7+GAS8)*GAS9R*GAS9/(DENO**2)
      GAMME=GAS2E+GAS3E+GAS4E+(GAS6E+GAS7E+GAS8E)/DENO
     *+(GAS5+GAS6+GAS7+GAS8)*GAS9E*GAS9/(DENO**2)
      GO TO 260
110   IF(Z.GT.2.2E00) GO TO 120
      GAS1=-1.70333E01-5.08545E-01*Y
      GAS2=(2.46299E01+4.45617E-01*Y)*Z
      GAS3=(-8.95298E-03+2.29618E-03*Z-2.89186E-04*Y)*Y*Y
      GAS4=(-1.10204E01-9.89727E-02*Y+1.62903E00*Z)*Z*Z
      GAS5=1.86797E01+5.19662E-01*Y
      GAS6=(-2.41338E01-4.34837E-01*Y)*Z
      GAS7=(9.16089E-03-1.52082E-03*Z+3.46482E-04*Y)*Y*Y
      GAS8=(1.02035E01+9.70762E-02*Y-1.39460E00*Z)*Z*Z
      GAS9=(-1.42762E02-1.647088E00*Y+7.660312E01*Z
     *+8.259346E-01*Y*Z)
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=-5.08545E-01
      GAS2R=4.45617E-01*Z
      GAS3R=(-1.790596E-02+4.59236E-03*Z-8.67558E-04*Y)*Y
      GAS4R=-9.89727E-02*Z*Z
      GAS5R=5.19662E-01
      GAS6R=-4.34837E-01*Z
      GAS7R=(1.832178E-02-3.04164E-03*Z+1.039446E-03*Y)*Y
      GAS8R=9.70762E-02*Z*Z
      GAS9R=-1.647088E00+8.259346E-01*Z
      GAS2E=GAS2/Z
      GAS3E=2.29618E-03*Y*Y
      GAS4E=(-2.20408E01-1.979454E-01*Y+4.88709E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=-1.52082E-03*Y*Y
      GAS8E=(2.0407E01+1.941524E-01*Y-4.1838E00*Z)*Z
      GAS9E=7.660312E01+8.259346E-01*Y
      GO TO 240
120   IF (Z.GT.3.05E00) GO TO 130
      GAS1=2.24374E00+1.03073E-01*Y
      GAS2=(-5.32238E-01-5.59852E-02*Y)*Z
      GAS3=(3.56484E-03-1.01359E-04*Z+1.59127E-04*Y)*Y*Y
      GAS4=(-4.80156E-02+1.06794E-02*Y+3.66035E-02*Z)*Z*Z
      GAS5=-5.70378E00-3.10056E-01*Y
      GAS6=(5.01094E00+1.80411E-01*Y)*Z
      GAS7=(-9.49361E-03+1.94839E-03*Z-2.24908E-04*Y)*Y*Y
      GAS8=(-1.40331E00-2.79718E-02*Y+1.20278E-01*Z)*Z*Z
      GAS9=(1.139755E02-4.985467E00*Y-4.223833E01*Z
     *+2.009706E00*Y*Z)
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=1.03073E-01
      GAS2R=-5.59852E-02*Z
      GAS3R=(7.12968E-03-2.0218E-04*Z+4.77381E-04*Y)*Y
      GAS4R=1.06794E-02*Z*Z
      GAS5R=-3.10056E-01
      GAS6R=1.80411E-01*Z
      GAS7R=(-1.898722E-02+3.89678E-03*Z-6.74724E-04*Y)*Y
      GAS8R=-2.79718E-02*Z*Z
      GAS9R=-4.985467E00+2.009706E00*Z
      GAS2E=GAS2/Z
      GAS3E=-1.01359E-04*Y*Y
      GAS4E=(-9.60312E-02+2.13588E-02*Y+1.098105E-01*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=1.94839E-03*Y*Y
      GAS8E=(-2.80662E00-5.59436E-02*Y+3.60834E-01*Z)*Z
      GAS9E=-4.223833E01+2.009706E00*Y
      GO TO 240
130   IF(Z.GT.3.4E00) GO TO 140
      GAS1=-0.20807E02+0.40197E00*Y
      GAS2=(0.22591E02-0.25660E00*Y)*Z
      GAS3=(-0.95833E-03+0.23966E-02*Z+0.33671E-03*Y)*Y*Y
      GAS4=(-0.77174E01+0.4606E-01*Y+0.878E00*Z)*Z*Z
      GAS5=-0.21737E03-0.46927E01*Y
      GAS6=(0.18101E03+0.26621E01*Y)*Z
      GAS7=(-0.34759E-01+0.64681E-02*Z-0.70391E-03*Y)*Y*Y
      GAS8=(-0.50019E02-0.38381E00*Y+0.45795E01*Z)*Z*Z
      GAS9=(0.4544373E03+0.1250133E02*Y-0.1376001E03*Z
     *-0.3641774E01*Y*Z)
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=0.40197E00
      GAS2R=-0.25660E00*Z
      GAS3R=(-1.91666E-03+4.7932E-03*Z+1.01013E-03*Y)*Y
      GAS4R=0.4606E-01*Z*Z
      GAS5R=-0.46927E01
      GAS6R=0.26621E01*Z
      GAS7R=(-6.9518E-02+1.29362E-02*Z-2.11173E-03*Y)*Y
      GAS8R=-0.38381E00*Z*Z
      GAS9R=0.1250133E02-0.3641774E01*Z
      GAS2E=GAS2/Z
      GAS3E=0.23966E-02*Y*Y
      GAS4E=(-1.54348E01+9.212E-02*Y+2.634E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=0.64681E-02*Y*Y
      GAS8E=(-1.00038E02-7.6762E-01*Y+1.37385E01*Z)*Z
      GAS9E=-0.1376001E03-0.3641774E01*Y
      GO TO 240
140   IF(Z.GT.3.69E00) WRITE(6,1000) R,E
      GAS1=-5.22951E01-4.00011E-01*Y
      GAS2=(4.56439E01+2.24484E-01*Y)*Z
      GAS3=(-3.73775E-03+2.43161E-03*Z+2.24755E-04*Y)*Y*Y
      GAS4=(-1.29756E01-2.79517E-02*Y+1.22998E00*Z)*Z*Z
      GAMM=GAS1+GAS2+GAS3+GAS4
      IF(KFLAG.EQ.0) GO TO 260
      GAS1R=-4.00011E-01
      GAS2R=2.24484E-01*Z
      GAS3R=(-7.4755E-03+4.86322E-03*Z+6.74265E-04*Y)*Y
      GAS4R=-2.79517E-02*Z*Z
      GAS2E=GAS2/Z
      GAS3E=2.43161E-03*Y*Y
      GAS4E=(-2.59512E01-5.59034E-02*Y+3.68994E00*Z)*Z
      GAMMR=GAS1R+GAS2R+GAS3R+GAS4R
      GAMME=GAS2E+GAS3E+GAS4E
      GO TO 260
150   IF(Z.GT.0.65E00) GO TO 160
      GAMM=1.398E00
      GO TO 250
160   IF (Z.GT.1.5E00) GO TO 170
      GAS1=1.39123E00-4.08321E-03*Y
      GAS2=(1.42545E-02+1.41769E-02*Y)*Z
      GAS3=(2.57225E-04+6.52912E-04*Z+8.46912E-05*Y)*Y*Y
      GAS4=(6.2555E-02-7.83637E-03*Y-9.78720E-02*Z)*Z*Z
      GAS5=5.80955-1.82302E-01*Y
      GAS6=(-9.62396E00+1.79619E-01*Y)*Z
      GAS7=(-2.30518E-02+1.18720E-02*Z-3.35499E-04*Y)*Y*Y
      GAS8=(5.27047E00-3.65507E-02*Y-9.19897E-01*Z)*Z*Z
      GAS9=(-10.0E00*Z+14.2E00)
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=-4.08321E-03
      GAS2R=1.41769E-02*Z
      GAS3R=(5.1445E-04+1.305824E-03*Z+2.540736E-04*Y)*Y
      GAS4R=-7.83637E-03*Z*Z
      GAS5R=-1.82302E-01
      GAS6R=1.79619E-01*Z
      GAS7R=(-4.61036E-02+2.3744E-02*Z-1.006497E-03*Y)*Y
      GAS8R=-3.65507E-02*Z*Z
      GAS9R=0.0E00
      GAS2E=GAS2/Z
      GAS3E=6.52912E-04*Y*Y
      GAS4E=(1.2511E-01-1.567274E-02*Y-2.93616E-01*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=1.1872E-02*Y*Y
      GAS8E=(1.054094E01-7.31014E-02*Y-2.759691E00*Z)*Z
      GAS9E=-10.0E00
      GO TO 240
170   IF (Z.GT.2.22E00) GO TO 180
      GAS1=-1.20784E00-2.57909E-01*Y
      GAS2=(5.02307E00+2.87201E-01*Y)*Z
      GAS3=(-9.95577E-03+5.23524E-03*Z-1.45574E-04*Y)*Y*Y
      GAS4=(-3.20619E00-7.50405E-02*Y+6.51564E-01*Z)*Z*Z
      GAS5=-6.62841E00+2.77112E-02*Y
      GAS6=(7.30762E00-7.68230E-02*Y)*Z
      GAS7=(7.19421E-03-3.62463E-03*Z+1.62777E-04*Y)*Y*Y
      GAS8=(-2.33161E00+3.04767E-02*Y+1.66856E-01*Z)*Z*Z
      GAS9=(1.255324E02+2.015335E00*Y-6.390747E01*Z-
     *6.515225E-01*Y*Z)
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=-2.57909E-01
      GAS2R=2.87201E-01*Z
      GAS3R=(-1.991154E-02+1.047048E-02*Z-4.36722E-04*Y)*Y
      GAS4R=-7.50405E-02*Z*Z
      GAS5R=2.77112E-02
      GAS6R=-7.6823E-02*Z
      GAS7R=(1.438842E-02-7.24926E-03*Z+4.88331E-04*Y)*Y
      GAS8R=3.04767E-02*Z*Z
      GAS9R=2.015335E00-6.515225E-01*Z
      GAS2E=GAS2/Z
      GAS3E=5.23524E-03*Y*Y
      GAS4E=(-6.41238E00-1.50081E-01*Y+1.954692E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=-3.62463E-03*Y*Y
      GAS8E=(-4.66322E00+6.09534E-02*Y+5.00568E-01*Z)*Z
      GAS9E=-6.390747E01-6.515225E-01*Y
      GO TO 240
180   IF (Z.GT.2.95) GO TO 190
      GAS1=-2.26460E00-7.82263E-02*Y
      GAS2=(4.90497E00+7.18096E-02*Y)*Z
      GAS3=(-3.06443E-03+1.74209E-03*Z+2.84214E-05*Y)*Y*Y
      GAS4=(-2.24750E00-1.31641E-02*Y+3.33658E-01*Z)*Z*Z
      GAS5=-1.47904E01-1.76627E-01*Y
      GAS6=(1.35036E01+8.77280E-02*Y)*Z
      GAS7=(-2.13327E-03+7.15487E-04*Z+7.30928E-05*Y)*Y*Y
      GAS8=(-3.95372E00-8.96151E-03*Y+3.63229E-01*Z)*Z*Z
      GAS9=(1.788542E02+6.317894E00*Y-6.756741E01*Z-
     *2.460060E00*Y*Z)
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=-7.82263E-02
      GAS2R=7.18096E-02*Z
      GAS3R=(-6.12886E-03+3.48418E-03*Z+8.52642E-05*Y)*Y
      GAS4R=-1.31641E-02*Z*Z
      GAS5R=-1.76627E-01
      GAS6R=8.7728E-02*Z
      GAS7R=(-4.26654E-03+1.430974E-03*Z+2.192784E-04*Y)*Y
      GAS8R=-8.96151E-03*Z*Z
      GAS9R=6.317894E00-2.46006E00*Z
      GAS2E=GAS2/Z
      GAS3E=1.74209E-03*Y*Y
      GAS4E=(-4.495E00-2.63282E-02*Y+1.000974E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=7.15487E-04*Y*Y
      GAS8E=(-7.90744E00-1.792302E-02*Y+1.089687E00*Z)*Z
      GAS9E=-6.756741E01-2.46006E00*Y
      GO TO 240
190   IF(Z.GT.3.4E00) WRITE(6,1000) R,E
      GAS1=-1.66904E01-2.58318E-01*Y
      GAS2=(1.78350E01+1.54898E-01*Y)*Z
      GAS3=(-9.71263E-03+3.97740E-03*Z+9.04300E-05*Y)*Y*Y
      GAS4=(-5.94108E00-2.01335E-02*Y+6.60432E-01*Z)*Z*Z
      GAS5=8.54690E01+1.17554E01*Y
      GAS6=(-7.21760E01-7.15723E00*Y)*Z
      GAS7=(-4.16150E-02+1.38147E-02*Z+5.45184E-04*Y)*Y*Y
      GAS8=(2.01758E01+1.08990E00*Y-1.86438E00*Z)*Z*Z
      GAS9=(2.883262E02+1.248536E01*Y-8.816985E01*Z-
     *3.720309E00*Y*Z)
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=-2.58318E-01
      GAS2R=1.54898E-01*Z
      GAS3R=(-1.942526E-02+7.9548E-03*Z+2.7129E-04*Y)*Y
      GAS4R=-2.01335E-02*Z*Z
      GAS5R=1.17554E01
      GAS6R=-7.15723E00*Z
      GAS7R=(-8.323E-02+2.76294E-02*Z+1.635552E-03*Y)*Y
      GAS8R=1.0899E00*Z*Z
      GAS9R=1.248536E01-3.720309E00*Z
      GAS2E=GAS2/Z
      GAS3E=3.9774E-03*Y*Y
      GAS4E=(-1.188216E01-4.0267E-02*Y+1.981296E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=1.38147E-02*Y*Y
      GAS8E=(4.03516E01+2.1798E00*Y-5.59314E00*Z)*Z
      GAS9E=-8.816985E01-3.720309E00*Y
      GO TO 240
200   IF(Z.GT.0.65E00) GO TO 210
      GAMM=1.3988E00
      GO TO 250
210   IF(Z.GT.1.7E00) GO TO 220
      GAS1=1.37062E00+1.29673E-02*Y
      GAS2=(1.11418E-01-3.26912E-02*Y)*Z
      GAS3=(1.06869E-03-2.00286E-03*Z+2.38305E-04*Y)*Y*Y
      GAS4=(-1.06133E-01+1.90251E-02*Y+3.02210E-03*Z)*Z*Z
      GAMM=GAS1+GAS2+GAS3+GAS4
      IF(KFLAG.EQ.0) GO TO 260
      GAS1R=1.29673E-02
      GAS2R=-3.26912E-02*Z
      GAS3R=(2.13738E-03-4.00572E-03*Z+7.14915E-04*Y)*Y
      GAS4R=1.90251E-02*Z*Z
      GAS2E=GAS2/Z
      GAS3E=-2.00286E-03*Y*Y
      GAS4E=(-2.12266E-01+3.80502E-02*Y+9.0663E-03*Z)*Z
      GAMMR=GAS1R+GAS2R+GAS3R+GAS4R
      GAMME=GAS2E+GAS3E+GAS4E
      GO TO 260
220   IF(Z.GT.2.35) GO TO 230
      GAS1=3.43846E-02-2.33584E-01*Y
      GAS2=(2.85574E00+2.59787E-01*Y)*Z
      GAS3=(-10.89927E-03+4.23659E-03*Z+3.85712E-04*Y)*Y*Y
      GAS4=(-1.94785E00-6.73865E-02*Y+4.08518E-01*Z)*Z*Z
      GAS5=-4.20569E00+1.33139E-01*Y
      GAS6=(4.51236E00-1.66341E-01*Y)*Z
      GAS7=(1.67787E-03-1.10022E-03*Z+3.06676E-04*Y)*Y*Y
      GAS8=(-1.35516E00+4.91716E-02*Y+7.52509E-02*Z)*Z*Z
      GAS9=(1.757042E02-2.163278E00*Y-8.833702E01*Z+
     *1.897543E00*Y*Z)
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=-2.33584E-01
      GAS2R=2.59787E-01*Z
      GAS3R=(-2.179854E-02+8.47318E-03*Z+1.157136E-03*Y)*Y
      GAS4R=-6.73865E-02*Z*Z
      GAS5R=1.33139E-01
      GAS6R=-1.66341E-01*Z
      GAS7R=(3.35574E-03-2.20044E-03*Z+9.20028E-04*Y)*Y
      GAS8R=4.91716E-02*Z*Z
      GAS9R=-2.163278E00+1.897543E00*Z
      GAS2E=GAS2/Z
      GAS3E=4.23659E-03*Y*Y
      GAS4E=(-3.8957E00-1.34773E-01*Y+1.225554E00*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=-1.10022E-03*Y*Y
      GAS8E=(-2.71032E00+9.83432E-02*Y+2.257527E-01*Z)*Z
      GAS9E=-8.833702E01+1.897543E00*Y
      GO TO 240
230   IF(Z.GT.2.9E00) WRITE(6,1000) R,E
      GAS1=-1.70633E00-1.48403E-01*Y
      GAS2=(4.23104E00+1.37290E-01*Y)*Z
      GAS3=(-9.10934E-03+3.85707E-03*Z+2.69026E-04*Y)*Y*Y
      GAS4=(-1.97292E00-2.81830E-02*Y+2.95882E-01*Z)*Z*Z
      GAS5=3.41580E01-1.89972E01*Y
      GAS6=(-4.0858E01+1.30321E01*Y)*Z
      GAS7=(-8.01272E-01+2.75121E-01*Z-1.77969E-04*Y)*Y*Y
      GAS8=(1.60826E01-2.23386E00*Y-2.08853E00*Z)*Z*Z
      GAS9=(2.561323E02+1.737089E02*Y-9.058890E01*Z-
     *5.838803E01*Y*Z)
      IF(GAS9.GT.30.E00) GAS9=30.E00
      IF(GAS9.LT.-30.E00) GAS9=-30.E00
      IF(KFLAG.EQ.0) GO TO 240
      GAS1R=-1.48403E-01
      GAS2R=1.3729E-01*Z
      GAS3R=(-1.821868E-02+7.71414E-03*Z+8.07078E-04*Y)*Y
      GAS4R=-2.8183E-02*Z*Z
      GAS5R=-1.89972E01
      GAS6R=1.30321E01*Z
      GAS7R=(-1.602544E00+5.50242E-01*Z-5.33907E-04*Y)*Y
      GAS8R=-2.23386E00*Z*Z
      GAS9R=1.737089E02-5.838803E01*Z
      GAS2E=GAS2/Z
      GAS3E=3.85707E-03*Y*Y
      GAS4E=(-3.94584E00-5.6366E-02*Y+8.87646E-01*Z)*Z
      GAS6E=GAS6/Z
      GAS7E=2.75121E-01*Y*Y
      GAS8E=(3.21652E01-4.46772E00*Y-6.26559E00*Z)*Z
      GAS9E=-9.05889E01-5.838803E01*Y
240   GAS9=EXP(GAS9)
      GAMM=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.+GAS9)
      IF(KFLAG.EQ.0) GO TO 260
      GAMMR=GAS1R+GAS2R+GAS3R+GAS4R+(GAS5R+GAS6R+GAS7R+GAS8R)/
     *(1.+GAS9)-(GAS5+GAS6+GAS7+GAS8)*GAS9R*GAS9/((1.+GAS9)**2)
      GAMME=GAS2E+GAS3E+GAS4E+(GAS6E+GAS7E+GAS8E)/(1.+GAS9)
     *-(GAS5+GAS6+GAS7+GAS8)*GAS9E*GAS9/((1.+GAS9)**2)
      GO TO 260
250   CONTINUE
      IF(KFLAG.EQ.0) GO TO 260
      GAMMR=0.0E00
      GAMME=0.0E00
260   P=(GAMM-1)*E*R
      IF(KFLAG.EQ.0) GO TO 270
      GAMMR=GAMMR/2.302585E00
      GAMME=GAMME/2.302585E00
      ASQ=E*((GAMM-1.E00)*(GAMM+GAMME)+GAMMR)
      A=SQRT(ASQ)
270   IF(IFLAG) 10,280,290
280   IF(JFLAG) 30,40,10
290   IF(JFLAG) 60,70,10
300   X=ALOG10(P/P0)
      Y=ALOG10(R/R0)
      Z1=X-Y
      IF (Y.GT.-0.5E00) GO TO 400
      IF(Y.GT.-4.5E00) GO TO 350
      IF(Z1.GT.0.25E00) GO TO 310
      T=P/(GASCON*R)
      RETURN
310   IF(Z1.GT.0.95E00) GO TO 320
      GAS1=1.44824E-01+1.36744E-02*Y
      GAS2=(1.17099E-01-8.22299E-02*Y)*Z1
      GAS3=(-6.75303E-04-1.47314E-03*Z1-7.90851E-05*Y)*Y*Y
      GAS4=(1.3937E00+6.83066E-02*Y-6.65673E-01*Z1)*Z1*Z1
      TNON=GAS1+GAS2+GAS3+GAS4
      GO TO 450
320   IF(Z1.GT.1.4E00) GO TO 330
      GAS1=-9.325E00-9.32017E-01*Y
      GAS2=(2.57176E01+1.61292E00*Y)*Z1
      GAS3=(-3.00242E-02+2.62959E-02*Z1-2.77651E-04*Y)*Y*Y
      GAS4=(-2.1662E01-6.81431E-01*Y+6.26962E00*Z1)*Z1*Z1
      GAS5=-3.38534E00+1.82594E-01*Y
      GAS6=(1.84928E-01-7.01109E-01*Y)*Z1
      GAS7=(1.10150E-02-1.60570E-02*Z1+1.57701E-05*Y)*Y*Y
      GAS8=(5.4702E00+4.11624E-01*Y-2.81498E00*Z1)*Z1*Z1
      GAS9=EXP(-3.887015E01-2.908228E01*Y+4.070557E01*Z1
     *+2.682347E01*Y*Z1)
      GO TO 440
330   IF( Z1.GT.1.95E00) GO TO 340
      GAS1=-1.93082E01-1.54557E00*Y
      GAS2=(3.69035E01+1.92214E00*Y)*Z1
      GAS3=(-3.59027E-02+2.31827E-02*Z1-2.01327E-04*Y)*Y*Y
      GAS4=(-2.20440E01-5.80935E-01*Y+4.43367E00*Z1)*Z1*Z1
      GAS5=-3.83069E00+1.32864E-01*Y
      GAS6=(-3.91902E00-6.79564E-01*Y)*Z1
      GAS7=(6.06341E-04-8.12997E-03*Z1-1.61012E-04*Y)*Y*Y
      GAS8=(7.24632E00+3.15461E-01*Y-2.17879E00*Z1)*Z1*Z1
      GAS9=EXP(2.08E01-2.56E01*Y+1.0E00*Z1+1.80E01*Y*Z1)
      GO TO 440
340   GAS1=-2.59721E01-1.77419E00*Y
      GAS2=(3.62495E01+1.55383E00*Y)*Z1
      GAS3=(-4.51359E-02+2.43648E-02*Z1+1.2804E-04*Y)*Y*Y
      GAS4=(-1.59988E01-3.17807E-01*Y+2.40584E00*Z1)*Z1*Z1
      GAS5=-1.81433E01+1.54896E-01*Y
      GAS6=(1.26582E01-3.66275E-01*Y)*Z1
      GAS7=(3.24496E-02-1.66385E-02*Z1+3.02177E-04*Y)*Y*Y
      GAS8=(-1.41759E00+1.11241E-01*Y-3.10983E-01*Z1)*Z1*Z1
      GAS9=EXP(1.115884E02-6.452606E00*Y-5.337863E01*Z1
     *+2.026986E00*Y*Z1)
      GO TO 440
350   IF(Z1.GT.0.25E00) GO TO 360
      T=P/(GASCON*R)
      RETURN
360   IF(Z1.GT.0.95E00) GO TO 370
      GAS1=2.94996E-02+7.24997E-03*Y
      GAS2=(7.81783E-01-3.27402E-02*Y)*Z1
      GAS3=(3.23357E-04-9.69989E-04*Z1-8.93240E-06*Y)*Y*Y
      GAS4=(3.95198E-01+2.92926E-02*Y-2.12182E-01*Z1)*Z1*Z1
      TNON=GAS1+GAS2+GAS3+GAS4
      GO TO 450
370   IF (Z1.GT.1.4E00) GO TO 380
      GAS1=-5.53324E00-3.53749E-01*Y
      GAS2=(1.63638E01+5.87547E-01*Y)*Z1
      GAS3=(-1.16081E-02+7.99571E-03*Z1-2.79316E-04*Y)*Y*Y
      GAS4=(-1.41239E01-2.35146E-01*Y+4.28891E00*Z1)*Z1*Z1
      GAS5=9.07979E00+1.01308E00*Y
      GAS6=(-2.29428E01-1.52122E00*Y)*Z1
      GAS7=(3.78390E-02-2.63115E-02*Z1+5.46402E-04*Y)*Y*Y
      GAS8=(1.95657E01+5.73839E-01*Y-5.63057E00*Z1)*Z1*Z1
      GAS9=EXP(7.619803E01-1.501155E01*Y-6.770845E01*Z1
     *+1.273147E01*Y*Z1)
      GO TO 440
380   IF (Z1.GT.2.00E00) GO TO 390
      GAS1=-1.13598E01-1.02049E00*Y
      GAS2=(2.22793E01+1.24038E00*Y)*Z1
      GAS3=(-3.10771E-02+1.92551E-02*Z1-2.69140E-04*Y)*Y*Y
      GAS4=(-1.31512E01-3.62875E-01*Y+2.64544E00*Z1)*Z1*Z1
      GAS5=8.72852E00+1.27564E00*Y
      GAS6=(-1.79172E01-1.52051E00*Y)*Z1
      GAS7=(4.91264E-02-2.81731E-02*Z1+5.23383E-04*Y)*Y*Y
      GAS8=(1.16719E01+4.45413E-01*Y-2.45584E00*Z1)*Z1*Z1
      GAS9=EXP(1.84792E02+9.583443E00*Y-1.020835E02*Z1
     *-4.166727E00*Y*Z1)
      GO TO 440
390   GAS1=-1.76079E01-1.26579E00*Y
      GAS2=(2.48544E01+1.09442E00*Y)*Z1
      GAS3=(-3.65534E-02+1.54346E-02*Z1-4.59822E-04*Y)*Y*Y
      GAS4=(-1.08166E01-2.27803E-01*Y+1.60641E00*Z1)*Z1*Z1
      GAS5=2.60669E01+2.31791E00*Y
      GAS6=(-3.22433E01-1.82645E00*Y)*Z1
      GAS7=(4.94621E-02-1.85542E-02*Z1+5.04815E-04*Y)*Y*Y
      GAS8=(1.33829E01+3.59744E-01*Y-1.86517E00*Z1)*Z1*Z1
      GAS9=EXP(3.093755E02+1.875018E01*Y-1.375004E02*Z1
     *-8.333418E00*Y*Z1)
      GO TO 440
400   IF (Z1.GT.0.25E00) GO TO 410
      T=P/(GASCON*R)
      RETURN
410   IF (Z1.GT.0.95E00) GO TO 420
      GAS1=-2.94081E-03+5.73915E-04*Y
      GAS2=(9.88883E-01-3.71241E-03*Y)*Z1
      GAS3=(1.12387E-04-3.76528E-04*Z1+1.76192E-05*Y)*Y*Y
      GAS4=(2.86656E-02+4.56059E-03*Y-1.99498E-02*Z1)*Z1*Z1
      TNON=GAS1+GAS2+GAS3+GAS4
      GO TO 450
420   IF (Z1.GT.1.45E00) GO TO 430
      GAS1=1.32396E00+8.52771E-02*Y
      GAS2=(-3.24257E00-2.00937E-01*Y)*Z1
      GAS3=(5.68146E-03-6.85856E-03*Z1+1.98366E-04*Y)*Y*Y
      GAS4=(4.53823E00+1.18123E-01*Y-1.6246E00*Z1)*Z1*Z1
      GAS5=-5.26673E-01-1.58691E-01*Y
      GAS6=(2.61600E00+3.16356E-01*Y)*Z1
      GAS7=(-1.90755E-02+1.70124E-02*Z1-5.58398E-04*Y)*Y*Y
      GAS8=(-3.3793E00-1.52212E-01*Y+1.30757E00*Z1)*Z1*Z1
      GAS9=EXP(1.442206E02-2.544727E01*Y-1.277055E02*Z1
     *+2.236647E01*Y*Z1)
      GO TO 440
430   GAS1=-1.60643E00-5.07368E-02*Y
      GAS2=(3.95872E00+3.69383E-02*Y)*Z1
      GAS3=(-1.59378E-03+1.06057E-03*Z1+6.53278E-05*Y)*Y*Y
      GAS4=(-1.71201E00+9.25124E-03*Y+2.71039E-01*Z1)*Z1*Z1
      GAS5=1.80476E01+1.62964E00*Y
      GAS6=(-2.73124E01-1.57430E00*Y)*Z1
      GAS7=(5.85277E-02-2.77313E-02*Z1+1.16146E-03*Y)*Y*Y
      GAS8=(1.36342E01+3.70714E-01*Y-2.23787E00*Z1)*Z1*Z1
      GAS9=EXP(1.292515E02+1.360552E00*Y-7.07482E01*Z1
     *+1.360532E00*Y*Z1)
440   TNON=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.+GAS9)
450   T=(10.**TNON)*T0
1000  FORMAT(/20X,48HWARNING]  OUTSIDE OF VALIDITY RANGE OF CURVE FIT
     *,/,20X,5HRHO =,1PE15.8,5X,3HE =,1PE15.8,/)
      RETURN
      END
C     SUBROUTINE TGAS2(E,R,S)
C
C     INPUTS FOR SUBROUTINE:
C     E=INTERNAL ENERGY IN (M/SEC)**2
C     R=DENSITY IN KG/M**3
C
C     OUTPUT:
C     S=ENTROPY IN (M/SEC)**2/K
C
C
      SUBROUTINE TGAS2(E,R,S)
      DATA E0,R0,GASCON/78408.4E00,1.292E00,287.06E00/
      RRATIO=R/R0
      ERATIO=E/E0
      Y=ALOG10(RRATIO)
      Z=ALOG10(ERATIO)
      IF(ABS(Y+4.5E00).LT.4.5E-02) GO TO 10
      IF(ABS(Y+0.5E00).LT.0.5E-02) GO TO 40
      IFLAG=-1
      GO TO 80
10    IFLAG=0
      RSAVE=R
      YM=Y
      Y=-4.5E00+4.5E-02
      YHIGH=Y
      R=(10.**Y)*R0
      JFLAG=-1
      GO TO 80
20    SHIGH=S
      Y=-4.5E00-4.5E-02
      YLOW=Y
      R=(10.**Y)*R0
      JFLAG=0
      GO TO 80
30    SLOW=S
      GO TO 70
40    IFLAG=1
      RSAVE=R
      YM=Y
      Y=-0.5E00+0.5E-02
      YHIGH=Y
      R=(10.**Y)*R0
      JFLAG=-1
      GO TO 80
50    SHIGH=S
      Y=-0.5E00-0.5E-02
      YLOW=Y
      R=(10.**Y)*R0
      JFLAG=0
      GO TO 80
60    SLOW=S
70    S=SLOW+(SHIGH-SLOW)/(YHIGH-YLOW)*(YM-YLOW)
      R=RSAVE
      RETURN
80    CONTINUE
      IF(Z.LE.0.65E00) GO TO 110
      IF(Y.GT.-4.5E00) GO TO 90
      IF(Z.GT.3.69E00) WRITE(6,1000) R,E
      GAS1=-9.91081E-01-5.00277E00*Y
      GAS2=(5.46521E01+5.10144E00*Y)*Z
      GAS3=(1.76206E-02+2.12002E-02*Z+1.76358E-03*Y)*Y*Y
      GAS4=(-2.97001E01-1.84915E00*Y+5.87892E00*Z)*Z*Z
      GO TO 120
90    IF(Y.GT.-0.50E00) GO TO 100
      IF(Z.GT.3.4E00) WRITE(6,1000) R,E
      GAS1=1.0836E01-4.55524E00*Y
      GAS2=(2.96473E01+3.90851E00*Y)*Z
      GAS3=(-2.05732E-03+3.65982E-02*Z+5.23821E-03*Y)*Y*Y
      GAS4=(-1.67001E01-1.44623E00*Y+3.98307E00*Z)*Z*Z
      GO TO 120
100   IF(Z.GT.3.0E00) WRITE(6,1000) R,E
      GAS1=2.01858E01-3.13458E00*Y
      GAS2=(1.03619E01+1.87767E00*Y)*Z
      GAS3=(-1.72922E-01+1.12174E-01*Z+1.28626E-02*Y)*Y*Y
      GAS4=(-5.43557E00-8.71048E-01*Y+2.01789E00*Z)*Z*Z
      GO TO 120
110   DELTZ=Z-0.4E00
      DELTS=(2.5E00*DELTZ-Y)*GASCON*2.302585E00
      S=6779.2004E00+DELTS
      GO TO 130
120   SNON=GAS1+GAS2+GAS3+GAS4
      S=GASCON*SNON
130   IF(IFLAG) 160,140,150
140   IF(JFLAG) 20,30,160
150   IF(JFLAG) 50,60,160
160   CONTINUE
1000  FORMAT(/20X,48HWARNING]  OUTSIDE VALIDITY RANGE OF CURVE FIT
     *,/,20X,5HRHO =,1PE15.8,5X,3HE =,1PE15.8,/)
      RETURN
      END
C     SUBROUTINE TGAS3 (P,RHO,T)
C
C     INPUTS FOR SUBROUTINE :
C
C     P= PRESSURE, IN NEWTONS/M**2.
C     RHO= DENSITY, IN KG/M**3.
C
C     OUTPUT :
C
C     T= TEMPERATURE, IN KELVIN.
C
C
      SUBROUTINE TGAS3 (P,RHO,T)
      DATA R0,P0,T0,GASCON/1.292E00,1.0133E05,273.15E00,287.06E00/
      Y=ALOG10(RHO/R0)
      X=ALOG10(P/P0)
      IF(ABS(Y+4.5E00).LT.4.5E-02) GO TO 20
      IF(ABS(Y+0.5E00).LT.5.0E-03) GO TO 50
      IFLAG=-1
      GO TO 90
10    RETURN
20    IFLAG=0
      RSAVE=RHO
      YM=Y
      Y=-4.5E00+4.5E-02
      YHIGH=Y
      RHO=(10.**Y)*R0
      JFLAG=-1
      GO TO 90
30    THIGH=T
      Y=-4.5E00-4.5E-02
      YLOW=Y
      RHO=(10.**Y)*R0
      JFLAG=0
      GO TO 90
40    TLOW=T
      GO TO 80
50    IFLAG=1
      RSAVE=RHO
      YM=Y
      Y=-0.5E00+0.5E-02
      YHIGH=Y
      RHO=(10.**Y)*R0
      JFLAG=-1
      GO TO 90
60    THIGH=T
      Y=-0.5E00-0.5E-02
      YLOW=Y
      RHO=(10.**Y)*R0
      JFLAG=0
      GO TO 90
70    TLOW=T
80    T=TLOW+(THIGH-TLOW)/(YHIGH-YLOW)*(YM-YLOW)
      RHO=RSAVE
      RETURN
90    Z1=X-Y
      IF (Y.GT.-0.5E00) GO TO 190
      IF (Y.GT.-4.5E00) GO TO 140
      IF (Z1.GT.0.25E00) GO TO 100
      T=P/(RHO*GASCON)
      GO TO 250
100   IF (Z1.GT.0.95E00) GO TO 110
      GAS1=1.23718E-01+1.08623E-02*Y
      GAS2=(2.24239E-01-8.24608E-02*Y)*Z1
      GAS3=(-1.17615E-03-1.87566E-03*Z1-1.19155E-04*Y)*Y*Y
      GAS4=(1.18397E00+6.48520E-02*Y-5.52634E-01*Z1)*Z1*Z1
      TNON=GAS1+GAS2+GAS3+GAS4
      GO TO 240
110   IF (Z1.GT.1.4E00) GO TO 120
      GAS1=-8.12952E00-8.28637E-01*Y
      GAS2=(2.26904E01+1.41132E00*Y)*Z1
      GAS3=(-2.98633E-02+2.70066E-02*Z1-2.28103E-04*Y)*Y*Y
      GAS4=(-1.91806E01-5.78875E-01*Y+5.62580E00*Z1)*Z1*Z1
      GAS5=-3.99845E00+2.26369E-01*Y
      GAS6=(2.52876E00-7.28448E-01*Y)*Z1
      GAS7=(1.09769E-02-1.83819E-02*Z1-1.51380E-04*Y)*Y*Y
      GAS8=(2.99238E00+3.91440E-01*Y-2.04463E00*Z1)*Z1*Z1
      GAS9=EXP(-3.887015E01-2.908228E01*Y+4.070557E01*Z1
     *+2.682347E01*Y*Z1)
      GO TO 230
 120  IF (Z1.GT.1.95E00) GO TO 130
      GAS1=-1.98573E01-1.67225E00*Y
      GAS2=(3.76159E01+2.10964E00*Y)*Z1
      GAS3=(-3.40174E-02+2.31712E-02*Z1-9.80275E-05*Y)*Y*Y
      GAS4=(-2.22215E01-6.44596E-01*Y+4.40486E00*Z1)*Z1*Z1
      GAS5=-5.36809E00+2.41201E-01*Y
      GAS6=(-1.25881E00-8.62744E-01*Y)*Z1
      GAS7=(-3.79774E-03-7.81335E-03*Z1-3.80005E-04*Y)*Y*Y
      GAS8=(5.58609E00+3.78963E-01*Y-1.81566E00*Z1)*Z1*Z1
      GAS9=EXP(2.08E01-2.56E01*Y+1.0E00*Z1+1.80E01*Y*Z1)
      GO TO 230
130   IF (Z1.GT.2.60E00) WRITE (6,1000) RHO,P
      GAS1=-2.33271E01-1.89958E00*Y
      GAS2=(3.21440E01+1.68622E00*Y)*Z1
      GAS3=(-4.42123E-02+2.82629E-02*Z1+6.63272E-04*Y)*Y*Y
      GAS4=(-1.38645E01-3.40976E-01*Y+2.04466E00*Z1)*Z1*Z1
      GAS5=8.35474E00+1.71347E00*Y
      GAS6=(-1.60715E01-1.63139E00*Y)*Z1
      GAS7=(4.14641E-02-2.30068E-02*Z1+1.53246E-05*Y)*Y*Y
      GAS8=(8.70275E00+3.60966E-01*Y-1.46166E00*Z1)*Z1*Z1
      GAS9=EXP(1.115884E02-6.452606E00*Y-5.337863E01*Z1
     *+2.026986E00*Y*Z1)
      GO TO 230
140   IF (Z1.GT.0.25E00) GO TO 150
      T=P/(RHO*GASCON)
      GO TO 250
150   IF (Z1.GT.0.95E00) GO TO 160
      GAS1=2.03910E-02+7.67310E-03*Y
      GAS2=(8.48581E-01-2.93086E-02*Y)*Z1
      GAS3=(8.40269E-04-1.47701E-03*Z1+3.13687E-05*Y)*Y*Y
      GAS4=(2.67251E-01+2.37262E-02*Y-1.41973E-01*Z1)*Z1*Z1
      TNON=GAS1+GAS2+GAS3+GAS4
      GO TO 240
160   IF (Z1.GT.1.45E00) GO TO 170
      GAS1=-5.12404E00-2.84740E-01*Y
      GAS2=(1.54532E01+4.52475E-01*Y)*Z1
      GAS3=(-1.22881E-02+8.56845E-03*Z1-3.25256E-04*Y)*Y*Y
      GAS4=(-1.35181E01-1.68725E-01*Y+4.18451E00*Z1)*Z1*Z1
      GAS5=7.52564E00+8.35238E-01*Y
      GAS6=(-1.95558E01-1.23393E00*Y)*Z1
      GAS7=(3.34510E-02-2.34269E-02*Z1+4.81788E-04*Y)*Y*Y
      GAS8=(1.71779E01+4.54628E-01*Y-5.09936E00*Z1)*Z1*Z1
      GAS9=EXP(6.148442E01-1.828123E01*Y-5.468755E01*Z1
     *+1.562500E01*Y*Z1)
      GO TO 230
170   IF (Z1.GT.2.05E00) GO TO 180
      GAS1=-1.23779E01-1.14728E00*Y
      GAS2=(2.41382E01+1.38957E00*Y)*Z1
      GAS3=(-3.63693E-02+2.24265E-02*Z1-3.23888E-04*Y)*Y*Y
      GAS4=(-1.42844E01-4.06553E-01*Y+2.87620E00*Z1)*Z1*Z1
      GAS5=4.40782E00+1.33046E00*Y
      GAS6=(-1.15405E01-1.59892E00*Y)*Z1
      GAS7=(5.30580E-02-3.10376E-02*Z1+4.77650E-04*Y)*Y*Y
      GAS8=(8.57309E00+4.71274E-01*Y-1.96233E00*Z1)*Z1*Z1
      GAS9=EXP(1.4075E02-6.499992E00*Y-7.75E01*Z1+5.0E00*Y*Z1)
      GO TO 230
180   IF (Z1.GT.2.50E00) WRITE (6,1000) RHO,P
      GAS1=-1.27244E01-1.66684E00*Y
      GAS2=(1.72708E01+1.45307E00*Y)*Z1
      GAS3=(-3.64515E-02+1.90463E-02*Z1+4.80787E-04*Y)*Y*Y
      GAS4=(-6.97208E00-3.04323E-01*Y+9.67524E-01*Z1)*Z1*Z1
      GAS5=7.71330E00+5.08340E-01*Y
      GAS6=(-9.82110E00-4.49138E-01*Y)*Z1
      GAS7=(-9.41787E-04-2.40293E-03*Z1-8.28450E-04*Y)*Y*Y
      GAS8=(4.16530E00+9.63923E-02*Y-5.88807E-01*Z1)*Z1*Z1
      GAS9=EXP(-1.092654E03-3.05312E02*Y+4.656243E02*Z1+
     *1.312498E02*Y*Z1)
      GO TO 230
190   IF (Z1.GT.0.25E00) GO TO 200
      T=P/(RHO*GASCON)
      GO TO 250
200   IF (Z1.GT.1.00E00) GO TO 210
      GAS1=-1.54141E-03+6.58337E-04*Y
      GAS2=(9.82201E-01-3.85028E-03*Y)*Z1
      GAS3=(1.23111E-04-4.08210E-04*Z1+2.13592E-05*Y)*Y*Y
      GAS4=(3.77441E-02+4.56963E-03*Y-2.35172E-02*Z1)*Z1*Z1
      TNON=GAS1+GAS2+GAS3+GAS4
      GO TO 240
210   IF (Z1.GT.1.45E00) GO TO 220
      GAS1=8.06492E-01+9.91293E-02*Y
      GAS2=(-1.70742E00-2.28264E-01*Y)*Z1
      GAS3=(5.03500E-03-6.13927E-03*Z1+1.69824E-04*Y)*Y*Y
      GAS4=(3.02351E00+1.31574E-01*Y-1.12755E00*Z1)*Z1*Z1
      GAS5=-1.17930E-01-2.12207E-01*Y
      GAS6=(1.36524E00+4.05886E-01*Y)*Z1
      GAS7=(-1.88260E-02+1.65486E-02*Z1-5.11400E-04*Y)*Y*Y
      GAS8=(-2.10926E00-1.89881E-01*Y+8.79806E-01*Z1)*Z1*Z1
      GAS9=EXP(1.959604E02-4.269391E01*Y-1.734931E02*Z1+
     *3.762898E01*Y*Z1)
      GO TO 230
220   IF (Z1.GT.2.3E00) WRITE (6,1000) RHO,P
      GAS1=-1.66249E00-8.91113E-02*Y
      GAS2=(4.11648E00+8.78093E-02*Y)*Z1
      GAS3=(-3.09742E-03+1.99879E-03*Z1+6.85472E-05*Y)*Y*Y
      GAS4=(-1.84445E00-7.50324E-03*Y+3.05784E-01*Z1)*Z1*Z1
      GAS5=1.11555E01+1.32100E00*Y
      GAS6=(-1.71236E01-1.29190E00*Y)*Z1
      GAS7=(6.28124E-02-3.07949E-02*Z1+1.57743E-03*Y)*Y*Y
      GAS8=(8.63804E00+3.07809E-01*Y-1.42634E00*Z1)*Z1*Z1
      GAS9=EXP(1.330611E02+8.979635E00*Y-7.265298E01*Z1
     *-2.449009E00*Y*Z1)
230   TNON=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.+GAS9)
240   T=(10.**TNON)*T0
250   IF (IFLAG) 10,260,270
260   IF (JFLAG) 30,40,10
270   IF (JFLAG) 60,70,10
1000  FORMAT(/20X,48HWARNING]  OUTSIDE OF VALIDITY RANGE OF CURVE FIT
     *,/,20X,5HRHO =,1PE15.8,5X,3HP =,1PE15.8,/)
      END
C     SUBROUTINE TGAS4 (P,RHO,H)
C
C
C     INPUTS FOR SUBROUTINE :
C
C     P = PRESSURE, IN NEWTONS/M.**2.
C     RHO = DENSITY, IN KG/M**3.
C
C     OUTPUT :
C
C     H = SPECIFIC ENTHALPY, IN (M/SEC)**2.
C
C
      SUBROUTINE TGAS4 (P,RHO,H)
      DATA R0,P0/1.292E00,1.0133E05/
      Y=ALOG10(RHO/R0)
      X=ALOG10(P/P0)
      IF(ABS(Y+4.5E00).LT.4.5E-02) GO TO 20
      IF(ABS(Y+0.5E00).LT.5.0E-03) GO TO 50
      IFLAG=-1
      GO TO 90
10    RETURN
20    IFLAG=0
      RSAVE=RHO
      YM=Y
      Y=-4.5E00+4.5E-02
      YHIGH=Y
      RHO=(10.**Y)*R0
      JFLAG=-1
      GO TO 90
30    HHIGH=H
      Y=-4.5E00-4.5E-02
      YLOW=Y
      RHO=(10.**Y)*R0
      JFLAG=0
      GO TO 90
40    HLOW=H
      GO TO 80
50    IFLAG=1
      RSAVE=RHO
      YM=Y
      Y=-0.5E00+0.5E-02
      YHIGH=Y
      RHO=(10.**Y)*R0
      JFLAG=-1
      GO TO 90
60    HHIGH=H
      Y=-0.5E00-0.5E-02
      YLOW=Y
      RHO=(10.**Y)*R0
      JFLAG=0
      GO TO 90
70    HLOW=H
80    H=HLOW+(HHIGH-HLOW)/(YHIGH-YLOW)*(YM-YLOW)
      RHO=RSAVE
      GO TO 10
90    Z1=X-Y
      IF (Y.GT.-0.5E00) GO TO 190
      IF (Y.GT.-4.5E00) GO TO 140
      IF (Z1.GT.0.10E00) GO TO 100
      GAMM=1.3986E00
      GO TO 240
100   IF (Z1.GT.0.85E00) GO TO 110
      GAS1=2.53908E02+1.01491E02*Y
      GAS2=(-3.87199E02-1.54304E02*Y)*Z1
      GAS3=(7.28532E00-8.04378E00*Z1-1.82577E-03*Y)*Y*Y
      GAS4=(9.86233E01+4.63763E01*Y+2.18994E01*Z1)*Z1*Z1
      GAS5=-2.52423E02-1.01445E02*Y
      GAS6=(3.87210E02+1.54298E02*Y)*Z1
      GAS7=(-7.2773E00+8.04277E00*Z1+2.28399E-03*Y)*Y*Y
      GAS8=(-9.87576E01-4.63883E01*Y-2.19438E01*Z1)*Z1*Z1
      GAS9=EXP(-11.E00+2.E00*Y+11.E00*Z1-2.E00*Y*Z1)
      GAMM=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.-GAS9)
      GO TO 240
110   IF (Z1.GT.1.30E00) GO TO 120
      GAS1=-1.05745E01-1.93693E00*Y
      GAS2=(3.07202E01+3.35578E00*Y)*Z1
      GAS3=(-7.79965E-02+6.68790E-02*Z1-9.86882E-04*Y)*Y*Y
      GAS4=(-2.60637E01-1.42391E00*Y+7.23223E00*Z1)*Z1*Z1
      GAS5=-1.86342E01+2.41997E-02*Y
      GAS6=(3.20880E01-7.46914E-01*Y)*Z1
      GAS7=(3.75161E-02-4.10125E-02*Z1+5.74637E-04*Y)*Y*Y
      GAS8=(-1.69985E01+5.39041E-01*Y+2.56253E00*Z1)*Z1*Z1
      GAS9=EXP(2.768567E02+2.152383E01*Y-2.164837E02*Z1
     *-1.394837E01*Y*Z1)
      GO TO 230
120   IF (Z1.GT.1.95E00) GO TO 130
      GAS1=6.17584E-01-2.40690E-01*Y
      GAS2=(1.95904E00+3.41644E-01*Y)*Z1
      GAS3=(-1.01073E-02+6.77631E-03*Z1-1.15922E-04*Y)*Y*Y
      GAS4=(-1.68951E00-1.10932E-01*Y+4.26058E-01*Z1)*Z1*Z1
      GAS5=-1.34222E01-5.43713E-01*Y
      GAS6=(1.81528E01+3.95928E-01*Y)*Z1
      GAS7=(-7.41105E-03+1.67768E-03*Z1-3.32714E-06*Y)*Y*Y
      GAS8=(-7.97425E00-5.80593E-02*Y+1.12448E00*Z1)*Z1*Z1
      GAS9=EXP(8.677803E01-8.370349E00*Y-4.074084E01*Z1
     *+7.407405E00*Y*Z1)
      GO TO 230
130   IF (Z1.GT.2.60E00) WRITE (6,1000) RHO,P
      GAS1=-8.32595E00-3.50219E-01*Y
      GAS2=(1.36455E01+3.59350E-01*Y)*Z1
      GAS3=(-3.70109E-03+3.30836E-03*Z1+1.10018E-04*Y)*Y*Y
      GAS4=(-6.49007E00-8.38594E-02*Y+1.02443E00*Z1)*Z1*Z1
      GAS5=-3.08441E01-1.49510E00*Y
      GAS6=(3.00585E01+9.19650E-01*Y)*Z1
      GAS7=(-3.60024E-02+1.02522E-02*Z1-4.68760E-04*Y)*Y*Y
      GAS8=(-9.33522E00-1.35228E-01*Y+8.92634E-01*Z1)*Z1*Z1
      GAS9=EXP(8.800047E01-1.679356E01*Y-3.333353E01*Z1
     *+8.465574E00*Y*Z1)
      GO TO 230
140   IF (Z1.GT.0.1E00) GO TO 150
      GAMM=1.399E00
      GO TO 240
150   IF (Z1.GT.0.95E00) GO TO 160
      GAS1=-1.33083E02-9.98707E00*Y
      GAS2=(3.94734E02+2.35810E01*Y)*Z1
      GAS3=(1.43957E00-1.43175E00*Z1+1.77068E-05*Y)*Y*Y
      GAS4=(-3.84712E02-1.36367E01*Y+1.24325E02*Z1)*Z1*Z1
      GAS5=1.34486E02+9.99122E00*Y
      GAS6=(-3.94719E02-2.35853E01*Y)*Z1
      GAS7=(-1.43799E00+1.43039E00*Z1+1.44367E-04*Y)*Y*Y
      GAS8=(3.84616E02+1.36318E01*Y-1.24348E02*Z1)*Z1*Z1
      GAS9=EXP(-2.141444E01+1.381584E00*Y+2.039473E01*Z1
     *-1.315789E00*Y*Z1)
      GAMM=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.-GAS9)
      GO TO 240
160   IF (Z1.GT.1.50E00) GO TO 170
      GAS1=-7.36684E00-1.13247E00*Y
      GAS2=(2.47879E01+1.99625E00*Y)*Z1
      GAS3=(-4.91630E-02+4.16673E-02*Z1-6.58149E-04*Y)*Y*Y
      GAS4=(-2.32990E01-8.59418E-01*Y+7.19016E00*Z1)*Z1*Z1
      GAS5=-2.42647E00+5.57912E-01*Y
      GAS6=(-2.03055E00-1.22031E00*Y)*Z1
      GAS7=(3.74866E-02-3.39278E-02*Z1+5.21042E-04*Y)*Y*Y
      GAS8=(7.75414E00+6.08488E-01*Y-3.68326E00*Z1)*Z1*Z1
      GAS9=EXP(8.077385E01-1.273807E01*Y-6.547623E01*Z1
     *+1.190475E01*Y*Z1)
      GO TO 230
170   IF (Z1.GT.2.00E00) GO TO 180
      GAS1=4.31520E-01-2.83857E-01*Y
      GAS2=(2.27791E00+3.99159E-01*Y)*Z1
      GAS3=(-1.29444E-02+8.78724E-03*Z1-1.60583E-04*Y)*Y*Y
      GAS4=(-1.84314E00-1.28136E-01*Y+4.45362E-01*Z1)*Z1*Z1
      GAS5=-1.03883E01-3.58718E-01*Y
      GAS6=(1.35068E01+1.87268E-01*Y)*Z1
      GAS7=(-4.28184E-03-9.52016E-04*Z1-4.10506E-05*Y)*Y*Y
      GAS8=(-5.63894E00-1.45626E-03*Y+7.39915E-01*Z1)*Z1*Z1
      GAS9=EXP(2.949221E02+1.368660E01*Y-1.559335E02*Z1
     *-3.787766E00*Y*Z1)
      GO TO 230
180   IF (Z1.GT.2.5E00) WRITE (6,1000) RHO,P
      GAS1=-3.77766E00-5.53738E-01*Y
      GAS2=(6.60834E00+4.87181E-01*Y)*Z1
      GAS3=(-2.11045E-02+9.67277E-03*Z1-2.19420E-04*Y)*Y*Y
      GAS4=(-2.94754E00-1.02365E-01*Y+4.39620E-01*Z1)*Z1*Z1
      GAS5=4.05813E01+3.25692E00*Y
      GAS6=(-4.79583E01-2.53660E00*Y)*Z1
      GAS7=(9.06436E-02-3.47578E-02*Z1+1.00077E-03*Y)*Y*Y
      GAS8=(1.89040E01+4.94114E-01*Y-2.48554E00*Z1)*Z1*Z1
      GAS9=EXP(5.34718E02+7.495657E01*Y-2.219822E02*Z1
     *-3.017229E01*Y*Z1)
      GO TO 230
190   IF (Z1.GT.0.1E00) GO TO 200
      GAMM=1.4017E00
      GO TO 240
200   IF (Z1.GT.1.05E00) GO TO 210
      GAS1=-9.67488E01+2.05296E-01*Y
      GAS2=(2.69927E02-1.92887E00*Y)*Z1
      GAS3=(3.78392E-01-3.24965E-01*Z1-3.61036E-03*Y)*Y*Y
      GAS4=(-2.46711E02+1.54416E00*Y+7.48760E01*Z1)*Z1*Z1
      GAS5=9.81502E01-2.05448E-01*Y
      GAS6=(-2.69913E02+1.93052E00*Y)*Z1
      GAS7=(-3.78527E-01+3.24832E-01*Z1+3.66182E-03*Y)*Y*Y
      GAS8=(2.46630E02-1.54646E00*Y-7.48980E01*Z1)*Z1*Z1
      GAS9=EXP(-2.659865E01+1.564631E00*Y+2.312926E01*Z1
     *-1.360543E00*Y*Z1)
      GAMM=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.-GAS9)
      GO TO 240
210   IF (Z1.GT.1.60E00) GO TO 220
      GAS1=-2.67593E-01-1.87457E-01*Y
      GAS2=(5.07693E00+2.72286E-01*Y)*Z1
      GAS3=(1.04541E-02-1.42211E-02*Z1+6.38962E-04*Y)*Y*Y
      GAS4=(-5.08520E00-7.81935E-02*Y+1.58711E00*Z1)*Z1*Z1
      GAS5=2.87969E00+3.9009E-01*Y
      GAS6=(-8.06179E00-5.51250E-01*Y)*Z1
      GAS7=(-1.01903E-02+1.35906E-02*Z1-8.97772E-04*Y)*Y*Y
      GAS8=(7.29592E00+1.83861E-01*Y-2.15153E00*Z1)*Z1*Z1
      GAS9=EXP(1.828573E02-3.428596E01*Y-1.51786E02*Z1
     *+2.976212E01*Y*Z1)
      GO TO 230
220   IF (Z1.GT.2.30E00) WRITE (6,1000) RHO,P
      GAS1=9.21537E-01-2.39670E-01*Y
      GAS2=(1.30714E00+3.42990E-01*Y)*Z1
      GAS3=(-2.18847E-02+1.36691E-02*Z1-4.90274E-04*Y)*Y*Y
      GAS4=(-1.20916E00-1.10206E-01*Y+3.087920E-01*Z1)*Z1*Z1
      GAS5=-6.77089E00-6.90476E-02*Y
      GAS6=(8.18168E00-9.52708E-02*Y)*Z1
      GAS7=(2.98487E-02-1.78706E-02*Z1+6.28419E-04*Y)*Y*Y
      GAS8=(-3.07662E00+6.60408E-02*Y+3.38590E-01*Z1)*Z1*Z1
      GAS9=EXP(1.5916669E02+3.976192E01*Y-7.966199E01*Z1
     *-1.66667E01*Y*Z1)
230   GAMM=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.+GAS9)
240   H=GAMM/(GAMM-1.0E00)*P/RHO
      IF (IFLAG) 10,250,260
250   IF (JFLAG) 30,40,10
260   IF (JFLAG) 60,70,10
1000  FORMAT(/20X,48HWARNING]  OUTSIDE OF VALIDITY RANGE OF CURVE FIT
     *,/,20X,5HRHO =,1PE15.8,5X,3HP =,1PE15.8,/)
      END
C     SUBROUTINE TGAS5 (P,S,RHO)
C
C
C     INPUTS FOR SUBROUTINE:
C     P=PRESSURE IN NEWTONS/M**2.
C     S=SPECIFIC ENTROPY IN (M/SEC)**2./KELVIN
C
C     OUTPUT:
C     RHO=DENSITY IN KG/M**3.
C
C
      SUBROUTINE TGAS5(P,S,RHO)
      DATA P0,R0,S0,GASCON/1.0133E05,1.292E00,6779.2E00,287.06E00/
      X=ALOG10(P/P0)
      SNON=ALOG10(S/GASCON)
      Z=X-SNON
      IF (SNON.GE.1.23E00) GO TO 10
      DELTS=S-S0
      RRATIO=ALOG(P/P0)/1.4-DELTS/(3.5*GASCON)
      RHO=R0*EXP(RRATIO)
      RETURN
10    IF (SNON.GE.1.42E00) GO TO 20
      GAS1=-1.72119E01+5.49354E01*SNON
      GAS2=(-1.99776E00+3.17884E00*SNON)*Z
      GAS3=(-4.69831E01-8.66580E-01*Z+1.21069E01*SNON)*SNON*SNON
      GAS4=(1.58567E-01-1.03055E-01*SNON-1.52322E-03*Z)*Z*Z
      Y=GAS1+GAS2+GAS3+GAS4
      GO TO 120
20    IF (SNON.GE.1.592E00) GO TO 30
      GAS1=-2.78074E02+6.11791E02*SNON
      GAS2=(1.37528E01-1.92394E01*SNON)*Z
      GAS3=(-4.42909E02+7.10425E00*Z+1.05869E02*SNON)*SNON*SNON
      GAS4=(-1.97269E-01+1.49708E-01*SNON+1.19153E-03*Z)*Z*Z
      GAS5=2.80393E02-5.95834E02*SNON
      GAS6=(-1.75934E01+2.49706E01*SNON)*Z
      GAS7=(4.21767E02-8.85461E00*Z-9.94515E01*SNON)*SNON*SNON
      GAS8=(3.61896E-01-2.55458E-01*SNON-2.96892E-03*Z)*Z*Z
      GAS9=EXP(-15.0*(X+54.179-86.947*SNON+33.583*SNON*SNON))
      GO TO 110
30    IF (SNON.GE.1.70E00) GO TO 50
      ZM=7.5269E00*SNON-14.9366
      IF (Z.GE.ZM) GO TO 40
      GAS1=1.10732E02-1.33968E02*SNON
      GAS2=(3.7583E-01+2.77887E-01*SNON)*Z
      GAS3=4.03018E01*SNON*SNON
      GAS4=(1.18506E-01-6.98812E-02*SNON)*Z*Z
      GAS5=-6.85292E01+8.23834E01*SNON
      GAS6=(-1.24942E00+8.31615E-01*SNON)*Z
      GAS7=-2.4524E01*SNON*SNON
      GAS8=(-1.13019E-01+7.46719E-02*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+33.976*SNON-49.659))
      GO TO 110
40    GAS1=3.97149E01-4.80988E01*SNON
      GAS2=(-1.17821E00+1.27522E00*SNON)*Z
      GAS3=1.45552E01*SNON*SNON
      GAS4=(-2.50279E-01+1.58399E-01*SNON)*Z*Z
      GAS5=-5.01859E01+6.31564E01*SNON
      GAS6=(2.39925E00-1.47883E00*SNON)*Z
      GAS7=-1.98852E01*SNON*SNON
      GAS8=(4.66791E-01-3.06926E-01*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+11.16*SNON-18.203))
      GO TO 110
50    IF (SNON.GE.1.80E00) GO TO 70
      ZM=7.5269E00*SNON-14.9366
      IF (Z.GE.ZM) GO TO 60
      GAS1=6.22639E01-7.8884E01*SNON
      GAS2=(-2.19123E00+1.84533E00*SNON)*Z
      GAS3=2.48413E01*SNON*SNON
      GAS4=(-8.76105E-02+5.55047E-02*SNON)*Z*Z
      GAS5=-7.28463E01+9.42375E01*SNON
      GAS6=(4.04979E00-2.45467E00*SNON)*Z
      GAS7=-3.02865E01*SNON*SNON
      GAS8=(1.2872E-01-8.63721E-02*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+13.4576*SNON-18.36))
      GO TO 110
60    GAS1=-2.99578E01+3.89998E01*SNON
      GAS2=(2.90256E00-1.25088E00*SNON)*Z
      GAS3=-1.26641E01*SNON*SNON
      GAS4=(6.13867E-02-5.17059E-02*SNON)*Z*Z
      GAS5=6.05677E01-7.08307E01*SNON
      GAS6=(-2.95622E00+1.70504E00*SNON)*Z
      GAS7=2.07549E01*SNON*SNON
      GAS8=(-2.70962E-01+1.80057E-01*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+16.822*SNON-29.139))
      GO TO 110
70    IF (SNON.GE.1.90E00) GO TO 80
      GAS1=6.23124E02-6.77571E02*SNON
      GAS2=(9.12811E01-9.55480E01*SNON)*Z
      GAS3=(1.84603E02+2.54274E01*Z)*SNON*SNON
      GAS4=(6.97635E-01-3.27916E-01*SNON+4.90838E-03*Z)*Z*Z
      GAS5=-6.39514E02+6.97458E02*SNON
      GAS6=(-1.00154E02+1.06701E02*SNON)*Z
      GAS7=(-1.90745E02-2.86323E01*Z)*SNON*SNON
      GAS8=(-4.81471E-01+2.00348E-01*SNON-6.43371E-03*Z)*Z*Z
      GAS9=EXP(-2.0*(Z+35.275*SNON-58.624))
      GO TO 110
80    IF (SNON.GE.2.00E00) GO TO 90
      GAS1=1.40088E01-1.58855E01*SNON
      GAS2=(1.71245E-01+4.32352E-01*SNON)*Z
      GAS3=4.42836E00*SNON*SNON
      GAS4=(-9.54417E-03+8.92335E-03*SNON)*Z*Z
      GAS5=-1.13217E02+1.24304E02*SNON
      GAS6=(4.41505E00-2.48530E00*SNON)*Z
      GAS7=-3.42370E01*SNON*SNON
      GAS8=(-7.84297E-02+1.21459E-02*SNON)*Z*Z
      GAS9=EXP(-2.00*(Z+20.884*SNON-36.54))
      GO TO 110
90    IF (SNON.GT.2.10) GO TO 100
      GAS1=-3.62767E01+3.8634E01*SNON
      GAS2=(1.48507E00-3.41824E-01*SNON)*Z
      GAS3=-1.04718E01*SNON*SNON
      GAS4=(-3.25437E-02+1.22032E-02*SNON)*Z*Z
      GAS5=(6.52920E01-6.28154E01*SNON)
      GAS6=(2.10906E00-1.11759E00*SNON)*Z
      GAS7=1.50026E01*SNON*SNON
      GAS8=(2.71716E-01-1.4431E-01*SNON)*Z*Z
      GAS9=EXP(-5.00*(Z+28.284*SNON-53.185))
      GO TO 110
100   GAS1=1.86938E02-1.45261E02*SNON
      GAS2=(2.23883E01-1.04974E01*SNON)*Z
      GAS3=2.60284E01*SNON*SNON
      GAS4=(1.85949E00-8.98218E-01*SNON)*Z*Z
      GAS5=-1.27867E02+8.58453E01*SNON
      GAS6=(-2.28808E01+1.13034E01*SNON)*Z
      GAS7=-1.1234E01*SNON*SNON
      GAS8=(-1.56005E00+7.79397E-01*SNON)*Z*Z
      GAS9=EXP(-2.00*(Z+15.048*SNON-26.307))
110   Y=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.+GAS9)
120   RHO=(10.**Y)*R0
      RETURN
      END
C     SUBROUTINE TGAS6 (P,S,E)
C
C     INPUTS FOR SUBROUTINE:
C     P=PRESSURE IN NEWTONS/M**2.
C     S=ENTROPY IN (M/SEC)**2./KELVIN
C
C     OUTPUT:
C     E=INTERNAL ENERGY IN (M/SEC)**2.
C
C
      SUBROUTINE TGAS6(P,S,E)
      DATA P0,E0,S0,GASCON/1.0133E05,78408.4E00,6779.2E00,287.06E00/
      X=ALOG10(P/P0)
      SNON=ALOG10(S/GASCON)
      Z=X-SNON
      IF (SNON.GE.1.23E00) GO TO 10
      DELTS=S-S0
      ERATIO=(ALOG(P/P0)+DELTS/GASCON)/3.5E00
      E=2.5E00*E0*EXP(ERATIO)
      RETURN
10    IF (SNON.GT.1.4E00) GO TO 20
      GAS1=4.89511E01-1.15989E02*SNON
      GAS2=(-4.43026E-01+1.49819E00*SNON)*Z
      GAS3=(8.70709E01-7.02417E-01*Z-2.04916E01*SNON)*SNON*SNON
      GAS4=(-5.09747E-02+2.94929E-02*SNON+5.24685E-04*Z)*Z*Z
      Y=GAS1+GAS2+GAS3+GAS4
      GO TO 120
20    IF (SNON.GE.1.592E00) GO TO 30
      GAS1=1.30563E02-2.87254E02*SNON
      GAS2=(-7.71873E00+1.17605E01*SNON)*Z
      GAS3=(2.06757E02-4.31838E00*Z-4.83472E01*SNON)*SNON*SNON
      GAS4=(1.64299E-01-1.21768E-01*SNON-1.26118E-03*Z)*Z*Z
      GAS5=-8.4598E01+1.74701E02*SNON
      GAS6=(9.52234E00-1.32819E01*SNON)*Z
      GAS7=(-1.20234E02+4.6271E00*Z+2.75818E01*SNON)*SNON*SNON
      GAS8=(-2.27725E-01+1.60365E-01*SNON+1.4933E-03*Z)*Z*Z
      GAS9=EXP(-15.0*(X+54.179-86.947*SNON+33.583*SNON*SNON))
      GO TO 110
30    IF (SNON.GE.1.70E00) GO TO 50
      ZM=-1.917E00*SNON+0.092E00
      IF (Z.GT.ZM) GO TO 40
      GAS1=-1.34875E02+1.92654E02*SNON
      GAS2=(1.04478E01-6.60355E00*SNON)*Z
      GAS3=-6.72013E01*SNON*SNON
      GAS4=(4.14546E-01-2.75698E-01*SNON)*Z*Z
      GAS5=1.07768E02-1.61662E02*SNON
      GAS6=(-1.01257E01+6.4962E00*SNON)*Z
      GAS7=5.93194E01*SNON*SNON
      GAS8=(-4.63204E-01+3.04448E-01*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+50.04*SNON-74.698))
      GO TO 110
40    GAS1=-3.39933E01+4.02792E01*SNON
      GAS2=(7.62742E-01-3.79044E-01*SNON)*Z
      GAS3=-1.09895E01*SNON*SNON
      GAS4=(-7.13412E-02+4.22359E-02*SNON)*Z*Z
      GAS5=3.32182E01-4.03847E01*SNON
      GAS6=(1.87601E-01-1.07599E-01*SNON)*Z
      GAS7=1.22657E01*SNON*SNON
      GAS8=(-1.65537E-01+1.02560E-01*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+14.062*SNON-24.046))
      GO TO 110
50    IF (SNON.GE.1.80E00) GO TO 70
      ZM=-1.917E00*SNON+0.092E00
      IF (Z.GT.ZM) GO TO 60
      GAS1=-1.66572E01+1.51243E01*SNON
      GAS2=(-4.72897E-01+2.95848E-01*SNON)*Z
      GAS3=-2.31418E00*SNON*SNON
      GAS4=(-3.61191E-02+1.7288E-02*SNON)*Z*Z
      GAS5=-3.27168E00+9.45383E00*SNON
      GAS6=(2.04E00-1.1342E00*SNON)*Z
      GAS7=-4.28765E00*SNON*SNON
      GAS8=(1.5021E-01-8.27388E-02*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+16.995*SNON-23.354))
      GO TO 110
60    GAS1=-1.94882E01+2.31472E01*SNON
      GAS2=(1.00783E00-5.18103E-01*SNON)*Z
      GAS3=-5.92829E00*SNON*SNON
      GAS4=(9.92242E-02-5.67928E-02*SNON)*Z*Z
      GAS5=-2.09813E00+1.22781E00*SNON
      GAS6=(-6.27531E-01+3.71651E-01*SNON)*Z
      GAS7=9.84125E-04*SNON*SNON
      GAS8=(-1.24024E-01+7.65034E-02*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+18.152*SNON-31.096))
      GO TO 110
70    IF (SNON.GE.1.90E00) GO TO 80
      GAS1=-6.37715E01+5.46005E01*SNON
      GAS2=(-8.90073E00+5.02063E00*SNON)*Z
      GAS3=-9.67094E00*SNON*SNON
      GAS4=(-7.13493E-01+3.97962E-01*SNON)*Z*Z
      GAS5=5.05131E01-3.97363E01*SNON
      GAS6=(9.27248E00-5.15576E00*SNON)*Z
      GAS7=6.45632E00*SNON*SNON
      GAS8=(7.2563E-01-4.03054E-01*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+35.275*SNON-58.624))
      GO TO 110
80    IF (SNON.GE.2.00E00) GO TO 90
      GAS1=-1.75434E01+2.00307E01*SNON
      GAS2=(6.20484E-01-2.76756E-01*SNON)*Z
      GAS3=-4.76084E00*SNON*SNON
      GAS4=(1.14921E-02-5.80043E-03*SNON)*Z*Z
      GAS5=1.10485E01-1.261E01*SNON
      GAS6=(-6.59043E-01+3.66266E-01*SNON)*Z
      GAS7=3.59417E00*SNON*SNON
      GAS8=(-6.04061E-03+6.78382E-03*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+20.884*SNON-36.54))
      GO TO 110
90    IF (SNON.GE.2.10E00) GO TO 100
      GAS1=-1.18487E01+1.26558E01*SNON
      GAS2=(6.09885E-04+5.90396E-02*SNON)*Z
      GAS3=-2.45275E00*SNON*SNON
      GAS4=(-6.70888E-03+5.21033E-03*SNON)*Z*Z
      GAS5=3.39157E00-3.835E00*SNON
      GAS6=(-2.14031E-01+9.90508E-02*SNON)*Z
      GAS7=1.07008E00*SNON*SNON
      GAS8=(-7.87516E-02+3.63642E-02*SNON)*Z*Z
      GAS9=EXP(-5.0*(Z+28.284*SNON-53.185))
      GO TO 110
100   GAS1=-2.40656E01+3.35589E00*SNON
      GAS2=(-1.14521E01+5.62572E00*SNON)*Z
      GAS3=4.93842E00*SNON*SNON
      GAS4=(-7.55608E-01+3.69774E-01*SNON)*Z*Z
      GAS5=2.23905E01-1.90842E00*SNON
      GAS6=(1.05618E01-5.17247E00*SNON)*Z
      GAS7=-4.3714E00*SNON*SNON
      GAS8=(6.27818E-01-3.12015E-01*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+15.048*SNON-26.307))
110   Y=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.+GAS9)
120   E=(10.**Y)*E0
      RETURN
      END
C     SUBROUTINE TGAS7 (P,S,A)
C
C     INPUTS FOR SUBROUTINE:
C     P=PRESSURE IN NEWTONS/M**2.
C     S=ENTROPY IN (M/SEC)**2./KELVIN
C
C     OUTPUT:
C     A=SPEED OF SOUND IN M/SEC.
C
C
      SUBROUTINE TGAS7(P,S,A)
      DATA P0,S0,R0,A0,GASCON/1.0133E05,6779.2E00,1.292E00,331.3613E00,
     *287.06E00/
      X=ALOG10(P/P0)
      SNON=ALOG10(S/GASCON)
      Z=X-SNON
      IF (SNON.GE.1.23E00) GO TO 10
      DELTS=S-S0
      ASQLOG=ALOG(1.4E00*P0/R0)+(ALOG(P/P0)+DELTS/GASCON)/3.5E00
      A=EXP(ASQLOG/2.0E00)
      RETURN
10    IF (SNON.GT.1.4E00) GO TO 20
      GAS1=-1.38377E-01-8.84138E00*SNON
      GAS2=(2.61050E00-3.16535E00*SNON)*Z
      GAS3=(1.10866E01+9.88389E-01*Z-3.25761E00*SNON)*SNON*SNON
      GAS4=(-1.00224E-01+6.62193E-02*SNON+8.20610E-04*Z)*Z*Z
      Y=GAS1+GAS2+GAS3+GAS4
      GO TO 120
20    IF (SNON.GE.1.595E00) GO TO 30
      GAS1=1.31057E02-2.88847E02*SNON
      GAS2=(-5.04887E00+7.73862E00*SNON)*Z
      GAS3=(2.10147E02-2.88963E00*Z-5.0396E01*SNON)*SNON*SNON
      GAS4=(5.48031E-02-4.39459E-02*SNON-2.10202E-04*Z)*Z*Z
      GAS5=-1.33465E02+2.84739E02*SNON
      GAS6=(7.57389E00-1.07749E01*SNON)*Z
      GAS7=(-2.02362E02+3.8313E00*Z+4.79075E01*SNON)*SNON*SNON
      GAS8=(-1.53453E-01+1.08531E-01*SNON+9.7931E-04*Z)*Z*Z
      GAS9=EXP(-15.0*(X+54.179-86.947*SNON+33.583*SNON*SNON))
      GO TO 110
30    IF (SNON.GE.1.693E00) GO TO 50
      ZM=-9.842E00*SNON+14.19E00
      IF (Z.GT.ZM) GO TO 40
      GAS1=-6.13548E01+7.80742E01*SNON
      GAS2=(2.08524E00-1.21609E00*SNON)*Z
      GAS3=-2.43686E01*SNON*SNON
      GAS4=(8.77563E-02-5.46311E-02*SNON)*Z*Z
      GAS5=2.07952E01-2.71591E01*SNON
      GAS6=(-7.43673E-01+4.08312E-01*SNON)*Z
      GAS7=8.68124E00*SNON*SNON
      GAS8=(-9.3592E-02+5.32328E-02*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+38.785E00*SNON-57.157E00))
      GO TO 110
40    GAS1=3.37056E00-4.87016E00*SNON
      GAS2=(-3.85754E-01+2.87192E-01*SNON)*Z
      GAS3=2.02041E00*SNON*SNON
      GAS4=(-4.63144E-03+8.30832E-03*SNON)*Z*Z
      Y=GAS1+GAS2+GAS3+GAS4
      GO TO 120
50    IF (SNON.GE.1.80) GO TO 70
      ZM=-1.917*SNON+0.092
      IF (Z.GT.ZM) GO TO 60
      GAS1=-8.04927E01+7.63739E01*SNON
      GAS2=(-9.381E00+5.72104E00*SNON)*Z
      GAS3=-1.63435E01*SNON*SNON
      GAS4=(-7.48578E-01+4.50043E-01*SNON)*Z*Z
      GAS5=8.34054E01-8.58837E01*SNON
      GAS6=(4.84197E00-3.11188E00*SNON)*Z
      GAS7=2.11196E01*SNON*SNON
      GAS8=(2.33945E-01-1.59099E-01*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+7.874*SNON-7.569))
      GO TO 110
60    GAS1=-4.73308E00+4.69363E00*SNON
      GAS2=(9.43798E-02+3.54953E-03*SNON)*Z
      GAS3=-7.98293E-01*SNON*SNON
      GAS4=(2.02561E-02-8.73036E-03*SNON)*Z*Z
      Y=GAS1+GAS2+GAS3+GAS4
      GO TO 120
70    IF (SNON.GE.1.900E00) GO TO 80
      GAS1=-6.60574E02+7.38042E02*SNON
      GAS2=(-8.77589E01+9.7894E01*SNON)*Z
      GAS3=(-2.06156E02-2.73753E01*Z)*SNON*SNON
      GAS4=-2.14028E-02*Z*Z
      GAS5=6.65014E02-7.43416E02*SNON
      GAS6=(8.87679E01-9.90508E01*SNON)*Z
      GAS7=(2.08117E02+2.77374E01*Z)*SNON*SNON
      GAS8=2.81148E-02*Z*Z
      GAS9=EXP(-2.0*(Z+35.275*SNON-58.624))
      GO TO 110
80    IF (SNON.GE.2.00E00) GO TO 90
      GAS1=-5.93554E00-7.79929E00*SNON
      GAS2=(-7.23618E00+3.31162E00*SNON)*Z
      GAS3=5.06381E00*SNON*SNON
      GAS4=(-5.377735E-01+2.46865E-01*SNON)*Z*Z
      GAS5=3.95260E01-2.90994E01*SNON
      GAS6=(6.24136E00-2.70007E00*SNON)*Z
      GAS7=5.42786E00*SNON*SNON
      GAS8=(5.95235E-01-2.67771E-01*SNON)*Z*Z
      GAS9=EXP(-2.0*(Z+13.6751*SNON-20.1676))
      GO TO 110
90    IF (SNON.GE.2.10E00) GO TO 100
      GAS1=7.02453E01-7.34732E01*SNON
      GAS2=-5.86844E-01*Z
      GAS3=(1.95548E01+1.81521E-01*Z)*SNON*SNON
      GAS4=7.36786E-03*Z*Z
      GAS5=-1.69610E01+1.80169E01*SNON
      GAS6=-3.65779E-01*Z
      GAS7=(-4.75063E00+1.07583E-01*Z)*SNON*SNON
      GAS8=2.01803E-02*Z*Z
      GAS9=EXP(-5.0*(Z+28.284*SNON-53.185))
      GO TO 110
100   GAS1=-1.12793E02+1.35296E02*SNON
      GAS2=2.74295E00*Z
      GAS3=(-4.08171E01-1.29257E00*Z)*SNON*SNON
      GAS4=-2.25652E-01*Z*Z
      GAS5=2.57057E02-2.83199E02*SNON
      GAS6=-5.84656E00*Z
      GAS7=(7.91574E01+2.17312E00*Z)*SNON*SNON
      GAS8=3.35658E-01*Z*Z
      GAS9=EXP(-2.0*(Z+15.048*SNON-26.307))
110   Y=GAS1+GAS2+GAS3+GAS4+(GAS5+GAS6+GAS7+GAS8)/(1.+GAS9)
120   A=(10.**Y)*A0
      RETURN
      END
