source: trunk/LMDZ.GENERIC/libf/phystd/dyn1d/calcenergy_kcm.F90 @ 3523

Last change on this file since 3523 was 1403, checked in by emillour, 10 years ago

All models: Reorganizing the physics/dynamics interface.

  • makelmdz and makelmdz_fcm scripts adapted to handle the new directory settings
  • misc: (replaces what was the "bibio" directory)
  • Should only contain extremely generic (and non physics or dynamics-specific) routines
  • Therefore moved initdynav.F90, initfluxsto.F, inithist.F, writedynav.F90, write_field.F90, writehist.F to "dyn3d_common"
  • dynlonlat_phylonlat: (new interface directory)
  • This directory contains routines relevent to physics/dynamics grid interactions, e.g. routines gr_dyn_fi or gr_fi_dyn and calfis
  • Moreover the dynlonlat_phylonlat contains directories "phy*" corresponding to each physics package "phy*" to be used. These subdirectories should only contain specific interfaces (e.g. iniphysiq) or main programs (e.g. newstart)
  • phy*/dyn1d: this subdirectory contains the 1D model using physics from phy*

EM

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1subroutine calcenergy_kcm(nlayer,Tsurf,T,Play,Plev,Qsurf,Q,muvar,Eatmtot)
2
3
4use params_h, only : Rc
5use watercommon_h, only : mH2O
6use comcstfi_mod, only: g, mugaz
7implicit 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
74end subroutine calcenergy_kcm
75
Note: See TracBrowser for help on using the repository browser.