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