source: trunk/LMDZ.GENERIC/libf/phystd/calc_cpp_mugaz.F90 @ 1115

Last change on this file since 1115 was 869, checked in by aslmd, 12 years ago

24/01/2013 == AS + JL

A more robust way to refer to gas type.

  • Gas names with an arbitrary number of characters (<20) can be used This is good for C2H2, C2H6, H2SO4, C17H21NO4, etc... !!! Remember this must be compliant with Q.dat in corrk_data !!!
  • igas_... labels are assigned once for all in su_gases Then using igas_... everywhere instead of gnom (except for kcm stuff)
  • Users can still use e.g. H2_ but H2 also works
  • Simplified condense_cloud so that igas_CO2 is used directly
File size: 4.2 KB
RevLine 
[253]1      subroutine calc_cpp_mugaz
2
3!==================================================================
4!     Purpose
5!     -------
[538]6!     Check to see if the atmospheric specific heat capacity and
7!     mean molar mass for the gas mixture defined in gases.def
8!     corresponds to what we're using. If it doesn't, abort run
9!     unless option 'check_cpp_match' is set to false in
10!     callphys.def.
[253]11!
12!     Authors
13!     -------
14!     Robin Wordsworth (2009)
[589]15!     A. Spiga: make the routine OK with latest changes in rcm1d
[253]16!
17!==================================================================
18
[471]19      use gases_h
[253]20      implicit none
21
[538]22#include "dimensions.h"
23#include "dimphys.h"
[253]24#include "comcstfi.h"
[538]25#include "callkeys.h"
[253]26
[589]27      real cpp_c   
[538]28      real mugaz_c
29
[253]30      integer igas
31
[538]32      cpp_c   = 0.0
33      mugaz_c = 0.0
[253]34
35      do igas=1,ngasmx
36
37         if(igas.eq.vgas)then
38            ! ignore variable gas in cpp calculation
39         else
40            ! all values at 300 K from Engineering Toolbox
[869]41            if(igas.eq.igas_CO2)then
[716]42               !cpp_c   = cpp_c   + 0.744*gfrac(igas) ! @ ~210 K (better for Mars conditions)
[538]43               cpp_c   = cpp_c   + 0.846*gfrac(igas)
44               mugaz_c = mugaz_c + 44.01*gfrac(igas)
[869]45            elseif(igas.eq.igas_N2)then
[538]46               cpp_c   = cpp_c   + 1.040*gfrac(igas)
47               mugaz_c = mugaz_c + 28.01*gfrac(igas)
[869]48            elseif(igas.eq.igas_H2)then
[538]49               cpp_c   = cpp_c   + 14.31*gfrac(igas)
50               mugaz_c = mugaz_c + 2.01*gfrac(igas)
[869]51            elseif(igas.eq.igas_He)then
[716]52               cpp_c   = cpp_c   + 5.19*gfrac(igas)
53               mugaz_c = mugaz_c + 4.003*gfrac(igas)
[869]54            elseif(igas.eq.igas_H2O)then
[538]55               cpp_c   = cpp_c   + 1.864*gfrac(igas)
56               mugaz_c = mugaz_c + 18.02*gfrac(igas)
[869]57            elseif(igas.eq.igas_SO2)then
[716]58               cpp_c   = cpp_c   + 0.64*gfrac(igas)
59               mugaz_c = mugaz_c + 64.066*gfrac(igas)
[869]60            elseif(igas.eq.igas_H2S)then
[716]61               cpp_c   = cpp_c   + 1.003*gfrac(igas) ! from wikipedia...
62               mugaz_c = mugaz_c + 34.08*gfrac(igas)
[869]63            elseif(igas.eq.igas_CH4)then
[538]64               cpp_c   = cpp_c   + 2.226*gfrac(igas)
65               mugaz_c = mugaz_c + 16.04*gfrac(igas)
[869]66            elseif(igas.eq.igas_NH3)then
[538]67               cpp_c   = cpp_c   + 2.175*gfrac(igas)
68               mugaz_c = mugaz_c + 17.03*gfrac(igas)
[868]69               print*,'WARNING, cpp for NH3 may be for liquid'
[869]70            elseif(igas.eq.igas_C2H6)then
[868]71               ! C2H6 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=28
72               cpp_c   = cpp_c   + 1.763*gfrac(igas)
73               mugaz_c = mugaz_c + 30.07*gfrac(igas)
[869]74            elseif(igas.eq.igas_C2H2)then
[868]75               ! C2H2 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=1
76               cpp_c   = cpp_c   + 1.575*gfrac(igas)
77               mugaz_c = mugaz_c + 26.04*gfrac(igas)
[253]78            else
79               print*,'Error in calc_cpp_mugaz: Gas species not recognised!'
80               call abort
81            endif
82         endif
83
84      enddo
85
[538]86      cpp_c = 1000.0*cpp_c
[253]87
[538]88      print*,'Cp in calc_cpp_mugaz is ',cpp_c,'J kg^-1 K^-1'
89      print*,'Mg in calc_cpp_mugaz is ',mugaz_c,'amu'
90      print*,'Predefined Cp in physics is ',cpp,'J kg^-1 K^-1'
91      print*,'Predefined Mg in physics is ',mugaz,'amu'
[253]92
[589]93      if (check_cpp_match) then
94         print*,'REQUEST TO CHECK cpp_match :'
95         if((abs(1.-cpp/cpp_c).gt.1.e-6) .or.  &
[588]96              (abs(1.-mugaz/mugaz_c).gt.1.e-6)) then
[589]97            ! Ehouarn: tolerate a small mismatch between computed/stored values
98            print*,'--> Values do not match!'
99            print*,'    Either adjust cpp / mugaz via newstart to calculated values,'
100            print*,'    or set check_cpp_match to .false. in callphys.def.'
[538]101            stop
[589]102         else
103            print*,'--> OK. Settings match composition.'
[538]104         endif
105      endif
[253]106
[589]107      if (.not.force_cpp) then
108          print*,'*** Setting cpp & mugaz to computations in calc_cpp_mugaz.'
109          mugaz = mugaz_c
110          cpp = cpp_c
111      else
112          print*,'*** Setting cpp & mugaz to predefined values.'
113      endif
114
115
[253]116      return
117    end subroutine calc_cpp_mugaz
Note: See TracBrowser for help on using the repository browser.