PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
mode_rotate_wind.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! #######################
7
8!$ACDC singlecolumn --dummy
9
10! #######################
11IMPLICIT NONE
12CONTAINS
13! ###########################################################
14 SUBROUTINE rotate_wind(D,PU,PV,PW, &
15 PDIRCOSXW, PDIRCOSYW, PDIRCOSZW, &
16 PCOSSLOPE,PSINSLOPE, &
17 PDXX,PDYY,PDZZ, &
18 PUSLOPE,PVSLOPE )
19! ###########################################################
20!
21!
22!!**** *ROTATE_WIND* - computes the wind components along the maximum slope
23!! direction and its normal direction in the first mass level.
24!!
25!! PURPOSE
26!! -------
27!!****
28! The purpose of this routine is to compute the wind component parallel
29! to the orography at the first mass level. The exact location where these
30! components are computed is the point of intersection between the normal
31! to the orography and the first mass-level hyper-plane at PDZZ(:,:,IKB)/2
32!
33!!** METHOD
34!! ------
35!! The values of the 3 cartesian components of the wind are determined
36!! by a bilinear interpolation between the 4 nearest points in the first
37!! mass-level hyper-plane. These points are found according to the signs of
38!! the slopes' sinus and cosinus. For each direction of interpolation, the
39!! two different localizations (mass or flux grids) are used to avoid
40!! lateral boundary problems.
41!! Then, the rotation is performed for the wind components. The rotation
42!! angle is the angle between the x axe and the maximum slope direction
43!! defined by the slope vector (dZs/dx , dZs/dy).
44!! Finally, the horizontal components are set at the marginal points
45!! according to cyclic boundary conditions because this is the only case
46!! where these points can be considered.
47!!
48!! EXTERNAL
49!! --------
50!! NONE
51!!
52!! IMPLICIT ARGUMENTS
53!! ------------------
54!!
55!! REFERENCE
56!! ---------
57!! Book 1 of documentation (Chapter: Turbulence)
58!!
59!! AUTHOR
60!! ------
61!! Joel Stein * Meteo-France *
62!!
63!! MODIFICATIONS
64!! -------------
65!! Original 14/11/95
66!! Modifications: 15/05/96, (N. wood)
67!! take into account no slip conditions
68!! at the surface
69!! 14/02/01 (V. Masson)
70!! Slip condition at the surface restored
71!!
72!! --------------------------------------------------------------------------
73!
74!* 0. DECLARATIONS
75! ------------
77!
78! These macro are handled by pft_tool.py --craybyPassDOCONCURRENT applied on Cray Rules
79#ifdef MNH_COMPILER_CCE
80!$mnh_undef(LOOP)
81!$mnh_undef(OPENACC)
82#endif
83!
84IMPLICIT NONE
85!
86!
87!* 0.1 declarations of arguments
88!
89TYPE(dimphyex_t), INTENT(IN) :: D
90REAL, DIMENSION(D%NIT,D%NJT,D%NKT), INTENT(IN) :: PU,PV,PW ! cartesian components
91 ! of the wind
92REAL, DIMENSION(D%NIT,D%NJT), INTENT(IN) :: PDIRCOSXW, PDIRCOSYW, PDIRCOSZW
93! Director Cosinus along x, y and z directions at surface w-point
94REAL, DIMENSION(D%NIT,D%NJT), INTENT(IN) :: PCOSSLOPE ! cosinus of the angle
95 ! between i and the slope vector
96REAL, DIMENSION(D%NIT,D%NJT), INTENT(IN) :: PSINSLOPE ! sinus of the angle
97 ! between i and the slope vector
98REAL, DIMENSION(D%NIT,D%NJT,D%NKT), INTENT(IN) :: PDXX, PDYY, PDZZ
99 ! Metric coefficients
100REAL, DIMENSION(D%NIT,D%NJT), INTENT(OUT) :: PUSLOPE ! wind component along
101 ! the maximum slope direction
102REAL, DIMENSION(D%NIT,D%NJT), INTENT(OUT) :: PVSLOPE ! wind component along
103 ! the direction normal to the maximum slope one
104!
105!-------------------------------------------------------------------------------
106!
107! 0.2 declaration of local variables
108!
109INTEGER, DIMENSION(D%NIT,D%NJT) :: ILOC,JLOC
110 ! shift index to find the 4 nearest points in x and y directions
111REAL, DIMENSION(D%NIT,D%NJT) :: ZCOEFF,ZCOEFM, &
112 ! interpolation weigths for flux and mass locations
113 zuint,zvint,zwint, &
114 ! intermediate values of the cartesian components after x interp.
115 zufin,zvfin,zwfin, &
116 ! final values of the cartesian components after the 2 interp.
117 zwground
118 ! vertical velocity at the surface
119INTEGER :: IIB,IIE,IJB,IJE,IKB
120 ! index values for the Beginning or the End of the physical
121 ! domain in x,y and z directions
122INTEGER :: IIU,IJU
123 ! arrays' sizes for i and j indices
124INTEGER :: JI,JJ
125!
126!----------------------------------------------------------------------------
127!
128!* 1. PRELIMINARIES
129! -------------
130!
131!
132iib = 2
133ijb = 2
134iiu = SIZE(pu,1)
135iju = SIZE(pu,2)
136iie = iiu - 1
137ije = iju - 1
138ikb = d%NKB
139!
140!$acc kernels present(pdircosyw,zvint,zwfin,zcoefm,zufin,pdxx,pdircosxw) &
141!$acc present (zwint,zwground,zvfin,puslope,pdircoszw,zuint,psinslope,pw,pcosslope) &
142!$acc present (pdyy,pu,pv,pvslope,zwground,zuint,jloc,zwint,pdzz,iloc)
143!$mnh_expand_array(JI=1:IIU,JJ=1:IJU)
144puslope(:iiu,1:iju)=0.
145pvslope(:iiu,1:iju)=0.
146!
147zwground(:iiu,1:iju) = pw(:iiu,1:iju,ikb)
148!
149!* 2. INTERPOLATE THE CARTESIAN COMPONENTS
150! ------------------------------------
151!
152iloc(:iiu,1:iju)=nint(sign(1.,-pcosslope(:iiu,1:iju)))
153jloc(:iiu,1:iju)=nint(sign(1.,-psinslope(:iiu,1:iju)))
154!$mnh_end_expand_array(JI=1:IIU,JJ=1:IJU)
155!
156! interpolation in x direction
157!
158!$mnh_do_concurrent(JI=IIB:IIE,JJ=1:IJU)
159DO jj=1,iju
160 DO ji=iib,iie
161 zcoeff(ji,jj) = &
162 (0.5*pdxx(ji,jj,ikb) + 0.5*pdzz(ji,jj,ikb)*pdircosxw(ji,jj) ) &
163 * 2. / (pdxx(ji,jj,ikb)+pdxx(ji+1,jj,ikb))
164 zuint(ji,jj) = zcoeff(ji,jj) * pu(ji+1,jj,ikb) + &
165 (1.-zcoeff(ji,jj)) * pu(ji,jj,ikb)
166 !
167 zcoefm(ji,jj) = 1. - 0.5 * pdzz(ji,jj,ikb) * abs(pdircosxw(ji,jj)) &
168 / pdxx(ji+(iloc(ji,jj)+1)/2,jj,ikb)
169 zvint(ji,jj) = zcoefm(ji,jj) * pv(ji,jj,ikb) + &
170 (1.-zcoefm(ji,jj)) * pv(ji+iloc(ji,jj),jj,ikb)
171 !
172 zwint(ji,jj) = zcoefm(ji,jj) * (pw(ji,jj,ikb+1)+zwground(ji,jj)) * 0.5 &
173 + (1.-zcoefm(ji,jj)) &
174 *(pw(ji+iloc(ji,jj),jj,ikb+1)+zwground(ji+iloc(ji,jj),jj)) * 0.5
175 END DO
176END DO
177!$mnh_end_do()
178!
179! interpolation in y direction
180!
181!$mnh_do_concurrent(JI=IIB:IIE,JJ=IJB:IJE)
182DO jj=ijb,ije
183 DO ji=iib,iie
184 zcoeff(ji,jj) = &
185 (0.5*pdyy(ji,jj,ikb) + 0.5*pdzz(ji,jj,ikb)*pdircosyw(ji,jj) ) &
186 * 2. / (pdyy(ji,jj,ikb)+pdyy(ji+1,jj,ikb))
187 zvfin(ji,jj) = zcoeff(ji,jj) * zvint(ji,jj+1) + &
188 (1.-zcoeff(ji,jj)) * zvint(ji,jj)
189 !
190 zcoefm(ji,jj) = 1. - 0.5 * pdzz(ji,jj,ikb) * abs(pdircosyw(ji,jj)) &
191 / pdyy(ji,jj+(jloc(ji,jj)+1)/2,ikb)
192 zufin(ji,jj) = zcoefm(ji,jj) * zuint(ji,jj) + &
193 (1.-zcoefm(ji,jj)) * zuint(ji,jj+jloc(ji,jj))
194 zwfin(ji,jj) = zcoefm(ji,jj) * zwint(ji,jj) + &
195 (1.-zcoefm(ji,jj)) * zwint(ji,jj+jloc(ji,jj))
196!
197!* 3. ROTATE THE WIND
198! ---------------
199!
200!
201 puslope(ji,jj) = pcosslope(ji,jj) * pdircoszw(ji,jj) * zufin(ji,jj) + &
202 psinslope(ji,jj) * pdircoszw(ji,jj) * zvfin(ji,jj) + &
203 sqrt(1.-pdircoszw(ji,jj)**2) * zwfin(ji,jj)
204 !
205 pvslope(ji,jj) =-psinslope(ji,jj) * zufin(ji,jj) + &
206 pcosslope(ji,jj) * zvfin(ji,jj)
207 !
208 END DO
209END DO
210!$mnh_end_do()
211!
212!$acc end kernels
213!
214!
215!----------------------------------------------------------------------------
216!
217END SUBROUTINE rotate_wind
218!
219! ##############################################
220 SUBROUTINE update_rotate_wind(D,PUSLOPE,PVSLOPE,HLBCX,HLBCY)
221! ##############################################
222!!
223!!**** *UPDATE_ROTATE_WIND* routine to set rotate wind values at the border
224!
225!! AUTHOR
226!! ------
227!!
228!! P Jabouille *CNRM METEO-FRANCE
229!!
230!! MODIFICATIONS
231!! -------------
232!! Original 24/06/99
233!! J.Escobar 21/03/2013: for HALOK comment all NHALO=1 test
234!!
235!-------------------------------------------------------------------------------
236!
237!* 0. DECLARATIONS
238! ------------
239!
243USE modd_argslist_ll, ONLY : list_ll
244USE modd_dimphyex, ONLY: dimphyex_t
245#ifdef MNH_OPENACC
246USE modi_get_halo, ONLY: get_2d_halo_ddc
247#endif
248IMPLICIT NONE
249!
250!* 0.1 Declarations of dummy arguments :
251!
252TYPE(dimphyex_t), INTENT(IN) :: D
253CHARACTER(LEN=4),DIMENSION(2),INTENT(IN):: HLBCX, HLBCY ! X- and Y-direc LBC
254REAL, DIMENSION(D%NIT,D%NJT), INTENT(INOUT) :: PUSLOPE,PVSLOPE
255!
256TYPE(list_ll), POINTER :: TZFIELDS_ll ! list of fields to exchange
257INTEGER :: IINFO_ll ! return code of parallel routine
258logical :: gwest, geast, gnorth, gsouth
259INTEGER :: IIB, IIE, IJB, IJE
260!
261! tangential surface fluxes in the axes following the orography
262!
263!* 1 PROLOGUE
264!
265NULLIFY(tzfields_ll)
266!
267iib = d%NIB
268ijb = d%NJB
269iie = d%NIE
270ije = d%NJE
271! 2 Update halo if necessary
272!
273!!$IF (NHALO == 1) THEN
274#ifndef MNH_OPENACC
275 CALL add2dfield_ll_phy(d, tzfields_ll, puslope, 'UPDATE_ROTATE_WIND::PUSLOPE' )
276 CALL add2dfield_ll_phy(d, tzfields_ll, pvslope, 'UPDATE_ROTATE_WIND::PVSLOPE' )
277 CALL update_halo_ll(tzfields_ll,iinfo_ll)
278 CALL cleanlist_ll(tzfields_ll)
279#else
280!
281! /!\ warning conner needed -> GET_HALO...C
282!
283CALL get_2d_halo_ddc( puslope, hname='UPDATE_ROTATE_WIND::PUSLOPE' )
284CALL get_2d_halo_ddc( pvslope, hname='UPDATE_ROTATE_WIND::PVSLOPE' )
285#endif
286!!$ENDIF
287!
288! 3 Boundary conditions for non cyclic case
289!
290gwest = hlbcx(1) /= "CYCL" .AND. lwest_ll()
291geast = hlbcx(2) /= "CYCL" .AND. least_ll()
292gsouth = hlbcy(1) /= "CYCL" .AND. lsouth_ll()
293gnorth = hlbcy(2) /= "CYCL" .AND. lnorth_ll()
294
295!$acc kernels present_cr(PUSLOPE,PVSLOPE)
296IF ( gwest ) THEN
297 puslope(iib-1,:)=puslope(iib,:)
298 pvslope(iib-1,:)=pvslope(iib,:)
299END IF
300IF ( geast ) THEN
301 puslope(iie+1,:)=puslope(iie,:)
302 pvslope(iie+1,:)=pvslope(iie,:)
303END IF
304IF ( gsouth ) THEN
305 puslope(:,ijb-1)=puslope(:,ijb)
306 pvslope(:,ijb-1)=pvslope(:,ijb)
307END IF
308IF( gnorth ) THEN
309 puslope(:,ije+1)=puslope(:,ije)
310 pvslope(:,ije+1)=pvslope(:,ije)
311END IF
312!$acc end kernels
313!
314END SUBROUTINE update_rotate_wind
315END MODULE mode_rotate_wind
subroutine add2dfield_ll_phy(d, tplist, pfield, hname)
subroutine update_halo_ll(tplist, kinfo, oongpu)
Definition mode_ll.F90:16
logical function lnorth_ll()
Definition mode_ll.F90:31
subroutine cleanlist_ll(tplist)
Definition mode_ll.F90:47
logical function lwest_ll()
Definition mode_ll.F90:39
logical function least_ll()
Definition mode_ll.F90:35
logical function lsouth_ll()
Definition mode_ll.F90:43
subroutine rotate_wind(d, pu, pv, pw, pdircosxw, pdircosyw, pdircoszw, pcosslope, psinslope, pdxx, pdyy, pdzz, puslope, pvslope)
subroutine update_rotate_wind(d, puslope, pvslope, hlbcx, hlbcy)