PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
mode_turb_ver_thermo_corr.F90
Go to the documentation of this file.
1!MNH_LIC Copyright 1994-2025 CNRS, Meteo-France and Universite Paul Sabatier
2!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
3!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4!MNH_LIC for details. version 1.
5!-----------------------------------------------------------------
7
8!$ACDC singlecolumn
9
10IMPLICIT NONE
11CONTAINS
12SUBROUTINE turb_ver_thermo_corr(D,CST,CSTURB,TURBN,NEBN,TLES, &
13 KRR,KRRL,KRRI,KSV, &
14 OCOMPUTE_SRC,OCOUPLES, &
15 PEXPL,TPFILE, &
16 PDXX,PDYY,PDZZ,PDZX,PDZY,PDIRCOSZW, &
17 PRHODJ,PTHVREF, &
18 PSFTHM,PSFRM,PSFTHP,PSFRP, &
19 PWM,PTHLM,PRM,PSVM, &
20 PTKEM,PLM,PLEPS, &
21 PLOCPEXNM,PATHETA,PAMOIST, &
22 PBETA, PSQRT_TKE, PDTH_DZ, PDR_DZ, PRED2TH3, &
23 PRED2R3, PRED2THR3, PBLL_O_E, PETHETA, &
24 PEMOIST, PREDTH1, PREDR1, PPHI3, PPSI3, PD, &
25 PFWTH,PFWR,PFTH2,PFR2,PFTHR, &
26 PTHLP,PRP,MFMOIST,PTURB_SPP,PSIGS )
27! ###############################################################
28!
29!
30!!**** *TURB_VER_THERMO_FLUX* -compute the source terms due to the vertical turbulent
31!! fluxes.
32!!
33!! PURPOSE
34!! -------
35! The purpose of this routine is to compute the vertical turbulent
36! fluxes of the evolutive variables and give back the source
37! terms to the main program. In the case of large horizontal meshes,
38! the divergence of these vertical turbulent fluxes represent the whole
39! effect of the turbulence but when the three-dimensionnal version of
40! the turbulence scheme is activated (CTURBDIM="3DIM"), these divergences
41! are completed in the next routine TURB_HOR.
42! An arbitrary degree of implicitness has been implemented for the
43! temporal treatment of these diffusion terms.
44! The vertical boundary conditions are as follows:
45! * at the bottom, the surface fluxes are prescribed at the same
46! as the other turbulent fluxes
47! * at the top, the turbulent fluxes are set to 0.
48! It should be noted that the condensation has been implicitely included
49! in this turbulence scheme by using conservative variables and computing
50! the subgrid variance of a statistical variable s indicating the presence
51! or not of condensation in a given mesh.
52!
53!!** METHOD
54!! ------
55!! 1D type calculations are made;
56!! The vertical turbulent fluxes are computed in an off-centered
57!! implicit scheme (a Crank-Nicholson type with coefficients different
58!! than 0.5), which allows to vary the degree of implicitness of the
59!! formulation.
60!! The different prognostic variables are treated one by one.
61!! The contributions of each turbulent fluxes are cumulated into the
62!! tendency PRvarS, and into the dynamic and thermal production of
63!! TKE if necessary.
64!!
65!! In section 2 and 3, the thermodynamical fields are considered.
66!! Only the turbulent fluxes of the conservative variables
67!! (Thetal and Rnp stored in PRx(:,:,:,1)) are computed.
68!! Note that the turbulent fluxes at the vertical
69!! boundaries are given either by the soil scheme for the surface one
70!! ( at the same instant as the others fluxes) and equal to 0 at the
71!! top of the model. The thermal production is computed by vertically
72!! averaging the turbulent flux and multiply this flux at the mass point by
73!! a function ETHETA or EMOIST, which preform the transformation from the
74!! conservative variables to the virtual potential temperature.
75!!
76!! In section 4, the variance of the statistical variable
77!! s indicating presence or not of condensation, is determined in function
78!! of the turbulent moments of the conservative variables and its
79!! squarred root is stored in PSIGS. This information will be completed in
80!! the horizontal turbulence if the turbulence dimensionality is not
81!! equal to "1DIM".
82!!
83!! In section 5, the x component of the stress tensor is computed.
84!! The surface flux <u'w'> is computed from the value of the surface
85!! fluxes computed in axes linked to the orography ( i", j" , k"):
86!! i" is parallel to the surface and in the direction of the maximum
87!! slope
88!! j" is also parallel to the surface and in the normal direction of
89!! the maximum slope
90!! k" is the normal to the surface
91!! In order to prevent numerical instability, the implicit scheme has
92!! been extended to the surface flux regarding to its dependence in
93!! function of U. The dependence in function of the other components
94!! introduced by the different rotations is only explicit.
95!! The turbulent fluxes are used to compute the dynamic production of
96!! TKE. For the last TKE level ( located at PDZZ(:,:,IKB)/2 from the
97!! ground), an harmonic extrapolation from the dynamic production at
98!! PDZZ(:,:,IKB) is used to avoid an evaluation of the gradient of U
99!! in the surface layer.
100!!
101!! In section 6, the same steps are repeated but for the y direction
102!! and in section 7, a diagnostic computation of the W variance is
103!! performed.
104!!
105!! In section 8, the turbulent fluxes for the scalar variables are
106!! computed by the same way as the conservative thermodynamical variables
107!!
108!!
109!! EXTERNAL
110!! --------
111!! GX_U_M, GY_V_M, GZ_W_M : cartesian gradient operators
112!! GX_U_UW,GY_V_VW (X,Y,Z) represent the direction of the gradient
113!! _(M,U,...)_ represent the localization of the
114!! field to be derivated
115!! _(M,UW,...) represent the localization of the
116!! field derivated
117!!
118!!
119!! MZM,MZF
120!! : Shuman functions (mean operators)
121!! DZM
122!! : Shuman functions (difference operators)
123!!
124!! FUNCTIONs ETHETA and EMOIST :
125!! allows to compute:
126!! - the coefficients for the turbulent correlation between
127!! any variable and the virtual potential temperature, of its
128!! correlations with the conservative potential temperature and
129!! the humidity conservative variable:
130!! ------- ------- -------
131!! A' Thv' = ETHETA A' Thl' + EMOIST A' Rnp'
132!!
133!!
134!! IMPLICIT ARGUMENTS
135!! ------------------
136!! Module MODD_CST : contains physical constants
137!!
138!! CST%XG : gravity constant
139!!
140!! Module MODD_CTURB: contains the set of constants for
141!! the turbulence scheme
142!!
143!! CSTURB%XCMFS,XCMFB : cts for the momentum flux
144!! CSTURB%XCSHF : ct for the sensible heat flux
145!! CSTURB%XCHF : ct for the moisture flux
146!! TURBN%XCTV,TURBN%XCHV : cts for the T and moisture variances
147!!
148!! Module MODD_PARAMETERS
149!!
150!! JPVEXT_TURB : number of vertical external points
151!! JPHEXT : number of horizontal external points
152!!
153!!
154!! REFERENCE
155!! ---------
156!! Book 1 of documentation (Chapter: Turbulence)
157!!
158!! AUTHOR
159!! ------
160!! Joan Cuxart * INM and Meteo-France *
161!!
162!! MODIFICATIONS
163!! -------------
164!! Original August 19, 1994
165!! Modifications: February 14, 1995 (J.Cuxart and J.Stein)
166!! Doctorization and Optimization
167!! Modifications: March 21, 1995 (J.M. Carriere)
168!! Introduction of cloud water
169!! Modifications: June 14, 1995 (J.Cuxart and J. Stein)
170!! Phi3 and Psi3 at w-point + bug in the all
171!! or nothing condens.
172!! Modifications: Sept 15, 1995 (J.Cuxart and J. Stein)
173!! Change the DP computation at the ground
174!! Modifications: October 10, 1995 (J.Cuxart and J. Stein)
175!! Psi for scal var and LES tools
176!! Modifications: November 10, 1995 (J. Stein)
177!! change the surface relations
178!! Modifications: February 20, 1995 (J. Stein) optimization
179!! Modifications: May 21, 1996 (J. Stein)
180!! bug in the vertical flux of the V wind
181!! component for explicit computation
182!! Modifications: May 21, 1996 (N. wood)
183!! modify the computation of the vertical
184!! part or the surface tangential flux
185!! Modifications: May 21, 1996 (P. Jabouille)
186!! same modification in the Y direction
187!!
188!! Modifications: Sept 17, 1996 (J. Stein) change the moist case by using
189!! Pi instead of Piref + use Atheta and Amoist
190!!
191!! Modifications: Nov 24, 1997 (V. Masson) removes the DO loops
192!! Modifications: Mar 31, 1998 (V. Masson) splits the routine TURB_VER_THERMO_FLUX
193!! Modifications: Oct 18, 2000 (V. Masson) LES computations
194!! Modifications: Dec 01, 2000 (V. Masson) conservation of energy from
195!! surface flux in 1DIM case
196!! when slopes are present
197!! Nov 06, 2002 (V. Masson) LES budgets
198!! October 2009 (G. Tanguy) add ILENCH=LEN(YCOMMENT) after
199!! change of YCOMMENT
200!! 2012-02 (Y. Seity) add possibility to run with reversed
201!! vertical levels
202!! Modifications July 2015 (Wim de Rooy) TURBN%LHARAT switch
203!! 04/2016 (M.Moge) Use openACC directives to port the TURB part of Meso-NH on GPU
204!! Philippe Wautelet: 05/2016-04/2018: new data structures and calls for I/O
205!! Modifications June 2019 (Wim de Rooy) New set up cloud scheme
206!! Modifications: June 2023 (S. Riette) tunable value for SIGS minimum value
207!!--------------------------------------------------------------------------
208!
209!* 0. DECLARATIONS
210! ------------
211!
212USE yomhook, ONLY: lhook, dr_hook, jphook
213!
214USE modd_cst, ONLY: cst_t
215USE modd_cturb, ONLY: csturb_t
216USE modd_dimphyex, ONLY: dimphyex_t
218USE modd_io, ONLY: tfiledata
219USE modd_les, ONLY: tles_t
222USE modd_neb_n, ONLY: neb_t
223!
237!
239USE modi_second_mnh, ONLY: second_mnh
240!
241#ifdef MNH_COMPILER_CCE
242!$mnh_undef(LOOP)
243!$mnh_undef(OPENACC)
244#endif
245!
246IMPLICIT NONE
247!
248!* 0.1 declarations of arguments
249!
250!
251!
252TYPE(dimphyex_t), INTENT(IN) :: D
253TYPE(cst_t), INTENT(IN) :: CST
254TYPE(csturb_t), INTENT(IN) :: CSTURB
255TYPE(turb_t), INTENT(IN) :: TURBN
256TYPE(neb_t), INTENT(IN) :: NEBN
257TYPE(tles_t), INTENT(INOUT):: TLES ! modd_les structure
258INTEGER, INTENT(IN) :: KRR ! number of moist var.
259INTEGER, INTENT(IN) :: KSV ! number of scalar var.
260INTEGER, INTENT(IN) :: KRRL ! number of liquid water var.
261INTEGER, INTENT(IN) :: KRRI ! number of ice water var.
262LOGICAL, INTENT(IN) :: OCOUPLES ! switch to activate atmos-ocean LES
263LOGICAL, INTENT(IN) :: OCOMPUTE_SRC ! flag to define dimensions of SIGS and version
264REAL, INTENT(IN) :: PEXPL ! Coef. for temporal disc.
265TYPE(tfiledata), INTENT(INOUT) :: TPFILE ! Output file
266!
267REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDZZ, PDXX, PDYY, PDZX, PDZY
268 ! Metric coefficients
269REAL, DIMENSION(D%NIJT), INTENT(IN) :: PDIRCOSZW ! Director Cosinus of the
270 ! normal to the ground surface
271!
272REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRHODJ ! dry density * grid volum
273
274REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTHVREF ! ref. state Virtual
275 ! Potential Temperature
276!
277REAL, DIMENSION(D%NIJT), INTENT(IN) :: PSFTHM,PSFRM ! surface fluxes at time
278! ! t - deltat
279!
280REAL, DIMENSION(D%NIJT), INTENT(IN) :: PSFTHP,PSFRP ! surface fluxes at time
281! ! t + deltat
282!
283REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PWM
284! Vertical wind
285REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTHLM
286! potential temperature at t-Delta t
287REAL, DIMENSION(D%NIJT,D%NKT,KRR), INTENT(IN) :: PRM ! Mixing ratios
288 ! at t-Delta t
289REAL, DIMENSION(D%NIJT,D%NKT,KSV), INTENT(IN) :: PSVM ! Mixing ratios
290!
291REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTKEM ! TKE at time t
292! In case TURBN%LHARATU=TRUE, PLM already includes all stability corrections
293REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PLM ! Turb. mixing length
294REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PLEPS ! dissipative length
295REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PLOCPEXNM ! Lv(T)/Cp/Exnref at time t-1
296REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PATHETA ! coefficients between
297REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PAMOIST ! s and Thetal and Rnp
298! 2nd-order flux s'r'c/2Sigma_s2 at t-1 multiplied by Lambda_3
299REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PBETA ! buoyancy coefficient
300REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PSQRT_TKE ! sqrt(e)
301REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDTH_DZ ! d(th)/dz
302REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDR_DZ ! d(rt)/dz
303REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRED2TH3 ! 3D Redeslperger number R*2_th
304REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRED2R3 ! 3D Redeslperger number R*2_r
305REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRED2THR3 ! 3D Redeslperger number R*2_thr
306REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PBLL_O_E ! beta * Lk * Leps / tke
307REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PETHETA ! Coefficient for theta in theta_v computation
308REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PEMOIST ! Coefficient for r in theta_v computation
309REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PREDTH1 ! 1D Redelsperger number for Th
310REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PREDR1 ! 1D Redelsperger number for r
311REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PPHI3 ! Prandtl number for temperature
312REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PPSI3 ! Prandtl number for vapor
313REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PD ! Denominator in Prandtl numbers
314REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFWTH ! d(w'2th' )/dz (at flux point)
315REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFWR ! d(w'2r' )/dz (at flux point)
316REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFTH2 ! d(w'th'2 )/dz (at mass point)
317REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFR2 ! d(w'r'2 )/dz (at mass point)
318REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFTHR ! d(w'th'r')/dz (at mass point)
319!
320REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTHLP ! guess of thl at t+ deltat
321REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRP ! guess of r at t+ deltat
322!
323REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: MFMOIST ! moist mass flux dual scheme
324REAL, DIMENSION(D%NIJT,D%NKT,NTURB_S), INTENT(IN) :: PTURB_SPP ! SPP for turbulence
325REAL, DIMENSION(MERGE(D%NIJT,0,OCOMPUTE_SRC),& MERGE(D%NKT,0,OCOMPUTE_SRC)), INTENT(OUT) :: PSIGS ! Vert. part of Sigma_s at t
326!
327!
328!
329!* 0.2 declaration of local variables
330!
331!
332REAL, DIMENSION(D%NIJT,D%NKT) :: &
333 ZFLXZ, & ! vertical flux of the treated variable
334 ZKEFF, & ! effectif diffusion coeff = LT * SQRT( TKE )
335 ZF, & ! Flux in dTh/dt =-dF/dz (evaluated at t-1)(or rt instead of Th)
336 ZDFDDTDZ, & ! dF/d(dTh/dz)
337 ZDFDDRDZ, & ! dF/d(dr/dz)
338! Estimate of full level length and dissipation length scale in case TURBN%LHARATU
339 plmf, & ! estimate full level length scale from half levels (sub optimal)
340 plepsf, & ! estimate full level diss length scale from half levels (sub optimal)
341 zwork1,zwork2,&
342 zwork3,zwork4,&
343 zwkphipsi1,zwkphipsi2,&
344 zwkphipsi3,zwkphipsi4,& ! working var. for shuman operators (array syntax)
345 zwkles ! working var. for LES calls
346
347INTEGER :: IIJB, IIJE, IKB,IKE,IKT,IKA ! index value for the mass points of the domain
348INTEGER :: IKU ! array sizes
349INTEGER :: IKL
350INTEGER :: JIJ, JK ! loop indexes
351
352REAL, DIMENSION(D%NIJT,MIN(D%NKA+JPVEXT_TURB*D%NKL,D%NKA+JPVEXT_TURB*D%NKL+2*D%NKL):&
353 MAX(D%NKA+JPVEXT_TURB*D%NKL,D%NKA+JPVEXT_TURB*D%NKL+2*D%NKL))&
354 :: ZCOEFF
355 ! coefficients for the uncentred gradient
356 ! computation near the ground, defined in
357 ! mass points of the domain in the 3 direct.
358!
359REAL :: ZTIME1, ZTIME2
360!
361LOGICAL :: GUSERV ! flag to use water
362LOGICAL :: GFTH2 ! flag to use w'th'2
363LOGICAL :: GFWTH ! flag to use w'2th'
364LOGICAL :: GFR2 ! flag to use w'r'2
365LOGICAL :: GFWR ! flag to use w'2r'
366LOGICAL :: GFTHR ! flag to use w'th'r'
367TYPE(tfieldmetadata) :: TZFIELD
368!----------------------------------------------------------------------------
369!
370!* 1. PRELIMINARIES
371! -------------
372!
373REAL(KIND=jphook) :: zhook_handle
374IF (lhook) CALL dr_hook('TURB_VER_THERMO_CORR',0,zhook_handle)
375!
376
377ikb=d%NKB
378ike=d%NKE
379ikt=d%NKT
380ika=d%NKA
381iku=d%NKU
382ikl=d%NKL
383iije=d%NIJE
384iijb=d%NIJB
385!
386guserv = (krr/=0)
387!
388! compute the coefficients for the uncentred gradient computation near the
389! ground
390!$acc kernels present_cr(ZCOEFF,ZKEFF)
391!$mnh_expand_array(JIJ=IIJB:IIJE)
392zcoeff(iijb:iije,ikb+2*ikl)= - pdzz(iijb:iije,ikb+ikl) / &
393 ( (pdzz(iijb:iije,ikb+2*ikl)+pdzz(iijb:iije,ikb+ikl)) * pdzz(iijb:iije,ikb+2*ikl) )
394zcoeff(iijb:iije,ikb+ikl)= (pdzz(iijb:iije,ikb+2*ikl)+pdzz(iijb:iije,ikb+ikl)) / &
395 ( pdzz(iijb:iije,ikb+ikl) * pdzz(iijb:iije,ikb+2*ikl) )
396zcoeff(iijb:iije,ikb)= - (pdzz(iijb:iije,ikb+2*ikl)+2.*pdzz(iijb:iije,ikb+ikl)) / &
397 ( (pdzz(iijb:iije,ikb+2*ikl)+pdzz(iijb:iije,ikb+ikl)) * pdzz(iijb:iije,ikb+ikl) )
398!$mnh_end_expand_array(JIJ=IIJB:IIJE)
399!$acc end kernels
400!
401!
402IF (turbn%LHARAT) THEN
403 plmf=mzf(plm)
404 !wc Part of the new statistical cloud scheme set up
405 IF (nebn%LSTATNW) THEN
406 plepsf=mzf(pleps)
407 ELSE
408!$acc kernels
409 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
410 plepsf(iijb:iije,1:ikt)=plmf(iijb:iije,1:ikt)
411 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
412!$acc end kernels
413 END IF
414 ! function MZF produces -999 for level IKU (82 for 80 levels)
415 ! so put these to normal value as this level (82) is indeed calculated
416!$acc kernels
417 !$mnh_expand_array(JIJ=IIJB:IIJE)
418 plmf(iijb:iije,ikt)=0.001
419 plepsf(iijb:iije,ikt)=0.001
420 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
421 ! with energy cascade contribution 50MF term can be omitted
422 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
423 zkeff(iijb:iije,1:ikt) = plm(iijb:iije,1:ikt) * sqrt(ptkem(iijb:iije,1:ikt))
424 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
425!$acc end kernels
426ELSE
427!$acc kernels
428 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
429 zwork1(iijb:iije,1:ikt) = plm(iijb:iije,1:ikt) * sqrt(ptkem(iijb:iije,1:ikt))
430 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
431!$acc end kernels
432 zkeff=mzm(zwork1)
433ENDIF
434!
435! Flags for 3rd order quantities
436!
437gfth2 = .false.
438gfr2 = .false.
439gfthr = .false.
440gfwth = .false.
441gfwr = .false.
442!
443IF (turbn%CTOM/='NONE') THEN
444 gfth2 = any(pfth2(:,:)/=0.)
445 gfr2 = any(pfr2(:,:) /=0.) .AND. guserv
446 gfthr = any(pfthr(:,:)/=0.) .AND. guserv
447 gfwth = any(pfwth(:,:)/=0.)
448 gfwr = any(pfwr(:,:) /=0.) .AND. guserv
449END IF
450!----------------------------------------------------------------------------
451!
452!
453!* 4. TURBULENT CORRELATIONS : <THl THl>, <THl Rnp>, <Rnp Rnp>
454! --------------------------------------------------------
455!
456!
457!* 4.2 <THl THl>
458!
459! Compute the turbulent variance F and F' at time t-dt.
460!
461 IF (turbn%LHARAT) THEN
462!$acc kernels
463 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
464 zwork1(iijb:iije,1:ikt)=pdth_dz(iijb:iije,1:ikt)**2
465 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
466!$acc end kernels
467 zwork2=mzf(zwork1)
468 IF (nebn%LSTATNW) THEN
469!$acc kernels
470 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
471 zf(iijb:iije,1:ikt) = pturb_spp(iijb:iije,1:ikt,nctv) * &
472 plmf(iijb:iije,1:ikt)*plepsf(iijb:iije,1:ikt)*zwork2(iijb:iije,1:ikt)
473 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
474!$acc end kernels
475 ELSE
476!$acc kernels
477 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
478 zf(iijb:iije,1:ikt) = plmf(iijb:iije,1:ikt)*plepsf(iijb:iije,1:ikt)*zwork2(iijb:iije,1:ikt)
479 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
480!$acc end kernels
481 END IF
482 ELSE
483!$acc kernels
484 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
485 zwork1(iijb:iije,1:ikt)=pphi3(iijb:iije,1:ikt)*pdth_dz(iijb:iije,1:ikt)**2
486 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
487!$acc end kernels
488 zwork2=mzf(zwork1)
489!$acc kernels
490 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
491 zf(iijb:iije,1:ikt) = pturb_spp(iijb:iije,1:ikt,nctv)*plm(iijb:iije,1:ikt)*pleps(iijb:iije,1:ikt)&
492 * zwork2(iijb:iije,1:ikt)
493 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
494!$acc end kernels
495 ENDIF
496!$acc kernels present_cr(ZDFDDTDZ)
497 zdfddtdz(:,:) = 0. ! this term, because of discretization, is treated separately
498!$acc end kernels
499 !
500 ! Effect of 3rd order terms in temperature flux (at mass point)
501 !
502 ! d(w'th'2)/dz
503 IF (gfth2) THEN
504 CALL m3_th2_wth2(d,csturb,turbn,predth1,predr1,pd,pleps,psqrt_tke,zwork1)
505 CALL d_m3_th2_wth2_o_ddtdz(d,csturb,turbn,predth1,predr1,&
506 & pd,pleps,psqrt_tke,pbll_o_e,petheta,zwork2,pturb_spp)
507 !
508!$acc kernels
509 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
510 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
511 * pfth2(iijb:iije,1:ikt)
512 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
513 * pfth2(iijb:iije,1:ikt)
514 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
515!$acc end kernels
516 END IF
517 !
518 ! d(w'2th')/dz
519 IF (gfwth) THEN
520 CALL m3_th2_w2th(d,csturb,turbn,predth1,predr1,pd,pdth_dz,&
521 & plm,pleps,ptkem,zwork1,pturb_spp)
522 zwork2=mzf(pfwth)
523 CALL d_m3_th2_w2th_o_ddtdz(d,csturb,turbn,predth1,predr1,pd,&
524 & plm,pleps,ptkem,guserv,zwork3,pturb_spp)
525 !
526!$acc kernels
527 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
528 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
529 * zwork2(iijb:iije,1:ikt)
530 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
531 * zwork2(iijb:iije,1:ikt)
532 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
533!$acc end kernels
534 END IF
535 !
536 IF (krr/=0) THEN
537 ! d(w'r'2)/dz
538 IF (gfr2) THEN
539 CALL m3_th2_wr2(d,csturb,turbn,pd,pleps,psqrt_tke,pbll_o_e,&
540 & pemoist,pdth_dz,zwork1,pturb_spp)
541 CALL d_m3_th2_wr2_o_ddtdz(d,csturb,turbn,predth1,predr1,pd,&
542 & pleps,psqrt_tke,pbll_o_e,pemoist,pdth_dz,zwork2,pturb_spp)
543 !
544!$acc kernels
545 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
546 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
547 * pfr2(iijb:iije,1:ikt)
548 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
549 * pfr2(iijb:iije,1:ikt)
550 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
551!$acc end kernels
552 END IF
553 !
554 ! d(w'2r')/dz
555 IF (gfwr) THEN
556 CALL m3_th2_w2r(d,csturb,turbn,pd,plm,pleps,ptkem,pbll_o_e,&
557 & pemoist,pdth_dz,zwork1,pturb_spp)
558 zwork2=mzf(pfwr)
559 CALL d_m3_th2_w2r_o_ddtdz(d,csturb,turbn,predth1,predr1,pd,&
560 & plm,pleps,ptkem,pbll_o_e,pemoist,pdth_dz,zwork3,pturb_spp)
561 !
562!$acc kernels
563 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
564 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
565 * zwork2(iijb:iije,1:ikt)
566 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
567 * zwork1(iijb:iije,1:ikt)
568 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
569!$acc end kernels
570 END IF
571 !
572 ! d(w'th'r')/dz
573 IF (gfthr) THEN
574 CALL m3_th2_wthr(d,csturb,turbn,predr1,pd,pleps,psqrt_tke,&
575 & pbll_o_e,pemoist,pdth_dz,zwork1,pturb_spp)
576 CALL d_m3_th2_wthr_o_ddtdz(d,csturb,turbn,predth1,predr1,&
577 & pd,pleps,psqrt_tke,pbll_o_e,pemoist,pdth_dz,zwork2,pturb_spp)
578 !
579!$acc kernels
580 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
581 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
582 * pfthr(iijb:iije,1:ikt)
583 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
584 * pfthr(iijb:iije,1:ikt)
585 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
586!$acc end kernels
587 END IF
588
589 END IF
590 !
591 zflxz(iijb:iije,:) = zf(iijb:iije,:) + turbn%XIMPL * zdfddtdz(iijb:iije,:) &
592 * mzf(dzm(pthlp(iijb:iije,:) - pthlm(iijb:iije,:)) / pdzz(iijb:iije,:) )
593 !
594 ! special case near the ground ( uncentred gradient )
595 IF (turbn%LHARAT) THEN
596!$acc kernels
597 !$mnh_expand_array(JIJ=IIJB:IIJE)
598 zflxz(iijb:iije,ikb) = plmf(iijb:iije,ikb) &
599 * plepsf(iijb:iije,ikb) &
600 *( pexpl * &
601 ( zcoeff(iijb:iije,ikb+2*ikl)*pthlm(iijb:iije,ikb+2*ikl) &
602 +zcoeff(iijb:iije,ikb+ikl )*pthlm(iijb:iije,ikb+ikl ) &
603 +zcoeff(iijb:iije,ikb )*pthlm(iijb:iije,ikb ) )**2 &
604 +turbn%XIMPL * &
605 ( zcoeff(iijb:iije,ikb+2*ikl)*pthlp(iijb:iije,ikb+2*ikl) &
606 +zcoeff(iijb:iije,ikb+ikl )*pthlp(iijb:iije,ikb+ikl ) &
607 +zcoeff(iijb:iije,ikb )*pthlp(iijb:iije,ikb ) )**2 &
608 )
609 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
610!$acc end kernels
611 IF (nebn%LSTATNW) THEN
612!$acc kernels
613 !$mnh_expand_array(JIJ=IIJB:IIJE)
614 zflxz(iijb:iije,ikb) = pturb_spp(iijb:iije,ikb,nctv) * zflxz(iijb:iije,ikb)
615 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
616!$acc end kernels
617 END IF
618 ELSE
619!$acc kernels
620 !$mnh_expand_array(JIJ=IIJB:IIJE)
621 zflxz(iijb:iije,ikb) = pturb_spp(iijb:iije,ikb,nctv) * pphi3(iijb:iije,ikb+ikl) * plm(iijb:iije,ikb) &
622 * pleps(iijb:iije,ikb) &
623 *( pexpl * &
624 ( zcoeff(iijb:iije,ikb+2*ikl)*pthlm(iijb:iije,ikb+2*ikl) &
625 +zcoeff(iijb:iije,ikb+ikl )*pthlm(iijb:iije,ikb+ikl ) &
626 +zcoeff(iijb:iije,ikb )*pthlm(iijb:iije,ikb ) )**2 &
627 +turbn%XIMPL * &
628 ( zcoeff(iijb:iije,ikb+2*ikl)*pthlp(iijb:iije,ikb+2*ikl) &
629 +zcoeff(iijb:iije,ikb+ikl )*pthlp(iijb:iije,ikb+ikl ) &
630 +zcoeff(iijb:iije,ikb )*pthlp(iijb:iije,ikb ) )**2 &
631 )
632 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
633!$acc end kernels
634 ENDIF
635 !
636!$acc kernels
637 !$mnh_expand_array(JIJ=IIJB:IIJE)
638 zflxz(iijb:iije,ika) = zflxz(iijb:iije,ikb)
639 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
640!$acc end kernels
641 !
642!$acc kernels
643 IF (nebn%LSTATNW) THEN
644 !wc The variance from the budget eq should be multiplied by 2 here
645 ! thl'2=2*L*LEPS*(dthl/dz**2)
646 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
647 zflxz(iijb:iije,1:ikt) = max(0., 2.*zflxz(iijb:iije,1:ikt))
648 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
649 ELSE
650 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
651 zflxz(iijb:iije,1:ikt) = max(0., zflxz(iijb:iije,1:ikt))
652 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
653 END IF
654!$acc end kernels
655 !
656!$acc kernels
657 IF (krrl > 0) THEN
658 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
659 psigs(iijb:iije,1:ikt) = zflxz(iijb:iije,1:ikt) * patheta(iijb:iije,1:ikt)**2
660 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
661 ELSE
662 psigs(:,:) = 0.
663 END IF
664!$acc end kernels
665 !
666 !
667 ! stores <THl THl>
668 IF ( turbn%LTURB_FLX .AND. tpfile%LOPENED ) THEN
669 tzfield = tfieldmetadata( &
670 cmnhname = 'THL_VVAR', &
671 cstdname = '', &
672 clongname = 'THL_VVAR', &
673 cunits = 'K2', &
674 cdir = 'XY', &
675 ccomment = 'X_Y_Z_THL_VVAR', &
676 ngrid = 1, &
677 ntype = typereal, &
678 ndims = 3, &
679 ltimedep = .true. )
680!$acc update self(ZFLXZ)
681 CALL io_field_write_phy(d,tpfile,tzfield,zflxz)
682 END IF
683!
684! and we store in LES configuration
685!
686 IF (tles%LLES_CALL) THEN
687 CALL second_mnh(ztime1)
688 !
689 CALL les_mean_subgrid_phy(d, tles, zflxz, tles%X_LES_SUBGRID_Thl2 )
690 zwkles(:,:) = mzf(pwm(:,:))*zflxz(:,:)
691 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_W_SBG_Thl2 )
692 zwkles(:,:) = -2.*csturb%XCTD*psqrt_tke(:,:)*zflxz(:,:)/pleps(:,:)
693 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_DISS_Thl2 )
694 zwkles(:,:) = petheta(:,:)*zflxz(:,:)
695 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_ThlThv )
696 zwkles(:,:) = -csturb%XA3*pbeta(:,:)*petheta(:,:)*zflxz(:,:)
697 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_ThlPz, .true. )
698 CALL second_mnh(ztime2)
699 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
700 END IF
701!
702 IF ( krr /= 0 ) THEN
703!
704!* 4.3 <THl Rnp>
705!
706!
707 ! Compute the turbulent variance F and F' at time t-dt.
708 IF (turbn%LHARAT) THEN
709!$acc kernels
710 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
711 zwork1(iijb:iije,1:ikt) = pdth_dz(iijb:iije,1:ikt)*pdr_dz(iijb:iije,1:ikt)
712 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
713!$acc end kernels
714 zwork2=mzf(zwork1)
715 IF (nebn%LSTATNW) THEN
716!$acc kernels
717 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
718 zf(iijb:iije,1:ikt) = pturb_spp(iijb:iije,1:ikt,nctv) * &
719 plmf(iijb:iije,1:ikt)*plepsf(iijb:iije,1:ikt)*zwork2(iijb:iije,1:ikt)
720 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
721!$acc end kernels
722 ELSE
723!$acc kernels
724 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
725 zf(iijb:iije,1:ikt) = plmf(iijb:iije,1:ikt)*plepsf(iijb:iije,1:ikt)*zwork2(iijb:iije,1:ikt)
726 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
727!$acc end kernels
728 END IF
729 ELSE
730 zf(iijb:iije,:) = pturb_spp(iijb:iije,:,nctv)*plm(iijb:iije,:)*pleps(iijb:iije,:)* &
731 mzf(0.5*(pphi3(iijb:iije,:)+ppsi3(iijb:iije,:))*pdth_dz(iijb:iije,:)*pdr_dz(iijb:iije,:))
732 ENDIF
733!$acc kernels present_cr(ZDFDDTDZ,ZDFDDRDZ)
734 zdfddtdz(:,:) = 0. ! this term, because of discretization, is treated separately
735 zdfddrdz(:,:) = 0. ! this term, because of discretization, is treated separately
736!$acc end kernels
737 !
738 ! Effect of 3rd order terms in temperature flux (at mass point)
739 !
740 ! d(w'th'2)/dz
741 IF (gfth2) THEN
742 CALL m3_thr_wth2(d,csturb,turbn,predr1,pd,pleps,psqrt_tke,&
743 & pbll_o_e,petheta,pdr_dz,zwork1,pturb_spp)
744 CALL d_m3_thr_wth2_o_ddtdz(d,csturb,turbn,predth1,predr1,&
745 & pd,pleps,psqrt_tke,pbll_o_e,petheta,pdr_dz,zwork2,pturb_spp)
746 CALL d_m3_thr_wth2_o_ddrdz(d,csturb,turbn,predth1,predr1,&
747 & pd,pleps,psqrt_tke,pbll_o_e,petheta,zwork3,pturb_spp)
748 !
749!$acc kernels
750 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
751 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) * pfth2(iijb:iije,1:ikt)
752 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
753 * pfth2(iijb:iije,1:ikt)
754 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
755 * pfth2(iijb:iije,1:ikt)
756 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
757!$acc end kernels
758 END IF
759 !
760 ! d(w'2th')/dz
761 IF (gfwth) THEN
762 zwork1=mzf(pfwth)
763 CALL m3_thr_w2th(d,csturb,turbn,predr1,pd,plm,pleps,ptkem,&
764 & pdr_dz,zwork2,pturb_spp)
765 CALL d_m3_thr_w2th_o_ddtdz(d,csturb,turbn,predth1,predr1,&
766 & pd,plm,pleps,ptkem,pbll_o_e,pdr_dz,petheta,zwork3,pturb_spp)
767 CALL d_m3_thr_w2th_o_ddrdz(d,csturb,turbn,predth1,predr1,&
768 & pd,plm,pleps,ptkem,zwork4,pturb_spp)
769 !
770!$acc kernels
771 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
772 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
773 * zwork1(iijb:iije,1:ikt)
774 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
775 * zwork1(iijb:iije,1:ikt)
776 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork4(iijb:iije,1:ikt) &
777 * zwork1(iijb:iije,1:ikt)
778 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
779!$acc end kernels
780 END IF
781 !
782 ! d(w'r'2)/dz
783 IF (gfr2) THEN
784 CALL m3_thr_wr2(d,csturb,turbn,predth1,pd,pleps,psqrt_tke,&
785 & pbll_o_e,pemoist,pdth_dz,zwork1,pturb_spp)
786 CALL d_m3_thr_wr2_o_ddtdz(d,csturb,turbn,predr1,predth1,pd,&
787 & pleps,psqrt_tke,pbll_o_e,pemoist,zwork2,pturb_spp)
788 CALL d_m3_thr_wr2_o_ddrdz(d,csturb,turbn,predr1,predth1,pd,&
789 & pleps,psqrt_tke,pbll_o_e,pemoist,pdth_dz,zwork3,pturb_spp)
790 !
791!$acc kernels
792 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
793 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) * pfr2(iijb:iije,1:ikt)
794 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
795 * pfr2(iijb:iije,1:ikt)
796 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
797 * pfr2(iijb:iije,1:ikt)
798 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
799!$acc end kernels
800 END IF
801 !
802 ! d(w'2r')/dz
803 IF (gfwr) THEN
804 zwork1=mzf(pfwr)
805 CALL m3_thr_w2r(d,csturb,turbn,predth1,pd,plm,pleps,ptkem,&
806 & pdth_dz,zwork2,pturb_spp)
807 CALL d_m3_thr_w2r_o_ddtdz(d,csturb,turbn,predr1,predth1,pd,&
808 & plm,pleps,ptkem,zwork3,pturb_spp)
809 CALL d_m3_thr_w2r_o_ddrdz(d,csturb,turbn,predr1,predth1,pd,&
810 & plm,pleps,ptkem,pbll_o_e,pdth_dz,pemoist,zwork4,pturb_spp)
811 !
812!$acc kernels
813 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
814 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt)*zwork1(iijb:iije,1:ikt)
815 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
816 * zwork1(iijb:iije,1:ikt)
817 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork4(iijb:iije,1:ikt) &
818 * zwork1(iijb:iije,1:ikt)
819 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
820!$acc end kernels
821 END IF
822 !
823 ! d(w'th'r')/dz
824 IF (gfthr) THEN
825 CALL m3_thr_wthr(d,csturb,turbn,predth1,predr1,pd,pleps,&
826 & psqrt_tke,zwork1)
827 CALL d_m3_thr_wthr_o_ddtdz(d,csturb,turbn,predth1,predr1,&
828 & pd,pleps,psqrt_tke,pbll_o_e,petheta,zwork2,pturb_spp)
829 CALL d_m3_thr_wthr_o_ddrdz(d,csturb,turbn,predr1,predth1,&
830 & pd,pleps,psqrt_tke,pbll_o_e,pemoist,zwork3,pturb_spp)
831 !
832!$acc kernels
833 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
834 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) * pfthr(iijb:iije,1:ikt)
835 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
836 * pfthr(iijb:iije,1:ikt)
837 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
838 * pfthr(iijb:iije,1:ikt)
839 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
840!$acc end kernels
841 END IF
842 !
843 IF (turbn%LHARAT) THEN
844 zflxz(iijb:iije,:) = zf(iijb:iije,:) &
845 + turbn%XIMPL * plmf(iijb:iije,:)*plepsf(iijb:iije,:)*0.5 &
846 * (2. *pdr_dz(iijb:iije,:) *dzm(pthlp(iijb:iije,:) - pthlm(iijb:iije,:)) / pdzz(iijb:iije,:) &
847 + 2. *pdth_dz(iijb:iije,:) *dzm(prp(iijb:iije,:) - prm(iijb:iije,:,1)) / pdzz(iijb:iije,:)) &
848 + turbn%XIMPL * zdfddtdz(iijb:iije,:) * mzf(dzm(pthlp(iijb:iije,:) - pthlm(iijb:iije,:)) / pdzz(iijb:iije,:)) &
849 + turbn%XIMPL * zdfddrdz(iijb:iije,:) * mzf(dzm(prp(iijb:iije,:) - prm(iijb:iije,:,1)) / pdzz(iijb:iije,:))
850 IF (nebn%LSTATNW) THEN
851!$acc kernels
852 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
853 zflxz(iijb:iije,1:ikt) = pturb_spp(iijb:iije,1:ikt,nctv) * zflxz(iijb:iije,1:ikt)
854 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
855!$acc end kernels
856 END IF
857 ELSE
858 CALL d_phi3dtdz_o_ddtdz(d,csturb,turbn,pphi3,predth1,predr1,pred2th3,pred2thr3,turbn%CTURBDIM,guserv,zwkphipsi1)
859 ! d(phi3*dthdz)/ddthdz term
860 CALL d_psi3dtdz_o_ddtdz(d,csturb,turbn,ppsi3,predr1,predth1,pred2r3,pred2thr3,turbn%CTURBDIM,guserv,zwkphipsi2)
861 ! d(psi3*dthdz)/ddthdz term
862 CALL d_phi3drdz_o_ddrdz(d,csturb,turbn,pphi3,predth1,predr1,pred2th3,pred2thr3,turbn%CTURBDIM,guserv,zwkphipsi3)
863 ! d(phi3*drdz )/ddrdz term
864 CALL d_psi3drdz_o_ddrdz(d,csturb,turbn,ppsi3,predr1,predth1,pred2r3,pred2thr3,turbn%CTURBDIM,guserv,zwkphipsi4)
865 ! d(psi3*drdz )/ddrdz term
866 !
867 zflxz(iijb:iije,:) = zf(iijb:iije,:) &
868 + turbn%XIMPL * pturb_spp(iijb:iije,:,nctv)*plm(iijb:iije,:)*pleps(iijb:iije,:)*0.5 &
869 * mzf((zwkphipsi1(iijb:iije,:)+zwkphipsi2(iijb:iije,:))&
870 * pdr_dz(iijb:iije,:)*dzm(pthlp(iijb:iije,:) - pthlm(iijb:iije,:)) /pdzz(iijb:iije,:) &
871 + (zwkphipsi3(iijb:iije,:) + zwkphipsi4(iijb:iije,:)) &
872 *pdth_dz(iijb:iije,:)*dzm(prp(iijb:iije,:) - prm(iijb:iije,:,1))/pdzz(iijb:iije,:)) &
873 + turbn%XIMPL * zdfddtdz(iijb:iije,:) * mzf(dzm(pthlp(iijb:iije,:) - pthlm(iijb:iije,:)) / pdzz(iijb:iije,:)) &
874 + turbn%XIMPL * zdfddrdz(iijb:iije,:) * mzf(dzm(prp(iijb:iije,:) - prm(iijb:iije,:,1)) / pdzz(iijb:iije,:))
875 ENDIF
876 !
877 ! special case near the ground ( uncentred gradient )
878 IF (turbn%LHARAT) THEN
879!$acc kernels
880 !$mnh_expand_array(JIJ=IIJB:IIJE)
881 zflxz(iijb:iije,ikb) = &
882 (1. ) &
883 *( pexpl * &
884 ( zcoeff(iijb:iije,ikb+2*ikl)*pthlm(iijb:iije,ikb+2*ikl) &
885 +zcoeff(iijb:iije,ikb+ikl )*pthlm(iijb:iije,ikb+ikl ) &
886 +zcoeff(iijb:iije,ikb )*pthlm(iijb:iije,ikb )) &
887 *( zcoeff(iijb:iije,ikb+2*ikl)*prm(iijb:iije,ikb+2*ikl,1) &
888 +zcoeff(iijb:iije,ikb+ikl )*prm(iijb:iije,ikb+ikl,1 ) &
889 +zcoeff(iijb:iije,ikb )*prm(iijb:iije,ikb ,1 )) &
890 +turbn%XIMPL * &
891 ( zcoeff(iijb:iije,ikb+2*ikl)*pthlp(iijb:iije,ikb+2*ikl) &
892 +zcoeff(iijb:iije,ikb+ikl )*pthlp(iijb:iije,ikb+ikl ) &
893 +zcoeff(iijb:iije,ikb )*pthlp(iijb:iije,ikb )) &
894 *( zcoeff(iijb:iije,ikb+2*ikl)*prp(iijb:iije,ikb+2*ikl ) &
895 +zcoeff(iijb:iije,ikb+ikl )*prp(iijb:iije,ikb+ikl ) &
896 +zcoeff(iijb:iije,ikb )*prp(iijb:iije,ikb )) &
897 )
898 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
899!$acc end kernels
900 IF (nebn%LSTATNW) THEN
901!$acc kernels
902 !$mnh_expand_array(JIJ=IIJB:IIJE)
903 zflxz(iijb:iije,ikb) = (pturb_spp(iijb:iije,ikb,ncht1) + pturb_spp(iijb:iije,ikb,ncht2)) * zflxz(iijb:iije,ikb)
904 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
905!$acc end kernels
906 END IF
907 ELSE
908!$acc kernels
909 !$mnh_expand_array(JIJ=IIJB:IIJE)
910 zflxz(iijb:iije,ikb) = &
911 (pturb_spp(iijb:iije,ikb,ncht1) * pphi3(iijb:iije,ikb+ikl) + pturb_spp(iijb:iije,ikb,ncht2) * ppsi3(iijb:iije,ikb+ikl)) &
912 *( pexpl * &
913 ( zcoeff(iijb:iije,ikb+2*ikl)*pthlm(iijb:iije,ikb+2*ikl) &
914 +zcoeff(iijb:iije,ikb+ikl )*pthlm(iijb:iije,ikb+ikl ) &
915 +zcoeff(iijb:iije,ikb )*pthlm(iijb:iije,ikb )) &
916 *( zcoeff(iijb:iije,ikb+2*ikl)*prm(iijb:iije,ikb+2*ikl,1) &
917 +zcoeff(iijb:iije,ikb+ikl )*prm(iijb:iije,ikb+ikl,1 ) &
918 +zcoeff(iijb:iije,ikb )*prm(iijb:iije,ikb ,1 )) &
919 +turbn%XIMPL * &
920 ( zcoeff(iijb:iije,ikb+2*ikl)*pthlp(iijb:iije,ikb+2*ikl) &
921 +zcoeff(iijb:iije,ikb+ikl )*pthlp(iijb:iije,ikb+ikl ) &
922 +zcoeff(iijb:iije,ikb )*pthlp(iijb:iije,ikb )) &
923 *( zcoeff(iijb:iije,ikb+2*ikl)*prp(iijb:iije,ikb+2*ikl ) &
924 +zcoeff(iijb:iije,ikb+ikl )*prp(iijb:iije,ikb+ikl ) &
925 +zcoeff(iijb:iije,ikb )*prp(iijb:iije,ikb )) &
926 )
927 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
928!$acc end kernels
929 ENDIF
930!$acc kernels
931 !
932 !$mnh_expand_array(JIJ=IIJB:IIJE)
933 zflxz(iijb:iije,ika) = zflxz(iijb:iije,ikb)
934 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
935 !
936 IF (nebn%LSTATNW) THEN
937 !wc The variance from the budget eq should be multiplied by 2 here
938 ! e.g. thl'2=2*L*LEPS*(cab)^-1 *(dthl/dz**2)
939 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
940 zflxz(iijb:iije,1:ikt) = min(0., 2.*zflxz(iijb:iije,1:ikt))
941 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
942 ENDIF
943!$acc end kernels
944 IF ( krrl > 0 ) THEN
945!$acc kernels
946 IF (nebn%LSTATNW) THEN
947 !wc Part of the new statistical cloud scheme set up. Normal notation so - sign
948 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
949 psigs(iijb:iije,1:ikt) = psigs(iijb:iije,1:ikt) - &
950 2. * patheta(iijb:iije,1:ikt) * pamoist(iijb:iije,1:ikt) * zflxz(iijb:iije,1:ikt)
951 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
952 ELSE
953 ! NB PATHETA is -b in Chaboureau Bechtold 2002 which explains the + sign here
954 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
955 psigs(iijb:iije,1:ikt) = psigs(iijb:iije,1:ikt) + &
956 2. * patheta(iijb:iije,1:ikt) * pamoist(iijb:iije,1:ikt) * zflxz(iijb:iije,1:ikt)
957 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
958 ENDIF
959!$acc end kernels
960 END IF
961 ! stores <THl Rnp>
962 IF ( turbn%LTURB_FLX .AND. tpfile%LOPENED ) THEN
963 tzfield = tfieldmetadata( &
964 cmnhname = 'THLRCONS_VCOR', &
965 cstdname = '', &
966 clongname = 'THLRCONS_VCOR', &
967 cunits = 'K kg kg-1', &
968 cdir = 'XY', &
969 ccomment = 'X_Y_Z_THLRCONS_VCOR', &
970 ngrid = 1, &
971 ntype = typereal, &
972 ndims = 3, &
973 ltimedep = .true. )
974!$acc update self(ZFLXZ)
975 CALL io_field_write_phy(d,tpfile,tzfield,zflxz)
976 END IF
977!
978! and we store in LES configuration
979!
980IF (tles%LLES_CALL) THEN
981 CALL second_mnh(ztime1)
982 !
983 CALL les_mean_subgrid_phy(d, tles, zflxz, tles%X_LES_SUBGRID_THlRt )
984 zwkles(:,:) = mzf(pwm(:,:))*zflxz(:,:)
985 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_W_SBG_ThlRt )
986 zwkles(:,:) = -2.*csturb%XCTD*psqrt_tke(:,:)*zflxz(:,:)/pleps(:,:)
987 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_DISS_ThlRt )
988 zwkles(:,:) = petheta(:,:)*zflxz(:,:)
989 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_RtThv )
990 zwkles(:,:) = -csturb%XA3*pbeta(:,:)*petheta(:,:)*zflxz(:,:)
991 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_RtPz, .true. )
992 zwkles(:,:) = pemoist(:,:)*zflxz(:,:)
993 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_ThlThv , .true. )
994 zwkles(:,:) = -csturb%XA3*pbeta(:,:)*pemoist(:,:)*zflxz(:,:)
995 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_ThlPz, .true. )
996 !
997 CALL second_mnh(ztime2)
998 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
999END IF
1000!
1001!
1002!* 4.4 <Rnp Rnp>
1003!
1004!
1005 ! Compute the turbulent variance F and F' at time t-dt.
1006IF (turbn%LHARAT) THEN
1007 zf(iijb:iije,:) = plmf(iijb:iije,:)*plepsf(iijb:iije,:)*mzf(pdr_dz(iijb:iije,:)**2)
1008 IF (nebn%LSTATNW) THEN
1009!$acc kernels
1010 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1011 zf(iijb:iije,1:ikt) = pturb_spp(iijb:iije,1:ikt,nctv) * zf(iijb:iije,1:ikt)
1012 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1013!$acc end kernels
1014 END IF
1015ELSE
1016 zf(iijb:iije,:) = pturb_spp(iijb:iije,:,nctv)*plm(iijb:iije,:)*pleps(iijb:iije,:)&
1017 *mzf(ppsi3(iijb:iije,:)*pdr_dz(iijb:iije,:)**2)
1018ENDIF
1019!$acc kernels
1020 zdfddrdz(:,:) = 0. ! this term, because of discretization, is treated separately
1021!$acc end kernels
1022 !
1023 ! Effect of 3rd order terms in temperature flux (at mass point)
1024 !
1025 ! d(w'r'2)/dz
1026 IF (gfr2) THEN
1027 CALL m3_r2_wr2(d,csturb,turbn,predr1,predth1,pd,pleps,&
1028 & psqrt_tke,zwork1)
1029 CALL d_m3_r2_wr2_o_ddrdz(d,csturb,turbn,predr1,predth1,&
1030 & pd,pleps,psqrt_tke,pbll_o_e,pemoist,zwork2,pturb_spp)
1031 !
1032!$acc kernels
1033 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1034 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) * pfr2(iijb:iije,1:ikt)
1035 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
1036 * pfr2(iijb:iije,1:ikt)
1037 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1038!$acc end kernels
1039 END IF
1040 !
1041 ! d(w'2r')/dz
1042 IF (gfwr) THEN
1043 zwork1=mzf(pfwr)
1044 CALL m3_r2_w2r(d,csturb,turbn,predr1,predth1,pd,pdr_dz,&
1045 & plm,pleps,ptkem,zwork2,pturb_spp)
1046 CALL d_m3_r2_w2r_o_ddrdz(d,csturb,turbn,predr1,predth1,&
1047 & pd,plm,pleps,ptkem,guserv,zwork3,pturb_spp)
1048 !
1049!$acc kernels
1050 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1051 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt)*zwork1(iijb:iije,1:ikt)
1052 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
1053 * zwork1(iijb:iije,1:ikt)
1054 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1055!$acc end kernels
1056 END IF
1057 !
1058 IF (krr/=0) THEN
1059 ! d(w'r'2)/dz
1060 IF (gfth2) THEN
1061 CALL m3_r2_wth2(d,csturb,turbn,pd,pleps,psqrt_tke,&
1062 & pbll_o_e,petheta,pdr_dz,zwork1,pturb_spp)
1063 CALL d_m3_r2_wth2_o_ddrdz(d,csturb,turbn,predr1,&
1064 & predth1,pd,pleps,psqrt_tke,pbll_o_e,petheta,pdr_dz,zwork2,pturb_spp)
1065 !
1066!$acc kernels
1067 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1068 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt)*pfth2(iijb:iije,1:ikt)
1069 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
1070 * pfth2(iijb:iije,1:ikt)
1071 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1072!$acc end kernels
1073 END IF
1074 !
1075 ! d(w'2r')/dz
1076 IF (gfwth) THEN
1077 zwork1=mzf(pfwth)
1078 CALL m3_r2_w2th(d,csturb,turbn,pd,plm,pleps,ptkem,&
1079 & pbll_o_e,petheta,pdr_dz,zwork2,pturb_spp)
1080 CALL d_m3_r2_w2th_o_ddrdz(d,csturb,turbn,predr1,predth1,&
1081 & pd,plm,pleps,ptkem,pbll_o_e,petheta,pdr_dz,zwork3,pturb_spp)
1082 !
1083!$acc kernels
1084 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1085 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt)+zwork2(iijb:iije,1:ikt)*zwork1(iijb:iije,1:ikt)
1086 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
1087 * zwork1(iijb:iije,1:ikt)
1088 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1089!$acc end kernels
1090 END IF
1091 !
1092 ! d(w'th'r')/dz
1093 IF (gfthr) THEN
1094 CALL m3_r2_wthr(d,csturb,turbn,predth1,pd,pleps,&
1095 & psqrt_tke,pbll_o_e,petheta,pdr_dz,zwork1,pturb_spp)
1096 CALL d_m3_r2_wthr_o_ddrdz(d,csturb,turbn,predr1,predth1,&
1097 & pd,pleps,psqrt_tke,pbll_o_e,petheta,pdr_dz,zwork2,pturb_spp)
1098 !
1099!$acc kernels
1100 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1101 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
1102 * pfthr(iijb:iije,1:ikt)
1103 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
1104 * pfthr(iijb:iije,1:ikt)
1105 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1106!$acc end kernels
1107 END IF
1108 END IF
1109 !
1110!$acc kernels
1111 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1112 zwork1(iijb:iije,1:ikt) = prp(iijb:iije,1:ikt) - prm(iijb:iije,1:ikt,1)
1113 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1114!$acc end kernels
1115 zwork2=dzm(zwork1)
1116 IF (turbn%LHARAT) THEN
1117 zflxz(iijb:iije,:) = zf(iijb:iije,:) &
1118 + turbn%XIMPL * plmf(iijb:iije,:) *plepsf(iijb:iije,:) &
1119 * mzf(2.*pdr_dz(iijb:iije,:)* dzm(prp(iijb:iije,:) - prm(iijb:iije,:,1)) / pdzz(iijb:iije,:)) &
1120 + turbn%XIMPL * zdfddrdz(iijb:iije,:) * mzf(dzm(prp(iijb:iije,:) - prm(iijb:iije,:,1)) / pdzz(iijb:iije,:))
1121 IF (nebn%LSTATNW) THEN
1122!$acc kernels
1123 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1124 zflxz(iijb:iije,1:ikt) = pturb_spp(iijb:iije,1:ikt,nctv) * zflxz(iijb:iije,1:ikt)
1125 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1126!$acc end kernels
1127 END IF
1128 ELSE
1129 CALL d_psi3drdz2_o_ddrdz(d,csturb,turbn,ppsi3,predr1,predth1,pred2r3,pred2thr3,pdr_dz,turbn%CTURBDIM,guserv,zwkphipsi1)
1130 !
1131 zflxz(iijb:iije,:) = zf(iijb:iije,:) &
1132 + turbn%XIMPL * pturb_spp(iijb:iije,:,nctv)*plm(iijb:iije,:) *pleps(iijb:iije,:) &
1133 * mzf(zwkphipsi1(iijb:iije,:)*dzm(prp(iijb:iije,:) - prm(iijb:iije,:,1)) / pdzz(iijb:iije,:)) &
1134 + turbn%XIMPL * zdfddrdz(iijb:iije,:) * mzf(dzm(prp(iijb:iije,:) - prm(iijb:iije,:,1)) / pdzz(iijb:iije,:))
1135 ENDIF
1136 !
1137 ! special case near the ground ( uncentred gradient )
1138 IF (turbn%LHARAT) THEN
1139!$acc kernels
1140 !$mnh_expand_array(JIJ=IIJB:IIJE)
1141 zflxz(iijb:iije,ikb) = plmf(iijb:iije,ikb) &
1142 * plepsf(iijb:iije,ikb) &
1143 *( pexpl * &
1144 ( zcoeff(iijb:iije,ikb+2*ikl)*prm(iijb:iije,ikb+2*ikl,1) &
1145 +zcoeff(iijb:iije,ikb+ikl )*prm(iijb:iije,ikb+ikl,1 ) &
1146 +zcoeff(iijb:iije,ikb )*prm(iijb:iije,ikb ,1 ))**2 &
1147 +turbn%XIMPL * &
1148 ( zcoeff(iijb:iije,ikb+2*ikl)*prp(iijb:iije,ikb+2*ikl) &
1149 +zcoeff(iijb:iije,ikb+ikl )*prp(iijb:iije,ikb+ikl ) &
1150 +zcoeff(iijb:iije,ikb )*prp(iijb:iije,ikb ))**2 &
1151 )
1152 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1153!$acc end kernels
1154 IF (nebn%LSTATNW) THEN
1155!$acc kernels
1156 !$mnh_expand_array(JIJ=IIJB:IIJE)
1157 zflxz(iijb:iije,ikb) = turbn%XCHV * zflxz(iijb:iije,ikb)
1158 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1159!$acc end kernels
1160 END IF
1161 ELSE
1162!$acc kernels
1163 !$mnh_expand_array(JIJ=IIJB:IIJE)
1164 zflxz(iijb:iije,ikb) = turbn%XCHV * ppsi3(iijb:iije,ikb+ikl) * plm(iijb:iije,ikb) &
1165 * pleps(iijb:iije,ikb) &
1166 *( pexpl * &
1167 ( zcoeff(iijb:iije,ikb+2*ikl)*prm(iijb:iije,ikb+2*ikl,1) &
1168 +zcoeff(iijb:iije,ikb+ikl )*prm(iijb:iije,ikb+ikl,1 ) &
1169 +zcoeff(iijb:iije,ikb )*prm(iijb:iije,ikb ,1 ))**2 &
1170 +turbn%XIMPL * &
1171 ( zcoeff(iijb:iije,ikb+2*ikl)*prp(iijb:iije,ikb+2*ikl) &
1172 +zcoeff(iijb:iije,ikb+ikl )*prp(iijb:iije,ikb+ikl ) &
1173 +zcoeff(iijb:iije,ikb )*prp(iijb:iije,ikb ))**2 &
1174 )
1175 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1176!$acc end kernels
1177 ENDIF
1178 !
1179!$acc kernels
1180 !$mnh_expand_array(JIJ=IIJB:IIJE)
1181 zflxz(iijb:iije,ika) = zflxz(iijb:iije,ikb)
1182 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1183 IF (nebn%LSTATNW) THEN
1184 !wc The variance from the budget eq should be multiplied by 2 here
1185 ! thl'2=2*L*LEPS*(dthl/dz**2)
1186 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1187 zflxz(iijb:iije,1:ikt) = max(0., 2.*zflxz(iijb:iije,1:ikt))
1188 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1189 ENDIF
1190!$acc end kernels
1191 !
1192 IF ( krrl > 0 ) THEN
1193!$acc kernels
1194 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1195 psigs(iijb:iije,1:ikt) = psigs(iijb:iije,1:ikt) + pamoist(iijb:iije,1:ikt) **2 &
1196 * zflxz(iijb:iije,1:ikt)
1197 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1198!$acc end kernels
1199 END IF
1200 ! stores <Rnp Rnp>
1201 IF ( turbn%LTURB_FLX .AND. tpfile%LOPENED ) THEN
1202 tzfield = tfieldmetadata( &
1203 cmnhname = 'RTOT_VVAR', &
1204 cstdname = '', &
1205 clongname = 'RTOT_VVAR', &
1206 cunits = 'kg2 kg-2', &
1207 cdir = 'XY', &
1208 ccomment = 'X_Y_Z_RTOT_VVAR', &
1209 ngrid = 1, &
1210 ntype = typereal, &
1211 ndims = 3, &
1212 ltimedep = .true. )
1213!$acc update self(ZFLXZ)
1214 CALL io_field_write_phy(d,tpfile,tzfield,zflxz)
1215 END IF
1216 !
1217 ! and we store in LES configuration
1218 !
1219 IF (tles%LLES_CALL) THEN
1220 CALL second_mnh(ztime1)
1221 !
1222 CALL les_mean_subgrid_phy(d, tles, zflxz, tles%X_LES_SUBGRID_Rt2 )
1223 zwkles(:,:) = mzf(pwm(:,:))*zflxz(:,:)
1224 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_W_SBG_Rt2 )
1225 zwkles(:,:) = pemoist(:,:)*zflxz(:,:)
1226 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_RtThv , .true. )
1227 zwkles(:,:) = -csturb%XA3*pbeta(:,:)*pemoist(:,:)*zflxz(:,:)
1228 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_RtPz, .true. )
1229 zwkles(:,:) = -2.*csturb%XCTD*psqrt_tke(:,:)*zflxz(:,:)/pleps(:,:)
1230 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_DISS_Rt2 )
1231 !
1232 CALL second_mnh(ztime2)
1233 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
1234 END IF
1235 !
1236 END IF ! end if KRR ne 0
1237!
1238!
1239! 4.5 Vertical part of Sigma_s
1240!
1241 IF ( krrl > 0 ) THEN
1242 ! Extrapolate PSIGS at the ground and at the top
1243!$acc kernels
1244 !$mnh_expand_array(JIJ=IIJB:IIJE)
1245 psigs(iijb:iije,ika) = psigs(iijb:iije,ikb)
1246 psigs(iijb:iije,iku) = psigs(iijb:iije,ike)
1247 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1248 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1249 psigs(iijb:iije,1:ikt) = sqrt( max(psigs(iijb:iije,1:ikt) , turbn%XMINSIGS) )
1250 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1251!$acc end kernels
1252 END IF
1253
1254!
1255! 4.6 Deallocate
1256!
1257!----------------------------------------------------------------------------
1258IF (lhook) CALL dr_hook('TURB_VER_THERMO_CORR',1,zhook_handle)
1259CONTAINS
1260include "shugrad.h"
1261END SUBROUTINE turb_ver_thermo_corr
1263
integer, parameter typereal
Definition modd_field.F90:9
integer, parameter jpvext_turb
integer, parameter ncht1
integer, parameter nturb_s
integer, parameter ncht2
integer, parameter nctv
subroutine m3_thr_wthr(d, csturb, turbn, predth1, predr1, pd, pleps, psqrt_tke, pm3_thr_wthr)
subroutine m3_r2_wr2(d, csturb, turbn, predr1, predth1, pd, pleps, psqrt_tke, pm3_r2_wr2)
subroutine d_phi3dtdz_o_ddtdz(d, csturb, turbn, pphi3, predth1, predr1, pred2th3, pred2thr3, hturbdim, ouserv, pd_phi3dtdz_o_ddtdz)
subroutine m3_thr_w2r(d, csturb, turbn, predth1, pd, plm, pleps, ptke, pdtdz, pm3_thr_w2r, pturb_spp)
subroutine d_m3_thr_wr2_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pdtdz, pd_m3_thr_wr2_o_ddrdz, pturb_spp)
subroutine d_m3_thr_wthr_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pd_m3_thr_wthr_o_ddrdz, pturb_spp)
subroutine m3_r2_w2th(d, csturb, turbn, pd, plm, pleps, ptke, pbll_o_e, petheta, pdrdz, pm3_r2_w2th, pturb_spp)
subroutine m3_th2_wth2(d, csturb, turbn, predth1, predr1, pd, pleps, psqrt_tke, pm3_th2_wth2)
subroutine d_m3_thr_wth2_o_ddrdz(d, csturb, turbn, predth1, predr1, pd, pleps, psqrt_tke, pbll_o_e, petheta, pd_m3_thr_wth2_o_ddrdz, pturb_spp)
subroutine d_psi3drdz_o_ddrdz(d, csturb, turbn, ppsi3, predr1, predth1, pred2r3, pred2thr3, hturbdim, ouserv, pd_psi3drdz_o_ddrdz)
subroutine d_m3_r2_wthr_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, pleps, psqrt_tke, pbll_o_e, petheta, pdrdz, pd_m3_r2_wthr_o_ddrdz, pturb_spp)
subroutine d_m3_thr_w2th_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, plm, pleps, ptke, pbll_o_e, pdrdz, petheta, pd_m3_thr_w2th_o_ddtdz, pturb_spp)
subroutine d_m3_thr_w2r_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, plm, pleps, ptke, pbll_o_e, pdtdz, pemoist, pd_m3_thr_w2r_o_ddrdz, pturb_spp)
subroutine m3_r2_wthr(d, csturb, turbn, predth1, pd, pleps, psqrt_tke, pbll_o_e, petheta, pdrdz, pm3_r2_wthr, pturb_spp)
subroutine d_psi3drdz2_o_ddrdz(d, csturb, turbn, ppsi3, predr1, predth1, pred2r3, pred2thr3, pdrdz, hturbdim, ouserv, pd_psi3drdz2_o_ddrdz)
subroutine m3_thr_wr2(d, csturb, turbn, predth1, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pdtdz, pm3_thr_wr2, pturb_spp)
subroutine d_m3_r2_wr2_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pd_m3_r2_wr2_o_ddrdz, pturb_spp)
subroutine m3_r2_w2r(d, csturb, turbn, predr1, predth1, pd, pdrdz, plm, pleps, ptke, pm3_r2_w2r, pturb_spp)
subroutine d_m3_r2_wth2_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, pleps, psqrt_tke, pbll_o_e, petheta, pdrdz, pd_m3_r2_wth2_o_ddrdz, pturb_spp)
subroutine m3_th2_wr2(d, csturb, turbn, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pdtdz, pm3_th2_wr2, pturb_spp)
subroutine d_m3_th2_wthr_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pdtdz, pd_m3_th2_wthr_o_ddtdz, pturb_spp)
subroutine d_m3_r2_w2th_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, plm, pleps, ptke, pbll_o_e, petheta, pdrdz, pd_m3_r2_w2th_o_ddrdz, pturb_spp)
subroutine m3_thr_w2th(d, csturb, turbn, predr1, pd, plm, pleps, ptke, pdrdz, pm3_thr_w2th, pturb_spp)
subroutine d_psi3dtdz_o_ddtdz(d, csturb, turbn, ppsi3, predr1, predth1, pred2r3, pred2thr3, hturbdim, ouserv, pd_psi3dtdz_o_ddtdz)
subroutine d_m3_th2_wr2_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pdtdz, pd_m3_th2_wr2_o_ddtdz, pturb_spp)
subroutine d_m3_thr_wthr_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, pleps, psqrt_tke, pbll_o_e, petheta, pd_m3_thr_wthr_o_ddtdz, pturb_spp)
subroutine m3_th2_w2r(d, csturb, turbn, pd, plm, pleps, ptke, pbll_o_e, pemoist, pdtdz, pm3_th2_w2r, pturb_spp)
subroutine m3_th2_wthr(d, csturb, turbn, predr1, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pdtdz, pm3_th2_wthr, pturb_spp)
subroutine d_m3_thr_w2r_o_ddtdz(d, csturb, turbn, predr1, predth1, pd, plm, pleps, ptke, pd_m3_thr_w2r_o_ddtdz, pturb_spp)
subroutine m3_thr_wth2(d, csturb, turbn, predr1, pd, pleps, psqrt_tke, pbll_o_e, petheta, pdrdz, pm3_thr_wth2, pturb_spp)
subroutine d_phi3drdz_o_ddrdz(d, csturb, turbn, pphi3, predth1, predr1, pred2th3, pred2thr3, hturbdim, ouserv, pd_phi3drdz_o_ddrdz)
subroutine d_m3_thr_w2th_o_ddrdz(d, csturb, turbn, predth1, predr1, pd, plm, pleps, ptke, pd_m3_thr_w2th_o_ddrdz, pturb_spp)
subroutine m3_r2_wth2(d, csturb, turbn, pd, pleps, psqrt_tke, pbll_o_e, petheta, pdrdz, pm3_r2_wth2, pturb_spp)
subroutine d_m3_th2_w2r_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, plm, pleps, ptke, pbll_o_e, pemoist, pdtdz, pd_m3_th2_w2r_o_ddtdz, pturb_spp)
subroutine d_m3_thr_wth2_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, pleps, psqrt_tke, pbll_o_e, petheta, pdrdz, pd_m3_thr_wth2_o_ddtdz, pturb_spp)
subroutine m3_th2_w2th(d, csturb, turbn, predth1, predr1, pd, pdtdz, plm, pleps, ptke, pm3_th2_w2th, pturb_spp)
subroutine d_m3_r2_w2r_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, plm, pleps, ptke, ouserv, pd_m3_r2_w2r_o_ddrdz, pturb_spp)
subroutine d_m3_th2_wth2_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, pleps, psqrt_tke, pbll_o_e, petheta, pd_m3_th2_wth2_o_ddtdz, pturb_spp)
subroutine d_m3_th2_w2th_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, plm, pleps, ptke, ouserv, pd_m3_th2_w2th_o_ddtdz, pturb_spp)
subroutine d_m3_thr_wr2_o_ddtdz(d, csturb, turbn, predr1, predth1, pd, pleps, psqrt_tke, pbll_o_e, pemoist, pd_m3_thr_wr2_o_ddtdz, pturb_spp)
subroutine turb_ver_thermo_corr(d, cst, csturb, turbn, nebn, tles, krr, krrl, krri, ksv, ocompute_src, ocouples, pexpl, tpfile, pdxx, pdyy, pdzz, pdzx, pdzy, pdircoszw, prhodj, pthvref, psfthm, psfrm, psfthp, psfrp, pwm, pthlm, prm, psvm, ptkem, plm, pleps, plocpexnm, patheta, pamoist, pbeta, psqrt_tke, pdth_dz, pdr_dz, pred2th3, pred2r3, pred2thr3, pbll_o_e, petheta, pemoist, predth1, predr1, pphi3, ppsi3, pd, pfwth, pfwr, pfth2, pfr2, pfthr, pthlp, prp, mfmoist, pturb_spp, psigs)
subroutine second_mnh(xt)
Definition second_mnh.F90:2
real function, dimension(size(pin, 1), size(pin, 2)) mzf(pin)
Definition shugrad.h:142
real function, dimension(size(pin, 1), size(pin, 2)) mzm(pin)
Definition shugrad.h:2
real function, dimension(size(pin, 1), size(pin, 2)) dzm(pin)
Definition shugrad.h:298