1 | !> @file subsidence_mod.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-2019 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: subsidence_mod.f90 4182 2019-08-22 15:20:23Z knoop $ |
---|
27 | ! Corrected "Former revisions" section |
---|
28 | ! |
---|
29 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
30 | ! add subroutine and variable description |
---|
31 | ! |
---|
32 | ! Revision 3.7 2009-12-11 14:15:58Z heinze |
---|
33 | ! Initial revision |
---|
34 | ! |
---|
35 | ! Description: |
---|
36 | ! ------------ |
---|
37 | !> Impact of large-scale subsidence or ascent as tendency term for use |
---|
38 | !> in the prognostic equation of potential temperature. This enables the |
---|
39 | !> construction of a constant boundary layer height z_i with time. |
---|
40 | !-----------------------------------------------------------------------------! |
---|
41 | MODULE subsidence_mod |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | IMPLICIT NONE |
---|
46 | |
---|
47 | PRIVATE |
---|
48 | PUBLIC init_w_subsidence, subsidence |
---|
49 | |
---|
50 | INTERFACE init_w_subsidence |
---|
51 | MODULE PROCEDURE init_w_subsidence |
---|
52 | END INTERFACE init_w_subsidence |
---|
53 | |
---|
54 | INTERFACE subsidence |
---|
55 | MODULE PROCEDURE subsidence |
---|
56 | MODULE PROCEDURE subsidence_ij |
---|
57 | END INTERFACE subsidence |
---|
58 | |
---|
59 | CONTAINS |
---|
60 | |
---|
61 | !------------------------------------------------------------------------------! |
---|
62 | ! Description: |
---|
63 | ! ------------ |
---|
64 | !> Initialize vertical subsidence velocity w_subs. |
---|
65 | !------------------------------------------------------------------------------! |
---|
66 | SUBROUTINE init_w_subsidence |
---|
67 | |
---|
68 | USE arrays_3d, & |
---|
69 | ONLY: dzu, w_subs, zu |
---|
70 | |
---|
71 | USE control_parameters, & |
---|
72 | ONLY: message_string, ocean_mode, subs_vertical_gradient, & |
---|
73 | subs_vertical_gradient_level, subs_vertical_gradient_level_i |
---|
74 | |
---|
75 | USE indices, & |
---|
76 | ONLY: nzb, nzt |
---|
77 | |
---|
78 | USE kinds |
---|
79 | |
---|
80 | IMPLICIT NONE |
---|
81 | |
---|
82 | INTEGER(iwp) :: i !< loop index |
---|
83 | INTEGER(iwp) :: k !< loop index |
---|
84 | |
---|
85 | REAL(wp) :: gradient !< vertical gradient of subsidence velocity |
---|
86 | REAL(wp) :: ws_surface !< subsidence velocity at the surface |
---|
87 | |
---|
88 | IF ( .NOT. ALLOCATED( w_subs ) ) THEN |
---|
89 | ALLOCATE( w_subs(nzb:nzt+1) ) |
---|
90 | w_subs = 0.0_wp |
---|
91 | ENDIF |
---|
92 | |
---|
93 | IF ( ocean_mode ) THEN |
---|
94 | message_string = 'applying large scale vertical motion is not ' // & |
---|
95 | 'allowed for ocean mode' |
---|
96 | CALL message( 'init_w_subsidence', 'PA0324', 2, 2, 0, 6, 0 ) |
---|
97 | ENDIF |
---|
98 | |
---|
99 | ! |
---|
100 | !-- Compute the profile of the subsidence/ascent velocity |
---|
101 | !-- using the given gradients |
---|
102 | i = 1 |
---|
103 | gradient = 0.0_wp |
---|
104 | ws_surface = 0.0_wp |
---|
105 | |
---|
106 | |
---|
107 | subs_vertical_gradient_level_i(1) = 0 |
---|
108 | DO k = 1, nzt+1 |
---|
109 | IF ( i < 11 ) THEN |
---|
110 | IF ( subs_vertical_gradient_level(i) < zu(k) .AND. & |
---|
111 | subs_vertical_gradient_level(i) >= 0.0_wp ) THEN |
---|
112 | gradient = subs_vertical_gradient(i) / 100.0_wp |
---|
113 | subs_vertical_gradient_level_i(i) = k - 1 |
---|
114 | i = i + 1 |
---|
115 | ENDIF |
---|
116 | ENDIF |
---|
117 | IF ( gradient /= 0.0_wp ) THEN |
---|
118 | IF ( k /= 1 ) THEN |
---|
119 | w_subs(k) = w_subs(k-1) + dzu(k) * gradient |
---|
120 | ELSE |
---|
121 | w_subs(k) = ws_surface + 0.5_wp * dzu(k) * gradient |
---|
122 | ENDIF |
---|
123 | ELSE |
---|
124 | w_subs(k) = w_subs(k-1) |
---|
125 | ENDIF |
---|
126 | ENDDO |
---|
127 | |
---|
128 | ! |
---|
129 | !-- In case of no given gradients for the subsidence/ascent velocity, |
---|
130 | !-- choose zero gradient |
---|
131 | IF ( subs_vertical_gradient_level(1) == -9999999.9_wp ) THEN |
---|
132 | subs_vertical_gradient_level(1) = 0.0_wp |
---|
133 | ENDIF |
---|
134 | |
---|
135 | END SUBROUTINE init_w_subsidence |
---|
136 | |
---|
137 | |
---|
138 | !------------------------------------------------------------------------------! |
---|
139 | ! Description: |
---|
140 | ! ------------ |
---|
141 | !> Add effect of large-scale subsidence to variable. |
---|
142 | !------------------------------------------------------------------------------! |
---|
143 | SUBROUTINE subsidence( tendency, var, var_init, ls_index ) |
---|
144 | |
---|
145 | USE arrays_3d, & |
---|
146 | ONLY: ddzu, w_subs |
---|
147 | |
---|
148 | USE control_parameters, & |
---|
149 | ONLY: dt_3d, intermediate_timestep_count, large_scale_forcing, & |
---|
150 | scalar_rayleigh_damping |
---|
151 | |
---|
152 | USE indices, & |
---|
153 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, & |
---|
154 | wall_flags_0 |
---|
155 | |
---|
156 | USE kinds |
---|
157 | |
---|
158 | USE statistics, & |
---|
159 | ONLY: sums_ls_l, weight_substep |
---|
160 | |
---|
161 | IMPLICIT NONE |
---|
162 | |
---|
163 | INTEGER(iwp) :: i !< loop index |
---|
164 | INTEGER(iwp) :: j !< loop index |
---|
165 | INTEGER(iwp) :: k !< loop index |
---|
166 | INTEGER(iwp) :: ls_index !< index of large-scale subsidence in sums_ls_l |
---|
167 | |
---|
168 | REAL(wp) :: tmp_tend !< temporary tendency |
---|
169 | REAL(wp) :: tmp_grad !< temporary gradient |
---|
170 | |
---|
171 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !< variable where to add subsidence |
---|
172 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tendency !< tendency of var |
---|
173 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_init !< initialization profile of var |
---|
174 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_mod !< modified profile of var |
---|
175 | |
---|
176 | var_mod = var_init |
---|
177 | |
---|
178 | ! |
---|
179 | !-- Influence of w_subsidence on the current tendency term |
---|
180 | DO i = nxl, nxr |
---|
181 | DO j = nys, nyn |
---|
182 | |
---|
183 | DO k = nzb+1, nzt |
---|
184 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
185 | tmp_tend = - w_subs(k) * & |
---|
186 | ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1) * & |
---|
187 | MERGE( 1.0_wp, 0.0_wp, & |
---|
188 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
189 | ELSE ! large-scale ascent |
---|
190 | tmp_tend = - w_subs(k) * & |
---|
191 | ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k) * & |
---|
192 | MERGE( 1.0_wp, 0.0_wp, & |
---|
193 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
194 | ENDIF |
---|
195 | |
---|
196 | tendency(k,j,i) = tendency(k,j,i) + tmp_tend |
---|
197 | |
---|
198 | IF ( large_scale_forcing ) THEN |
---|
199 | sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend & |
---|
200 | * weight_substep(intermediate_timestep_count) & |
---|
201 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
202 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
203 | ENDIF |
---|
204 | ENDDO |
---|
205 | |
---|
206 | IF ( large_scale_forcing ) THEN |
---|
207 | sums_ls_l(nzt+1,ls_index) = sums_ls_l(nzt,ls_index) |
---|
208 | ENDIF |
---|
209 | |
---|
210 | ENDDO |
---|
211 | ENDDO |
---|
212 | |
---|
213 | ! |
---|
214 | !-- Shifting of the initial profile is especially necessary with Rayleigh |
---|
215 | !-- damping switched on |
---|
216 | IF ( scalar_rayleigh_damping .AND. & |
---|
217 | intermediate_timestep_count == 1 ) THEN |
---|
218 | DO k = nzb, nzt |
---|
219 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
220 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
221 | ( var_init(k+1) - var_init(k) ) * ddzu(k+1) |
---|
222 | ENDIF |
---|
223 | ENDDO |
---|
224 | ! |
---|
225 | !-- At the upper boundary, the initial profile is shifted with aid of |
---|
226 | !-- the gradient tmp_grad. (This is ok if the gradients are linear.) |
---|
227 | IF ( w_subs(nzt) < 0.0_wp ) THEN |
---|
228 | tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1) |
---|
229 | var_mod(nzt+1) = var_init(nzt+1) - & |
---|
230 | dt_3d * w_subs(nzt+1) * tmp_grad |
---|
231 | ENDIF |
---|
232 | |
---|
233 | |
---|
234 | DO k = nzt+1, nzb+1, -1 |
---|
235 | IF ( w_subs(k) >= 0.0_wp ) THEN ! large-scale ascent |
---|
236 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
237 | ( var_init(k) - var_init(k-1) ) * ddzu(k) |
---|
238 | ENDIF |
---|
239 | ENDDO |
---|
240 | ! |
---|
241 | !-- At the lower boundary shifting is not necessary because the |
---|
242 | !-- subsidence velocity w_subs(nzb) vanishes. |
---|
243 | IF ( w_subs(nzb+1) >= 0.0_wp ) THEN |
---|
244 | var_mod(nzb) = var_init(nzb) |
---|
245 | ENDIF |
---|
246 | |
---|
247 | var_init = var_mod |
---|
248 | ENDIF |
---|
249 | |
---|
250 | |
---|
251 | END SUBROUTINE subsidence |
---|
252 | |
---|
253 | !------------------------------------------------------------------------------! |
---|
254 | ! Description: |
---|
255 | ! ------------ |
---|
256 | !> Add effect of large-scale subsidence to variable. |
---|
257 | !------------------------------------------------------------------------------! |
---|
258 | SUBROUTINE subsidence_ij( i, j, tendency, var, var_init, ls_index ) |
---|
259 | |
---|
260 | USE arrays_3d, & |
---|
261 | ONLY: ddzu, w_subs |
---|
262 | |
---|
263 | USE control_parameters, & |
---|
264 | ONLY: dt_3d, intermediate_timestep_count, large_scale_forcing, & |
---|
265 | scalar_rayleigh_damping |
---|
266 | |
---|
267 | USE indices, & |
---|
268 | ONLY: nxl, nxlg, nxrg, nyng, nys, nysg, nzb, nzt, wall_flags_0 |
---|
269 | |
---|
270 | USE kinds |
---|
271 | |
---|
272 | USE statistics, & |
---|
273 | ONLY: sums_ls_l, weight_substep |
---|
274 | |
---|
275 | IMPLICIT NONE |
---|
276 | |
---|
277 | INTEGER(iwp) :: i !< loop variable |
---|
278 | INTEGER(iwp) :: j !< loop variable |
---|
279 | INTEGER(iwp) :: k !< loop variable |
---|
280 | INTEGER(iwp) :: ls_index !< index of large-scale subsidence in sums_ls_l |
---|
281 | |
---|
282 | REAL(wp) :: tmp_tend !< temporary tendency |
---|
283 | REAL(wp) :: tmp_grad !< temporary gradient |
---|
284 | |
---|
285 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !< variable where to add subsidence |
---|
286 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tendency !< tendency of var |
---|
287 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_init !< initialization profile of var |
---|
288 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_mod !< modified profile of var |
---|
289 | |
---|
290 | var_mod = var_init |
---|
291 | |
---|
292 | ! |
---|
293 | !-- Influence of w_subsidence on the current tendency term |
---|
294 | DO k = nzb+1, nzt |
---|
295 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
296 | tmp_tend = - w_subs(k) * ( var(k+1,j,i) - var(k,j,i) ) & |
---|
297 | * ddzu(k+1) & |
---|
298 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
299 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
300 | ELSE ! large-scale ascent |
---|
301 | tmp_tend = - w_subs(k) * ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k) & |
---|
302 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
303 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
304 | ENDIF |
---|
305 | |
---|
306 | tendency(k,j,i) = tendency(k,j,i) + tmp_tend |
---|
307 | |
---|
308 | IF ( large_scale_forcing ) THEN |
---|
309 | sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend & |
---|
310 | * weight_substep(intermediate_timestep_count)& |
---|
311 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
312 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
313 | ENDIF |
---|
314 | ENDDO |
---|
315 | |
---|
316 | IF ( large_scale_forcing ) THEN |
---|
317 | sums_ls_l(nzt+1,ls_index) = sums_ls_l(nzt,ls_index) |
---|
318 | ENDIF |
---|
319 | |
---|
320 | ! |
---|
321 | !-- Shifting of the initial profile is especially necessary with Rayleigh |
---|
322 | !-- damping switched on |
---|
323 | IF ( scalar_rayleigh_damping .AND. & |
---|
324 | intermediate_timestep_count == 1 ) THEN |
---|
325 | IF ( i == nxl .AND. j == nys ) THEN ! shifting only once per PE |
---|
326 | |
---|
327 | DO k = nzb, nzt |
---|
328 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
329 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
330 | ( var_init(k+1) - var_init(k) ) * ddzu(k+1) |
---|
331 | ENDIF |
---|
332 | ENDDO |
---|
333 | ! |
---|
334 | !-- At the upper boundary, the initial profile is shifted with aid of |
---|
335 | !-- the gradient tmp_grad. (This is ok if the gradients are linear.) |
---|
336 | IF ( w_subs(nzt) < 0.0_wp ) THEN |
---|
337 | tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1) |
---|
338 | var_mod(nzt+1) = var_init(nzt+1) - & |
---|
339 | dt_3d * w_subs(nzt+1) * tmp_grad |
---|
340 | ENDIF |
---|
341 | |
---|
342 | |
---|
343 | DO k = nzt+1, nzb+1, -1 |
---|
344 | IF ( w_subs(k) >= 0.0_wp ) THEN ! large-scale ascent |
---|
345 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
346 | ( var_init(k) - var_init(k-1) ) * ddzu(k) |
---|
347 | ENDIF |
---|
348 | ENDDO |
---|
349 | ! |
---|
350 | !-- At the lower boundary shifting is not necessary because the |
---|
351 | !-- subsidence velocity w_subs(nzb) vanishes. |
---|
352 | IF ( w_subs(nzb+1) >= 0.0_wp ) THEN |
---|
353 | var_mod(nzb) = var_init(nzb) |
---|
354 | ENDIF |
---|
355 | |
---|
356 | var_init = var_mod |
---|
357 | |
---|
358 | ENDIF |
---|
359 | ENDIF |
---|
360 | |
---|
361 | END SUBROUTINE subsidence_ij |
---|
362 | |
---|
363 | |
---|
364 | END MODULE subsidence_mod |
---|