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