source: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/phystd/calc_cpp_mugaz.F90 @ 298

Last change on this file since 298 was 298, checked in by milmd, 10 years ago

Less output messages are written. On 20000 cores it is better. In LMDZ, only master of MPI and OpenMP can write.

File size: 4.3 KB
Line 
1      subroutine calc_cpp_mugaz
2
3!==================================================================
4!     Purpose
5!     -------
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.
11!
12!     Authors
13!     -------
14!     Robin Wordsworth (2009)
15!     A. Spiga: make the routine OK with latest changes in rcm1d
16!
17!==================================================================
18
19      use gases_h
20      use mod_phys_lmdz_para, only : is_master
21      implicit none
22
23!#include "dimensions.h"
24!#include "dimphys.h"
25#include "comcstfi.h"
26#include "callkeys.h"
27
28      real cpp_c   
29      real mugaz_c
30
31      integer igas
32
33      cpp_c   = 0.0
34      mugaz_c = 0.0
35
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               !cpp_c   = cpp_c   + 0.744*gfrac(igas) ! @ ~210 K (better for Mars conditions)
44               cpp_c   = cpp_c   + 0.846*gfrac(igas)
45               mugaz_c = mugaz_c + 44.01*gfrac(igas)
46            elseif(igas.eq.igas_N2)then
47               cpp_c   = cpp_c   + 1.040*gfrac(igas)
48               mugaz_c = mugaz_c + 28.01*gfrac(igas)
49            elseif(igas.eq.igas_H2)then
50               cpp_c   = cpp_c   + 14.31*gfrac(igas)
51               mugaz_c = mugaz_c + 2.01*gfrac(igas)
52            elseif(igas.eq.igas_He)then
53               cpp_c   = cpp_c   + 5.19*gfrac(igas)
54               mugaz_c = mugaz_c + 4.003*gfrac(igas)
55            elseif(igas.eq.igas_H2O)then
56               cpp_c   = cpp_c   + 1.864*gfrac(igas)
57               mugaz_c = mugaz_c + 18.02*gfrac(igas)
58            elseif(igas.eq.igas_SO2)then
59               cpp_c   = cpp_c   + 0.64*gfrac(igas)
60               mugaz_c = mugaz_c + 64.066*gfrac(igas)
61            elseif(igas.eq.igas_H2S)then
62               cpp_c   = cpp_c   + 1.003*gfrac(igas) ! from wikipedia...
63               mugaz_c = mugaz_c + 34.08*gfrac(igas)
64            elseif(igas.eq.igas_CH4)then
65               cpp_c   = cpp_c   + 2.226*gfrac(igas)
66               mugaz_c = mugaz_c + 16.04*gfrac(igas)
67            elseif(igas.eq.igas_NH3)then
68               cpp_c   = cpp_c   + 2.175*gfrac(igas)
69               mugaz_c = mugaz_c + 17.03*gfrac(igas)
70               print*,'WARNING, cpp for NH3 may be for liquid'
71            elseif(igas.eq.igas_C2H6)then 
72               ! C2H6 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=28
73               cpp_c   = cpp_c   + 1.763*gfrac(igas)
74               mugaz_c = mugaz_c + 30.07*gfrac(igas)
75            elseif(igas.eq.igas_C2H2)then
76               ! C2H2 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=1
77               cpp_c   = cpp_c   + 1.575*gfrac(igas)
78               mugaz_c = mugaz_c + 26.04*gfrac(igas)
79            else
80               print*,'Error in calc_cpp_mugaz: Gas species not recognised!'
81               call abort
82            endif
83         endif
84
85      enddo
86
87      cpp_c = 1000.0*cpp_c
88
89      if (is_master) then
90      print*,'Cp in calc_cpp_mugaz is ',cpp_c,'J kg^-1 K^-1'
91      print*,'Mg in calc_cpp_mugaz is ',mugaz_c,'amu'
92      print*,'Predefined Cp in physics is ',cpp,'J kg^-1 K^-1'
93      print*,'Predefined Mg in physics is ',mugaz,'amu'
94      end if
95
96      if (check_cpp_match) then
97         if (is_master) print*,'REQUEST TO CHECK cpp_match :'
98         if((abs(1.-cpp/cpp_c).gt.1.e-6) .or.  &
99              (abs(1.-mugaz/mugaz_c).gt.1.e-6)) then
100            ! Ehouarn: tolerate a small mismatch between computed/stored values
101            print*,'--> Values do not match!'
102            print*,'    Either adjust cpp / mugaz via newstart to calculated values,'
103            print*,'    or set check_cpp_match to .false. in callphys.def.'
104            stop
105         else
106            if (is_master) print*,'--> OK. Settings match composition.'
107         endif
108      endif
109
110      if (.not.force_cpp) then
111          if (is_master) print*,'*** Setting cpp & mugaz to computations in calc_cpp_mugaz.'
112          mugaz = mugaz_c
113          cpp = cpp_c
114      else
115          if (is_master) print*,'*** Setting cpp & mugaz to predefined values.'
116      endif
117
118
119      return
120    end subroutine calc_cpp_mugaz
Note: See TracBrowser for help on using the repository browser.