1 | !> @file coriolis_mod.f90 |
---|
2 | !--------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
7 | ! either version 3 of the License, or (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with |
---|
14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: coriolis_mod.f90 1851 2016-04-08 13:32:50Z maronga $ |
---|
26 | ! |
---|
27 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
28 | ! Module renamed |
---|
29 | ! |
---|
30 | ! |
---|
31 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
32 | ! Code annotations made doxygen readable |
---|
33 | ! |
---|
34 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
35 | ! REAL constants provided with KIND-attribute |
---|
36 | ! |
---|
37 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
38 | ! ONLY-attribute added to USE-statements, |
---|
39 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
40 | ! kinds are defined in new module kinds, |
---|
41 | ! revision history before 2012 removed, |
---|
42 | ! comment fields (!:) to be used for variable explanations added to |
---|
43 | ! all variable declaration statements |
---|
44 | ! |
---|
45 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
46 | ! openacc loop and loop vector clauses removed |
---|
47 | ! |
---|
48 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
49 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
50 | ! j_north |
---|
51 | ! |
---|
52 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
53 | ! code put under GPL (PALM 3.9) |
---|
54 | ! |
---|
55 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
56 | ! accelerator version (*_acc) added |
---|
57 | ! |
---|
58 | ! Revision 1.1 1997/08/29 08:57:38 raasch |
---|
59 | ! Initial revision |
---|
60 | ! |
---|
61 | ! |
---|
62 | ! Description: |
---|
63 | ! ------------ |
---|
64 | !> Computation of all Coriolis terms in the equations of motion. |
---|
65 | !------------------------------------------------------------------------------! |
---|
66 | MODULE coriolis_mod |
---|
67 | |
---|
68 | |
---|
69 | PRIVATE |
---|
70 | PUBLIC coriolis, coriolis_acc |
---|
71 | |
---|
72 | INTERFACE coriolis |
---|
73 | MODULE PROCEDURE coriolis |
---|
74 | MODULE PROCEDURE coriolis_ij |
---|
75 | END INTERFACE coriolis |
---|
76 | |
---|
77 | INTERFACE coriolis_acc |
---|
78 | MODULE PROCEDURE coriolis_acc |
---|
79 | END INTERFACE coriolis_acc |
---|
80 | |
---|
81 | CONTAINS |
---|
82 | |
---|
83 | |
---|
84 | !------------------------------------------------------------------------------! |
---|
85 | ! Description: |
---|
86 | ! ------------ |
---|
87 | !> Call for all grid points |
---|
88 | !------------------------------------------------------------------------------! |
---|
89 | SUBROUTINE coriolis( component ) |
---|
90 | |
---|
91 | USE arrays_3d, & |
---|
92 | ONLY: tend, u, ug, v, vg, w |
---|
93 | |
---|
94 | USE control_parameters, & |
---|
95 | ONLY: f, fs, message_string |
---|
96 | |
---|
97 | USE indices, & |
---|
98 | ONLY: nxl, nxlu, nxr, nyn, nys, nysv, nzb_u_inner, nzb_v_inner, & |
---|
99 | nzb_w_inner, nzt |
---|
100 | |
---|
101 | USE kinds |
---|
102 | |
---|
103 | IMPLICIT NONE |
---|
104 | |
---|
105 | INTEGER(iwp) :: component !< |
---|
106 | INTEGER(iwp) :: i !< |
---|
107 | INTEGER(iwp) :: j !< |
---|
108 | INTEGER(iwp) :: k !< |
---|
109 | |
---|
110 | |
---|
111 | ! |
---|
112 | !-- Compute Coriolis terms for the three velocity components |
---|
113 | SELECT CASE ( component ) |
---|
114 | |
---|
115 | ! |
---|
116 | !-- u-component |
---|
117 | CASE ( 1 ) |
---|
118 | DO i = nxlu, nxr |
---|
119 | DO j = nys, nyn |
---|
120 | DO k = nzb_u_inner(j,i)+1, nzt |
---|
121 | tend(k,j,i) = tend(k,j,i) + f * ( 0.25_wp * & |
---|
122 | ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) + & |
---|
123 | v(k,j+1,i) ) - vg(k) ) & |
---|
124 | - fs * ( 0.25_wp * & |
---|
125 | ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + & |
---|
126 | w(k,j,i) ) & |
---|
127 | ) |
---|
128 | ENDDO |
---|
129 | ENDDO |
---|
130 | ENDDO |
---|
131 | |
---|
132 | ! |
---|
133 | !-- v-component |
---|
134 | CASE ( 2 ) |
---|
135 | DO i = nxl, nxr |
---|
136 | DO j = nysv, nyn |
---|
137 | DO k = nzb_v_inner(j,i)+1, nzt |
---|
138 | tend(k,j,i) = tend(k,j,i) - f * ( 0.25_wp * & |
---|
139 | ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + & |
---|
140 | u(k,j,i+1) ) - ug(k) ) |
---|
141 | ENDDO |
---|
142 | ENDDO |
---|
143 | ENDDO |
---|
144 | |
---|
145 | ! |
---|
146 | !-- w-component |
---|
147 | CASE ( 3 ) |
---|
148 | DO i = nxl, nxr |
---|
149 | DO j = nys, nyn |
---|
150 | DO k = nzb_w_inner(j,i)+1, nzt |
---|
151 | tend(k,j,i) = tend(k,j,i) + fs * 0.25_wp * & |
---|
152 | ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + & |
---|
153 | u(k+1,j,i+1) ) |
---|
154 | ENDDO |
---|
155 | ENDDO |
---|
156 | ENDDO |
---|
157 | |
---|
158 | CASE DEFAULT |
---|
159 | |
---|
160 | WRITE( message_string, * ) ' wrong component: ', component |
---|
161 | CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 ) |
---|
162 | |
---|
163 | END SELECT |
---|
164 | |
---|
165 | END SUBROUTINE coriolis |
---|
166 | |
---|
167 | |
---|
168 | !------------------------------------------------------------------------------! |
---|
169 | ! Description: |
---|
170 | ! ------------ |
---|
171 | !> Call for all grid points - accelerator version |
---|
172 | !------------------------------------------------------------------------------! |
---|
173 | SUBROUTINE coriolis_acc( component ) |
---|
174 | |
---|
175 | USE arrays_3d, & |
---|
176 | ONLY: tend, u, ug, v, vg, w |
---|
177 | |
---|
178 | USE control_parameters, & |
---|
179 | ONLY: f, fs, message_string |
---|
180 | |
---|
181 | USE indices, & |
---|
182 | ONLY: i_left, i_right, j_north, j_south, nzb_u_inner, & |
---|
183 | nzb_v_inner, nzb_w_inner, nzt |
---|
184 | |
---|
185 | USE kinds |
---|
186 | |
---|
187 | IMPLICIT NONE |
---|
188 | |
---|
189 | INTEGER(iwp) :: component !< |
---|
190 | INTEGER(iwp) :: i !< |
---|
191 | INTEGER(iwp) :: j !< |
---|
192 | INTEGER(iwp) :: k !< |
---|
193 | |
---|
194 | |
---|
195 | ! |
---|
196 | !-- Compute Coriolis terms for the three velocity components |
---|
197 | SELECT CASE ( component ) |
---|
198 | |
---|
199 | ! |
---|
200 | !-- u-component |
---|
201 | CASE ( 1 ) |
---|
202 | !$acc kernels present( nzb_u_inner, tend, v, vg, w ) |
---|
203 | DO i = i_left, i_right |
---|
204 | DO j = j_south, j_north |
---|
205 | DO k = 1, nzt |
---|
206 | IF ( k > nzb_u_inner(j,i) ) THEN |
---|
207 | tend(k,j,i) = tend(k,j,i) + f * ( 0.25_wp * & |
---|
208 | ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) + & |
---|
209 | v(k,j+1,i) ) - vg(k) ) & |
---|
210 | - fs * ( 0.25_wp * & |
---|
211 | ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) & |
---|
212 | + w(k,j,i) ) & |
---|
213 | ) |
---|
214 | ENDIF |
---|
215 | ENDDO |
---|
216 | ENDDO |
---|
217 | ENDDO |
---|
218 | !$acc end kernels |
---|
219 | |
---|
220 | ! |
---|
221 | !-- v-component |
---|
222 | CASE ( 2 ) |
---|
223 | !$acc kernels present( nzb_v_inner, tend, u, ug ) |
---|
224 | DO i = i_left, i_right |
---|
225 | DO j = j_south, j_north |
---|
226 | DO k = 1, nzt |
---|
227 | IF ( k > nzb_v_inner(j,i) ) THEN |
---|
228 | tend(k,j,i) = tend(k,j,i) - f * ( 0.25_wp * & |
---|
229 | ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + & |
---|
230 | u(k,j,i+1) ) - ug(k) ) |
---|
231 | ENDIF |
---|
232 | ENDDO |
---|
233 | ENDDO |
---|
234 | ENDDO |
---|
235 | !$acc end kernels |
---|
236 | |
---|
237 | ! |
---|
238 | !-- w-component |
---|
239 | CASE ( 3 ) |
---|
240 | !$acc kernels present( nzb_w_inner, tend, u ) |
---|
241 | DO i = i_left, i_right |
---|
242 | DO j = j_south, j_north |
---|
243 | DO k = 1, nzt |
---|
244 | IF ( k > nzb_w_inner(j,i) ) THEN |
---|
245 | tend(k,j,i) = tend(k,j,i) + fs * 0.25_wp * & |
---|
246 | ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + & |
---|
247 | u(k+1,j,i+1) ) |
---|
248 | ENDIF |
---|
249 | ENDDO |
---|
250 | ENDDO |
---|
251 | ENDDO |
---|
252 | !$acc end kernels |
---|
253 | |
---|
254 | CASE DEFAULT |
---|
255 | |
---|
256 | WRITE( message_string, * ) ' wrong component: ', component |
---|
257 | CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 ) |
---|
258 | |
---|
259 | END SELECT |
---|
260 | |
---|
261 | END SUBROUTINE coriolis_acc |
---|
262 | |
---|
263 | |
---|
264 | !------------------------------------------------------------------------------! |
---|
265 | ! Description: |
---|
266 | ! ------------ |
---|
267 | !> Call for grid point i,j |
---|
268 | !------------------------------------------------------------------------------! |
---|
269 | SUBROUTINE coriolis_ij( i, j, component ) |
---|
270 | |
---|
271 | USE arrays_3d, & |
---|
272 | ONLY: tend, u, ug, v, vg, w |
---|
273 | |
---|
274 | USE control_parameters, & |
---|
275 | ONLY: f, fs, message_string |
---|
276 | |
---|
277 | USE indices, & |
---|
278 | ONLY: nzb_u_inner, nzb_v_inner, nzb_w_inner, nzt |
---|
279 | |
---|
280 | USE kinds |
---|
281 | |
---|
282 | IMPLICIT NONE |
---|
283 | |
---|
284 | INTEGER(iwp) :: component !< |
---|
285 | INTEGER(iwp) :: i !< |
---|
286 | INTEGER(iwp) :: j !< |
---|
287 | INTEGER(iwp) :: k !< |
---|
288 | |
---|
289 | ! |
---|
290 | !-- Compute Coriolis terms for the three velocity components |
---|
291 | SELECT CASE ( component ) |
---|
292 | |
---|
293 | ! |
---|
294 | !-- u-component |
---|
295 | CASE ( 1 ) |
---|
296 | DO k = nzb_u_inner(j,i)+1, nzt |
---|
297 | tend(k,j,i) = tend(k,j,i) + f * ( 0.25_wp * & |
---|
298 | ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) + & |
---|
299 | v(k,j+1,i) ) - vg(k) ) & |
---|
300 | - fs * ( 0.25_wp * & |
---|
301 | ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + & |
---|
302 | w(k,j,i) ) ) |
---|
303 | ENDDO |
---|
304 | |
---|
305 | ! |
---|
306 | !-- v-component |
---|
307 | CASE ( 2 ) |
---|
308 | DO k = nzb_v_inner(j,i)+1, nzt |
---|
309 | tend(k,j,i) = tend(k,j,i) - f * ( 0.25_wp * & |
---|
310 | ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + & |
---|
311 | u(k,j,i+1) ) - ug(k) ) |
---|
312 | ENDDO |
---|
313 | |
---|
314 | ! |
---|
315 | !-- w-component |
---|
316 | CASE ( 3 ) |
---|
317 | DO k = nzb_w_inner(j,i)+1, nzt |
---|
318 | tend(k,j,i) = tend(k,j,i) + fs * 0.25_wp * & |
---|
319 | ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + & |
---|
320 | u(k+1,j,i+1) ) |
---|
321 | ENDDO |
---|
322 | |
---|
323 | CASE DEFAULT |
---|
324 | |
---|
325 | WRITE( message_string, * ) ' wrong component: ', component |
---|
326 | CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 ) |
---|
327 | |
---|
328 | END SELECT |
---|
329 | |
---|
330 | END SUBROUTINE coriolis_ij |
---|
331 | |
---|
332 | END MODULE coriolis_mod |
---|