PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
mode_turb_ver_thermo_flux.F90
Go to the documentation of this file.
1!MNH_LIC Copyright 1994-2026 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_flux(D,CST,CSTURB,TURBN,TLES, &
13 KRR,KRRL,KRRI,KSV,KGRADIENTS, &
14 OOCEAN,ODEEPOC,OFLYER, &
15 OCOUPLES, OCOMPUTE_SRC, &
16 PEXPL,PTSTEP, &
17 TPFILE, &
18 PDXX,PDYY,PDZZ,PDZX,PDZY,PDIRCOSZW,PZZ, &
19 PRHODJ,PTHVREF,PHGRAD,PZS, &
20 PSFTHM,PSFRM,PSFTHP,PSFRP, &
21 PWM,PTHLM,PRM,PSVM, &
22 PTKEM,PLM,PLEPS, &
23 PLOCPEXNM,PATHETA,PAMOIST,PSRCM,PFRAC_ICE, &
24 PBETA, PSQRT_TKE, PDTH_DZ, PDR_DZ, PRED2TH3, &
25 PRED2R3, PRED2THR3, PBLL_O_E, PETHETA, &
26 PEMOIST, PREDTH1, PREDR1, PPHI3, PPSI3, PD, &
27 PFWTH,PFWR,PFTH2,PFR2,PFTHR,MFMOIST,PBL_DEPTH,&
28 PWTHV,PRTHLS,PRRS,PTHLP,PRP,PTP,PWTH,PWRC, &
29 PSSTFL, PSSTFL_C, PSSRFL_C,PTURB_SPP )
30! ###############################################################
31!
32!
33!!**** *TURB_VER_THERMO_FLUX* -compute the source terms due to the vertical turbulent
34!! fluxes.
35!!
36!! PURPOSE
37!! -------
38! The purpose of this routine is to compute the vertical turbulent
39! fluxes of the evolutive variables and give back the source
40! terms to the main program. In the case of large horizontal meshes,
41! the divergence of these vertical turbulent fluxes represent the whole
42! effect of the turbulence but when the three-dimensionnal version of
43! the turbulence scheme is activated (CTURBDIM="3DIM"), these divergences
44! are completed in the next routine TURB_HOR.
45! An arbitrary degree of implicitness has been implemented for the
46! temporal treatment of these diffusion terms.
47! The vertical boundary conditions are as follows:
48! * at the bottom, the surface fluxes are prescribed at the same
49! as the other turbulent fluxes
50! * at the top, the turbulent fluxes are set to 0.
51! It should be noted that the condensation has been implicitely included
52! in this turbulence scheme by using conservative variables and computing
53! the subgrid variance of a statistical variable s indicating the presence
54! or not of condensation in a given mesh.
55!
56!!** METHOD
57!! ------
58!! 1D type calculations are made;
59!! The vertical turbulent fluxes are computed in an off-centered
60!! implicit scheme (a Crank-Nicholson type with coefficients different
61!! than 0.5), which allows to vary the degree of implicitness of the
62!! formulation.
63!! The different prognostic variables are treated one by one.
64!! The contributions of each turbulent fluxes are cumulated into the
65!! tendency PRvarS, and into the dynamic and thermal production of
66!! TKE if necessary.
67!!
68!! In section 2 and 3, the thermodynamical fields are considered.
69!! Only the turbulent fluxes of the conservative variables
70!! (Thetal and Rnp stored in PRx(:,:,:,1)) are computed.
71!! Note that the turbulent fluxes at the vertical
72!! boundaries are given either by the soil scheme for the surface one
73!! ( at the same instant as the others fluxes) and equal to 0 at the
74!! top of the model. The thermal production is computed by vertically
75!! averaging the turbulent flux and multiply this flux at the mass point by
76!! a function ETHETA or EMOIST, which preform the transformation from the
77!! conservative variables to the virtual potential temperature.
78!!
79!! In section 4, the variance of the statistical variable
80!! s indicating presence or not of condensation, is determined in function
81!! of the turbulent moments of the conservative variables and its
82!! squarred root is stored in PSIGS. This information will be completed in
83!! the horizontal turbulence if the turbulence dimensionality is not
84!! equal to "1DIM".
85!!
86!! In section 5, the x component of the stress tensor is computed.
87!! The surface flux <u'w'> is computed from the value of the surface
88!! fluxes computed in axes linked to the orography ( i", j" , k"):
89!! i" is parallel to the surface and in the direction of the maximum
90!! slope
91!! j" is also parallel to the surface and in the normal direction of
92!! the maximum slope
93!! k" is the normal to the surface
94!! In order to prevent numerical instability, the implicit scheme has
95!! been extended to the surface flux regarding to its dependence in
96!! function of U. The dependence in function of the other components
97!! introduced by the different rotations is only explicit.
98!! The turbulent fluxes are used to compute the dynamic production of
99!! TKE. For the last TKE level ( located at PDZZ(:,:,IKB)/2 from the
100!! ground), an harmonic extrapolation from the dynamic production at
101!! PDZZ(:,:,IKB) is used to avoid an evaluation of the gradient of U
102!! in the surface layer.
103!!
104!! In section 6, the same steps are repeated but for the y direction
105!! and in section 7, a diagnostic computation of the W variance is
106!! performed.
107!!
108!! In section 8, the turbulent fluxes for the scalar variables are
109!! computed by the same way as the conservative thermodynamical variables
110!!
111!!
112!! EXTERNAL
113!! --------
114!! GX_U_M, GY_V_M, GZ_W_M : cartesian gradient operators
115!! GX_U_UW,GY_V_VW (X,Y,Z) represent the direction of the gradient
116!! _(M,U,...)_ represent the localization of the
117!! field to be derivated
118!! _(M,UW,...) represent the localization of the
119!! field derivated
120!!
121!!
122!! MXM,MXF,MYM,MYF,MZM,MZF
123!! : Shuman functions (mean operators)
124!! DXF,DYF,DZF,DZM
125!! : Shuman functions (difference operators)
126!!
127!! SUBROUTINE TRIDIAG : to compute the splitted implicit evolution
128!! of a variable located at a mass point
129!!
130!! SUBROUTINE TRIDIAG_WIND: to compute the splitted implicit evolution
131!! of a variable located at a wind point
132!!
133!! FUNCTIONs ETHETA and EMOIST :
134!! allows to compute:
135!! - the coefficients for the turbulent correlation between
136!! any variable and the virtual potential temperature, of its
137!! correlations with the conservative potential temperature and
138!! the humidity conservative variable:
139!! ------- ------- -------
140!! A' Thv' = ETHETA A' Thl' + EMOIST A' Rnp'
141!!
142!!
143!! IMPLICIT ARGUMENTS
144!! ------------------
145!! Module MODD_CST : contains physical constants
146!!
147!! CST%XG : gravity constant
148!!
149!! Module MODD_CTURB: contains the set of constants for
150!! the turbulence scheme
151!!
152!! CSTURB%XCMFS,XCMFB : cts for the momentum flux
153!! TURBN%XCSHF : ct for the sensible heat flux
154!! CSTURB%XCHF : ct for the moisture flux
155!! TURBN%XCTV,CSTURB%XCHV : cts for the T and moisture variances
156!!
157!! Module MODD_PARAMETERS
158!!
159!! JPVEXT_TURB : number of vertical external points
160!! JPHEXT : number of horizontal external points
161!!
162!!
163!! REFERENCE
164!! ---------
165!! Book 1 of documentation (Chapter: Turbulence)
166!!
167!! AUTHOR
168!! ------
169!! Joan Cuxart * INM and Meteo-France *
170!!
171!! MODIFICATIONS
172!! -------------
173!! Original August 19, 1994
174!! Modifications: February 14, 1995 (J.Cuxart and J.Stein)
175!! Doctorization and Optimization
176!! Modifications: March 21, 1995 (J.M. Carriere)
177!! Introduction of cloud water
178!! Modifications: June 14, 1995 (J.Cuxart and J. Stein)
179!! Phi3 and Psi3 at w-point + bug in the all
180!! or nothing condens.
181!! Modifications: Sept 15, 1995 (J.Cuxart and J. Stein)
182!! Change the DP computation at the ground
183!! Modifications: October 10, 1995 (J.Cuxart and J. Stein)
184!! Psi for scal var and LES tools
185!! Modifications: November 10, 1995 (J. Stein)
186!! change the surface relations
187!! Modifications: February 20, 1995 (J. Stein) optimization
188!! Modifications: May 21, 1996 (J. Stein)
189!! bug in the vertical flux of the V wind
190!! component for explicit computation
191!! Modifications: May 21, 1996 (N. wood)
192!! modify the computation of the vertical
193!! part or the surface tangential flux
194!! Modifications: May 21, 1996 (P. Jabouille)
195!! same modification in the Y direction
196!!
197!! Modifications: Sept 17, 1996 (J. Stein) change the moist case by using
198!! Pi instead of Piref + use Atheta and Amoist
199!!
200!! Modifications: Nov 24, 1997 (V. Masson) removes the DO loops
201!! Modifications: Mar 31, 1998 (V. Masson) splits the routine TURB_VER_THERMO_FLUX
202!! Modifications: Oct 18, 2000 (V. Masson) LES computations
203!! Modifications: Dec 01, 2000 (V. Masson) conservation of energy from
204!! surface flux in 1DIM case
205!! when slopes are present
206!! Nov 06, 2002 (V. Masson) LES budgets
207!! Feb 20, 2003 (JP Pinty) Add PFRAC_ICE
208!! May 20, 2003 (JP Pinty) Correction of ETHETA
209!! and EMOIST calls
210!! July 2005 (S. Tomas, V. Masson)
211!! Add 3rd order moments
212!! and implicitation of PHI3 and PSI3
213!! October 2009 (G. Tanguy) add ILENCH=LEN(YCOMMENT) after
214!! change of YCOMMENT
215!! 2012-02 (Y. Seity) add possibility to run with reversed
216!! vertical levels
217!! Modifications July 2015 (Wim de Rooy) TURBN%LHARAT switch
218!! 04/2016 (M.Moge) Use openACC directives to port the TURB part of Meso-NH on GPU
219!! Philippe Wautelet: 05/2016-04/2018: new data structures and calls for I/O
220!! 2021 (D. Ricard) last version of HGRAD turbulence scheme
221!! Leronard terms instead of Reynolds terms
222!! applied to vertical fluxes of r_np and Thl
223!! for implicit version of turbulence scheme
224!! corrections and cleaning
225!! Modifications: June 2019 (Wim de Rooy) with energycascade, 50MF nog
226!! longer necessary
227!! June 2020 (B. Vie) Patch preventing negative rc and ri in 2.3 and 3.3
228!! JL Redelsperger : 03/2021: Ocean and Autocoupling O-A LES Cases
229!! Sfc flux shape for LDEEPOC Case
230! P. Wautelet 30/11/2022: compute PWTH and PWRC only when needed
231!!--------------------------------------------------------------------------
232!
233!* 0. DECLARATIONS
234! ------------
235!
236USE yomhook, ONLY: lhook, dr_hook, jphook
237!
238USE modd_cst, ONLY: cst_t
239USE modd_cturb, ONLY: csturb_t
240USE modd_dimphyex, ONLY: dimphyex_t
241USE modd_io, ONLY: tfiledata
242USE modd_les, ONLY: tles_t
243USE modd_parameters, ONLY: xundef
244USE modd_turb_n, ONLY: turb_t, nctp, ncshf, nturb_s
245!
254USE mode_tm06_h, ONLY: tm06_h
256!
258USE modi_second_mnh, ONLY: second_mnh
259!
260IMPLICIT NONE
261!
262!* 0.1 declarations of arguments
263!
264!
265!
266TYPE(dimphyex_t), INTENT(IN) :: D
267TYPE(cst_t), INTENT(IN) :: CST
268TYPE(csturb_t), INTENT(IN) :: CSTURB
269TYPE(turb_t), INTENT(IN) :: TURBN
270TYPE(tles_t), INTENT(INOUT):: TLES ! modd_les structure
271INTEGER, INTENT(IN) :: KRR ! number of moist var.
272INTEGER, INTENT(IN) :: KRRL ! number of liquid water var.
273INTEGER, INTENT(IN) :: KRRI ! number of ice water var.
274INTEGER, INTENT(IN) :: KSV ! number of scalar var.
275INTEGER, INTENT(IN) :: KGRADIENTS ! Number of stored horizontal gradients
276LOGICAL, INTENT(IN) :: OOCEAN ! switch for Ocean model version
277LOGICAL, INTENT(IN) :: ODEEPOC ! activates sfc forcing for ideal ocean deep conv
278LOGICAL, INTENT(IN) :: OFLYER ! MesoNH flyer diagnostic
279LOGICAL, INTENT(IN) :: OCOUPLES ! switch to activate atmos-ocean LES version
280LOGICAL, INTENT(IN) :: OCOMPUTE_SRC ! flag to define dimensions of SIGS and
281REAL, INTENT(IN) :: PEXPL ! Coef. for temporal disc.
282REAL, INTENT(IN) :: PTSTEP ! Double Time Step
283TYPE(tfiledata), INTENT(INOUT) :: TPFILE ! Output file
284!
285REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDZZ, PDXX, PDYY, PDZX, PDZY ! Metric coefficients
286REAL, DIMENSION(D%NIJT), INTENT(IN) :: PDIRCOSZW ! Director Cosinus of the normal to the ground surface
287REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PZZ ! altitudes
288!
289REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRHODJ ! dry density * grid volum
290REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTHVREF ! ref. state Virtual Potential Temperature
291!
292REAL, DIMENSION(MERGE(D%NIJT,0,TURBN%LLEONARD),MERGE(D%NKT,0,TURBN%LLEONARD), & MERGE(KGRADIENTS,0,TURBN%LLEONARD)), INTENT(IN) :: PHGRAD ! horizontal gradients in Moeng
293REAL, DIMENSION(D%NIJT), INTENT(IN) :: PZS ! orography (for LEONARD terms)
294REAL, DIMENSION(D%NIJT), INTENT(IN) :: PSFTHM,PSFRM ! surface fluxes at time t - deltat
295REAL, DIMENSION(D%NIJT), INTENT(IN) :: PSFTHP,PSFRP ! surface fluxes at time t + deltat
296!
297REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PWM ! Vertical wind
298REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTHLM ! potential temperature at t-Delta t
299REAL, DIMENSION(D%NIJT,D%NKT,KRR), INTENT(IN) :: PRM ! Mixing ratios at t-Delta t
300REAL, DIMENSION(D%NIJT,D%NKT,KSV), INTENT(IN) :: PSVM ! Mixing ratios
301!
302REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTKEM ! TKE at time t
303!
304! In case TURBN%LHARAT=TRUE, PLM already includes all stability corrections
305REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PLM ! Turb. mixing length
306REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PLEPS ! dissipative length
307REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PLOCPEXNM ! Lv(T)/Cp/Exnref at time t-1
308REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PATHETA ! coefficients between
309REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PAMOIST ! s and Thetal and Rnp
310REAL, DIMENSION(MERGE(D%NIJT,0,OCOMPUTE_SRC),& MERGE(D%NKT,0,OCOMPUTE_SRC)), INTENT(IN) :: PSRCM ! normalized
311! 2nd-order flux s'r'c/2Sigma_s2 at t-1 multiplied by Lambda_3
312REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFRAC_ICE ! ri fraction of rc+ri
313REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PBETA ! buoyancy coefficient
314REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PSQRT_TKE ! sqrt(e)
315REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDTH_DZ ! d(th)/dz
316REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDR_DZ ! d(rt)/dz
317REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRED2TH3 ! 3D Redeslperger number R*2_th
318REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRED2R3 ! 3D Redeslperger number R*2_r
319REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRED2THR3 ! 3D Redeslperger number R*2_thr
320REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PBLL_O_E ! beta * Lk * Leps / tke
321REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PETHETA ! Coefficient for theta in theta_v computation
322REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PEMOIST ! Coefficient for r in theta_v computation
323REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PREDTH1 ! 1D Redelsperger number for Th
324REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PREDR1 ! 1D Redelsperger number for r
325REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PPHI3 ! Prandtl number for temperature
326REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PPSI3 ! Prandtl number for vapor
327REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PD ! Denominator in Prandtl numbers
328REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFWTH ! d(w'2th' )/dz (at flux point)
329REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFWR ! d(w'2r' )/dz (at flux point)
330REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFTH2 ! d(w'th'2 )/dz (at mass point)
331REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFR2 ! d(w'r'2 )/dz (at mass point)
332REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PFTHR ! d(w'th'r')/dz (at mass point)
333REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: MFMOIST ! moist mass flux dual scheme
334REAL, DIMENSION(MERGE(D%NIJT,0,TURBN%CTOM=='TM06')), INTENT(INOUT):: PBL_DEPTH ! BL depth
335REAL, DIMENSION(D%NIJT,D%NKT), INTENT(OUT) :: PWTHV ! buoyancy flux
336!
337REAL, DIMENSION(D%NIJT,D%NKT), INTENT(INOUT) :: PRTHLS ! cumulated source for theta
338REAL, DIMENSION(D%NIJT,D%NKT,KRR), INTENT(INOUT) :: PRRS ! cumulated source for rt
339REAL, DIMENSION(D%NIJT,D%NKT), INTENT(OUT) :: PTHLP ! guess of thl at t+ deltat
340REAL, DIMENSION(D%NIJT,D%NKT), INTENT(OUT) :: PRP ! guess of r at t+ deltat
341!
342REAL, DIMENSION(D%NIJT,D%NKT), INTENT(OUT) :: PTP ! Dynamic and thermal
343 ! TKE production terms
344!
345REAL, DIMENSION(MERGE(D%NIJT,0,OFLYER),MERGE(D%NKT,0,OFLYER)), INTENT(OUT) :: PWTH ! heat flux
346REAL, DIMENSION(MERGE(D%NIJT,0,OFLYER),MERGE(D%NKT,0,OFLYER)), INTENT(OUT) :: PWRC ! cloud water flux
347REAL, DIMENSION(MERGE(D%NIJT,0,OCOUPLES)), INTENT(IN),OPTIONAL :: PSSTFL ! Time evol Flux of T at sea surface (LOCEAN and LCOUPLES)
348REAL, DIMENSION(MERGE(D%NIJT,0,OCOUPLES)), INTENT(IN),OPTIONAL :: PSSTFL_C ! O-A interface flux for theta(LOCEAN and LCOUPLES)
349REAL, DIMENSION(MERGE(D%NIJT,0,OCOUPLES)), INTENT(IN),OPTIONAL :: PSSRFL_C ! O-A interface flux for vapor (LOCEAN and LCOUPLES)
350REAL, DIMENSION(D%NIJT,D%NKT,NTURB_S), INTENT(IN) :: PTURB_SPP ! SPP variables
351!
352!
353!* 0.2 declaration of local variables
354!
355!
356REAL, DIMENSION(D%NIJT,D%NKT) :: &
357 ZA, & ! work variable for wrc or LES computation
358 ZFLXZ, & ! vertical flux of the treated variable
359 ZKEFF, & ! effectif diffusion coeff = LT * SQRT( TKE )
360 ZF, & ! Flux in dTh/dt =-dF/dz (evaluated at t-1)(or rt instead of Th)
361 ZDFDDTDZ, & ! dF/d(dTh/dz)
362 ZDFDDRDZ, & ! dF/d(dr/dz)
363 Z3RDMOMENT,& ! 3 order term in flux or variance equation
364 ZF_LEONARD,& ! Leonard terms
365 ZRWTHL, &
366 ZRWRNP, &
367 ZCLD_THOLD,&
368 ZALT, &
369 ZWORK1,ZWORK2, &
370 ZWORK3,ZWORK4, & ! working var. for shuman operators (array syntax)
371 ZWKLES ! working var. for LES calls
372!
373INTEGER :: IKB,IKE ! I index values for the Beginning and End
374 ! mass points of the domain in the 3 direct.
375INTEGER :: IKT,IKA,IKU ! array size in k direction
376INTEGER :: IKTB,IKTE ! start, end of k loops in physical domain
377INTEGER :: JIJ, JK ! loop indexes
378INTEGER :: IIJB, IIJE
379INTEGER :: IKL
380!
381REAL :: ZTIME1, ZTIME2
382!
383LOGICAL :: GUSERV ! flag to use water
384LOGICAL :: GFTH2 ! flag to use w'th'2
385LOGICAL :: GFWTH ! flag to use w'2th'
386LOGICAL :: GFR2 ! flag to use w'r'2
387LOGICAL :: GFWR ! flag to use w'2r'
388LOGICAL :: GFTHR ! flag to use w'th'r'
389REAL :: ZALTHGRAD, ZCLDTHOLD !Intermediate variable used to work around a Cray compiler bug (CCE 13.0.0)
390!----------------------------------------------------------------------------
391!
392!* 1. PRELIMINARIES
393! -------------
394!
395REAL(KIND=jphook) :: zhook_handle
396IF (lhook) CALL dr_hook('TURB_VER_THERMO_FLUX',0,zhook_handle)
397!
398! Size for a given proc & a given model
399iije=d%NIJE
400iijb=d%NIJB
401ikt=d%NKT
402ika=d%NKA
403iku=d%NKU
404iktb=d%NKTB
405ikte=d%NKTE
406ikb=d%NKB
407ike=d%NKE
408ikl=d%NKL
409!
410zalthgrad = turbn%XALTHGRAD
411zcldthold = turbn%XCLDTHOLD
412!
413guserv = (krr/=0)
414!
415! compute the coefficients for the uncentred gradient computation near the ground
416!
417IF (turbn%LHARAT) THEN
418!$acc kernels
419 ! LHARAT so TKE and length scales at half levels!
420 !wc 50MF can be omitted with energy cascade included
421 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
422 zkeff(iijb:iije,1:ikt) = plm(iijb:iije,1:ikt) * sqrt(ptkem(iijb:iije,1:ikt))
423 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
424!$acc end kernels
425ELSE
426!$acc kernels
427 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
428 zwork1(iijb:iije,1:ikt) = plm(iijb:iije,1:ikt) * sqrt(ptkem(iijb:iije,1:ikt))
429 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
430!$acc end kernels
431 zkeff=mzm(zwork1)
432ENDIF
433!
434! Define a cloud mask with ri and rc (used after with a threshold) for Leonard terms
435!
436IF(turbn%LLEONARD) THEN
437!$acc kernels present_cr(zcld_thold)
438 IF ( krrl >= 1 ) THEN
439 IF ( krri >= 1 ) THEN
440 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
441 zcld_thold(iijb:iije,1:ikt) = prm(iijb:iije,1:ikt,2) + prm(iijb:iije,1:ikt,4)
442 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
443 ELSE
444 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
445 zcld_thold(iijb:iije,1:ikt) = prm(iijb:iije,1:ikt,2)
446 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
447 END IF
448 END IF
449!$acc end kernels
450END IF
451!
452! Flags for 3rd order quantities
453!
454gfth2 = .false.
455gfr2 = .false.
456gfthr = .false.
457gfwth = .false.
458gfwr = .false.
459!
460IF (turbn%CTOM/='NONE') THEN
461 gfth2 = any(pfth2(:,:)/=0.)
462 gfr2 = any(pfr2(:,:)/=0.) .AND. guserv
463 gfthr = any(pfthr(:,:)/=0.) .AND. guserv
464 gfwth = any(pfwth(:,:)/=0.)
465 gfwr = any(pfwr(:,:)/=0.) .AND. guserv
466END IF
467!----------------------------------------------------------------------------
468!
469!* 2. SOURCES OF CONSERVATIVE POTENTIAL TEMPERATURE AND
470! PARTIAL THERMAL PRODUCTION
471! ---------------------------------------------------------------
472!
473!* 2.1 Splitted value for cons. potential temperature at t+deltat
474!
475! Compute the turbulent flux F and F' at time t-dt.
476!
477zwork1=dzm(pthlm)
478CALL d_phi3dtdz_o_ddtdz(d,csturb,turbn,pphi3,predth1,predr1,pred2th3,pred2thr3,turbn%CTURBDIM,guserv,zwork2)
479IF (turbn%LHARAT) THEN
480!$acc kernels
481 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
482 zf(iijb:iije,1:ikt) = -zkeff(iijb:iije,1:ikt)*zwork1(iijb:iije,1:ikt)/pdzz(iijb:iije,1:ikt)
483 zdfddtdz(iijb:iije,1:ikt) = -zkeff(iijb:iije,1:ikt)
484 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
485!$acc end kernels
486ELSE
487!$acc kernels
488 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
489 zf(iijb:iije,1:ikt) = -pturb_spp(iijb:iije,1:ikt,ncshf)*pphi3(iijb:iije,1:ikt)*zkeff(iijb:iije,1:ikt)&
490 *zwork1(iijb:iije,1:ikt)/pdzz(iijb:iije,1:ikt)
491 zdfddtdz(iijb:iije,1:ikt) = -pturb_spp(iijb:iije,1:ikt,ncshf)*zkeff(iijb:iije,1:ikt)*zwork2(iijb:iije,1:ikt)
492 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
493!$acc end kernels
494END IF
495!
496IF (turbn%LLEONARD) THEN
497! ! Compute the Leonard terms for thl
498 zwork1=mxf(phgrad(:,:,1)) ! GX_W_UW(XWT)
499 zwork2=mzm(phgrad(:,:,3)) ! GX_M_M(PTHLM
500 zwork3=myf(phgrad(:,:,2)) ! GY_W_VW(PWM)
501 zwork4=mzm(phgrad(:,:,4)) ! GY_M_M(PTHLM)
502 !$acc kerne=ls
503 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
504 zf_leonard(iijb:iije,1:ikt)= turbn%XCOEFHGRADTHL*pdxx(iijb:iije,1:ikt)*pdyy(iijb:iije,1:ikt)/12.0*( &
505 zwork1(iijb:iije,1:ikt)*zwork2(iijb:iije,1:ikt) &
506 + zwork3(iijb:iije,1:ikt)*zwork4(iijb:iije,1:ikt))
507 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
508 !$acc end kernels
509END IF
510!
511! Effect of 3rd order terms in temperature flux (at flux point)
512!
513! d(w'2th')/dz
514IF (gfwth) THEN
515 CALL m3_wth_w2th(d,csturb,turbn,predth1,predr1,pd,zkeff,ptkem,z3rdmoment,pturb_spp)
516 CALL d_m3_wth_w2th_o_ddtdz(d,csturb,turbn,predth1,predr1,&
517 & pd,pbll_o_e,petheta,zkeff,ptkem,zwork1,pturb_spp)
518 !
519!$acc kernels
520 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
521 zf(iijb:iije,1:ikt)= zf(iijb:iije,1:ikt) + z3rdmoment(iijb:iije,1:ikt) * pfwth(iijb:iije,1:ikt)
522 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
523 * pfwth(iijb:iije,1:ikt)
524 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
525!$acc end kernels
526END IF
527!
528! d(w'th'2)/dz
529IF (gfth2) THEN
530 CALL m3_wth_wth2(d,csturb,turbn,predth1,predr1,pd,pbll_o_e,petheta,z3rdmoment,pturb_spp)
531 CALL d_m3_wth_wth2_o_ddtdz(d,csturb,turbn,z3rdmoment,predth1,predr1,&
532 & pd,pbll_o_e,petheta,zwork1,pturb_spp)
533 zwork2=mzm(pfth2)
534 !
535!$acc kernels
536 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
537 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + z3rdmoment(iijb:iije,1:ikt) &
538 * zwork2(iijb:iije,1:ikt)
539 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
540 * zwork2(iijb:iije,1:ikt)
541 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
542!$acc end kernels
543END IF
544!
545! d(w'2r')/dz
546IF (gfwr) THEN
547 CALL m3_wth_w2r(d,csturb,turbn,pd,zkeff,ptkem,pbll_o_e,pemoist,pdth_dz,zwork1,pturb_spp)
548 CALL d_m3_wth_w2r_o_ddtdz(d,csturb,turbn,predth1,predr1,pd,zkeff,ptkem,pbll_o_e,pemoist,zwork2,pturb_spp)
549 !
550!$acc kernels
551 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
552 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) * pfwr(iijb:iije,1:ikt)
553 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
554 * pfwr(iijb:iije,1:ikt)
555 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
556!$acc end kernels
557END IF
558!
559! d(w'r'2)/dz
560IF (gfr2) THEN
561 CALL m3_wth_wr2(d,csturb,turbn,pd,zkeff,ptkem,psqrt_tke,pbll_o_e,pbeta,pleps,pemoist,pdth_dz,zwork1,pturb_spp)
562 zwork2=mzm(pfr2)
563 CALL d_m3_wth_wr2_o_ddtdz(d,csturb,turbn,predth1,predr1,pd,&
564 & zkeff,ptkem,psqrt_tke,pbll_o_e,pbeta,pleps,pemoist,zwork3,pturb_spp)
565 !
566!$acc kernels
567 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
568 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) * zwork2(iijb:iije,1:ikt)
569 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
570 * zwork2(iijb:iije,1:ikt)
571 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
572!$acc end kernels
573END IF
574!
575! d(w'th'r')/dz
576IF (gfthr) THEN
577 CALL m3_wth_wthr(d,csturb,turbn,predr1,pd,zkeff,ptkem,psqrt_tke,pbeta,&
578 & pleps,pemoist,z3rdmoment,pturb_spp)
579 CALL d_m3_wth_wthr_o_ddtdz(d,csturb,turbn,z3rdmoment,predth1,predr1,pd,pbll_o_e,petheta,zwork1,pturb_spp)
580 zwork2=mzm(pfthr)
581 !
582!$acc kernels
583 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
584 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + z3rdmoment(iijb:iije,1:ikt) &
585 * zwork2(iijb:iije,1:ikt)
586 zdfddtdz(iijb:iije,1:ikt) = zdfddtdz(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
587 * zwork2(iijb:iije,1:ikt)
588 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
589!$acc end kernels
590END IF
591! specialcase for surface
592IF (oocean) THEN ! ocean model in coupled case
593!$acc kernels
594 !$mnh_expand_array(JIJ=IIJB:IIJE)
595 zf(iijb:iije,ike+1) = psfthm(iijb:iije) &
596 *0.5* ( 1. + prhodj(iijb:iije,iku)/prhodj(iijb:iije,ike) )
597 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
598!$acc end kernels
599ELSE ! atmosp bottom
600 !*In 3D, a part of the flux goes vertically,
601 ! and another goes horizontally (in presence of slopes)
602 !*In 1D, part of energy released in horizontal flux is taken into account in the vertical part
603 IF (turbn%CTURBDIM=='3DIM') THEN
604!$acc kernels
605 !$mnh_expand_array(JIJ=IIJB:IIJE)
606 zf(iijb:iije,ikb) = ( turbn%XIMPL*psfthp(iijb:iije) + pexpl*psfthm(iijb:iije) ) &
607 * pdircoszw(iijb:iije) &
608 * 0.5 * (1. + prhodj(iijb:iije,ika) / prhodj(iijb:iije,ikb))
609 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
610!$acc end kernels
611 ELSE
612!$acc kernels
613 !$mnh_expand_array(JIJ=IIJB:IIJE)
614 zf(iijb:iije,ikb) = ( turbn%XIMPL*psfthp(iijb:iije) + pexpl*psfthm(iijb:iije) ) &
615 / pdircoszw(iijb:iije) &
616 * 0.5 * (1. + prhodj(iijb:iije,ika) / prhodj(iijb:iije,ikb))
617 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
618!$acc end kernels
619 END IF
620 !
621 ! atmos top
622!$acc kernels
623 zf(iijb:iije,ike+1)=0.
624!$acc end kernels
625END IF
626!
627! Compute the split conservative potential temperature at t+deltat
628CALL tridiag_thermo(d,pthlm,zf,zdfddtdz,ptstep,turbn%XIMPL,pdzz,&
629 prhodj,pthlp)
630!
631! Compute the equivalent tendency for the conservative potential temperature
632!
633!$acc kernels
634!$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
635zrwthl(iijb:iije,1:ikt)= prhodj(iijb:iije,1:ikt)*(pthlp(iijb:iije,1:ikt)-pthlm(iijb:iije,1:ikt))&
636 /ptstep
637!$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
638!$acc end kernels
639! replace the flux by the Leonard terms above ZALT and ZCLD_THOLD
640IF (turbn%LLEONARD) THEN
641 DO jk=1,ikt
642!$acc kernels
643 !$mnh_expand_array(JIJ=IIJB:IIJE)
644 zalt(iijb:iije,jk) = pzz(iijb:iije,jk)-pzs(iijb:iije)
645 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
646!$acc end kernels
647 END DO
648 zwork1=mzm(prhodj)
649!$acc kernels
650 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
651 zwork2(iijb:iije,1:ikt) = zwork1(iijb:iije,1:ikt)*zf_leonard(iijb:iije,1:ikt)
652 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
653!$acc end kernels
654 zwork3=gz_w_m(zwork2,pdzz)
655 !$mnh_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
656 WHERE ( (zcld_thold(iijb:iije,1:ikt) >= turbn%XCLDTHOLD) .AND. ( zalt(iijb:iije,1:ikt) >= turbn%XALTHGRAD) )
657 zrwthl(iijb:iije,1:ikt) = -zwork3(iijb:iije,1:ikt)
658 pthlp(iijb:iije,1:ikt)=pthlm(iijb:iije,1:ikt)+ptstep*zrwthl(iijb:iije,1:ikt)/prhodj(iijb:iije,1:ikt)
659 END WHERE
660 !$mnh_end_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
661END IF
662!
663!$acc kernels
664!$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
665zwork1(iijb:iije,1:ikt) = pthlp(iijb:iije,1:ikt) - pthlm(iijb:iije,1:ikt)
666!$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
667!$acc end kernels
668zwork2=dzm(zwork1)
669!
670!$acc kernels
671!$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
672prthls(iijb:iije,1:ikt)= prthls(iijb:iije,1:ikt) + zrwthl(iijb:iije,1:ikt)
673!
674!* 2.2 Partial Thermal Production
675!
676! Conservative potential temperature flux :
677!
678!
679zflxz(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + turbn%XIMPL * zdfddtdz(iijb:iije,1:ikt) * &
680 zwork2(iijb:iije,1:ikt)/ pdzz(iijb:iije,1:ikt)
681!$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
682!$acc end kernels
683!
684! replace the flux by the Leonard terms
685IF (turbn%LLEONARD) THEN
686 !$mnh_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
687 WHERE ( (zcld_thold(iijb:iije,1:ikt) >= turbn%XCLDTHOLD) .AND. ( zalt(iijb:iije,1:ikt) >= turbn%XALTHGRAD) )
688 zflxz(iijb:iije,1:ikt) = zf_leonard(iijb:iije,1:ikt)
689 END WHERE
690 !$mnh_end_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
691END IF
692!
693!$acc kernels
694IF (oocean) THEN
695 !$mnh_expand_array(JIJ=IIJB:IIJE)
696 zflxz(iijb:iije,ike+1) = zflxz(iijb:iije,ike)
697 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
698ELSE
699 !$mnh_expand_array(JIJ=IIJB:IIJE)
700 zflxz(iijb:iije,ika) = zflxz(iijb:iije,ikb)
701 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
702END IF
703!$acc end kernels
704!
705IF ( oflyer ) THEN
706!$acc kernels
707 pwth(:,:iktb) = xundef
708 pwth(:,ikte:) = xundef
709 !
710 DO jk = iktb + 1, ikte - 1
711 !$mnh_expand_array(JIJ=IIJB:IIJE)
712 pwth(iijb:iije,jk)=0.5*(zflxz(iijb:iije,jk)+zflxz(iijb:iije,jk+ikl))
713 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
714 END DO
715 !
716 !$mnh_expand_array(JIJ=IIJB:IIJE)
717 pwth(iijb:iije,ikb)=0.5*(zflxz(iijb:iije,ikb)+zflxz(iijb:iije,ikb+ikl))
718 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
719 !
720 IF (oocean) THEN
721 !$mnh_expand_array(JIJ=IIJB:IIJE)
722 pwth(iijb:iije,ike)=0.5*(zflxz(iijb:iije,ike)+zflxz(iijb:iije,ike+ikl))
723 pwth(iijb:iije,ika)=0.
724 pwth(iijb:iije,iku)=pwth(iijb:iije,ike)! not used
725 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
726 ELSE
727 !$mnh_expand_array(JIJ=IIJB:IIJE)
728 pwth(iijb:iije,ika)=0.5*(zflxz(iijb:iije,ika)+zflxz(iijb:iije,ika+ikl))
729 pwth(iijb:iije,ike)=pwth(iijb:iije,ike-ikl)
730 pwth(iijb:iije,iku)=0.
731 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
732 END IF
733!$acc end kernels
734END IF
735!
736IF ( turbn%LTURB_FLX .AND. tpfile%LOPENED ) THEN
737!$acc update self(ZFLXZ)
738 ! stores the conservative potential temperature vertical flux
739 CALL io_field_write_phy(d,tpfile,'THLW_FLX',zflxz)
740END IF
741!
742! Contribution of the conservative temperature flux to the buoyancy flux
743IF (oocean) THEN
744 ptp(iijb:iije,:)= cst%XG*cst%XALPHAOC * mzf(zflxz(iijb:iije,:))
745ELSE
746 IF (krr /= 0) THEN
747 ptp(iijb:iije,:) = pbeta(iijb:iije,:) * mzf( mzm(petheta(iijb:iije,:)) * zflxz(iijb:iije,:) )
748!$acc kernels
749 !$mnh_expand_array(JIJ=IIJB:IIJE)
750 ptp(iijb:iije,ikb)= pbeta(iijb:iije,ikb) * petheta(iijb:iije,ikb) * &
751 0.5 * ( zflxz(iijb:iije,ikb) + zflxz(iijb:iije,ikb+ikl) )
752 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
753!$acc end kernels
754 ELSE
755 ptp(iijb:iije,:)= pbeta(iijb:iije,:) * mzf(zflxz(iijb:iije,:))
756 END IF
757END IF
758!
759! Buoyancy flux at flux points
760!
761pwthv(iijb:iije,:) = mzm(petheta(iijb:iije,:)) * zflxz(iijb:iije,:)
762
763!$acc kernels
764!$mnh_expand_array(JIJ=IIJB:IIJE)
765pwthv(iijb:iije,ikb) = petheta(iijb:iije,ikb) * zflxz(iijb:iije,ikb)
766!$mnh_end_expand_array(JIJ=IIJB:IIJE)
767!$acc end kernels
768!
769IF (oocean) THEN
770 ! temperature contribution to Buy flux
771!$acc kernels
772 !$mnh_expand_array(JIJ=IIJB:IIJE)
773 pwthv(iijb:iije,ike) = petheta(iijb:iije,ike) * zflxz(iijb:iije,ike)
774 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
775!$acc end kernels
776END IF
777!* 2.3 Partial vertical divergence of the < Rc w > flux
778! Correction for qc and qi negative in AROME
779IF(turbn%LPROJQITURB) THEN
780 IF ( krrl >= 1 ) THEN
781!$acc kernels
782 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
783 zwork1(iijb:iije,1:ikt) = zflxz(iijb:iije,1:ikt)/pdzz(iijb:iije,1:ikt)
784 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
785!$acc end kernels
786 zwork2=dzf(zwork1)
787 IF ( krri >= 1 ) THEN
788!$acc kernels
789 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
790 prrs(iijb:iije,1:ikt,2) = prrs(iijb:iije,1:ikt,2) - &
791 prhodj(iijb:iije,1:ikt)*patheta(iijb:iije,1:ikt)*2.*psrcm(iijb:iije,1:ikt)&
792 *zwork2(iijb:iije,1:ikt) *(1.0-pfrac_ice(iijb:iije,1:ikt))
793 prrs(iijb:iije,1:ikt,4) = prrs(iijb:iije,1:ikt,4) - &
794 prhodj(iijb:iije,1:ikt)*patheta(iijb:iije,1:ikt)*2.*psrcm(iijb:iije,1:ikt)&
795 * zwork2(iijb:iije,1:ikt)*pfrac_ice(iijb:iije,1:ikt)
796 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
797!$acc end kernels
798 ELSE
799!$acc kernels
800 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
801 prrs(iijb:iije,1:ikt,2) = prrs(iijb:iije,1:ikt,2) - &
802 prhodj(iijb:iije,1:ikt)*patheta(iijb:iije,1:ikt)*2.*psrcm(iijb:iije,1:ikt)&
803 *zwork2(iijb:iije,1:ikt)
804 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
805!$acc end kernels
806 END IF
807 END IF
808END IF
809!
810!* 2.4 Storage in LES configuration
811!
812IF (tles%LLES_CALL) THEN
813 CALL second_mnh(ztime1)
814 !
815 zwkles(:,:) = mzf(zflxz)
816 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_WThl )
817 zwkles(:,:) = mzf(pwm*zflxz)
818 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_W_SBG_WThl )
819 zwkles(:,:) = gz_w_m(pwm,pdzz)*mzf(zflxz)
820 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_W_SBG_UaThl )
821 zwkles(:,:) = mzf(pdth_dz*zflxz)
822 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_Thl_SBG_UaThl )
823 zwkles(:,:) = -pturb_spp(:,:,nctp)*psqrt_tke/plm*mzf(zflxz)
824 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_ThlPz )
825 zwkles(:,:) = mzf(mzm(petheta)*zflxz)
826 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_WThv, .true. )
827 IF (krr>=1) THEN
828 zwkles(:,:) = mzf(pdr_dz*zflxz)
829 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_Rt_SBG_UaThl )
830 END IF
831 !
832 !* diagnostic of mixing coefficient for heat
833 za=dzm(pthlp)
834 !$mnh_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
835 WHERE (za(iijb:iije,1:ikt)==0.)
836 za(iijb:iije,1:ikt)=1.e-6
837 END WHERE
838 !$mnh_end_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
839!$acc kernels
840 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
841 za(iijb:iije,1:ikt) = - zflxz(iijb:iije,1:ikt) / za(iijb:iije,1:ikt) * pdzz(iijb:iije,1:ikt)
842 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
843 !$mnh_expand_array(JIJ=IIJB:IIJE)
844 za(iijb:iije,ikb) = pturb_spp(iijb:iije,ikb,ncshf)*pphi3(iijb:iije,ikb)*zkeff(iijb:iije,ikb)
845 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
846!$acc end kernels
847 za(:,:) = mzf(za(:,:))
848!$acc kernels
849 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
850 za(iijb:iije,1:ikt) = min(max(za(iijb:iije,1:ikt),-1000.),1000.)
851 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
852!$acc end kernels
853 CALL les_mean_subgrid_phy(d, tles, za, tles%X_LES_SUBGRID_Kh )
854 CALL second_mnh(ztime2)
855 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
856END IF
857!
858!* 2.5 New boundary layer depth for TOMs
859!
860IF (turbn%CTOM=='TM06') CALL tm06_h(d,turbn,ptstep,pzz,zflxz,pbl_depth)
861!
862!----------------------------------------------------------------------------
863!
864!
865!* 3. SOURCES OF CONSERVATIVE AND CLOUD MIXING RATIO AND
866! COMPLETE THERMAL PRODUCTION
867! ------------------------------------------------------
868!
869!* 3.1 Splitted value for cons. mixing ratio at t+deltat
870!
871!
872IF (krr /= 0) THEN
873 ! Compute the turbulent flux F and F' at time t-dt.
874 !
875 zwork1=dzm(prm(:,:,1))
876 IF (turbn%LHARAT) THEN
877!$acc kernels
878 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
879 zf(iijb:iije,1:ikt) = -zkeff(iijb:iije,1:ikt)*zwork1(iijb:iije,1:ikt)/pdzz(iijb:iije,1:ikt)
880 zdfddrdz(iijb:iije,1:ikt) = -zkeff(iijb:iije,1:ikt)
881 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
882!$acc end kernels
883 ELSE
884 CALL d_psi3drdz_o_ddrdz(d,csturb,turbn,ppsi3,predr1,predth1,pred2r3,pred2thr3,turbn%CTURBDIM,guserv,zwork2)
885!$acc kernels
886 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
887 zf(iijb:iije,1:ikt) = -pturb_spp(iijb:iije,1:ikt,ncshf)*ppsi3(iijb:iije,1:ikt)*zkeff(iijb:iije,1:ikt)&
888 *zwork1(iijb:iije,1:ikt)/pdzz(iijb:iije,1:ikt)
889 zdfddrdz(iijb:iije,1:ikt) = -pturb_spp(iijb:iije,1:ikt,ncshf)*zkeff(iijb:iije,1:ikt)*zwork2(iijb:iije,1:ikt)
890 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
891!$acc end kernels
892 ENDIF
893 !
894 ! Compute Leonard Terms for Cloud mixing ratio
895 IF (turbn%LLEONARD) THEN
896 zwork1=mxf(phgrad(:,:,1)) ! GX_W_UW(PWM)
897 zwork2=mzm(phgrad(:,:,5)) ! GX_M_M(PRM)
898 zwork3=myf(phgrad(:,:,2)) ! GY_W_VW(PWM)
899 zwork4=mzm(phgrad(:,:,6)) ! GY_M_M(PRM)
900!$acc kernels
901 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
902 zf_leonard(iijb:iije,1:ikt)= turbn%XCOEFHGRADTHL*pdxx(iijb:iije,1:ikt)*pdyy(iijb:iije,1:ikt)/12.0*( &
903 zwork1(iijb:iije,1:ikt)*zwork2(iijb:iije,1:ikt) &
904 + zwork3(iijb:iije,1:ikt)*zwork4(iijb:iije,1:ikt))
905 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
906!$acc end kernels
907 END IF
908 !
909 ! Effect of 3rd order terms in temperature flux (at flux point)
910 !
911 ! d(w'2r')/dz
912 IF (gfwr) THEN
913 CALL m3_wr_w2r(d,csturb,turbn,predr1,predth1,pd,zkeff,ptkem,z3rdmoment,pturb_spp)
914 CALL d_m3_wr_w2r_o_ddrdz(d,csturb,turbn,predr1,predth1,pd,&
915 & pbll_o_e,pemoist,zkeff,ptkem,zwork1,pturb_spp)
916 !
917!$acc kernels
918 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
919 zf(iijb:iije,1:ikt)= zf(iijb:iije,1:ikt) + z3rdmoment(iijb:iije,1:ikt) * pfwr(iijb:iije,1:ikt)
920 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) &
921 * pfwr(iijb:iije,1:ikt)
922 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
923!$acc end kernels
924 END IF
925 !
926 ! d(w'r'2)/dz
927 IF (gfr2) THEN
928 CALL m3_wr_wr2(d,csturb,turbn,predr1,predth1,pd,pbll_o_e,pemoist,z3rdmoment,pturb_spp)
929 zwork1=mzm(pfr2)
930 CALL d_m3_wr_wr2_o_ddrdz(d,csturb,turbn,z3rdmoment,predr1,&
931 & predth1,pd,pbll_o_e,pemoist,zwork2,pturb_spp)
932 !
933!$acc kernels
934 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
935 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + z3rdmoment(iijb:iije,1:ikt) &
936 * zwork1(iijb:iije,1:ikt)
937 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
938 * zwork1(iijb:iije,1:ikt)
939 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
940!$acc end kernels
941 END IF
942 !
943 ! d(w'2th')/dz
944 IF (gfwth) THEN
945 CALL m3_wr_w2th(d,csturb,turbn,pd,zkeff,&
946 & ptkem,pbll_o_e,petheta,pdr_dz,zwork1,pturb_spp)
947 CALL d_m3_wr_w2th_o_ddrdz(d,csturb,turbn,predr1,predth1,&
948 & pd,zkeff,ptkem,pbll_o_e,petheta,zwork2,pturb_spp)
949 !
950!$acc kernels
951 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
952 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork1(iijb:iije,1:ikt) * pfwth(iijb:iije,1:ikt)
953 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
954 * pfwth(iijb:iije,1:ikt)
955 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
956!$acc end kernels
957 END IF
958 !
959 ! d(w'th'2)/dz
960 IF (gfth2) THEN
961 zwork1=mzm(pfth2)
962 CALL m3_wr_wth2(d,csturb,turbn,pd,zkeff,ptkem,&
963 & psqrt_tke,pbll_o_e,pbeta,pleps,petheta,pdr_dz,zwork2,pturb_spp)
964 CALL d_m3_wr_wth2_o_ddrdz(d,csturb,turbn,predr1,predth1,pd,&
965 &zkeff,ptkem,psqrt_tke,pbll_o_e,pbeta,pleps,petheta,zwork3,pturb_spp)
966 !
967!$acc kernels
968 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
969 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) * zwork1(iijb:iije,1:ikt)
970 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork3(iijb:iije,1:ikt) &
971 * zwork1(iijb:iije,1:ikt)
972 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
973!$acc end kernels
974 END IF
975 !
976 ! d(w'th'r')/dz
977 IF (gfthr) THEN
978 CALL m3_wr_wthr(d,csturb,turbn,predth1,pd,zkeff,ptkem,psqrt_tke,pbeta,&
979 & pleps,petheta,z3rdmoment,pturb_spp)
980 zwork1=mzm(pfthr)
981 CALL d_m3_wr_wthr_o_ddrdz(d,csturb,turbn,z3rdmoment,predr1, &
982 & predth1,pd,pbll_o_e,pemoist,zwork2,pturb_spp)
983 !
984!$acc kernels
985 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
986 zf(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) + z3rdmoment(iijb:iije,1:ikt) &
987 * zwork1(iijb:iije,1:ikt)
988 zdfddrdz(iijb:iije,1:ikt) = zdfddrdz(iijb:iije,1:ikt) + zwork2(iijb:iije,1:ikt) &
989 * zwork1(iijb:iije,1:ikt)
990 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
991!$acc end kernels
992 END IF
993 !
994 !special case at sfc
995 IF (oocean) THEN
996 ! General ocean case
997 ! salinity/evap effect to be added later !!!!!
998!$acc kernels
999 zf(iijb:iije,ike) = 0.
1000!$acc end kernels
1001 ELSE ! atmosp case
1002 ! atmosp bottom
1003 !* in 3DIM case, a part of the flux goes vertically, and another goes horizontally
1004 ! (in presence of slopes)
1005 !* in 1DIM case, the part of energy released in horizontal flux
1006 ! is taken into account in the vertical part
1007 !
1008 IF (turbn%CTURBDIM=='3DIM') THEN
1009!$acc kernels present_cr(zf)
1010 !$mnh_expand_array(JIJ=IIJB:IIJE)
1011 zf(iijb:iije,ikb) = ( turbn%XIMPL*psfrp(iijb:iije) + pexpl*psfrm(iijb:iije) ) &
1012 * pdircoszw(iijb:iije) &
1013 * 0.5 * (1. + prhodj(iijb:iije,ika) / prhodj(iijb:iije,ikb))
1014 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1015!$acc end kernels
1016 ELSE
1017!$acc kernels present_cr(zf)
1018 !$mnh_expand_array(JIJ=IIJB:IIJE)
1019 zf(iijb:iije,ikb) = ( turbn%XIMPL*psfrp(iijb:iije) + pexpl*psfrm(iijb:iije) ) &
1020 / pdircoszw(iijb:iije) &
1021 * 0.5 * (1. + prhodj(iijb:iije,ika) / prhodj(iijb:iije,ikb))
1022 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1023!$acc end kernels
1024 END IF
1025 ! atmos top
1026!$acc kernels
1027 zf(iijb:iije,ike+1)=0.
1028!$acc end kernels
1029 END IF
1030 ! Compute the split conservative potential temperature at t+deltat
1031 CALL tridiag_thermo(d,prm(:,:,1),zf,zdfddrdz,ptstep,turbn%XIMPL,&
1032 pdzz,prhodj,prp)
1033 !
1034 ! Compute the equivalent tendency for the conservative mixing ratio
1035 !
1036!$acc kernels
1037 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1038 zrwrnp(iijb:iije,1:ikt) = prhodj(iijb:iije,1:ikt)*(prp(iijb:iije,1:ikt)-prm(iijb:iije,1:ikt,1))&
1039 /ptstep
1040 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1041!$acc end kernels
1042 !
1043 ! replace the flux by the Leonard terms above ZALT and ZCLD_THOLD
1044 IF (turbn%LLEONARD) THEN
1045 zwork1=mzm(prhodj)
1046!$acc kernels
1047 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1048 zwork2(iijb:iije,1:ikt) = zwork1(iijb:iije,1:ikt)*zf_leonard(iijb:iije,1:ikt)
1049 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1050!$acc end kernels
1051 zwork3=gz_w_m(zwork2,pdzz)
1052 !$mnh_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
1053 WHERE ( (zcld_thold(iijb:iije,1:ikt) >= turbn%XCLDTHOLD ) .AND. ( zalt(iijb:iije,1:ikt) >= turbn%XALTHGRAD ) )
1054 zrwrnp(iijb:iije,1:ikt) = -zwork3(iijb:iije,1:ikt)
1055 prp(iijb:iije,1:ikt)=prm(iijb:iije,1:ikt,1)+ptstep*zrwthl(iijb:iije,1:ikt)/prhodj(iijb:iije,1:ikt)
1056 END WHERE
1057 !$mnh_end_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
1058 END IF
1059 !
1060!$acc kernels
1061 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1062 zwork1(iijb:iije,1:ikt) = prp(iijb:iije,1:ikt) - prm(iijb:iije,1:ikt,1)
1063 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1064!$acc end kernels
1065 zwork2=dzm(zwork1)
1066!$acc kernels
1067 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1068 prrs(iijb:iije,1:ikt,1) = prrs(iijb:iije,1:ikt,1) + zrwrnp(iijb:iije,1:ikt)
1069 !
1070 !* 3.2 Complete thermal production
1071 !
1072 ! cons. mixing ratio flux :
1073 !
1074 zflxz(iijb:iije,1:ikt) = zf(iijb:iije,1:ikt) &
1075 + turbn%XIMPL * zdfddrdz(iijb:iije,1:ikt) * zwork2(iijb:iije,1:ikt) / pdzz(iijb:iije,1:ikt)
1076 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1077!$acc end kernels
1078 !
1079 ! replace the flux by the Leonard terms above ZALT and ZCLD_THOLD
1080 IF (turbn%LLEONARD) THEN
1081 !$mnh_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
1082 WHERE ( (zcld_thold(iijb:iije,1:ikt) >= turbn%XCLDTHOLD ) .AND. ( zalt(iijb:iije,1:ikt) >= turbn%XALTHGRAD ) )
1083 zflxz(iijb:iije,1:ikt) = zf_leonard(iijb:iije,1:ikt)
1084 END WHERE
1085 !$mnh_end_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
1086 END IF
1087 !
1088!$acc kernels
1089 !$mnh_expand_array(JIJ=IIJB:IIJE)
1090 zflxz(iijb:iije,ika) = zflxz(iijb:iije,ikb)
1091 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1092!$acc end kernels
1093 !
1094 IF (oocean) THEN
1095!$acc kernels
1096 !$mnh_expand_array(JIJ=IIJB:IIJE)
1097 zflxz(iijb:iije,iku) = zflxz(iijb:iije,ike)
1098 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1099!$acc end kernels
1100 END IF
1101 !
1102 IF ( oflyer ) THEN
1103!$acc kernels
1104 DO jk=iktb+1,ikte-1
1105 !$mnh_expand_array(JIJ=IIJB:IIJE)
1106 pwrc(iijb:iije,jk)=0.5*(zflxz(iijb:iije,jk)+zflxz(iijb:iije,jk+ikl))
1107 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1108 END DO
1109 !$mnh_expand_array(JIJ=IIJB:IIJE)
1110 pwrc(iijb:iije,ikb)=0.5*(zflxz(iijb:iije,ikb)+zflxz(iijb:iije,ikb+ikl))
1111 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1112 !
1113 IF (oocean) THEN
1114 !$mnh_expand_array(JIJ=IIJB:IIJE)
1115 pwrc(iijb:iije,ike)=0.5*(zflxz(iijb:iije,ike)+zflxz(iijb:iije,ike+ikl))
1116 pwrc(iijb:iije,ika)=0.
1117 pwrc(iijb:iije,ike+1)=zflxz(iijb:iije,ike+1)
1118 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1119 ELSE
1120 !$mnh_expand_array(JIJ=IIJB:IIJE)
1121 pwrc(iijb:iije,ika)=0.5*(zflxz(iijb:iije,ika)+zflxz(iijb:iije,ika+ikl))
1122 pwrc(iijb:iije,ike)=pwrc(iijb:iije,ike-ikl)
1123 pwrc(iijb:iije,iku)=0.
1124 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1125 END IF
1126!$acc end kernels
1127 END IF
1128 !
1129 IF ( turbn%LTURB_FLX .AND. tpfile%LOPENED ) THEN
1130!$acc update self(ZFLXZ)
1131 ! stores the conservative mixing ratio vertical flux
1132 CALL io_field_write_phy(d,tpfile,'RCONSW_FLX',zflxz)
1133 END IF
1134 !
1135 ! Contribution of the conservative water flux to the Buoyancy flux
1136 IF (oocean) THEN
1137 za(iijb:iije,:)= -cst%XG * cst%XBETAOC * mzf(zflxz(iijb:iije,:))
1138 ELSE
1139 za(iijb:iije,:) = pbeta(iijb:iije,:) * mzf( mzm(pemoist(iijb:iije,:)) * zflxz(iijb:iije,:) )
1140!$acc kernels
1141 !$mnh_expand_array(JIJ=IIJB:IIJE)
1142 za(iijb:iije,ikb) = pbeta(iijb:iije,ikb) * pemoist(iijb:iije,ikb) * &
1143 0.5 * ( zflxz(iijb:iije,ikb) + zflxz(iijb:iije,ikb+ikl) )
1144 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1145 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1146 ptp(iijb:iije,1:ikt) = ptp(iijb:iije,1:ikt) + za(iijb:iije,1:ikt)
1147 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1148!$acc end kernels
1149 END IF
1150 !
1151 ! Buoyancy flux at flux points
1152 !
1153 pwthv(iijb:iije,:) = pwthv(iijb:iije,:) + mzm(pemoist(iijb:iije,:)) * zflxz(iijb:iije,:)
1154 !
1155!$acc kernels
1156 !$mnh_expand_array(JIJ=IIJB:IIJE)
1157 pwthv(iijb:iije,ikb) = pwthv(iijb:iije,ikb) + pemoist(iijb:iije,ikb) * zflxz(iijb:iije,ikb)
1158 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1159!$acc end kernels
1160 IF (oocean) THEN
1161!$acc kernels
1162 !$mnh_expand_array(JIJ=IIJB:IIJE)
1163 pwthv(iijb:iije,ike) = pwthv(iijb:iije,ike) + pemoist(iijb:iije,ike)* zflxz(iijb:iije,ike)
1164 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1165!$acc end kernels
1166 END IF
1167!
1168!* 3.3 Complete vertical divergence of the < Rc w > flux
1169! Correction of qc and qi negative for AROME
1170IF(turbn%LPROJQITURB) THEN
1171 IF ( krrl >= 1 ) THEN
1172!$acc kernels
1173 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1174 zwork2(iijb:iije,1:ikt) = zflxz(iijb:iije,1:ikt) / &
1175 pdzz(iijb:iije,1:ikt)
1176 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1177!$acc end kernels
1178 zwork1=dzf(zwork2)
1179 !
1180 IF ( krri >= 1 ) THEN
1181!$acc kernels
1182 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1183 prrs(iijb:iije,1:ikt,2) = prrs(iijb:iije,1:ikt,2) - &
1184 prhodj(iijb:iije,1:ikt)*pamoist(iijb:iije,1:ikt)*2.*psrcm(iijb:iije,1:ikt)&
1185 *zwork1(iijb:iije,1:ikt) *(1.0-pfrac_ice(iijb:iije,1:ikt))
1186 prrs(iijb:iije,1:ikt,4) = prrs(iijb:iije,1:ikt,4) - &
1187 prhodj(iijb:iije,1:ikt)*pamoist(iijb:iije,1:ikt)*2.*psrcm(iijb:iije,1:ikt)&
1188 *zwork1(iijb:iije,1:ikt) *pfrac_ice(iijb:iije,1:ikt)
1189 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1190!$acc end kernels
1191 ELSE
1192!$acc kernels
1193 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1194 prrs(iijb:iije,1:ikt,2) = prrs(iijb:iije,1:ikt,2) - &
1195 prhodj(iijb:iije,1:ikt)*pamoist(iijb:iije,1:ikt)*2.*psrcm(iijb:iije,1:ikt)&
1196 *zwork1(iijb:iije,1:ikt)
1197 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1198!$acc end kernels
1199 END IF
1200 END IF
1201END IF
1202!
1203!* 3.4 Storage in LES configuration
1204!
1205 IF (tles%LLES_CALL) THEN
1206 CALL second_mnh(ztime1)
1207 zwkles(:,:) = mzf(zflxz)
1208 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_WRt )
1209 zwkles(:,:) = mzf(pwm(:,:)*zflxz(:,:))
1210 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_W_SBG_WRt )
1211 zwkles(:,:) = gz_w_m(pwm,pdzz)*mzf(zflxz)
1212 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_W_SBG_UaRt )
1213 zwkles(:,:) = mzf(pdth_dz(:,:)*zflxz(:,:))
1214 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_Thl_SBG_UaRt )
1215 zwkles(:,:) = mzf(pdr_dz(:,:)*zflxz(:,:))
1216 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_Rt_SBG_UaRt )
1217 zwkles(:,:) = mzf(mzm(pemoist)*zflxz(:,:))
1218 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_WThv , .true. )
1219 zwkles(:,:) = -pturb_spp(:,:,nctp)*psqrt_tke(:,:)/plm(:,:)*mzf(zflxz)
1220 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_SUBGRID_RtPz )
1221 CALL second_mnh(ztime2)
1222 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
1223 END IF
1224!
1225END IF
1226!
1227!----------------------------------------------------------------------------
1228!
1229!
1230!* 4. TURBULENT CORRELATIONS : <w Rc>
1231! -------------------------------
1232!
1233!
1234!* 4.1 <w Rc>
1235!
1236IF ( ((turbn%LTURB_FLX .AND. tpfile%LOPENED) .OR. tles%LLES_CALL) .AND. (krrl > 0) ) THEN
1237!
1238! recover the Conservative potential temperature flux :
1239! With TURBN%LHARAT is true tke and length scales at half levels
1240! yet modify to use length scale and tke at half levels from vdfexcuhl
1241!$acc kernels
1242 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1243 zwork1(iijb:iije,1:ikt) = turbn%XIMPL * pthlp(iijb:iije,1:ikt) + pexpl * pthlm(iijb:iije,1:ikt)
1244 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1245!$acc end kernels
1246 zwork2=dzm(zwork1)
1247 IF (turbn%LHARAT) THEN
1248!$acc kernels
1249 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1250 za(iijb:iije,1:ikt) = zwork2(iijb:iije,1:ikt)/ pdzz(iijb:iije,1:ikt) * &
1251 (-plm(iijb:iije,1:ikt)*psqrt_tke(iijb:iije,1:ikt))
1252 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1253!$acc end kernels
1254 ELSE
1255!$acc kernels
1256 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1257 zwork1(iijb:iije,1:ikt) = plm(iijb:iije,1:ikt)*psqrt_tke(iijb:iije,1:ikt)
1258 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1259!$acc end kernels
1260 zwork3=mzm(zwork1)
1261!$acc kernels
1262 !$mnh_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1263 za(iijb:iije,1:ikt) = zwork2(iijb:iije,1:ikt)/ pdzz(iijb:iije,1:ikt) * &
1264 (-pphi3(iijb:iije,1:ikt)*zwork3(iijb:iije,1:ikt)) * pturb_spp(iijb:iije,1:ikt,ncshf)
1265 !$mnh_end_expand_array(JIJ=IIJB:IIJE,JK=1:IKT)
1266!$acc end kernels
1267 ENDIF
1268!$acc kernels
1269 !$mnh_expand_array(JIJ=IIJB:IIJE)
1270 za(iijb:iije,ikb) = (turbn%XIMPL*psfthp(iijb:iije) + pexpl*psfthm(iijb:iije)) * pdircoszw(iijb:iije)
1271 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1272!$acc end kernels
1273 !
1274 ! compute <w Rc>
1275 zflxz(iijb:iije,1:ikt) = mzm( pamoist(iijb:iije,1:ikt) * 2.* psrcm(iijb:iije,1:ikt) ) * zflxz(iijb:iije,1:ikt) + &
1276 mzm( patheta(iijb:iije,1:ikt) * 2.* psrcm(iijb:iije,1:ikt) ) * za(iijb:iije,1:ikt)
1277!$acc kernels
1278 !$mnh_expand_array(JIJ=IIJB:IIJE)
1279 zflxz(iijb:iije,ika) = zflxz(iijb:iije,ikb)
1280 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
1281!$acc end kernels
1282 !
1283 ! store the liquid water mixing ratio vertical flux
1284 IF ( turbn%LTURB_FLX .AND. tpfile%LOPENED ) THEN
1285!$acc update self(ZFLXZ)
1286 CALL io_field_write_phy(d,tpfile,'RCW_FLX',zflxz)
1287 END IF
1288 !
1289! and we store in LES configuration this subgrid flux <w'rc'>
1290!
1291 IF (tles%LLES_CALL) THEN
1292 CALL second_mnh(ztime1)
1293 zwork1=mzf(zflxz)
1294 CALL les_mean_subgrid_phy(d,tles,zwork1, tles%X_LES_SUBGRID_WRc )
1295 CALL second_mnh(ztime2)
1296 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
1297 END IF
1298!
1299END IF !end of <w Rc>
1300!
1301!----------------------------------------------------------------------------
1302IF (lhook) CALL dr_hook('TURB_VER_THERMO_FLUX',1,zhook_handle)
1303CONTAINS
1304include "shugrad.h"
1305END SUBROUTINE turb_ver_thermo_flux
1307
real, parameter xundef
integer, parameter nctp
integer, parameter nturb_s
integer, parameter ncshf
subroutine m3_wr_wth2(d, csturb, turbn, pd, pkeff, ptke, psqrt_tke, pbll_o_e, pbeta, pleps, petheta, pdrdz, pm3_wr_wth2, pturb_spp)
subroutine d_phi3dtdz_o_ddtdz(d, csturb, turbn, pphi3, predth1, predr1, pred2th3, pred2thr3, hturbdim, ouserv, pd_phi3dtdz_o_ddtdz)
subroutine d_m3_wth_wr2_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, pkeff, ptke, psqrt_tke, pbll_o_e, pbeta, pleps, pemoist, pd_m3_wth_wr2_o_ddtdz, pturb_spp)
subroutine d_m3_wr_wth2_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, pkeff, ptke, psqrt_tke, pbll_o_e, pbeta, pleps, petheta, pd_m3_wr_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_wth_w2th_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, pbll_o_e, petheta, pkeff, ptke, pd_m3_wth_w2th_o_ddtdz, pturb_spp)
subroutine m3_wth_w2th(d, csturb, turbn, predth1, predr1, pd, pkeff, ptke, pm3_wth_w2th, pturb_spp)
subroutine d_m3_wr_wthr_o_ddrdz(d, csturb, turbn, pm3_wr_wthr, predr1, predth1, pd, pbll_o_e, pemoist, pd_m3_wr_wthr_o_ddrdz, pturb_spp)
subroutine m3_wr_wr2(d, csturb, turbn, predr1, predth1, pd, pbll_o_e, pemoist, pm3_wr_wr2, pturb_spp)
subroutine m3_wr_wthr(d, csturb, turbn, predth1, pd, pkeff, ptke, psqrt_tke, pbeta, pleps, petheta, pm3_wr_wthr, pturb_spp)
subroutine d_m3_wr_wr2_o_ddrdz(d, csturb, turbn, pm3_wr_wr2, predr1, predth1, pd, pbll_o_e, pemoist, pd_m3_wr_wr2_o_ddrdz, pturb_spp)
subroutine m3_wth_wr2(d, csturb, turbn, pd, pkeff, ptke, psqrt_tke, pbll_o_e, pbeta, pleps, pemoist, pdtdz, pm3_wth_wr2, pturb_spp)
subroutine d_m3_wth_wth2_o_ddtdz(d, csturb, turbn, pm3_wth_wth2, predth1, predr1, pd, pbll_o_e, petheta, pd_m3_wth_wth2_o_ddtdz, pturb_spp)
subroutine d_m3_wr_w2r_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, pbll_o_e, pemoist, pkeff, ptke, pd_m3_wr_w2r_o_ddrdz, pturb_spp)
subroutine d_m3_wth_wthr_o_ddtdz(d, csturb, turbn, pm3_wth_wthr, predth1, predr1, pd, pbll_o_e, petheta, pd_m3_wth_wthr_o_ddtdz, pturb_spp)
subroutine d_m3_wr_w2th_o_ddrdz(d, csturb, turbn, predr1, predth1, pd, pkeff, ptke, pbll_o_e, petheta, pd_m3_wr_w2th_o_ddrdz, pturb_spp)
subroutine m3_wth_wthr(d, csturb, turbn, predr1, pd, pkeff, ptke, psqrt_tke, pbeta, pleps, pemoist, pm3_wth_wthr, pturb_spp)
subroutine m3_wr_w2th(d, csturb, turbn, pd, pkeff, ptke, pbll_o_e, petheta, pdrdz, pm3_wr_w2th, pturb_spp)
subroutine m3_wth_wth2(d, csturb, turbn, predth1, predr1, pd, pbll_o_e, petheta, pm3_wth_wth2, pturb_spp)
subroutine m3_wth_w2r(d, csturb, turbn, pd, pkeff, ptke, pbll_o_e, pemoist, pdtdz, pm3_wth_w2r, pturb_spp)
subroutine d_m3_wth_w2r_o_ddtdz(d, csturb, turbn, predth1, predr1, pd, pkeff, ptke, pbll_o_e, pemoist, pd_m3_wth_w2r_o_ddtdz, pturb_spp)
subroutine m3_wr_w2r(d, csturb, turbn, predr1, predth1, pd, pkeff, ptke, pm3_wr_w2r, pturb_spp)
subroutine tm06_h(d, turbn, ptstep, pzz, pflxz, pbl_depth)
subroutine tridiag_thermo(d, pvarm, pf, pdfddtdz, ptstep, turbn_pimpl, pdzz, prhodj, pvarp)
subroutine turb_ver_thermo_flux(d, cst, csturb, turbn, tles, krr, krrl, krri, ksv, kgradients, oocean, odeepoc, oflyer, ocouples, ocompute_src, pexpl, ptstep, tpfile, pdxx, pdyy, pdzz, pdzx, pdzy, pdircoszw, pzz, prhodj, pthvref, phgrad, pzs, psfthm, psfrm, psfthp, psfrp, pwm, pthlm, prm, psvm, ptkem, plm, pleps, plocpexnm, patheta, pamoist, psrcm, pfrac_ice, 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, mfmoist, pbl_depth, pwthv, prthls, prrs, pthlp, prp, ptp, pwth, pwrc, psstfl, psstfl_c, pssrfl_c, pturb_spp)
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)) dzf(pin)
Definition shugrad.h:158
real function, dimension(size(pin, 1), size(pin, 2)) myf(pin)
Definition shugrad.h:80
real function, dimension(size(pa, 1), size(pa, 2)) gz_w_m(pa, pdzz)
Definition shugrad.h:598
real function, dimension(size(pin, 1), size(pin, 2)) mxf(pin)
Definition shugrad.h:18
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