1 | MODULE subsidence_mod |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later 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-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: subsidence.f90 1381 2014-04-28 12:41:59Z heinze $ |
---|
27 | ! |
---|
28 | ! 1380 2014-04-28 12:40:45Z heinze |
---|
29 | ! Shifting only necessary in case of scalar Rayleigh damping |
---|
30 | ! |
---|
31 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
32 | ! Summation of subsidence tendencies for data output added |
---|
33 | ! +ls_index, sums_ls_l, tmp_tend |
---|
34 | ! |
---|
35 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
36 | ! REAL constants provided with KIND-attribute |
---|
37 | ! |
---|
38 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
39 | ! ONLY-attribute added to USE-statements, |
---|
40 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
41 | ! kinds are defined in new module kinds, |
---|
42 | ! old module precision_kind is removed, |
---|
43 | ! revision history before 2012 removed, |
---|
44 | ! comment fields (!:) to be used for variable explanations added to |
---|
45 | ! all variable declaration statements |
---|
46 | ! |
---|
47 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
48 | ! code put under GPL (PALM 3.9) |
---|
49 | ! |
---|
50 | ! Revision 3.7 2009-12-11 14:15:58Z heinze |
---|
51 | ! Initial revision |
---|
52 | ! |
---|
53 | ! Description: |
---|
54 | ! ------------ |
---|
55 | ! Impact of large-scale subsidence or ascent as tendency term for use |
---|
56 | ! in the prognostic equation of potential temperature. This enables the |
---|
57 | ! construction of a constant boundary layer height z_i with time. |
---|
58 | !-----------------------------------------------------------------------------! |
---|
59 | |
---|
60 | |
---|
61 | IMPLICIT NONE |
---|
62 | |
---|
63 | PRIVATE |
---|
64 | PUBLIC init_w_subsidence, subsidence |
---|
65 | |
---|
66 | INTERFACE init_w_subsidence |
---|
67 | MODULE PROCEDURE init_w_subsidence |
---|
68 | END INTERFACE init_w_subsidence |
---|
69 | |
---|
70 | INTERFACE subsidence |
---|
71 | MODULE PROCEDURE subsidence |
---|
72 | MODULE PROCEDURE subsidence_ij |
---|
73 | END INTERFACE subsidence |
---|
74 | |
---|
75 | CONTAINS |
---|
76 | |
---|
77 | SUBROUTINE init_w_subsidence |
---|
78 | |
---|
79 | USE arrays_3d, & |
---|
80 | ONLY: dzu, w_subs, zu |
---|
81 | |
---|
82 | USE control_parameters, & |
---|
83 | ONLY: message_string, ocean, subs_vertical_gradient, & |
---|
84 | subs_vertical_gradient_level, subs_vertical_gradient_level_i |
---|
85 | |
---|
86 | USE indices, & |
---|
87 | ONLY: nzb, nzt |
---|
88 | |
---|
89 | USE kinds |
---|
90 | |
---|
91 | IMPLICIT NONE |
---|
92 | |
---|
93 | INTEGER(iwp) :: i !: |
---|
94 | INTEGER(iwp) :: k !: |
---|
95 | |
---|
96 | REAL(wp) :: gradient !: |
---|
97 | REAL(wp) :: ws_surface !: |
---|
98 | |
---|
99 | IF ( .NOT. ALLOCATED( w_subs )) THEN |
---|
100 | ALLOCATE( w_subs(nzb:nzt+1) ) |
---|
101 | w_subs = 0.0_wp |
---|
102 | ENDIF |
---|
103 | |
---|
104 | IF ( ocean ) THEN |
---|
105 | message_string = 'Applying large scale vertical motion is not ' // & |
---|
106 | 'allowed for ocean runs' |
---|
107 | CALL message( 'init_w_subsidence', 'PA0324', 2, 2, 0, 6, 0 ) |
---|
108 | ENDIF |
---|
109 | |
---|
110 | ! |
---|
111 | !-- Compute the profile of the subsidence/ascent velocity |
---|
112 | !-- using the given gradients |
---|
113 | i = 1 |
---|
114 | gradient = 0.0_wp |
---|
115 | ws_surface = 0.0_wp |
---|
116 | |
---|
117 | |
---|
118 | subs_vertical_gradient_level_i(1) = 0 |
---|
119 | DO k = 1, nzt+1 |
---|
120 | IF ( i < 11 ) THEN |
---|
121 | IF ( subs_vertical_gradient_level(i) < zu(k) .AND. & |
---|
122 | subs_vertical_gradient_level(i) >= 0.0_wp ) THEN |
---|
123 | gradient = subs_vertical_gradient(i) / 100.0_wp |
---|
124 | subs_vertical_gradient_level_i(i) = k - 1 |
---|
125 | i = i + 1 |
---|
126 | ENDIF |
---|
127 | ENDIF |
---|
128 | IF ( gradient /= 0.0_wp ) THEN |
---|
129 | IF ( k /= 1 ) THEN |
---|
130 | w_subs(k) = w_subs(k-1) + dzu(k) * gradient |
---|
131 | ELSE |
---|
132 | w_subs(k) = ws_surface + 0.5_wp * dzu(k) * gradient |
---|
133 | ENDIF |
---|
134 | ELSE |
---|
135 | w_subs(k) = w_subs(k-1) |
---|
136 | ENDIF |
---|
137 | ENDDO |
---|
138 | |
---|
139 | ! |
---|
140 | !-- In case of no given gradients for the subsidence/ascent velocity, |
---|
141 | !-- choose zero gradient |
---|
142 | IF ( subs_vertical_gradient_level(1) == -9999999.9_wp ) THEN |
---|
143 | subs_vertical_gradient_level(1) = 0.0_wp |
---|
144 | ENDIF |
---|
145 | |
---|
146 | END SUBROUTINE init_w_subsidence |
---|
147 | |
---|
148 | |
---|
149 | SUBROUTINE subsidence( tendency, var, var_init, ls_index ) |
---|
150 | |
---|
151 | USE arrays_3d, & |
---|
152 | ONLY: ddzu, w_subs |
---|
153 | |
---|
154 | USE control_parameters, & |
---|
155 | ONLY: dt_3d, intermediate_timestep_count, large_scale_forcing, & |
---|
156 | scalar_rayleigh_damping |
---|
157 | |
---|
158 | USE indices, & |
---|
159 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_s_inner,& |
---|
160 | nzt |
---|
161 | |
---|
162 | USE kinds |
---|
163 | |
---|
164 | USE statistics, & |
---|
165 | ONLY: sums_ls_l, weight_pres |
---|
166 | |
---|
167 | IMPLICIT NONE |
---|
168 | |
---|
169 | INTEGER(iwp) :: i !: |
---|
170 | INTEGER(iwp) :: j !: |
---|
171 | INTEGER(iwp) :: k !: |
---|
172 | INTEGER(iwp) :: ls_index !: |
---|
173 | |
---|
174 | REAL(wp) :: tmp_tend !: |
---|
175 | REAL(wp) :: tmp_grad !: |
---|
176 | |
---|
177 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !: |
---|
178 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tendency !: |
---|
179 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_init !: |
---|
180 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_mod !: |
---|
181 | |
---|
182 | var_mod = var_init |
---|
183 | |
---|
184 | ! |
---|
185 | !-- Influence of w_subsidence on the current tendency term |
---|
186 | DO i = nxl, nxr |
---|
187 | DO j = nys, nyn |
---|
188 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
189 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
190 | tmp_tend = - w_subs(k) * & |
---|
191 | ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1) |
---|
192 | ELSE ! large-scale ascent |
---|
193 | tmp_tend = - w_subs(k) * & |
---|
194 | ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k) |
---|
195 | ENDIF |
---|
196 | |
---|
197 | tendency(k,j,i) = tendency(k,j,i) + tmp_tend |
---|
198 | |
---|
199 | IF ( large_scale_forcing ) THEN |
---|
200 | sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend & |
---|
201 | * weight_pres(intermediate_timestep_count) |
---|
202 | ENDIF |
---|
203 | ENDDO |
---|
204 | ENDDO |
---|
205 | ENDDO |
---|
206 | |
---|
207 | ! |
---|
208 | !-- Shifting of the initial profile is especially necessary with Rayleigh |
---|
209 | !-- damping switched on |
---|
210 | IF ( scalar_rayleigh_damping ) THEN |
---|
211 | DO k = nzb, nzt |
---|
212 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
213 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
214 | ( var_init(k+1) - var_init(k) ) * ddzu(k+1) |
---|
215 | ENDIF |
---|
216 | ENDDO |
---|
217 | ! |
---|
218 | !-- At the upper boundary, the initial profile is shifted with aid of |
---|
219 | !-- the gradient tmp_grad. (This is ok if the gradients are linear.) |
---|
220 | IF ( w_subs(nzt) < 0.0_wp ) THEN |
---|
221 | tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1) |
---|
222 | var_mod(nzt+1) = var_init(nzt+1) - & |
---|
223 | dt_3d * w_subs(nzt+1) * tmp_grad |
---|
224 | ENDIF |
---|
225 | |
---|
226 | |
---|
227 | DO k = nzt+1, nzb+1, -1 |
---|
228 | IF ( w_subs(k) >= 0.0_wp ) THEN ! large-scale ascent |
---|
229 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
230 | ( var_init(k) - var_init(k-1) ) * ddzu(k) |
---|
231 | ENDIF |
---|
232 | ENDDO |
---|
233 | ! |
---|
234 | !-- At the lower boundary shifting is not necessary because the |
---|
235 | !-- subsidence velocity w_subs(nzb) vanishes. |
---|
236 | IF ( w_subs(nzb+1) >= 0.0_wp ) THEN |
---|
237 | var_mod(nzb) = var_init(nzb) |
---|
238 | ENDIF |
---|
239 | |
---|
240 | var_init = var_mod |
---|
241 | ENDIF |
---|
242 | |
---|
243 | |
---|
244 | END SUBROUTINE subsidence |
---|
245 | |
---|
246 | SUBROUTINE subsidence_ij( i, j, tendency, var, var_init, ls_index ) |
---|
247 | |
---|
248 | USE arrays_3d, & |
---|
249 | ONLY: ddzu, w_subs |
---|
250 | |
---|
251 | USE control_parameters, & |
---|
252 | ONLY: dt_3d, intermediate_timestep_count, large_scale_forcing, & |
---|
253 | scalar_rayleigh_damping |
---|
254 | |
---|
255 | USE indices, & |
---|
256 | ONLY: nxl, nxlg, nxrg, nyng, nys, nysg, nzb_s_inner, nzb, nzt |
---|
257 | |
---|
258 | USE kinds |
---|
259 | |
---|
260 | USE statistics, & |
---|
261 | ONLY: sums_ls_l, weight_pres |
---|
262 | |
---|
263 | IMPLICIT NONE |
---|
264 | |
---|
265 | INTEGER(iwp) :: i !: |
---|
266 | INTEGER(iwp) :: j !: |
---|
267 | INTEGER(iwp) :: k !: |
---|
268 | INTEGER(iwp) :: ls_index !: |
---|
269 | |
---|
270 | REAL(wp) :: tmp_tend !: |
---|
271 | REAL(wp) :: tmp_grad !: |
---|
272 | |
---|
273 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !: |
---|
274 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tendency !: |
---|
275 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_init !: |
---|
276 | REAL(wp), DIMENSION(nzb:nzt+1) :: var_mod !: |
---|
277 | |
---|
278 | var_mod = var_init |
---|
279 | |
---|
280 | ! |
---|
281 | !-- Influence of w_subsidence on the current tendency term |
---|
282 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
283 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
284 | tmp_tend = - w_subs(k) * ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1) |
---|
285 | ELSE ! large-scale ascent |
---|
286 | tmp_tend = - w_subs(k) * ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k) |
---|
287 | ENDIF |
---|
288 | |
---|
289 | tendency(k,j,i) = tendency(k,j,i) + tmp_tend |
---|
290 | |
---|
291 | IF ( large_scale_forcing ) THEN |
---|
292 | sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend & |
---|
293 | * weight_pres(intermediate_timestep_count) |
---|
294 | ENDIF |
---|
295 | ENDDO |
---|
296 | |
---|
297 | |
---|
298 | ! |
---|
299 | !-- Shifting of the initial profile is especially necessary with Rayleigh |
---|
300 | !-- damping switched on |
---|
301 | IF ( scalar_rayleigh_damping ) THEN |
---|
302 | IF ( i == nxl .AND. j == nys ) THEN ! shifting only once per PE |
---|
303 | |
---|
304 | DO k = nzb, nzt |
---|
305 | IF ( w_subs(k) < 0.0_wp ) THEN ! large-scale subsidence |
---|
306 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
307 | ( var_init(k+1) - var_init(k) ) * ddzu(k+1) |
---|
308 | ENDIF |
---|
309 | ENDDO |
---|
310 | ! |
---|
311 | !-- At the upper boundary, the initial profile is shifted with aid of |
---|
312 | !-- the gradient tmp_grad. (This is ok if the gradients are linear.) |
---|
313 | IF ( w_subs(nzt) < 0.0_wp ) THEN |
---|
314 | tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1) |
---|
315 | var_mod(nzt+1) = var_init(nzt+1) - & |
---|
316 | dt_3d * w_subs(nzt+1) * tmp_grad |
---|
317 | ENDIF |
---|
318 | |
---|
319 | |
---|
320 | DO k = nzt+1, nzb+1, -1 |
---|
321 | IF ( w_subs(k) >= 0.0_wp ) THEN ! large-scale ascent |
---|
322 | var_mod(k) = var_init(k) - dt_3d * w_subs(k) * & |
---|
323 | ( var_init(k) - var_init(k-1) ) * ddzu(k) |
---|
324 | ENDIF |
---|
325 | ENDDO |
---|
326 | ! |
---|
327 | !-- At the lower boundary shifting is not necessary because the |
---|
328 | !-- subsidence velocity w_subs(nzb) vanishes. |
---|
329 | IF ( w_subs(nzb+1) >= 0.0_wp ) THEN |
---|
330 | var_mod(nzb) = var_init(nzb) |
---|
331 | ENDIF |
---|
332 | |
---|
333 | var_init = var_mod |
---|
334 | |
---|
335 | ENDIF |
---|
336 | ENDIF |
---|
337 | |
---|
338 | END SUBROUTINE subsidence_ij |
---|
339 | |
---|
340 | |
---|
341 | END MODULE subsidence_mod |
---|