PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
mode_turb_hor_uw.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! ################################################################
10 SUBROUTINE turb_hor_uw(D,TURBN,TLES,KSPLT, &
11 KRR,KSV,OFLAT, &
12 TPFILE, &
13 PK,PINV_PDXX,PINV_PDZZ,PMZM_PRHODJ, &
14 PDXX,PDZZ,PDZX, &
15 PRHODJ,PTHVREF, &
16 PUM,PWM,PTHLM,PRM,PSVM, &
17 PTKEM,PLM, &
18 PTURB_SPP,PDP, &
19 PRUS,PRWS )
20! ################################################################
21!
22!
23!!**** *TURB_HOR* -routine to compute the source terms in the meso-NH
24!! model equations due to the non-vertical turbulent fluxes.
25!!
26!! PURPOSE
27!! -------
28!!
29!! see TURB_HOR
30!!
31!!** METHOD
32!! ------
33!!
34!! EXTERNAL
35!! --------
36!!
37!! IMPLICIT ARGUMENTS
38!! ------------------
39!!
40!! REFERENCE
41!! ---------
42!!
43!! AUTHOR
44!! ------
45!!
46!! Joan Cuxart * INM and Meteo-France *
47!!
48!! MODIFICATIONS
49!! -------------
50!! Aug , 1997 (V. Saravane) spliting of TURB_HOR
51!! Nov 27, 1997 (V. Masson) clearing of the routine
52!! Oct 18, 2000 (V. Masson) LES computations + OFLAT switch
53!! Feb 14, 2001 (V. Masson and J. Stein) DZF bug on PRWS
54!! + remove the use of W=0 at the ground
55!! + extrapolation under the ground
56!! Nov 06, 2002 (V. Masson) LES budgets
57!! October 2009 (G. Tanguy) add ILENCH=LEN(YCOMMENT) after
58!! change of YCOMMENT
59!! 04/2016 (M.Moge) Use openACC directives to port the TURB part of Meso-NH on GPU
60!! Philippe Wautelet: 05/2016-04/2018: new data structures and calls for I/O
61!! --------------------------------------------------------------------------
62!
63!* 0. DECLARATIONS
64! ------------
65!
68!
70USE modd_io, ONLY: tfiledata
71USE modd_parameters, ONLY: jpvext
72USE modd_les, ONLY: tles_t
73!
75!
77!
78USE modi_second_mnh, ONLY: second_mnh
79!
80IMPLICIT NONE
81!
82!
83!* 0.1 declaration of arguments
84!
85!
86!
87TYPE(dimphyex_t), INTENT(IN) :: D
88TYPE(turb_t), INTENT(IN) :: TURBN
89TYPE(tles_t), INTENT(INOUT) :: TLES ! modd_les structure
90INTEGER, INTENT(IN) :: KSPLT ! split process index
91INTEGER, INTENT(IN) :: KRR ! number of moist var.
92INTEGER, INTENT(IN) :: KSV ! number of sv var.
93LOGICAL, INTENT(IN) :: OFLAT ! Logical for zero ororography
94TYPE(tfiledata), INTENT(INOUT) :: TPFILE ! Output file
95!
96
97REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PK ! Turbulent diffusion doef.
98 ! PK = PLM * SQRT(PTKEM)
99REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PINV_PDXX ! 1./PDXX
100REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PINV_PDZZ ! 1./PDZZ
101REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PMZM_PRHODJ ! MZM(PRHODJ)
102REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDXX, PDZZ, PDZX
103 ! Metric coefficients
104REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRHODJ ! density * grid volume
105REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTHVREF ! ref. state VPT
106!
107! Variables at t-1
108REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PUM,PWM,PTHLM
109REAL, DIMENSION(D%NIJT,D%NKT,KRR), INTENT(IN) :: PRM
110REAL, DIMENSION(D%NIJT,D%NKT,KSV), INTENT(IN) :: PSVM
111!
112REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTKEM ! TKE at time t- dt
113REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PLM ! Turb. mixing length
114REAL, DIMENSION(D%NIJT,D%NKT,NTURB_S), INTENT(IN) :: PTURB_SPP ! SPP for turbulence
115!
116REAL, DIMENSION(D%NIJT,D%NKT), INTENT(INOUT) :: PRUS, PRWS
117REAL, DIMENSION(D%NIJT,D%NKT), INTENT(INOUT) :: PDP ! TKE production terms
118!
119!
120!
121!
122!* 0.2 declaration of local variables
123!
124REAL, DIMENSION(D%NIJT,D%NKT) :: ZFLX,ZWORK
125 ! work arrays
126!
127INTEGER :: IKB,IKE,IKU, IIJT, IKT
128 ! Index values for the Beginning and End
129 ! mass points of the domain
130INTEGER :: JSV,JIJ,JK ! scalar loop counter
131!
132REAL, DIMENSION(D%NIJT,D%NKT) :: GX_W_UW_PWM
133!
134REAL :: ZTIME1, ZTIME2
135TYPE(tfieldmetadata) :: TZFIELD
136!
137!
138! ---------------------------------------------------------------------------
139!
140!* 1. PRELIMINARY COMPUTATIONS
141! ------------------------
142!
143!
144ikb = 1+jpvext
145ike = SIZE(pwm,2)-jpvext
146iku = SIZE(pwm,2)
147iijt=d%NIJT
148ikt=d%NKT
149!
150!
151gx_w_uw_pwm = gx_w_uw(oflat,pwm,pdxx,pdzz,pdzx)
152!
153!
154!* 13. < U'W'>
155! -------
156!
157! residual part of < U'W'> depending on dw/dx
158!
159zflx(:,:) = &
160 - pturb_spp(:,:,ncmfs) * mxm(mzm(pk)) * gx_w_uw_pwm
161!! & to be tested
162!! - (2./3.) * XCMFB * MZM( ZVPTU * MXM( PLM / SQRT(PTKEM) * XG / PTHVREF ) )
163!
164!$acc kernels
165!$mnh_expand_array(JIJ=1:IIJT)
166zflx(:,ike+1) = 0. ! rigid wall condition => no turbulent flux
167!
168! Nullify the flux at the ground level because it has been fully taken into
169! account in turb_ver and extrapolate the flux under the ground
170zflx(:,ikb) = 0.
171zflx(:,ikb-1)=2.*zflx(:,ikb)- zflx(:,ikb+1)
172!$mnh_end_expand_array(JIJ=1:IIJT)
173!$acc end kernels
174!
175! stores <U W>
176IF ( tpfile%LOPENED .AND. turbn%LTURB_FLX ) THEN
177 tzfield = tfieldmetadata( &
178 cmnhname = 'UW_HFLX', &
179 cstdname = '', &
180 clongname = 'UW_HFLX', &
181 cunits = 'm2 s-2', &
182 cdir = 'XY', &
183 ccomment = 'X_Y_Z_UW_HFLX', &
184 ngrid = 6, &
185 ntype = typereal, &
186 ndims = 3, &
187 ltimedep = .true. )
188!$acc update self(ZFLX)
189 CALL io_field_write_phy(d,tpfile,tzfield,zflx)
190END IF
191!
192!
193! compute the source for rho*U due to this residual flux ( the other part is
194! taken into account in TURB_VER)
195prus(:,:) = prus(:,:) - dzf( zflx* mxm( pmzm_prhodj ) / mxm( pdzz ) )
196!
197!computation of the source for rho*W due to this flux
198IF (.NOT. oflat) THEN
199 prws(:,:) = prws(:,:) &
200 -dxf( mzm( mxm(prhodj) * pinv_pdxx) * zflx) &
201 +dzm( prhodj * mxf( mzf( zflx*pdzx ) * pinv_pdxx ) / mzf(pdzz) )
202ELSE
203 prws(:,:) = prws(:,:) -dxf( mzm( mxm(prhodj) * pinv_pdxx) * zflx)
204END IF
205!
206IF (ksplt==1) THEN
207 !
208 !Contribution to the dynamic production of TKE:
209 !
210 zwork(:,:) =-mzf( mxf( &
211 zflx *( gz_u_uw(pum,pdzz) + gx_w_uw_pwm ) ) )
212 !
213 !
214 ! evaluate the dynamic production at w(IKB+1) in PDP(IKB)
215 zwork(:,ikb) = - mxf2d( &
216 zflx(:,ikb+1) * &
217 ( (pum(:,ikb+1)-pum(:,ikb)) / mxm2d(pdzz(:,ikb+1))&
218 + ( dxm2d( pwm(:,ikb+1) ) &
219 -mxm2d( (pwm(:,ikb+2)-pwm(:,ikb+1)) &
220 /(pdzz(:,ikb+2)+pdzz(:,ikb+1)) &
221 +(pwm(:,ikb+1)-pwm(:,ikb)) &
222 /(pdzz(:,ikb+1)+pdzz(:,ikb)) &
223 ) &
224 * pdzx(:,ikb+1) &
225 ) / (0.5*(pdxx(:,ikb+1)+pdxx(:,ikb))) &
226 ) )
227 !
228 ! dynamic production computation
229 !$acc kernels
230 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
231 pdp(1:iijt,1:ikt) = pdp(1:iijt,1:ikt) + zwork(1:iijt,1:ikt)
232 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
233 !$acc end kernels
234 !
235END IF
236!
237! Storage in the LES configuration (addition to TURB_VER computation)
238!
239IF (tles%LLES_CALL .AND. ksplt==1) THEN
240 CALL second_mnh(ztime1)
241 CALL les_mean_subgrid_phy(d, tles, mzf(mxf(zflx)), tles%X_LES_SUBGRID_WU , .true. )
242 CALL les_mean_subgrid_phy(d, tles, mzf(mxf(gz_u_uw(pum,pdzz)*zflx)), tles%X_LES_RES_ddxa_U_SBG_UaU , .true.)
243 CALL les_mean_subgrid_phy(d, tles, mzf(mxf(gx_w_uw_pwm*zflx)), tles%X_LES_RES_ddxa_W_SBG_UaW , .true.)
244 CALL les_mean_subgrid_phy(d, tles, mxf(gx_m_u(oflat,pthlm,pdxx,pdzz,pdzx)*mzf(zflx)),&
245 tles%X_LES_RES_ddxa_Thl_SBG_UaW , .true.)
246 IF (krr>=1) THEN
247 CALL les_mean_subgrid_phy(d, tles, mxf(gx_m_u(oflat,prm(:,:,1),pdxx,pdzz,pdzx)*mzf(zflx)), &
248 tles%X_LES_RES_ddxa_Rt_SBG_UaW , .true.)
249 END IF
250 DO jsv=1,ksv
251 CALL les_mean_subgrid_phy(d, tles, mxf(gx_m_u(oflat,psvm(:,:,jsv),pdxx,pdzz,pdzx)*mzf(zflx)), &
252 tles%X_LES_RES_ddxa_Sv_SBG_UaW(:,:,:,jsv) , .true.)
253 END DO
254 CALL second_mnh(ztime2)
255 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
256END IF
257
258!
259CONTAINS
260include "shugrad.h"
261END SUBROUTINE turb_hor_uw
262END MODULE mode_turb_hor_uw
integer, parameter typereal
Definition modd_field.F90:9
integer, parameter jpvext
integer, parameter nturb_s
integer, parameter ncmfs
subroutine turb_hor_uw(d, turbn, tles, ksplt, krr, ksv, oflat, tpfile, pk, pinv_pdxx, pinv_pdzz, pmzm_prhodj, pdxx, pdzz, pdzx, prhodj, pthvref, pum, pwm, pthlm, prm, psvm, ptkem, plm, pturb_spp, pdp, prus, prws)
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)) 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)) dxm2d(pin)
Definition shugrad.h:220
real function, dimension(size(pin, 1), size(pin, 2)) mxm(pin)
Definition shugrad.h:49
real function, dimension(size(pin, 1)) mxf2d(pin)
Definition shugrad.h:33
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(pa, 1), size(pa, 2)) gx_w_uw(oflat, pa, pdxx, pdzz, pdzx)
Definition shugrad.h:617
real function, dimension(size(pin, 1), size(pin, 2)) dzm(pin)
Definition shugrad.h:298
real function, dimension(size(py, 1), size(py, 2)) gx_m_u(oflat, py, pdxx, pdzz, pdzx)
Definition shugrad.h:340
real function, dimension(size(pa, 1), size(pa, 2)) gz_u_uw(pa, pdzz)
Definition shugrad.h:508