PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
mode_turb_hor_dyn_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!-----------------------------------------------------------------
7IMPLICIT NONE
8CONTAINS
9 SUBROUTINE turb_hor_dyn_corr(D,TURBN,TLES,KSPLT, PTSTEP, &
10 KRR, KSV,OFLAT,O2D, &
11 TPFILE, &
12 PK,PINV_PDZZ, &
13 PDXX,PDYY,PDZZ,PDZX,PDZY,PZZ, &
14 PDIRCOSZW, &
15 PCOSSLOPE,PSINSLOPE, &
16 PRHODJ, &
17 PCDUEFF,PTAU11M,PTAU12M,PTAU22M,PTAU33M, &
18 PUM,PVM,PWM,PUSLOPEM,PVSLOPEM, &
19 PTHLM,PRM,PSVM, &
20 PTKEM,PLM,PTURB_SPP, &
21 PDP,PTP, &
22 PRUS,PRVS,PRWS )
23! ################################################################
24!
25!!**** *TURB_HOR* -routine to compute the source terms in the meso-NH
26!! model equations due to the non-vertical turbulent fluxes.
27!!
28!! PURPOSE
29!! -------
30!!
31!! see TURB_HOR
32!!
33!!** METHOD
34!! ------
35!!
36!! EXTERNAL
37!! --------
38!!
39!! IMPLICIT ARGUMENTS
40!! ------------------
41!!
42!! REFERENCE
43!! ---------
44!!
45!! AUTHOR
46!! ------
47!!
48!! Joan Cuxart * INM and Meteo-France *
49!!
50!! MODIFICATIONS
51!! -------------
52!! Aug , 1997 (V. Saravane) spliting of TURB_HOR
53!! Nov 27, 1997 (V. Masson) clearing of the routine
54!! Oct 18, 2000 (V. Masson) LES computations + OFLAT switch
55!! Feb 15, 2001 (J. Stein) remove the use of w=0 at the
56!! ground
57!! Mar 12, 2001 (V. Masson and J. Stein) major bugs
58!! + change of discretization at the surface
59!! Nov 06, 2002 (V. Masson) LES budgets
60!! October 2009 (G. Tanguy) add ILENCH=LEN(YCOMMENT) after
61!! change of YCOMMENT
62!! July 2012 (V.Masson) Implicitness of W
63!! March 2014 (V.Masson) tridiag_w : bug between
64!! mass and flux position
65!! J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1
66!! M.Moge 04/2016 Use openACC directives to port the TURB part of Meso-NH on GPU
67!! Philippe Wautelet: 05/2016-04/2018: new data structures and calls for I/O
68! P. Wautelet 20/05/2019: add name argument to ADDnFIELD_ll + new ADD4DFIELD_ll subroutine
69! J.Escobar 13/08/2020: PGI/NVHPC BUG , extend DO CONCURRENT to 3D indexes
70!! --------------------------------------------------------------------------
71!
72!* 0. DECLARATIONS
73! ------------
74!
77!
80USE modd_io, ONLY: tfiledata
81USE modd_parameters, ONLY: jpvext
82USE modd_les, ONLY: tles_t
83!
87!
88#ifdef MNH_OPENACC
89USE modi_get_halo, ONLY: get_halo_d
90#endif
93!
94USE modi_second_mnh, ONLY: second_mnh
95!
96! These macro are handled by pft_tool.py --craybyPassDOCONCURRENT applied on Cray Rules
97#ifdef MNH_COMPILER_CCE
98!$mnh_undef(LOOP)
99!$mnh_undef(OPENACC)
100#endif
101!
102IMPLICIT NONE
103!
104!
105!* 0.1 declaration of arguments
106!
107!
108!
109TYPE(dimphyex_t), INTENT(IN) :: D
110TYPE(turb_t), INTENT(IN) :: TURBN
111TYPE(tles_t), INTENT(INOUT) :: TLES ! modd_les structure
112INTEGER, INTENT(IN) :: KSPLT ! split process index
113REAL, INTENT(IN) :: PTSTEP ! timestep
114INTEGER, INTENT(IN) :: KRR ! number of moist var.
115INTEGER, INTENT(IN) :: KSV ! number of sv var.
116LOGICAL, INTENT(IN) :: OFLAT ! Logical for zero ororography
117LOGICAL, INTENT(IN) :: O2D ! Logical for 2D model version (modd_conf)
118TYPE(tfiledata), INTENT(INOUT) :: TPFILE ! Output file
119!
120REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PK ! Turbulent diffusion doef.
121 ! PK = PLM * SQRT(PTKEM)
122REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PINV_PDZZ ! 1./PDZZ
123REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDXX, PDYY, PDZZ, PDZX, PDZY
124 ! Metric coefficients
125REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PZZ ! vertical grid
126REAL, DIMENSION(D%NIJT), INTENT(IN) :: PDIRCOSZW
127! Director Cosinus along z directions at surface w-point
128REAL, DIMENSION(D%NIJT), INTENT(IN) :: PCOSSLOPE ! cosinus of the angle
129 ! between i and the slope vector
130REAL, DIMENSION(D%NIJT), INTENT(IN) :: PSINSLOPE ! sinus of the angle
131 ! between i and the slope vector
132REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PRHODJ ! density * grid volume
133!
134REAL, DIMENSION(D%NIJT), INTENT(IN) :: PCDUEFF ! Cd * || u || at time t
135REAL, DIMENSION(D%NIJT), INTENT(IN) :: PTAU11M ! <uu> in the axes linked
136 ! to the maximum slope direction and the surface normal and the binormal
137 ! at time t - dt
138REAL, DIMENSION(D%NIJT), INTENT(IN) :: PTAU12M ! <uv> in the same axes
139REAL, DIMENSION(D%NIJT), INTENT(IN) :: PTAU22M ! <vv> in the same axes
140REAL, DIMENSION(D%NIJT), INTENT(IN) :: PTAU33M ! <ww> in the same axes
141!
142! Variables at t-1
143REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PUM,PVM,PWM,PTHLM
144REAL, DIMENSION(D%NIJT,D%NKT,KRR), INTENT(IN) :: PRM
145REAL, DIMENSION(D%NIJT,D%NKT,KSV), INTENT(IN) :: PSVM
146REAL, DIMENSION(D%NIJT), INTENT(IN) :: PUSLOPEM ! wind component along the
147 ! maximum slope direction
148REAL, DIMENSION(D%NIJT), INTENT(IN) :: PVSLOPEM ! wind component along the
149 ! direction normal to the maximum slope one
150!
151REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PTKEM ! TKE at time t- dt
152REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PLM ! Turb. mixing length
153REAL, DIMENSION(D%NIJT,D%NKT,NTURB_S), INTENT(IN) :: PTURB_SPP ! Turb. SPP
154!
155REAL, DIMENSION(D%NIJT,D%NKT), INTENT(INOUT) :: PRUS, PRVS, PRWS
156REAL, DIMENSION(D%NIJT,D%NKT), INTENT(INOUT) :: PDP,PTP ! TKE production terms
157!
158!
159!
160!* 0.2 declaration of local variables
161!
162REAL, DIMENSION(D%NIJT,D%NKT) :: ZFLX,ZWORK,ZWKLES
163 ! work arrays, PK is the turb. mixing coef.
164!
165REAL, DIMENSION(D%NIJT) ::ZDIRSINZW
166 ! sinus of the angle between the vertical and the normal to the orography
167INTEGER :: IKB,IKE
168 ! Index values for the Beginning and End
169 ! mass points of the domain
170INTEGER :: IKU,IKT,IIJT
171INTEGER :: JSV,JIJ,JK ! scalar loop counter
172!
173REAL, DIMENSION(D%NIJT,D%NKT) :: GX_U_M_PUM
174REAL, DIMENSION(D%NIJT,D%NKT) :: GY_V_M_PVM
175REAL, DIMENSION(D%NIJT,D%NKT) :: GZ_W_M_PWM
176REAL, DIMENSION(D%NIJT,D%NKT) :: GZ_W_M_ZWP
177REAL, DIMENSION(D%NIJT,D%NKT) :: ZMZF_DZZ ! MZF(PDZZ)
178REAL, DIMENSION(D%NIJT,D%NKT) :: ZDFDDWDZ ! formal derivative of the
179! ! flux (variable: dW/dz)
180REAL, DIMENSION(D%NIJT,D%NKT) :: ZWP ! W at future time-step
181!
182REAL, DIMENSION(D%NIJT) :: ZDU_DZ_DZS_DX ! du/dz*dzs/dx surf
183REAL, DIMENSION(D%NIJT) :: ZDV_DZ_DZS_DY ! dv/dz*dzs/dy surf
184REAL, DIMENSION(D%NIJT) :: ZDU_DX ! du/dx surf
185REAL, DIMENSION(D%NIJT) :: ZDV_DY ! dv/dy surf
186REAL, DIMENSION(D%NIJT) :: ZDW_DZ ! dw/dz surf
187!
188INTEGER :: IINFO_ll ! return code of parallel routine
189TYPE(list_ll), POINTER :: TZFIELDS_ll ! list of fields to exchange
190
191REAL :: ZTIME1, ZTIME2
192
193
194REAL, DIMENSION(D%NIJT,1+JPVEXT:3+JPVEXT) :: ZCOEFF , ZDZZ
195 ! coefficients for the uncentred gradient
196 ! computation near the ground
197TYPE(tfieldmetadata) :: TZFIELD
198!
199!
200! --------------------------------------------------------------------------
201!
202!* 1. PRELIMINARY COMPUTATIONS
203! ------------------------
204!
205!
206NULLIFY(tzfields_ll)
207!
208ikb = 1+jpvext
209ike = SIZE(pum,2)-jpvext
210iku = SIZE(pum,2)
211iijt=d%NIJT
212ikt=d%NKT
213!
214!
215!$acc kernels ! async(1)
216!$mnh_expand_array(JIJ=1:IIJT)
217zdirsinzw(1:iijt) = sqrt( 1. - pdircoszw(1:iijt)**2 )
218!$mnh_end_expand_array(JIJ=1:IIJT)
219!$acc end kernels
220!
221gx_u_m_pum = gx_u_m(oflat,pum,pdxx,pdzz,pdzx)
222IF (.NOT. o2d) gy_v_m_pvm = gy_v_m(oflat,pvm,pdyy,pdzz,pdzy)
223gz_w_m_pwm = gz_w_m(pwm,pdzz)
224!
225zmzf_dzz = mzf(pdzz)
226!
227CALL add3dfield_ll_phy(d, tzfields_ll, zflx, 'TURB_HOR_DYN_CORR::ZFLX' )
228
229
230! compute the coefficients for the uncentred gradient computation near the
231! ground
232!
233!* 9. < U'U'>
234! -------
235!
236! Computes the U variance
237IF (.NOT. o2d) THEN
238 !$acc kernels present_cr(zflx,gz_w_m_pwm) ! async(2)
239 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
240 zflx(1:iijt,1:ikt)= (2./3.) * ptkem(1:iijt,1:ikt) &
241 - pturb_spp(1:iijt,1:ikt,ncmfs) * pk(1:iijt,1:ikt) *( (4./3.) * gx_u_m_pum(1:iijt,1:ikt) &
242 -(2./3.) * ( gy_v_m_pvm(1:iijt,1:ikt) &
243 +gz_w_m_pwm(1:iijt,1:ikt) ) )
244 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
245 !$acc end kernels
246 !! & to be tested later
247 !! + XCMFB * PLM / SQRT(PTKEM) * (-2./3.) * PTP
248ELSE
249 !$acc kernels ! async(2)
250 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
251 zflx(1:iijt,1:ikt)= (2./3.) * ptkem(1:iijt,1:ikt) &
252 - pturb_spp(1:iijt,1:ikt,ncmfs) * pk(1:iijt,1:ikt) *( (4./3.) * gx_u_m_pum(1:iijt,1:ikt) &
253 -(2./3.) * ( gz_w_m_pwm(1:iijt,1:ikt) ) )
254 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
255 !$acc end kernels
256 !! & to be tested later
257 !! + XCMFB * PLM / SQRT(PTKEM) * (-2./3.) * PTP
258END IF
259!
260!$acc kernels ! async(2)
261!$mnh_expand_array(JIJ=1:IIJT)
262 zflx(1:iijt,ike+1) = zflx(1:iijt,ike)
263!$mnh_end_expand_array(JIJ=1:IIJT)
264!$acc end kernels
265!
266!* prescription of du/dz and dv/dz with uncentered gradient at the surface
267! prescription of dw/dz at Dz/2 above ground using the continuity equation
268! using a Boussinesq hypothesis to remove the z dependance of rhod_ref
269! (div u = 0)
270!
271! ZDZZ(:,:) = MXM(PDZZ(:,IKB:IKB+2)) ! case not handled yet by pyft --expandAllArraysConcurrent and shumanFUNCtoCALL
272zdzz(:,ikb) = mxm2d(pdzz(:,ikb))
273zdzz(:,ikb+1) = mxm2d(pdzz(:,ikb+1))
274zdzz(:,ikb+2) = mxm2d(pdzz(:,ikb+2))
275!$acc kernels present_cr(zdzz,zcoeff) ! async(3)
276!$mnh_expand_array(JIJ=1:IIJT)
277 zcoeff(1:iijt,ikb+2)= - zdzz(1:iijt,2) / &
278 ( (zdzz(1:iijt,3)+zdzz(1:iijt,2)) * zdzz(1:iijt,3) )
279 zcoeff(1:iijt,ikb+1)= (zdzz(1:iijt,3)+zdzz(1:iijt,2)) / &
280 ( zdzz(1:iijt,2) * zdzz(1:iijt,3) )
281 zcoeff(1:iijt,ikb)= - (zdzz(1:iijt,3)+2.*zdzz(1:iijt,2)) / &
282 ( (zdzz(1:iijt,3)+zdzz(1:iijt,2)) * zdzz(1:iijt,2) )
283!$mnh_end_expand_array(JIJ=1:IIJT)
284!$acc end kernels
285!
286zdu_dz_dzs_dx(:)=mxf2d((zcoeff(:,ikb+2)*pum(:,ikb+2) &
287 +zcoeff(:,ikb+1)*pum(:,ikb+1) &
288 +zcoeff(:,ikb)*pum(:,ikb) &
289 )* 0.5 * ( pdzx(:,ikb+1)+pdzx(:,ikb)) &
290 )/ mxf2d(pdxx(:,ikb))
291!
292zdzz(:,ikb) = mym2d(pdzz(:,ikb))
293zdzz(:,ikb+1) = mym2d(pdzz(:,ikb+1))
294zdzz(:,ikb+2) = mym2d(pdzz(:,ikb+2))
295!
296!$acc kernels present_cr(zdzz,zcoeff) ! async(4)
297!$mnh_expand_array(JIJ=1:IIJT)
298 zcoeff(1:iijt,ikb+2)= - zdzz(1:iijt,2) / &
299 ( (zdzz(1:iijt,3)+zdzz(1:iijt,2)) * zdzz(1:iijt,3) )
300 zcoeff(1:iijt,ikb+1)= (zdzz(1:iijt,3)+zdzz(1:iijt,2)) / &
301 ( zdzz(1:iijt,2) * zdzz(1:iijt,3) )
302 zcoeff(1:iijt,ikb)= - (zdzz(1:iijt,3)+2.*zdzz(1:iijt,2)) / &
303 ( (zdzz(1:iijt,3)+zdzz(1:iijt,2)) * zdzz(1:iijt,2) )
304!$mnh_end_expand_array(JIJ=1:IIJT)
305!$acc end kernels
306
307zdv_dz_dzs_dy(:)=myf2d((zcoeff(:,ikb+2)*pvm(:,ikb+2) &
308 +zcoeff(:,ikb+1)*pvm(:,ikb+1) &
309 +zcoeff(:,ikb)*pvm(:,ikb) &
310 )* 0.5 * ( pdzy(:,ikb+1)+pdzy(:,ikb)) &
311 )/ myf2d(pdyy(:,ikb))
312!
313!
314zdu_dx(:)= dxf2d(pum(:,ikb)) / mxf2d(pdxx(:,ikb)) &
315 - zdu_dz_dzs_dx(:)
316
317zdv_dy(:)= dyf2d(pvm(:,ikb)) / myf2d(pdyy(:,ikb)) &
318 - zdv_dz_dzs_dy(:)
319!
320!$acc kernels present_cr(zdv_dy,zdw_dz) ! async(4)
321!$mnh_expand_array(JIJ=1:IIJT)
322zdw_dz(1:iijt)=-zdu_dx(1:iijt)-zdv_dy(1:iijt)
323!$mnh_end_expand_array(JIJ=1:IIJT)
324!$acc end kernels
325!
326!* computation
327!
328!!! wait for the computation of ZFLX
329!!$acc ! wait(2) async(4)
330!!! wait for the computation of ZDW_DZ
331!!$acc ! wait(4)
332!
333! ! !!! we can launch the update of ZFLX on the part that has already been computed
334! ! !$acc update self(ZFLX(:,IKB+1:)) async(10)
335!attention !!!!! je ne comprends pas pourquoi mais ce update plante à l'execution...
336! du coup je ne peux pas faire de update self asynchrone...
337!
338!$acc kernels present_cr(zdu_dx,zflx) ! async(3)
339!$mnh_expand_array(JIJ=1:IIJT)
340 zflx(1:iijt,ikb) = (2./3.) * ptkem(1:iijt,ikb) &
341 - pturb_spp(1:iijt,ikb,ncmfs) * pk(1:iijt,ikb) * 2. * zdu_dx(1:iijt)
342!$mnh_end_expand_array(JIJ=1:IIJT)
343!$acc end kernels
344
345!! & to be tested later
346!! + XCMFB * PLM(:,IKB:IKB) /SQRT(PTKEM(:,IKB:IKB)) * &
347!! (-2./3.) * PTP(:,IKB:IKB)
348!
349! extrapolates this flux under the ground with the surface flux
350!
351!
352!!! wait for the computation of ZDIRSINZW
353!!$acc ! wait(1)
354!
355!$acc kernels present_cr(ZFLX,ZDIRSINZW) ! async(4)
356!$mnh_expand_array(JIJ=1:IIJT)
357zflx(1:iijt,ikb-1) = &
358 ptau11m(1:iijt) * pcosslope(1:iijt)**2 * pdircoszw(1:iijt)**2 &
359 -2. * ptau12m(1:iijt) * pcosslope(1:iijt)* psinslope(1:iijt) * pdircoszw(1:iijt) &
360 + ptau22m(1:iijt) * psinslope(1:iijt)**2 &
361 + ptau33m(1:iijt) * pcosslope(1:iijt)**2 * zdirsinzw(1:iijt)**2 &
362 +2. * pcdueff(1:iijt) * ( &
363 pvslopem(1:iijt) * pcosslope(1:iijt) * psinslope(1:iijt) * zdirsinzw(1:iijt) &
364 - puslopem(1:iijt) * pcosslope(1:iijt)**2 * zdirsinzw(1:iijt) * pdircoszw(1:iijt) )
365!$mnh_end_expand_array(JIJ=1:IIJT)
366!$acc end kernels
367!
368!!! wait for the computation of ZFLX(:,IKB) and ZFLX(:,IKB-1)
369!!$acc ! wait(3) async(4)
370!
371!$acc kernels ! async(4)
372!$mnh_expand_array(JIJ=1:IIJT)
373 zflx(1:iijt,ikb-1) = 2. * zflx(1:iijt,ikb-1) - zflx(1:iijt,ikb)
374!$mnh_end_expand_array(JIJ=1:IIJT)
375!$acc end kernels
376!
377!
378!!! wait for the computation of ZFLX(:,IKB-1)
379!!$acc ! wait(4)
380!
381
382
383! ! !!! we can launch the update of ZFLX on the rest
384! ! !$acc update self(ZFLX(:,1:IKB)) async(11)
385! ! !
386! ! !!! and wait for the update self(ZFLX(...)) to complete
387! ! !$acc wait(10)
388! ! !$acc wait(11)
389!attention !!!!! je ne comprends pas pourquoi mais le update self(ZFLX(:,IKB+1:)) plante à l'execution...
390! du coup je ne peux pas faire de update self asynchrone...
391
392
393!
394!!! at this point there are no more async operations running
395!!! to be absolutely sure, we do a wait
396!!$acc ! wait
397!
398#ifndef MNH_OPENACC
399CALL update_halo_ll(tzfields_ll, iinfo_ll)
400#else
401CALL get_halo_d(zflx,hname='TURB_HOR_DYN_CORR::ZFLX')
402#endif
403!
404IF ( tpfile%LOPENED .AND. turbn%LTURB_FLX ) THEN
405 !$acc update self( ZFLX )
406 ! stores <U U>
407 tzfield = tfieldmetadata( &
408 cmnhname = 'U_VAR', &
409 cstdname = '', &
410 clongname = 'U_VAR', &
411 cunits = 'm2 s-2', &
412 cdir = 'XY', &
413 ccomment = 'X_Y_Z_U_VAR', &
414 ngrid = 1, &
415 ntype = typereal, &
416 ndims = 3, &
417 ltimedep = .true. )
418 CALL io_field_write_phy(d, tpfile,tzfield,zflx)
419END IF
420!
421! Complete the U tendency
422IF (.NOT. oflat) THEN
423 prus(:,:)=prus &
424 -dxm(prhodj * zflx / mxf(pdxx) ) &
425 +dzf( pdzx / mzm(pdxx) * mxm( mzm(prhodj*zflx) * pinv_pdzz ) )
426ELSE
427 prus(:,:)=prus -dxm(prhodj * zflx / mxf(pdxx) )
428END IF
429!
430IF (ksplt==1) THEN
431 ! Contribution to the dynamic production of TKE:
432 !$acc kernels present_cr(gx_u_m_pum,zwork) ! async(2)
433 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
434 zwork(1:iijt,1:ikt) = - zflx(1:iijt,1:ikt) * gx_u_m_pum(1:iijt,1:ikt)
435 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
436 !$acc end kernels
437 !
438 ! evaluate the dynamic production at w(IKB+1) in PDP(IKB)
439 !
440 !$acc kernels present_cr(zdu_dx,zwork) ! async(2)
441 !$mnh_expand_array(JIJ=1:IIJT)
442 zwork(1:iijt,ikb) = 0.5* ( -zflx(1:iijt,ikb)*zdu_dx(1:iijt) + zwork(1:iijt,ikb+1) )
443 !$mnh_end_expand_array(JIJ=1:IIJT)
444 !$acc end kernels
445 !
446 !$acc kernels present_cr(ZWORK) ! async(2)
447 pdp(:,:) = pdp(:,:) + zwork(:,:)
448 !$acc end kernels
449END IF
450!
451! Storage in the LES configuration
452!
453IF (tles%LLES_CALL .AND. ksplt==1) THEN
454 CALL second_mnh(ztime1)
455 CALL les_mean_subgrid_phy(d, tles, zflx, tles%X_LES_SUBGRID_U2 )
456 zwkles = -zwork
457 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_U_SBG_UaU , .true.)
458 CALL second_mnh(ztime2)
459 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
460END IF
461
462!
463!* 10. < V'V'>
464! -------
465!
466!!! wait for the computation of ZWORK and PDP (that uses ZFLX)
467!!$acc ! wait(2)
468!
469! Computes the V variance
470IF (.NOT. o2d) THEN
471 !$acc kernels present_cr(gz_w_m_pwm,zflx) ! async(3)
472 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
473 zflx(1:iijt,1:ikt)= (2./3.) * ptkem(1:iijt,1:ikt) &
474 - pturb_spp(1:iijt,1:ikt,ncmfs) * pk(1:iijt,1:ikt) *( (4./3.) * gy_v_m_pvm(1:iijt,1:ikt) &
475 -(2./3.) * ( gx_u_m_pum(1:iijt,1:ikt) &
476 +gz_w_m_pwm(1:iijt,1:ikt) ) )
477 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
478 !$acc end kernels
479 !! & to be tested
480 !! + XCMFB * PLM / SQRT(PTKEM) * (-2./3.) * PTP
481 !
482ELSE
483 !$acc kernels present_cr(gz_w_m_pwm,zflx) ! async(3)
484 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
485 zflx(1:iijt,1:ikt)= (2./3.) * ptkem(1:iijt,1:ikt) &
486 - pturb_spp(1:iijt,1:ikt,ncmfs) * pk(1:iijt,1:ikt) *(-(2./3.) * ( gx_u_m_pum(1:iijt,1:ikt) &
487 +gz_w_m_pwm(1:iijt,1:ikt) ) )
488 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
489 !$acc end kernels
490 !! & to be tested
491 !! + XCMFB * PLM / SQRT(PTKEM) * (-2./3.) * PTP
492 !
493END IF
494!
495!$acc kernels ! async(3)
496!$mnh_expand_array(JIJ=1:IIJT)
497zflx(1:iijt,ike+1) = zflx(1:iijt,ike)
498!$mnh_end_expand_array(JIJ=1:IIJT)
499!$acc end kernels
500!
501! ! !!! wait for the computation of ZFLX to begin the update
502! ! !$acc wait(3)
503! ! !$acc update self(ZFLX(:,IKB+1:)) async(10)
504!
505!$acc kernels present_cr(zdv_dy,zflx) ! async(3)
506!$mnh_expand_array(JIJ=1:IIJT)
507 zflx(1:iijt,ikb) = (2./3.) * ptkem(1:iijt,ikb) &
508 - pturb_spp(1:iijt,ikb,ncmfs) * pk(1:iijt,ikb) * 2. * zdv_dy(1:iijt)
509!$mnh_end_expand_array(JIJ=1:IIJT)
510!$acc end kernels
511
512!! & to be tested
513!! + XCMFB * PLM(:,IKB:IKB) /SQRT(PTKEM(:,IKB:IKB)) * &
514!! (-2./3.) * PTP(:,IKB:IKB)
515!
516! extrapolates this flux under the ground with the surface flux
517!$acc kernels present_cr(ZFLX,ZDIRSINZW)
518!$mnh_expand_array(JIJ=1:IIJT)
519zflx(1:iijt,ikb-1) = &
520 ptau11m(1:iijt) * psinslope(1:iijt)**2 * pdircoszw(1:iijt)**2 &
521 +2. * ptau12m(1:iijt) * pcosslope(1:iijt)* psinslope(1:iijt) * pdircoszw(1:iijt) &
522 + ptau22m(1:iijt) * pcosslope(1:iijt)**2 &
523 + ptau33m(1:iijt) * psinslope(1:iijt)**2 * zdirsinzw(1:iijt)**2 &
524 -2. * pcdueff(1:iijt)* ( &
525 puslopem(1:iijt) * psinslope(1:iijt)**2 * zdirsinzw(1:iijt) * pdircoszw(1:iijt) &
526 + pvslopem(1:iijt) * pcosslope(1:iijt) * psinslope(1:iijt) * zdirsinzw(1:iijt) )
527!$mnh_end_expand_array(JIJ=1:IIJT)
528!$acc end kernels
529!
530!$acc kernels ! async(3)
531zflx(:,ikb-1) = 2. * zflx(:,ikb-1) - zflx(:,ikb)
532!$acc end kernels
533!
534!
535! ! !!! wait for the computation of ZFLX(:,1:IKB) to begin the update
536! ! !$acc update self(ZFLX(:,IKB+1:)) async(3)
537! ! !
538! ! !!! and wait for the update self(ZFLX(...)) to complete
539! ! !$acc wait(10)
540! ! !$acc wait(3)
541!
542!!$acc ! wait(3)
543#ifndef MNH_OPENACC
544CALL update_halo_ll(tzfields_ll, iinfo_ll)
545#else
546CALL get_halo_d(zflx,hname='TURB_HOR_DYN_CORR::ZFLX')
547#endif
548!
549IF ( tpfile%LOPENED .AND. turbn%LTURB_FLX ) THEN
550 !$acc update self( ZFLX )
551 ! stores <V V>
552 tzfield = tfieldmetadata( &
553 cmnhname = 'V_VAR', &
554 cstdname = '', &
555 clongname = 'V_VAR', &
556 cunits = 'm2 s-2', &
557 cdir = 'XY', &
558 ccomment = 'X_Y_Z_V_VAR', &
559 ngrid = 1, &
560 ntype = typereal, &
561 ndims = 3, &
562 ltimedep = .true. )
563 CALL io_field_write_phy(d, tpfile,tzfield,zflx)
564END IF
565!
566!!! wait for the computation of PRUS (that uses temporary variables)
567!!$acc ! wait(1)
568!
569!
570!
571! Complete the V tendency
572IF (.NOT. o2d) THEN
573 IF (.NOT. oflat) THEN
574 prvs(:,:)=prvs &
575 -dym(prhodj * zflx / myf(pdyy) ) &
576 +dzf( pdzy / mzm(pdyy) * &
577 mym( mzm(prhodj*zflx) * pinv_pdzz ) )
578 ELSE
579 prvs(:,:)=prvs -dym(prhodj * zflx / myf(pdyy) )
580 END IF
581!
582! Contribution to the dynamic production of TKE:
583 IF (ksplt==1) THEN
584 !$acc kernels
585 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
586 zwork(1:iijt,1:ikt) = - zflx(1:iijt,1:ikt) * gy_v_m_pvm(1:iijt,1:ikt)
587 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
588 !$acc end kernels
589 END IF
590ELSE
591 !$acc kernels ! async(2)
592 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
593 zwork(1:iijt,1:ikt) = 0.
594 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
595 !$acc end kernels
596END IF
597!
598IF (ksplt==1) THEN
599 !
600 ! evaluate the dynamic production at w(IKB+1) in PDP(IKB)
601 !
602 !$acc kernels present_cr(zdv_dy,zwork) ! async(2)
603 !$mnh_expand_array(JIJ=1:IIJT)
604 zwork(1:iijt,ikb) = 0.5* ( -zflx(1:iijt,ikb)*zdv_dy(1:iijt) + zwork(1:iijt,ikb+1) )
605 !$mnh_end_expand_array(JIJ=1:IIJT)
606 !$acc end kernels
607 !
608 !$acc kernels ! async(2)
609 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
610 pdp(1:iijt,1:ikt) = pdp(1:iijt,1:ikt) + zwork(1:iijt,1:ikt)
611 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
612 !$acc end kernels
613END IF
614!
615! Storage in the LES configuration
616!
617IF (tles%LLES_CALL .AND. ksplt==1) THEN
618 CALL second_mnh(ztime1)
619 CALL les_mean_subgrid_phy(d, tles, zflx, tles%X_LES_SUBGRID_V2 )
620 zwkles = -zwork
621 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_V_SBG_UaV , .true.)
622 CALL second_mnh(ztime2)
623 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
624END IF
625!
626!* 11. < W'W'>
627! -------
628!
629! Computes the W variance
630IF (.NOT. o2d) THEN
631 !$acc kernels present_cr(gy_v_m_pvm,zflx) ! async(2)
632 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
633 zflx(1:iijt,1:ikt) = (2./3.) * ptkem(1:iijt,1:ikt) &
634 - pturb_spp(1:iijt,1:ikt,ncmfs) * pk(1:iijt,1:ikt) *( (4./3.) * gz_w_m_pwm(1:iijt,1:ikt) &
635 -(2./3.) * ( gx_u_m_pum(1:iijt,1:ikt) &
636 +gy_v_m_pvm(1:iijt,1:ikt) ) )
637 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
638 !$acc end kernels
639 !! & to be tested
640 !! -2.* XCMFB * PLM / SQRT(PTKEM) * (-2./3.) * PTP
641ELSE
642 !$acc kernels present_cr(gx_u_m_pum,zflx) ! async(2)
643 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
644 zflx(1:iijt,1:ikt)= (2./3.) * ptkem(1:iijt,1:ikt) &
645 - pturb_spp(1:iijt,1:ikt,ncmfs) * pk(1:iijt,1:ikt) *( (4./3.) * gz_w_m_pwm(1:iijt,1:ikt) &
646 -(2./3.) * ( gx_u_m_pum(1:iijt,1:ikt) ) )
647 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
648 !$acc end kernels
649 !! & to be tested
650 !! -2.* XCMFB * PLM / SQRT(PTKEM) * (-2./3.) * PTP
651END IF
652!
653!$acc kernels ! async(2)
654!$mnh_expand_array(JIJ=1:IIJT)
655zflx(1:iijt,ike+1)= zflx(1:iijt,ike)
656!$mnh_end_expand_array(JIJ=1:IIJT)
657!$acc end kernels
658!!! wait for the computation of ZWORK, PDP and ZFLX
659!!$acc ! wait(2)
660!
661!
662!$acc kernels present_cr(zdw_dz,zflx) ! async(2)
663!$mnh_expand_array(JIJ=1:IIJT)
664 zflx(1:iijt,ikb) = (2./3.) * ptkem(1:iijt,ikb) &
665 - pturb_spp(1:iijt,ikb,ncmfs) * pk(1:iijt,ikb) * 2. * zdw_dz(1:iijt)
666!$mnh_end_expand_array(JIJ=1:IIJT)
667
668!$acc end kernels
669!
670
671! & to be tested
672! - 2.* XCMFB * PLM(:,IKB:IKB) /SQRT(PTKEM(:,IKB:IKB)) * &
673! (-2./3.) * PTP(:,IKB:IKB)
674! extrapolates this flux under the ground with the surface flux
675!$acc kernels present_cr(ZFLX) ! async(3)
676!$mnh_expand_array(JIJ=1:IIJT)
677zflx(1:iijt,ikb-1) = &
678 ptau11m(1:iijt) * zdirsinzw(1:iijt)**2 &
679 + ptau33m(1:iijt) * pdircoszw(1:iijt)**2 &
680 +2. * pcdueff(1:iijt)* puslopem(1:iijt) * zdirsinzw(1:iijt) * pdircoszw(1:iijt)
681!$mnh_end_expand_array(JIJ=1:IIJT)
682!$acc end kernels
683!
684!
685!!! wait for the computation of ZFLX(:,IKB-1) and ZFLX(:,IKB)
686!!$acc ! wait(2) ! async(3)
687!
688!$acc kernels ! async(3)
689!$mnh_expand_array(JIJ=1:IIJT)
690zflx(1:iijt,ikb-1) = 2. * zflx(1:iijt,ikb-1) - zflx(1:iijt,ikb)
691!$mnh_end_expand_array(JIJ=1:IIJT)
692!$acc end kernels
693!
694IF ( tpfile%LOPENED .AND. turbn%LTURB_FLX ) THEN
695 !!$acc ! wait(3)
696 !$acc update self(ZFLX)
697 ! stores <W W>
698 tzfield = tfieldmetadata( &
699 cmnhname = 'W_VAR', &
700 cstdname = '', &
701 clongname = 'W_VAR', &
702 cunits = 'm2 s-2', &
703 cdir = 'XY', &
704 ccomment = 'X_Y_Z_W_VAR', &
705 ngrid = 1, &
706 ntype = typereal, &
707 ndims = 3, &
708 ltimedep = .true. )
709 CALL io_field_write_phy(d, tpfile,tzfield,zflx)
710END IF
711!
712!
713!!! wait for the computation of PRVS (that uses temporary variables)
714!!$acc ! wait(1)
715!
716
717!
718! Complete the W tendency
719!
720!PRWS(:,:)=PRWS(:,:) - DZM( PRHODJ*ZFLX/MZF(PDZZ) )
721!$acc kernels ! async(2)
722!$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
723zdfddwdz(1:iijt,1:ikt) = - pturb_spp(1:iijt,1:ikt,ncmfs) * pk(1:iijt,1:ikt) * (4./3.)
724!$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
725!$acc end kernels
726!$acc kernels ! async(2)
727!$mnh_expand_array(JIJ=1:IIJT,JK=1:IKB)
728zdfddwdz(1:iijt,1:ikb) = 0.
729!$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKB)
730!$acc end kernels
731!
732!!! wait for the computation of ZFLX(:,IKB-1) and ZDFDDWDZ
733!!$acc ! wait(3) async(2)
734!!$acc ! wait(2)
735!
736CALL tridiag_w(d,pwm,zflx,zdfddwdz,ptstep,zmzf_dzz,prhodj,zwp)
737!
738prws = prws(:,:) + mzm(prhodj(:,:))*(zwp(:,:)-pwm(:,:))/ptstep
739!
740!* recomputes flux using guess of W
741!
742gz_w_m_zwp = gz_w_m(zwp,pdzz)
743!$acc kernels present_cr(gz_w_m_pwm,zflx) ! async(2)
744!$mnh_expand_array(JIJ=1:IIJT,JK=IKB+1:IKT)
745 zflx(1:iijt,ikb+1:ikt)=zflx(1:iijt,ikb+1:ikt) &
746 - pturb_spp(1:iijt,ikb+1:ikt,ncmfs) * pk(1:iijt,ikb+1:ikt) * (4./3.) &
747 & * (gz_w_m_zwp(1:iijt,ikb+1:ikt) - gz_w_m_pwm(1:iijt,ikb+1:ikt))
748!$mnh_end_expand_array(JIJ=1:IIJT,JK=IKB+1:IKT)
749!$acc end kernels
750!
751IF (ksplt==1) THEN
752 !Contribution to the dynamic production of TKE:
753 !$acc kernels present_cr(gz_w_m_zwp,zwork) ! async(2)
754 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
755 zwork(1:iijt,1:ikt) = - zflx(1:iijt,1:ikt) * gz_w_m_zwp(1:iijt,1:ikt)
756 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
757 !$acc end kernels
758 !
759 ! evaluate the dynamic production at w(IKB+1) in PDP(IKB)
760 !
761 !$acc kernels present_cr(zdw_dz,zwork) ! async(2)
762 !$mnh_expand_array(JIJ=1:IIJT)
763 zwork(1:iijt,ikb) = 0.5* ( -zflx(1:iijt,ikb)*zdw_dz(1:iijt) + zwork(1:iijt,ikb+1) )
764 !$mnh_end_expand_array(JIJ=1:IIJT)
765 !$acc end kernels
766 !
767 !$acc kernels ! async(2)
768 !$mnh_expand_array(JIJ=1:IIJT,JK=1:IKT)
769 pdp(1:iijt,1:ikt) = pdp(1:iijt,1:ikt) + zwork(1:iijt,1:ikt)
770 !$mnh_end_expand_array(JIJ=1:IIJT,JK=1:IKT)
771 !$acc end kernels
772END IF
773!
774! Storage in the LES configuration
775!
776!
777IF (tles%LLES_CALL .AND. ksplt==1) THEN
778 CALL second_mnh(ztime1)
779 CALL les_mean_subgrid_phy(d, tles, zflx, tles%X_LES_SUBGRID_W2 )
780 zwkles = -zwork
781 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_W_SBG_UaW , .true.)
782 zwkles = gz_m_m(pthlm,pdzz)*zflx
783 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddxa_Thl_SBG_UaW , .true.)
784 zwkles = zflx*mzf(gz_m_w(pthlm,pdzz))
785 CALL les_mean_subgrid_phy(d, tles, zwkles, tles%X_LES_RES_ddz_Thl_SBG_W2)
786 IF (krr>=1) THEN
787 zwkles = gz_m_m(prm(:,:,1),pdzz)*zflx
788 CALL les_mean_subgrid_phy(d, tles, zwkles, &
789 tles%X_LES_RES_ddxa_Rt_SBG_UaW , .true.)
790 zwkles = zflx*mzf(gz_m_w(prm(:,:,1),pdzz))
791 CALL les_mean_subgrid_phy(d, tles, zwkles, &
792 tles%X_LES_RES_ddz_Rt_SBG_W2)
793 END IF
794 DO jsv=1,ksv
795 zwkles = gz_m_m(psvm(:,:,jsv),pdzz)*zflx
796 CALL les_mean_subgrid_phy(d, tles, zwkles, &
797 tles%X_LES_RES_ddxa_Sv_SBG_UaW(:,:,:,jsv) , .true.)
798 zwkles = zflx*mzf(gz_m_w(psvm(:,:,jsv),pdzz))
799 CALL les_mean_subgrid_phy(d, tles, zwkles, &
800 tles%X_LES_RES_ddz_Sv_SBG_W2(:,:,:,jsv))
801 END DO
802 CALL second_mnh(ztime2)
803 tles%XTIME_LES = tles%XTIME_LES + ztime2 - ztime1
804END IF
805!
806CALL cleanlist_ll(tzfields_ll)
807!
808!
809CONTAINS
810include "shugrad.h"
811END SUBROUTINE turb_hor_dyn_corr
812END MODULE mode_turb_hor_dyn_corr
integer, parameter typereal
Definition modd_field.F90:9
integer, parameter jpvext
integer, parameter nturb_s
integer, parameter ncmfs
subroutine add3dfield_ll_phy(d, tplist, pfield, hname)
subroutine update_halo_ll(tplist, kinfo, oongpu)
Definition mode_ll.F90:16
subroutine cleanlist_ll(tplist)
Definition mode_ll.F90:47
subroutine tridiag_w(d, pvarm, pf, pdfddwdz, ptstep, pmzf_dzz, prhodj, pvarp)
subroutine turb_hor_dyn_corr(d, turbn, tles, ksplt, ptstep, krr, ksv, oflat, o2d, tpfile, pk, pinv_pdzz, pdxx, pdyy, pdzz, pdzx, pdzy, pzz, pdircoszw, pcosslope, psinslope, prhodj, pcdueff, ptau11m, ptau12m, ptau22m, ptau33m, pum, pvm, pwm, puslopem, pvslopem, pthlm, prm, psvm, ptkem, plm, pturb_spp, pdp, ptp, prus, prvs, prws)
subroutine second_mnh(xt)
Definition second_mnh.F90:2
real function, dimension(size(pin, 1), size(pin, 2)) mym(pin)
Definition shugrad.h:111
real function, dimension(size(pin, 1)) dxf2d(pin)
Definition shugrad.h:189
real function, dimension(size(pin, 1), size(pin, 2)) mzf(pin)
Definition shugrad.h:142
real function, dimension(size(pin, 1), size(pin, 2)) dym(pin)
Definition shugrad.h:267
real function, dimension(size(pin, 1), size(pin, 2)) dzf(pin)
Definition shugrad.h:158
real function, dimension(size(pin, 1), size(pin, 2)) dxm(pin)
Definition shugrad.h:205
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)) mxm(pin)
Definition shugrad.h:49
real function, dimension(size(pa, 1), size(pa, 2)) gx_u_m(oflat, pa, pdxx, pdzz, pdzx)
Definition shugrad.h:456
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)) myf2d(pin)
Definition shugrad.h:95
real function, dimension(size(pin, 1)) dyf2d(pin)
Definition shugrad.h:251
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(pa, 1), size(pa, 2)) gz_m_m(pa, pdzz)
Definition shugrad.h:418
real function, dimension(size(py, 1), size(py, 2)) gz_m_w(py, pdzz)
Definition shugrad.h:437
real function, dimension(size(pa, 1), size(pa, 2)) gy_v_m(oflat, pa, pdyy, pdzz, pdzy)
Definition shugrad.h:553