1 | subroutine calcenergy_kcm(nlayer,Tsurf,T,Play,Plev,Qsurf,Q,muvar,Eatmtot) |
---|
2 | |
---|
3 | |
---|
4 | use params_h, only : Rc |
---|
5 | use watercommon_h, only : mH2O |
---|
6 | implicit none |
---|
7 | |
---|
8 | ! ---------------------------------------------------------------- |
---|
9 | ! Purpose: Calculate total energy of the (steam) atmosphere |
---|
10 | ! Authour: R. Wordsworth (2011) |
---|
11 | ! ---------------------------------------------------------------- |
---|
12 | |
---|
13 | !#include "dimensions.h" |
---|
14 | !#include "dimphys.h" |
---|
15 | #include "comcstfi.h" |
---|
16 | !#include "callkeys.h" |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | ! inputs |
---|
21 | integer,intent(in) :: nlayer |
---|
22 | real Tsurf,T(1:nlayer) |
---|
23 | real Play(1:nlayer),Plev(1:nlayer+1) |
---|
24 | real Qsurf,Q(1:nlayer) |
---|
25 | real muvar(1,nlayer+1) |
---|
26 | |
---|
27 | ! internal |
---|
28 | integer il |
---|
29 | real m_n,m_v,cp_n,cp_v,cp_a,Eatmlay |
---|
30 | real s_c,rho_v,L |
---|
31 | double precision p_v, s_v, nul |
---|
32 | real VMR(1:nlayer) |
---|
33 | |
---|
34 | ! output |
---|
35 | real Eatmtot |
---|
36 | |
---|
37 | ! functions |
---|
38 | double precision cp_neutral |
---|
39 | |
---|
40 | m_n = mugaz/1000. |
---|
41 | m_v = mH2O/1000. |
---|
42 | |
---|
43 | |
---|
44 | do il=1,nlayer |
---|
45 | VMR(il)=Q(il)*(muvar(1,il+1)/mH2O) |
---|
46 | end do |
---|
47 | |
---|
48 | |
---|
49 | Eatmtot = 0.0 |
---|
50 | do il=1,nlayer |
---|
51 | |
---|
52 | |
---|
53 | cp_n = cp_neutral(dble(T(il))) |
---|
54 | cp_v = (32.24+1.923d-3*T(il) + 1.055d-5*T(il)**2-3.511d-9*T(il)**3)/m_v |
---|
55 | ! / by m_v makes it per kg not per mol |
---|
56 | |
---|
57 | call psat_H2O(dble(T(il)),p_v) |
---|
58 | p_v = p_v*1d6 |
---|
59 | rho_v = real(p_v)*m_v/(real(Rc)*T(il)) |
---|
60 | |
---|
61 | call therm(dble(T(il)),dble(rho_v)*1d-3,nul,nul,nul,nul,nul,nul,nul,& |
---|
62 | nul,nul,nul,s_v,nul) |
---|
63 | |
---|
64 | s_c = 2.06 * log(T(il)/273.15) |
---|
65 | s_v = s_v * 1d3 |
---|
66 | s_c = s_c * 1d3 |
---|
67 | L = (real(s_v)-s_c)*T(il) |
---|
68 | |
---|
69 | cp_a = (1-VMR(il))*cp_n + VMR(il)*cp_v |
---|
70 | !cp_a = (1-Q(il))*cp_n + Q(il)*cp_v |
---|
71 | |
---|
72 | Eatmlay = ( cp_a*T(il) + L*VMR(il) ) * (Plev(il)-Plev(il+1))/g |
---|
73 | |
---|
74 | Eatmtot = Eatmtot + Eatmlay |
---|
75 | enddo |
---|
76 | |
---|
77 | print*,'WARNING: E-calc currently assumes H2O saturation!' |
---|
78 | |
---|
79 | end subroutine calcenergy_kcm |
---|
80 | |
---|