PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
mode_turb_hor_tke.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!-----------------------------------------------------------------
7IMPLICIT NONE
8CONTAINS
9 SUBROUTINE turb_hor_tke(D,KSPLT,TLES,OFLAT,O2D, &
10 PDXX, PDYY, PDZZ,PDZX,PDZY, &
11 PINV_PDXX, PINV_PDYY, PINV_PDZZ, PMZM_PRHODJ, &
12 PK, PRHODJ, PTKEM, &
13 PTRH )
14! ################################################################
15!
16!
17!!**** *TURB_HOR_TKE* computes the horizontal turbulant transports of Tke
18!!
19!! PURPOSE
20!! -------
21
22!!** METHOD
23!! ------
24!!
25!!
26!!
27!! EXTERNAL
28!! --------
29!!
30!! IMPLICIT ARGUMENTS
31!! ------------------
32!!
33!!
34!! REFERENCE
35!! ---------
36!!
37!! AUTHOR
38!! ------
39!! Joan Cuxart * INM and Meteo-France *
40!!
41!! MODIFICATIONS
42!! -------------
43!! Original Aug 29, 1994
44!! Mar 07 2001 (V. Masson and J. Stein) new routine
45!! Nov 06, 2002 (V. Masson) LES budgets
46!! 04/2016 (M.Moge) Use openACC directives to port the TURB part of Meso-NH on GPU
47!! --------------------------------------------------------------------------
48!
49!* 0. DECLARATIONS
50! ------------
51!
53USE modd_cturb, ONLY: cturb_xcet => xcet
54USE modd_parameters, ONLY: jpvext
55USE modd_les, ONLY: tles_t
56!
57!
59!
60USE modi_second_mnh, ONLY: second_mnh
61!
62IMPLICIT NONE
63!
64!
65!* 0.1 declaration of arguments
66!
67!
68TYPE(dimphyex_t), INTENT(IN) :: D
69TYPE(tles_t), INTENT(INOUT) :: TLES ! modd_les structure
70INTEGER, INTENT(IN) :: KSPLT ! current split index
71LOGICAL, INTENT(IN) :: OFLAT ! Logical for zero ororography
72LOGICAL, INTENT(IN) :: O2D ! Logical for 2D model version (modd_conf)
73REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDXX, PDYY, PDZZ, PDZX, PDZY
74 ! Metric coefficients
75REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PK ! Turbulent diffusion doef.
76 ! PK = PLM * SQRT(PTKEM)
77REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PINV_PDXX ! 1./PDXX
78REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PINV_PDYY ! 1./PDYY
79REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PINV_PDZZ ! 1./PDZZ
80REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PMZM_PRHODJ ! MZM(PRHODJ)
81REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRHODJ ! density * grid volume
82!
83!
84REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTKEM ! TKE at time t- dt
85REAL, DIMENSION(D%NIJT,D%NKT), INTENT(OUT) :: PTRH ! horizontal transport of Tke
86!
87!
88!
89!* 0.2 declaration of local variables
90!
91INTEGER :: IKB, IKU, IIJT, IKT, JIJ
92!
93REAL, DIMENSION(D%NIJT,1+JPVEXT:3+JPVEXT) :: ZCOEFF
94 ! coefficients for the uncentred gradient
95 ! computation near the ground
96!
97REAL, DIMENSION(D%NIJT,D%NKT):: ZFLX
98!
99REAL :: ZTIME1, ZTIME2
100!
101REAL :: XCET
102! ---------------------------------------------------------------------------
103!
104!* 1. PRELIMINARY COMPUTATIONS
105! ------------------------
106!
107xcet = cturb_xcet
108!
109ikb = 1.+jpvext
110iku = SIZE(ptkem,2)
111iijt=d%NIJT
112ikt=d%NKT
113!
114! compute the coefficients for the uncentred gradient computation near the
115! ground
116!
117!$acc kernels
118!$mnh_expand_array(JIJ=1:IIJT)
119zcoeff(:,ikb+2)= - pdzz(:,ikb+1) / &
120 ( (pdzz(:,ikb+2)+pdzz(:,ikb+1)) * pdzz(:,ikb+2) )
121zcoeff(:,ikb+1)= (pdzz(:,ikb+2)+pdzz(:,ikb+1)) / &
122 ( pdzz(:,ikb+1) * pdzz(:,ikb+2) )
123zcoeff(:,ikb)= - (pdzz(:,ikb+2)+2.*pdzz(:,ikb+1)) / &
124 ( (pdzz(:,ikb+2)+pdzz(:,ikb+1)) * pdzz(:,ikb+1) )
125!$mnh_end_expand_array(JIJ=1:IIJT)
126!$acc end kernels
127!
128!--------------------------------------------------------------------
129!
130!* 2. horizontal transport of Tke u'e
131! -------------------------------
132!
133!
134zflx = -xcet * mxm(pk) * gx_m_u(oflat,ptkem,pdxx,pdzz,pdzx) ! < u'e >
135!
136! special case near the ground ( uncentred gradient )
137!
138!$acc kernels
139!$mnh_expand_array(JIJ=1:IIJT)
140zflx(:,ikb) = zcoeff(:,ikb+2)*ptkem(:,ikb+2) &
141 + zcoeff(:,ikb+1)*ptkem(:,ikb+1) &
142 + zcoeff(:,ikb )*ptkem(:,ikb )
143!$mnh_end_expand_array(JIJ=1:IIJT)
144!$acc end kernels
145!
146zflx(:,ikb) = &
147 - xcet * mxm2d( pk(:,ikb) ) * ( &
148 dxm2d( ptkem(:,ikb) ) * pinv_pdxx(:,ikb) &
149 -mxm2d( zflx(:,ikb) ) * pinv_pdxx(:,ikb) &
150 * 0.5 * ( pdzx(:,ikb+1) + pdzx(:,ikb) ) )
151!
152! extrapolate the fluxes to obtain < u'e > = 0 at the ground
153!
154!$acc kernels
155!$mnh_expand_array(JIJ=1:IIJT)
156zflx(:,ikb-1) = - zflx(:,ikb)
157!
158! let the same flux at IKU-1 and IKU level
159!
160zflx(:,iku) = zflx(:,iku-1)
161!$mnh_end_expand_array(JIJ=1:IIJT)
162!$acc end kernels
163!
164IF (.NOT. oflat) THEN
165 ptrh =-( dxf( mxm(prhodj) * zflx * pinv_pdxx)&
166 - dzf( pmzm_prhodj * mxf( pdzx * mzm(zflx*pinv_pdxx)) * pinv_pdzz)&
167 ) /prhodj
168ELSE
169 ptrh =-( dxf( mxm(prhodj) * zflx * pinv_pdxx)&
170 ) /prhodj
171END IF
172!
173IF (tles%LLES_CALL .AND. ksplt==1) THEN
174 CALL second_mnh(ztime1)
175 CALL les_mean_subgrid_phy(d, tles, mxf(zflx), tles%X_LES_SUBGRID_UTke )
176 CALL second_mnh(ztime2)
177 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
178END IF
179!
180!
181!--------------------------------------------------------------------
182!
183!* 3. horizontal transport of Tke v'e
184! -------------------------------
185!
186IF (.NOT. o2d) THEN
187 zflx =-xcet * mym(pk) * gy_m_v(oflat,ptkem,pdyy,pdzz,pdzy) ! < v'e >
188!
189! special case near the ground ( uncentred gradient )
190!
191!$acc kernels
192!$mnh_expand_array(JIJ=1:IIJT)
193 zflx(:,ikb) = zcoeff(:,ikb+2)*ptkem(:,ikb+2) &
194 + zcoeff(:,ikb+1)*ptkem(:,ikb+1) &
195 + zcoeff(:,ikb )*ptkem(:,ikb )
196!
197!$mnh_end_expand_array(JIJ=1:IIJT)
198!$acc end kernels
199 zflx(:,ikb) = &
200 - xcet * mym2d( pk(:,ikb) ) * ( &
201 dym2d( ptkem(:,ikb) ) * pinv_pdyy(:,ikb) &
202 - mym2d( zflx(:,ikb) ) * pinv_pdyy(:,ikb) &
203 * 0.5 * ( pdzy(:,ikb+1) + pdzy(:,ikb) ) )
204!
205! extrapolate the fluxes to obtain < v'e > = 0 at the ground
206!
207!$acc kernels
208!$mnh_expand_array(JIJ=1:IIJT)
209 zflx(:,ikb-1) = - zflx(:,ikb)
210!
211! let the same flux at IKU-1 and IKU level
212!
213 zflx(:,iku) = zflx(:,iku-1)
214!$mnh_end_expand_array(JIJ=1:IIJT)
215!$acc end kernels
216!
217! complete the explicit turbulent transport
218!
219 IF (.NOT. oflat) THEN
220 ptrh = ptrh - ( dyf( mym(prhodj) * zflx * pinv_pdyy ) &
221 - dzf( pmzm_prhodj * myf( pdzy * mzm(zflx*pinv_pdyy) ) * pinv_pdzz ) &
222 ) /prhodj
223 ELSE
224 ptrh = ptrh - ( dyf( mym(prhodj) * zflx * pinv_pdyy ) &
225 ) /prhodj
226 END IF
227!
228 IF (tles%LLES_CALL .AND. ksplt==1) THEN
229 CALL second_mnh(ztime1)
230 CALL les_mean_subgrid_phy(d, tles, myf(zflx), tles%X_LES_SUBGRID_VTke )
231 CALL second_mnh(ztime2)
232 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
233 END IF
234!
235END IF
236!
237!----------------------------------------------------------------------------
238!
239CONTAINS
240include "shugrad.h"
241END SUBROUTINE turb_hor_tke
242END MODULE mode_turb_hor_tke
real, pointer xcet
integer, parameter jpvext
subroutine turb_hor_tke(d, ksplt, tles, oflat, o2d, pdxx, pdyy, pdzz, pdzx, pdzy, pinv_pdxx, pinv_pdyy, pinv_pdzz, pmzm_prhodj, pk, prhodj, ptkem, ptrh)
subroutine second_mnh(xt)
Definition second_mnh.F90:2
real function, dimension(size(pin, 1), size(pin, 2)) dyf(pin)
Definition shugrad.h:236
real function, dimension(size(pin, 1), size(pin, 2)) mym(pin)
Definition shugrad.h:111
real function, dimension(size(pin, 1), size(pin, 2)) dxf(pin)
Definition shugrad.h:174
real function, dimension(size(pin, 1), size(pin, 2)) dzf(pin)
Definition shugrad.h:158
real function, dimension(size(pin, 1)) dym2d(pin)
Definition shugrad.h:282
real function, dimension(size(py, 1), size(py, 2)) gy_m_v(oflat, py, pdyy, pdzz, pdzy)
Definition shugrad.h:392
real function, dimension(size(pin, 1)) dxm2d(pin)
Definition shugrad.h:220
real function, dimension(size(pin, 1), size(pin, 2)) myf(pin)
Definition shugrad.h:80
real function, dimension(size(pin, 1), size(pin, 2)) mxm(pin)
Definition shugrad.h:49
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)) mxm2d(pin)
Definition shugrad.h:64
real function, dimension(size(pin, 1)) mym2d(pin)
Definition shugrad.h:126
real function, dimension(size(py, 1), size(py, 2)) gx_m_u(oflat, py, pdxx, pdzz, pdzx)
Definition shugrad.h:340