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