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
RevLine 
[253]1      subroutine calc_cpp_mugaz
2
3!==================================================================
4!     Purpose
5!     -------
[2635]6!     Computes atmospheric specific heat capacity and
[538]7!     mean molar mass for the gas mixture defined in gases.def
[2635]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.
[253]11!
12!     Authors
13!     -------
14!     Robin Wordsworth (2009)
[589]15!     A. Spiga: make the routine OK with latest changes in rcm1d
[2635]16!     Jeremy Leconte (2022)
[253]17!
18!==================================================================
19
[471]20      use gases_h
[1384]21      use comcstfi_mod, only: cpp, mugaz
[2635]22      use callkeys_mod, only: cpp_mugaz_mode
23      use mod_phys_lmdz_para, only : is_master
[253]24      implicit none
25
[589]26      real cpp_c   
[538]27      real mugaz_c
28
[253]29      integer igas
30
[538]31      cpp_c   = 0.0
32      mugaz_c = 0.0
[253]33
[1364]34
35! compute mugaz
[253]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
[869]42            if(igas.eq.igas_CO2)then
[538]43               mugaz_c = mugaz_c + 44.01*gfrac(igas)
[869]44            elseif(igas.eq.igas_N2)then
[538]45               mugaz_c = mugaz_c + 28.01*gfrac(igas)
[869]46            elseif(igas.eq.igas_H2)then
[538]47               mugaz_c = mugaz_c + 2.01*gfrac(igas)
[869]48            elseif(igas.eq.igas_He)then
[716]49               mugaz_c = mugaz_c + 4.003*gfrac(igas)
[869]50            elseif(igas.eq.igas_H2O)then
[538]51               mugaz_c = mugaz_c + 18.02*gfrac(igas)
[869]52            elseif(igas.eq.igas_SO2)then
[716]53               mugaz_c = mugaz_c + 64.066*gfrac(igas)
[869]54            elseif(igas.eq.igas_H2S)then
[716]55               mugaz_c = mugaz_c + 34.08*gfrac(igas)
[869]56            elseif(igas.eq.igas_CH4)then
[538]57               mugaz_c = mugaz_c + 16.04*gfrac(igas)
[869]58            elseif(igas.eq.igas_NH3)then
[538]59               mugaz_c = mugaz_c + 17.03*gfrac(igas)
[869]60            elseif(igas.eq.igas_C2H6)then
[868]61               ! C2H6 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=28
62               mugaz_c = mugaz_c + 30.07*gfrac(igas)
[869]63            elseif(igas.eq.igas_C2H2)then
[868]64               ! C2H2 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=1
65               mugaz_c = mugaz_c + 26.04*gfrac(igas)
[253]66            else
67               print*,'Error in calc_cpp_mugaz: Gas species not recognised!'
68               call abort
69            endif
70         endif
71
72      enddo
73
[1364]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
[538]122      cpp_c = 1000.0*cpp_c
[253]123
[538]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'
[253]126
[2635]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).'
[538]136      endif
[253]137
[2635]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.'
[589]140          mugaz = mugaz_c
141          cpp = cpp_c
142      else
[2635]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)).'
[589]145      endif
146
147
[253]148      return
149    end subroutine calc_cpp_mugaz
Note: See TracBrowser for help on using the repository browser.