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

Last change on this file since 2757 was 2635, checked in by aslmd, 3 years ago

Introduction of cpp_mugaz_mode to decide what source should be used for cpp and mugaz. Force_cpp and check_cpp_match are deprecated (see issue la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk#27).

File size: 5.6 KB
Line 
1      subroutine calc_cpp_mugaz
2
3!==================================================================
4!     Purpose
5!     -------
6!     Computes atmospheric specific heat capacity and
7!     mean molar mass for the gas mixture defined in gases.def
8!     with standard values.
9!     In 1d, one can force the model to adopt these standard values
10!     by setting cpp_mugaz_mode=2 in callfis.def.
11!
12!     Authors
13!     -------
14!     Robin Wordsworth (2009)
15!     A. Spiga: make the routine OK with latest changes in rcm1d
16!     Jeremy Leconte (2022)
17!
18!==================================================================
19
20      use gases_h
21      use comcstfi_mod, only: cpp, mugaz
22      use callkeys_mod, only: cpp_mugaz_mode
23      use mod_phys_lmdz_para, only : is_master
24      implicit none
25
26      real cpp_c   
27      real mugaz_c
28
29      integer igas
30
31      cpp_c   = 0.0
32      mugaz_c = 0.0
33
34
35! compute mugaz
36      do igas=1,ngasmx
37
38         if(igas.eq.vgas)then
39            ! ignore variable gas in cpp calculation
40         else
41            ! all values at 300 K from Engineering Toolbox
42            if(igas.eq.igas_CO2)then
43               mugaz_c = mugaz_c + 44.01*gfrac(igas)
44            elseif(igas.eq.igas_N2)then
45               mugaz_c = mugaz_c + 28.01*gfrac(igas)
46            elseif(igas.eq.igas_H2)then
47               mugaz_c = mugaz_c + 2.01*gfrac(igas)
48            elseif(igas.eq.igas_He)then
49               mugaz_c = mugaz_c + 4.003*gfrac(igas)
50            elseif(igas.eq.igas_H2O)then
51               mugaz_c = mugaz_c + 18.02*gfrac(igas)
52            elseif(igas.eq.igas_SO2)then
53               mugaz_c = mugaz_c + 64.066*gfrac(igas)
54            elseif(igas.eq.igas_H2S)then
55               mugaz_c = mugaz_c + 34.08*gfrac(igas)
56            elseif(igas.eq.igas_CH4)then
57               mugaz_c = mugaz_c + 16.04*gfrac(igas)
58            elseif(igas.eq.igas_NH3)then
59               mugaz_c = mugaz_c + 17.03*gfrac(igas)
60            elseif(igas.eq.igas_C2H6)then
61               ! C2H6 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=28
62               mugaz_c = mugaz_c + 30.07*gfrac(igas)
63            elseif(igas.eq.igas_C2H2)then
64               ! C2H2 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=1
65               mugaz_c = mugaz_c + 26.04*gfrac(igas)
66            else
67               print*,'Error in calc_cpp_mugaz: Gas species not recognised!'
68               call abort
69            endif
70         endif
71
72      enddo
73
74!compute cpp
75      do igas=1,ngasmx
76
77         if(igas.eq.vgas)then
78            ! ignore variable gas in cpp calculation
79         else
80            ! all values at 300 K from Engineering Toolbox
81            if(igas.eq.igas_CO2)then
82               !cpp_c   = cpp_c   + 0.744*gfrac(igas) ! @ ~210 K (better for
83               !Mars conditions)
84               cpp_c   = cpp_c   + 0.846*gfrac(igas)*44.01/mugaz_c
85            elseif(igas.eq.igas_N2)then
86               cpp_c   = cpp_c   + 1.040*gfrac(igas)*28.01/mugaz_c
87            elseif(igas.eq.igas_H2)then
88               cpp_c   = cpp_c   + 14.31*gfrac(igas)*2.01/mugaz_c
89            elseif(igas.eq.igas_He)then
90               cpp_c   = cpp_c   + 5.19*gfrac(igas)*4.003/mugaz_c
91            elseif(igas.eq.igas_H2O)then
92               cpp_c   = cpp_c   + 1.864*gfrac(igas)*18.02/mugaz_c
93            elseif(igas.eq.igas_SO2)then
94               cpp_c   = cpp_c   + 0.64*gfrac(igas)*64.066/mugaz_c
95            elseif(igas.eq.igas_H2S)then
96               cpp_c   = cpp_c   + 1.003*gfrac(igas)*34.08/mugaz_c ! from wikipedia...
97            elseif(igas.eq.igas_CH4)then
98               cpp_c   = cpp_c   + 2.226*gfrac(igas)*16.04/mugaz_c
99            elseif(igas.eq.igas_NH3)then
100               cpp_c   = cpp_c   + 2.175*gfrac(igas)*17.03/mugaz_c
101               print*,'WARNING, cpp for NH3 may be for liquid'
102            elseif(igas.eq.igas_C2H6)then
103               ! C2H6
104               ! http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=28
105               cpp_c   = cpp_c   + 1.763*gfrac(igas)*30.07/mugaz_c
106            elseif(igas.eq.igas_C2H2)then
107               ! C2H2
108               ! http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=1
109               cpp_c   = cpp_c   + 1.575*gfrac(igas)*26.04/mugaz_c
110            else
111               print*,'Error in calc_cpp_mugaz: Gas species not recognised!'
112               call abort
113            endif
114         endif
115
116      enddo
117
118
119
120
121
122      cpp_c = 1000.0*cpp_c
123
124      print*,'Cp in calc_cpp_mugaz is ',cpp_c,'J kg^-1 K^-1'
125      print*,'Mg in calc_cpp_mugaz is ',mugaz_c,'amu'
126
127      if(((abs(1.-cpp/cpp_c).gt.1.e-6) .or.  &
128           (abs(1.-mugaz/mugaz_c).gt.1.e-6)).and. is_master ) then
129         ! Ehouarn: tolerate a small mismatch between computed/stored values
130         print*,'--> Values do not match with the predefined one ! (',cpp,',',mugaz,')'
131         print*,'    Because cp varies with temperature and that some gases may not appear in gases.def,'
132         print*,'    a small discrepancy might be completely normal.'
133         print*,'    But you might want to check that!'
134         print*,'    If you want to use the values calculated here, adjust cpp / mugaz in the dynamics via newstart (3d)'
135         print*,'    or use cpp_mugaz_mode=2 (if you are in 1d).'
136      endif
137
138      if (cpp_mugaz_mode==2) then
139          if (is_master) print*,'*** cpp_mugaz_mode==2, so setting cpp & mugaz to computations in calc_cpp_mugaz.'
140          mugaz = mugaz_c
141          cpp = cpp_c
142      else
143          if (is_master) print*,'*** Leaving cpp & mugaz equal to predefined values'
144          if (is_master) print*,'(either from dynamics (cpp_mugaz_mode=0) or callfis (cpp_mugaz_mode=1)).'
145      endif
146
147
148      return
149    end subroutine calc_cpp_mugaz
Note: See TracBrowser for help on using the repository browser.