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

Last change on this file since 648 was 589, checked in by aslmd, 13 years ago

LMDZ.GENERIC: Cleaned rcm1d.F and made it truly generic by asking for planetary constants without any default values. Settings are now needed in a rcm1d.def file. Unbeknown to the user, we create a minimal run.def file, read parameters, then remove this dummy run.def. Introduced a keyword force_cpp if the user wants to give values for cpp and mugaz in def files.

File size: 3.2 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      implicit none
21
22#include "dimensions.h"
23#include "dimphys.h"
24#include "comcstfi.h"
25#include "callkeys.h"
26
27      real cpp_c   
28      real mugaz_c
29
30      integer igas
31
32      cpp_c   = 0.0
33      mugaz_c = 0.0
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
41            if(gnom(igas).eq.'CO2')then
42               cpp_c   = cpp_c   + 0.846*gfrac(igas)
43               mugaz_c = mugaz_c + 44.01*gfrac(igas)
44            elseif(gnom(igas).eq.'N2_')then
45               cpp_c   = cpp_c   + 1.040*gfrac(igas)
46               mugaz_c = mugaz_c + 28.01*gfrac(igas)
47            elseif(gnom(igas).eq.'H2_')then
48               cpp_c   = cpp_c   + 14.31*gfrac(igas)
49               mugaz_c = mugaz_c + 2.01*gfrac(igas)
50            elseif(gnom(igas).eq.'H2O')then
51               cpp_c   = cpp_c   + 1.864*gfrac(igas)
52               mugaz_c = mugaz_c + 18.02*gfrac(igas)
53            elseif(gnom(igas).eq.'CH4')then
54               cpp_c   = cpp_c   + 2.226*gfrac(igas)
55               mugaz_c = mugaz_c + 16.04*gfrac(igas)
56            elseif(gnom(igas).eq.'NH3')then
57               cpp_c   = cpp_c   + 2.175*gfrac(igas)
58               mugaz_c = mugaz_c + 17.03*gfrac(igas)
59               print*,'WARNING, cpp for NH3 may be for liquid'
60            else
61               print*,'Error in calc_cpp_mugaz: Gas species not recognised!'
62               call abort
63            endif
64         endif
65
66      enddo
67
68      cpp_c = 1000.0*cpp_c
69
70      print*,'Cp in calc_cpp_mugaz is ',cpp_c,'J kg^-1 K^-1'
71      print*,'Mg in calc_cpp_mugaz is ',mugaz_c,'amu'
72      print*,'Predefined Cp in physics is ',cpp,'J kg^-1 K^-1'
73      print*,'Predefined Mg in physics is ',mugaz,'amu'
74
75      if (check_cpp_match) then
76         print*,'REQUEST TO CHECK cpp_match :'
77         if((abs(1.-cpp/cpp_c).gt.1.e-6) .or.  &
78              (abs(1.-mugaz/mugaz_c).gt.1.e-6)) then
79            ! Ehouarn: tolerate a small mismatch between computed/stored values
80            print*,'--> Values do not match!'
81            print*,'    Either adjust cpp / mugaz via newstart to calculated values,'
82            print*,'    or set check_cpp_match to .false. in callphys.def.'
83            stop
84         else
85            print*,'--> OK. Settings match composition.'
86         endif
87      endif
88
89      if (.not.force_cpp) then
90          print*,'*** Setting cpp & mugaz to computations in calc_cpp_mugaz.'
91          mugaz = mugaz_c
92          cpp = cpp_c
93      else
94          print*,'*** Setting cpp & mugaz to predefined values.'
95      endif
96
97
98      return
99    end subroutine calc_cpp_mugaz
Note: See TracBrowser for help on using the repository browser.