source: LMDZ6/trunk/libf/phylmd/ener_conserv.f90 @ 5428

Last change on this file since 5428 was 5390, checked in by yann meurdesoif, 2 weeks ago
  • Remove UTF8 character that inihibit fortran parsing with GPU morphosis
  • Add missing END SUBROUTINE instead of simple END, that inhibit correct parsing with regulat expression parser (quick and dirty parsing)

YM

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
File size: 9.1 KB
Line 
1subroutine ener_conserv(klon,klev,pdtphys, &
2 &                      puo,pvo,pto,qx,ivap,iliq,isol, &
3 &                      pun,pvn,ptn,pqn,pqln,pqsn,dtke,masse,exner,d_t_ec)
4
5!=============================================================
6! Energy conservation
7! Based on the TKE equation
8! The M2 and N2 terms at the origin of TKE production are
9! concerted into heating in the d_t_ec term
10! Option 1 is the standard
11!        101 is for M2 term only
12!        101 for N2 term only
13!         -1 is a previours treatment for kinetic energy only
14!  FH (hourdin@lmd.jussieu.fr), 2013/04/25
15!=============================================================
16
17!=============================================================
18! Declarations
19!=============================================================
20
21! From module
22USE compbl_mod_h
23USE yoethf_mod_h
24USE clesphys_mod_h
25USE phys_local_var_mod, ONLY : d_u_vdf,d_v_vdf,d_t_vdf,d_u_ajs,d_v_ajs,d_t_ajs, &
26 &                             d_u_con,d_v_con,d_t_con,d_t_diss
27USE phys_local_var_mod, ONLY : d_t_eva,d_t_lsc,d_q_eva,d_q_lsc
28USE phys_local_var_mod, ONLY : d_u_oro,d_v_oro,d_u_lif,d_v_lif
29USE phys_local_var_mod, ONLY : du_gwd_hines,dv_gwd_hines,dv_gwd_front,dv_gwd_rando
30USE phys_state_var_mod, ONLY : du_gwd_front,du_gwd_rando
31USE phys_output_var_mod, ONLY : bils_ec,bils_ech,bils_tke,bils_kinetic,bils_enthalp,bils_latent,bils_diss
32USE add_phys_tend_mod, ONLY : fl_cor_ebil
33USE infotrac_phy, ONLY: nqtot
34
35
36USE yomcst_mod_h
37IMPLICIT none
38
39
40! Arguments
41INTEGER, INTENT(IN) :: klon,klev
42REAL, INTENT(IN) :: pdtphys
43REAL, DIMENSION(klon,klev), INTENT(IN)      :: puo,pvo,pto
44REAL, DIMENSION(klon,klev,nqtot), INTENT(IN):: qx
45INTEGER, INTENT(IN)                         :: ivap, iliq, isol
46REAL, DIMENSION(klon,klev), INTENT(IN)      :: pun,pvn,ptn,pqn,pqln,pqsn
47REAL, DIMENSION(klon,klev), INTENT(IN)      :: masse,exner
48REAL, DIMENSION(klon,klev+1), INTENT(IN)    :: dtke
49!
50REAL, DIMENSION(klon,klev), INTENT(OUT)     :: d_t_ec
51
52! Local
53      integer k,i
54REAL, DIMENSION(klon,klev+1) :: fluxu,fluxv,fluxt
55REAL, DIMENSION(klon,klev+1) :: dddu,dddv,dddt
56REAL, DIMENSION(klon,klev) :: d_u,d_v,d_t,zv,zu,d_t_ech, pqo, pql0, pqs0
57REAL ZRCPD
58
59character*80 abort_message
60character*20 :: modname
61
62
63modname='ener_conser'
64d_t_ec(:,:)=0.
65
66IF(ivap == 0) CALL abort_physic (modname,'can''t run without water vapour',1)
67IF(iliq == 0) CALL abort_physic (modname,'can''t run without liquid water',1)
68pqo  = qx(:,:,ivap)
69pql0 = qx(:,:,iliq)
70IF(isol /= 0) pqs0 = qx(:,:,isol)
71
72IF (iflag_ener_conserv==-1) THEN
73!+jld ec_conser
74   DO k = 1, klev
75   DO i = 1, klon
76     IF (fl_cor_ebil .GT. 0) then
77       ZRCPD = RCPD*(1.0+RVTMP2*(pqn(i,k)+pqln(i,k)+pqsn(i,k)))
78     ELSE
79       ZRCPD = RCPD*(1.0+RVTMP2*pqn(i,k))
80     ENDIF
81     d_t_ec(i,k)=0.5/ZRCPD &
82 &     *(puo(i,k)**2+pvo(i,k)**2-pun(i,k)**2-pvn(i,k)**2)
83   ENDDO
84   ENDDO
85!-jld ec_conser
86
87
88
89ELSEIF (iflag_ener_conserv>=1) THEN
90
91   IF (iflag_ener_conserv<=2) THEN
92!     print*,'ener_conserv pbl=',iflag_pbl
93      IF (iflag_pbl>=20 .AND. iflag_pbl<=27) THEN !d_t_diss accounts for conserv
94         d_t(:,:)=d_t_ajs(:,:)   ! d_t_ajs = adjust + thermals
95         d_u(:,:)=d_u_ajs(:,:)+d_u_con(:,:)
96         d_v(:,:)=d_v_ajs(:,:)+d_v_con(:,:)
97      ELSE
98         d_t(:,:)=d_t_vdf(:,:)+d_t_ajs(:,:)   ! d_t_ajs = adjust + thermals
99         d_u(:,:)=d_u_vdf(:,:)+d_u_ajs(:,:)+d_u_con(:,:)
100         d_v(:,:)=d_v_vdf(:,:)+d_v_ajs(:,:)+d_v_con(:,:)
101      ENDIF
102   ELSEIF (iflag_ener_conserv==101) THEN
103      d_t(:,:)=0.
104      d_u(:,:)=d_u_vdf(:,:)+d_u_ajs(:,:)+d_u_con(:,:)
105      d_v(:,:)=d_v_vdf(:,:)+d_v_ajs(:,:)+d_v_con(:,:)
106   ELSEIF (iflag_ener_conserv==110) THEN
107      d_t(:,:)=d_t_vdf(:,:)+d_t_ajs(:,:)
108      d_u(:,:)=0.
109      d_v(:,:)=0.
110
111   ELSEIF (iflag_ener_conserv==3) THEN
112      d_t(:,:)=0.
113      d_u(:,:)=0.
114      d_v(:,:)=0.
115   ELSEIF (iflag_ener_conserv==4) THEN
116      d_t(:,:)=0.
117      d_u(:,:)=d_u_vdf(:,:)
118      d_v(:,:)=d_v_vdf(:,:)
119   ELSEIF (iflag_ener_conserv==5) THEN
120      d_t(:,:)=d_t_vdf(:,:)
121      d_u(:,:)=d_u_vdf(:,:)
122      d_v(:,:)=d_v_vdf(:,:)
123   ELSEIF (iflag_ener_conserv==6) THEN
124      d_t(:,:)=d_t_vdf(:,:)
125      d_u(:,:)=d_u_vdf(:,:)+d_u_ajs(:,:)
126      d_v(:,:)=d_v_vdf(:,:)+d_v_ajs(:,:)
127   ELSEIF (iflag_ener_conserv==7) THEN
128      d_t(:,:)=d_t_vdf(:,:)+d_t_ajs(:,:)
129      d_u(:,:)=d_u_vdf(:,:)+d_u_ajs(:,:)
130      d_v(:,:)=d_v_vdf(:,:)+d_v_ajs(:,:)
131   ELSEIF (iflag_ener_conserv==8) THEN
132      d_t(:,:)=d_t_vdf(:,:)
133      d_u(:,:)=d_u_vdf(:,:)+d_u_ajs(:,:)+d_u_con(:,:)
134      d_v(:,:)=d_v_vdf(:,:)+d_v_ajs(:,:)+d_v_con(:,:)
135   ELSEIF (iflag_ener_conserv==9) THEN
136      d_t(:,:)=d_t_vdf(:,:)
137      d_u(:,:)=d_u_vdf(:,:)+d_u_ajs(:,:)+d_u_con(:,:)+d_u_oro(:,:)
138      d_v(:,:)=d_v_vdf(:,:)+d_v_ajs(:,:)+d_v_con(:,:)+d_v_oro(:,:)
139   ELSEIF (iflag_ener_conserv==10) THEN
140      d_t(:,:)=d_t_vdf(:,:)
141      d_u(:,:)=d_u_vdf(:,:)+d_u_ajs(:,:)+d_u_con(:,:)+d_u_oro(:,:)+d_u_lif(:,:)
142      d_v(:,:)=d_v_vdf(:,:)+d_v_ajs(:,:)+d_v_con(:,:)+d_v_oro(:,:)+d_v_lif(:,:)
143   ELSEIF (iflag_ener_conserv==11) THEN
144      d_t(:,:)=d_t_vdf(:,:)
145      d_u(:,:)=d_u_vdf(:,:)+d_u_ajs(:,:)+d_u_con(:,:)+d_u_oro(:,:)+d_u_lif(:,:)
146      d_v(:,:)=d_v_vdf(:,:)+d_v_ajs(:,:)+d_v_con(:,:)+d_v_oro(:,:)+d_v_lif(:,:)
147      IF (ok_hines) THEN
148         d_u_vdf(:,:)=d_u_vdf(:,:)+du_gwd_hines(:,:)
149         d_v_vdf(:,:)=d_v_vdf(:,:)+dv_gwd_hines(:,:)
150      ENDIF
151      IF (.not. ok_hines .and. ok_gwd_rando) THEN
152         d_u_vdf(:,:)=d_u_vdf(:,:)+du_gwd_front(:,:)
153         d_v_vdf(:,:)=d_v_vdf(:,:)+dv_gwd_front(:,:)
154      ENDIF
155      IF (ok_gwd_rando) THEN
156         d_u_vdf(:,:)=d_u_vdf(:,:)+du_gwd_rando(:,:)
157         d_v_vdf(:,:)=d_v_vdf(:,:)+dv_gwd_rando(:,:)
158      ENDIF
159   ELSE
160      abort_message = 'iflag_ener_conserv non prevu'
161      CALL abort_physic (modname,abort_message,1)
162   ENDIF
163
164!----------------------------------------------------------------------------
165! Two options wether we consider time integration in the energy conservation
166!----------------------------------------------------------------------------
167
168   if (iflag_ener_conserv==2) then
169      zu(:,:)=puo(:,:)
170      zv(:,:)=pvo(:,:)
171   else
172      IF (iflag_pbl>=20 .AND. iflag_pbl<=27) THEN
173         zu(:,:)=puo(:,:)+d_u_vdf(:,:)+0.5*d_u(:,:)
174         zv(:,:)=pvo(:,:)+d_v_vdf(:,:)+0.5*d_v(:,:)
175      ELSE
176         zu(:,:)=puo(:,:)+0.5*d_u(:,:)
177         zv(:,:)=pvo(:,:)+0.5*d_v(:,:)
178      ENDIF
179   endif
180
181   fluxu(:,klev+1)=0.
182   fluxv(:,klev+1)=0.
183   fluxt(:,klev+1)=0.
184
185   do k=klev,1,-1
186      fluxu(:,k)=fluxu(:,k+1)+masse(:,k)*d_u(:,k)
187      fluxv(:,k)=fluxv(:,k+1)+masse(:,k)*d_v(:,k)
188      fluxt(:,k)=fluxt(:,k+1)+masse(:,k)*d_t(:,k)/exner(:,k)
189   enddo
190
191   dddu(:,1)=2*zu(:,1)*fluxu(:,1)
192   dddv(:,1)=2*zv(:,1)*fluxv(:,1)
193   dddt(:,1)=(exner(:,1)-1.)*fluxt(:,1)
194
195   do k=2,klev
196      dddu(:,k)=(zu(:,k)-zu(:,k-1))*fluxu(:,k)
197      dddv(:,k)=(zv(:,k)-zv(:,k-1))*fluxv(:,k)
198      dddt(:,k)=(exner(:,k)-exner(:,k-1))*fluxt(:,k)
199   enddo
200   dddu(:,klev+1)=0.
201   dddv(:,klev+1)=0.
202   dddt(:,klev+1)=0.
203
204   do k=1,klev
205      d_t_ech(:,k)=-(rcpd*(dddt(:,k)+dddt(:,k+1)))/(2.*rcpd*masse(:,k))
206      d_t_ec(:,k)=-(dddu(:,k)+dddu(:,k+1)+dddv(:,k)+dddv(:,k+1))/(2.*rcpd*masse(:,k))+d_t_ech(:,k)
207   enddo
208
209ENDIF
210
211!================================================================
212!  Computation of integrated enthalpie and kinetic energy variation
213!  FH (hourdin@lmd.jussieu.fr), 2013/04/25
214!  bils_ec : energie conservation term
215!  bils_ech : part of this term linked to temperature
216!  bils_tke : change of TKE
217!  bils_diss : dissipation of TKE (when activated)
218!  bils_kinetic : change of kinetic energie of the column
219!  bils_enthalp : change of enthalpie
220!  bils_latent  : change of latent heat. Computed between
221!          after reevaporation (at the beginning of the physics)
222!          and before large scale condensation (fisrtilp)
223!================================================================
224
225      bils_ec(:)=0.
226      bils_ech(:)=0.
227      bils_tke(:)=0.
228      bils_diss(:)=0.
229      bils_kinetic(:)=0.
230      bils_enthalp(:)=0.
231      bils_latent(:)=0.
232      DO k=1,klev
233        bils_ec(:)=bils_ec(:)-d_t_ec(:,k)*masse(:,k)
234        bils_diss(:)=bils_diss(:)-d_t_diss(:,k)*masse(:,k)
235        bils_kinetic(:)=bils_kinetic(:)+masse(:,k)* &
236     &           (pun(:,k)*pun(:,k)+pvn(:,k)*pvn(:,k) &
237     &            -puo(:,k)*puo(:,k)-pvo(:,k)*pvo(:,k))
238        bils_enthalp(:)= &
239     &  bils_enthalp(:)+masse(:,k)*(ptn(:,k)-pto(:,k)+d_t_ec(:,k)-d_t_eva(:,k)-d_t_lsc(:,k))
240!    &  bils_enthalp(:)+masse(:,k)*(ptn(:,k)-pto(:,k)+d_t_ec(:,k))
241        bils_latent(:)=bils_latent(:)+masse(:,k)* &
242!    &             (pqn(:,k)-pqo(:,k))
243     &             (pqn(:,k)-pqo(:,k)-d_q_eva(:,k)-d_q_lsc(:,k))
244      ENDDO
245      bils_ec(:)=rcpd*bils_ec(:)/pdtphys
246      bils_diss(:)=rcpd*bils_diss(:)/pdtphys
247      bils_kinetic(:)= 0.5*bils_kinetic(:)/pdtphys
248      bils_enthalp(:)=rcpd*bils_enthalp(:)/pdtphys
249      bils_latent(:)=rlvtt*bils_latent(:)/pdtphys
250!jyg<
251      IF (iflag_pbl > 1) THEN
252        DO k=1,klev
253          bils_tke(:)=bils_tke(:)+0.5*(dtke(:,k)+dtke(:,k+1))*masse(:,k)
254        ENDDO
255        bils_tke(:)=bils_tke(:)/pdtphys
256      ENDIF  ! (iflag_pbl > 1)
257!>jyg
258
259IF (iflag_ener_conserv>=1) THEN
260      bils_ech(:)=0.
261      DO k=1,klev
262        bils_ech(:)=bils_ech(:)-d_t_ech(:,k)*masse(:,k)
263      ENDDO
264      bils_ech(:)=rcpd*bils_ech(:)/pdtphys
265ENDIF
266
267RETURN
268
269END SUBROUTINE ener_conserv
Note: See TracBrowser for help on using the repository browser.