1 | !> @file nudging_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 |
---|
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: nudging_mod.f90 2233 2017-05-30 18:08:54Z sward $ |
---|
27 | ! |
---|
28 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
29 | ! Adjustments to new topography concept |
---|
30 | ! |
---|
31 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
32 | ! Forced header and separation lines into 80 columns |
---|
33 | ! |
---|
34 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
35 | ! Module renamed |
---|
36 | ! |
---|
37 | ! |
---|
38 | ! 1757 2016-02-22 15:49:32Z maronga |
---|
39 | ! Bugfix: allow for using higher vertical resolution in nudging file than grid |
---|
40 | ! spacing in the LES model |
---|
41 | ! |
---|
42 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
43 | ! Code annotations made doxygen readable |
---|
44 | ! |
---|
45 | ! 1398 2014-05-07 11:15:00Z heinze |
---|
46 | ! Subroutine nudge_ref is extended to set u_init and v_init to the current |
---|
47 | ! nudging profiles |
---|
48 | ! |
---|
49 | ! 1382 2014-04-30 12:15:41Z boeske |
---|
50 | ! Changed the weighting factor that is used in the summation of nudging |
---|
51 | ! tendencies for profile data output from weight_pres to weight_substep, |
---|
52 | ! added Neumann boundary conditions for profile data output of nudging terms at |
---|
53 | ! nzt+1 |
---|
54 | ! |
---|
55 | ! 1380 2014-04-28 12:40:45Z heinze |
---|
56 | ! Subroutine nudge_ref added to account for proper upper scalar boundary |
---|
57 | ! conditions in case of nudging |
---|
58 | ! |
---|
59 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
60 | ! Variable t renamed nt, variable currtnudge renamed tmp_tnudge, |
---|
61 | ! summation of nudging tendencies for data output added |
---|
62 | ! +sums_ls_l, tmp_tend |
---|
63 | ! Added new subroutine calc_tnudge, which calculates the current nudging time |
---|
64 | ! scale at each time step |
---|
65 | ! |
---|
66 | ! 1355 2014-04-10 10:21:29Z heinze |
---|
67 | ! Error message specified. |
---|
68 | ! |
---|
69 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
70 | ! REAL constants provided with KIND-attribute |
---|
71 | ! |
---|
72 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
73 | ! ONLY-attribute added to USE-statements, |
---|
74 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
75 | ! kinds are defined in new module kinds, |
---|
76 | ! old module precision_kind is removed, |
---|
77 | ! revision history before 2012 removed, |
---|
78 | ! comment fields (!:) to be used for variable explanations added to |
---|
79 | ! all variable declaration statements |
---|
80 | ! |
---|
81 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
82 | ! module interfaces removed |
---|
83 | ! |
---|
84 | ! 1268 2013-12-12 09:47:53Z heinze |
---|
85 | ! bugfix: argument of calc_mean_profile corrected |
---|
86 | ! |
---|
87 | ! 1251 2013-11-07 08:14:30Z heinze |
---|
88 | ! bugfix: calculate dtm and dtp also in vector version |
---|
89 | ! |
---|
90 | ! 1249 2013-11-06 10:45:47Z heinze |
---|
91 | ! remove call of user module |
---|
92 | ! reformatting |
---|
93 | ! |
---|
94 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
95 | ! Initial revision |
---|
96 | ! |
---|
97 | ! Description: |
---|
98 | ! ------------ |
---|
99 | !> Nudges u, v, pt and q to given profiles on a relaxation timescale tnudge. |
---|
100 | !> Profiles are read in from NUDGIN_DATA. Code is based on Neggers et al. (2012) |
---|
101 | !> and also part of DALES and UCLA-LES. |
---|
102 | !--------------------------------------------------------------------------------! |
---|
103 | MODULE nudge_mod |
---|
104 | |
---|
105 | |
---|
106 | PRIVATE |
---|
107 | PUBLIC init_nudge, calc_tnudge, nudge, nudge_ref |
---|
108 | SAVE |
---|
109 | |
---|
110 | INTERFACE nudge |
---|
111 | MODULE PROCEDURE nudge |
---|
112 | MODULE PROCEDURE nudge_ij |
---|
113 | END INTERFACE nudge |
---|
114 | |
---|
115 | CONTAINS |
---|
116 | |
---|
117 | !------------------------------------------------------------------------------! |
---|
118 | ! Description: |
---|
119 | ! ------------ |
---|
120 | !> @todo Missing subroutine description. |
---|
121 | !------------------------------------------------------------------------------! |
---|
122 | SUBROUTINE init_nudge |
---|
123 | |
---|
124 | USE arrays_3d, & |
---|
125 | ONLY: ptnudge, qnudge, timenudge, tmp_tnudge, tnudge, unudge, & |
---|
126 | vnudge, wnudge, zu |
---|
127 | |
---|
128 | USE control_parameters, & |
---|
129 | ONLY: dt_3d, lptnudge, lqnudge, lunudge, lvnudge, lwnudge, & |
---|
130 | message_string, ntnudge |
---|
131 | |
---|
132 | USE indices, & |
---|
133 | ONLY: nzb, nzt |
---|
134 | |
---|
135 | USE kinds |
---|
136 | |
---|
137 | IMPLICIT NONE |
---|
138 | |
---|
139 | |
---|
140 | INTEGER(iwp) :: finput = 90 !< |
---|
141 | INTEGER(iwp) :: ierrn !< |
---|
142 | INTEGER(iwp) :: k !< |
---|
143 | INTEGER(iwp) :: nt !< |
---|
144 | |
---|
145 | CHARACTER(1) :: hash !< |
---|
146 | |
---|
147 | REAL(wp) :: highheight !< |
---|
148 | REAL(wp) :: highqnudge !< |
---|
149 | REAL(wp) :: highptnudge !< |
---|
150 | REAL(wp) :: highunudge !< |
---|
151 | REAL(wp) :: highvnudge !< |
---|
152 | REAL(wp) :: highwnudge !< |
---|
153 | REAL(wp) :: hightnudge !< |
---|
154 | |
---|
155 | REAL(wp) :: lowheight !< |
---|
156 | REAL(wp) :: lowqnudge !< |
---|
157 | REAL(wp) :: lowptnudge !< |
---|
158 | REAL(wp) :: lowunudge !< |
---|
159 | REAL(wp) :: lowvnudge !< |
---|
160 | REAL(wp) :: lowwnudge !< |
---|
161 | REAL(wp) :: lowtnudge !< |
---|
162 | |
---|
163 | REAL(wp) :: fac !< |
---|
164 | |
---|
165 | ALLOCATE( ptnudge(nzb:nzt+1,1:ntnudge), qnudge(nzb:nzt+1,1:ntnudge), & |
---|
166 | tnudge(nzb:nzt+1,1:ntnudge), unudge(nzb:nzt+1,1:ntnudge), & |
---|
167 | vnudge(nzb:nzt+1,1:ntnudge), wnudge(nzb:nzt+1,1:ntnudge) ) |
---|
168 | |
---|
169 | ALLOCATE( tmp_tnudge(nzb:nzt) ) |
---|
170 | |
---|
171 | ALLOCATE( timenudge(0:ntnudge) ) |
---|
172 | |
---|
173 | ptnudge = 0.0_wp; qnudge = 0.0_wp; tnudge = 0.0_wp; unudge = 0.0_wp |
---|
174 | vnudge = 0.0_wp; wnudge = 0.0_wp; timenudge = 0.0_wp |
---|
175 | ! |
---|
176 | !-- Initialize array tmp_nudge with a current nudging time scale of 6 hours |
---|
177 | tmp_tnudge = 21600.0_wp |
---|
178 | |
---|
179 | nt = 0 |
---|
180 | OPEN ( finput, FILE='NUDGING_DATA', STATUS='OLD', & |
---|
181 | FORM='FORMATTED', IOSTAT=ierrn ) |
---|
182 | |
---|
183 | IF ( ierrn /= 0 ) THEN |
---|
184 | message_string = 'file NUDGING_DATA does not exist' |
---|
185 | CALL message( 'nudging', 'PA0365', 1, 2, 0, 6, 0 ) |
---|
186 | ENDIF |
---|
187 | |
---|
188 | ierrn = 0 |
---|
189 | |
---|
190 | rloop:DO |
---|
191 | nt = nt + 1 |
---|
192 | hash = "#" |
---|
193 | ierrn = 1 ! not zero |
---|
194 | ! |
---|
195 | !-- Search for the next line consisting of "# time", |
---|
196 | !-- from there onwards the profiles will be read |
---|
197 | DO WHILE ( .NOT. ( hash == "#" .AND. ierrn == 0 ) ) |
---|
198 | |
---|
199 | READ ( finput, *, IOSTAT=ierrn ) hash, timenudge(nt) |
---|
200 | IF ( ierrn < 0 ) EXIT rloop |
---|
201 | |
---|
202 | ENDDO |
---|
203 | |
---|
204 | ierrn = 0 |
---|
205 | READ ( finput, *, IOSTAT=ierrn ) lowheight, lowtnudge, lowunudge, & |
---|
206 | lowvnudge, lowwnudge , lowptnudge, & |
---|
207 | lowqnudge |
---|
208 | |
---|
209 | IF ( ierrn /= 0 ) THEN |
---|
210 | message_string = 'errors in file NUDGING_DATA' |
---|
211 | CALL message( 'nudging', 'PA0366', 1, 2, 0, 6, 0 ) |
---|
212 | ENDIF |
---|
213 | |
---|
214 | ierrn = 0 |
---|
215 | READ ( finput, *, IOSTAT=ierrn ) highheight, hightnudge, highunudge, & |
---|
216 | highvnudge, highwnudge , highptnudge, & |
---|
217 | highqnudge |
---|
218 | |
---|
219 | IF ( ierrn /= 0 ) THEN |
---|
220 | message_string = 'errors in file NUDGING_DATA' |
---|
221 | CALL message( 'nudging', 'PA0366', 1, 2, 0, 6, 0 ) |
---|
222 | ENDIF |
---|
223 | |
---|
224 | DO k = nzb, nzt+1 |
---|
225 | DO WHILE ( highheight < zu(k) ) |
---|
226 | lowheight = highheight |
---|
227 | lowtnudge = hightnudge |
---|
228 | lowunudge = highunudge |
---|
229 | lowvnudge = highvnudge |
---|
230 | lowwnudge = highwnudge |
---|
231 | lowptnudge = highptnudge |
---|
232 | lowqnudge = highqnudge |
---|
233 | |
---|
234 | ierrn = 0 |
---|
235 | READ ( finput, *, IOSTAT=ierrn ) highheight , hightnudge , & |
---|
236 | highunudge , highvnudge , & |
---|
237 | highwnudge , highptnudge, & |
---|
238 | highqnudge |
---|
239 | IF (ierrn /= 0 ) THEN |
---|
240 | WRITE( message_string, * ) 'zu(nzt+1) = ', zu(nzt+1), 'm is ',& |
---|
241 | 'higher than the maximum height in NUDING_DATA which ', & |
---|
242 | 'is ', lowheight, 'm. Interpolation on PALM ', & |
---|
243 | 'grid is not possible.' |
---|
244 | CALL message( 'nudging', 'PA0364', 1, 2, 0, 6, 0 ) |
---|
245 | ENDIF |
---|
246 | ENDDO |
---|
247 | |
---|
248 | ! |
---|
249 | !-- Interpolation of prescribed profiles in space |
---|
250 | |
---|
251 | fac = ( highheight - zu(k) ) / ( highheight - lowheight ) |
---|
252 | |
---|
253 | tnudge(k,nt) = fac * lowtnudge + ( 1.0_wp - fac ) * hightnudge |
---|
254 | unudge(k,nt) = fac * lowunudge + ( 1.0_wp - fac ) * highunudge |
---|
255 | vnudge(k,nt) = fac * lowvnudge + ( 1.0_wp - fac ) * highvnudge |
---|
256 | wnudge(k,nt) = fac * lowwnudge + ( 1.0_wp - fac ) * highwnudge |
---|
257 | ptnudge(k,nt) = fac * lowptnudge + ( 1.0_wp - fac ) * highptnudge |
---|
258 | qnudge(k,nt) = fac * lowqnudge + ( 1.0_wp - fac ) * highqnudge |
---|
259 | ENDDO |
---|
260 | |
---|
261 | ENDDO rloop |
---|
262 | |
---|
263 | CLOSE ( finput ) |
---|
264 | |
---|
265 | ! |
---|
266 | !-- Prevent nudging if nudging profiles exhibt too small values |
---|
267 | !-- not used so far |
---|
268 | lptnudge = ANY( ABS( ptnudge ) > 1.0e-8_wp ) |
---|
269 | lqnudge = ANY( ABS( qnudge ) > 1.0e-8_wp ) |
---|
270 | lunudge = ANY( ABS( unudge ) > 1.0e-8_wp ) |
---|
271 | lvnudge = ANY( ABS( vnudge ) > 1.0e-8_wp ) |
---|
272 | lwnudge = ANY( ABS( wnudge ) > 1.0e-8_wp ) |
---|
273 | |
---|
274 | END SUBROUTINE init_nudge |
---|
275 | |
---|
276 | |
---|
277 | !------------------------------------------------------------------------------! |
---|
278 | ! Description: |
---|
279 | ! ------------ |
---|
280 | !> @todo Missing subroutine description. |
---|
281 | !------------------------------------------------------------------------------! |
---|
282 | SUBROUTINE calc_tnudge ( time ) |
---|
283 | |
---|
284 | USE arrays_3d, & |
---|
285 | ONLY: timenudge, tmp_tnudge, tnudge |
---|
286 | |
---|
287 | USE control_parameters, & |
---|
288 | ONLY: dt_3d |
---|
289 | |
---|
290 | USE indices, & |
---|
291 | ONLY: nzb, nzt |
---|
292 | |
---|
293 | USE kinds |
---|
294 | |
---|
295 | IMPLICIT NONE |
---|
296 | |
---|
297 | |
---|
298 | REAL(wp) :: dtm !< |
---|
299 | REAL(wp) :: dtp !< |
---|
300 | REAL(wp) :: time !< |
---|
301 | |
---|
302 | INTEGER(iwp) :: k !< |
---|
303 | INTEGER(iwp) :: nt !< |
---|
304 | |
---|
305 | nt = 1 |
---|
306 | DO WHILE ( time > timenudge(nt) ) |
---|
307 | nt = nt+1 |
---|
308 | ENDDO |
---|
309 | IF ( time /= timenudge(1) ) THEN |
---|
310 | nt = nt-1 |
---|
311 | ENDIF |
---|
312 | |
---|
313 | dtm = ( time - timenudge(nt) ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
314 | dtp = ( timenudge(nt+1) - time ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
315 | |
---|
316 | DO k = nzb, nzt |
---|
317 | tmp_tnudge(k) = MAX( dt_3d, tnudge(k,nt) * dtp + tnudge(k,nt+1) * dtm ) |
---|
318 | ENDDO |
---|
319 | |
---|
320 | END SUBROUTINE calc_tnudge |
---|
321 | |
---|
322 | !------------------------------------------------------------------------------! |
---|
323 | ! Description: |
---|
324 | ! ------------ |
---|
325 | !> Call for all grid points |
---|
326 | !------------------------------------------------------------------------------! |
---|
327 | SUBROUTINE nudge ( time, prog_var ) |
---|
328 | |
---|
329 | USE arrays_3d, & |
---|
330 | ONLY: pt, ptnudge, q, qnudge, tend, timenudge, tmp_tnudge, tnudge, & |
---|
331 | u, unudge, v, vnudge |
---|
332 | |
---|
333 | USE control_parameters, & |
---|
334 | ONLY: dt_3d, intermediate_timestep_count, message_string |
---|
335 | |
---|
336 | USE indices, & |
---|
337 | ONLY: nxl, nxr, nys, nyn, nzb, nzt, wall_flags_0 |
---|
338 | |
---|
339 | USE kinds |
---|
340 | |
---|
341 | USE statistics, & |
---|
342 | ONLY: hom, sums_ls_l, weight_substep |
---|
343 | |
---|
344 | IMPLICIT NONE |
---|
345 | |
---|
346 | CHARACTER (LEN=*) :: prog_var !< |
---|
347 | |
---|
348 | REAL(wp) :: tmp_tend !< |
---|
349 | REAL(wp) :: dtm !< |
---|
350 | REAL(wp) :: dtp !< |
---|
351 | REAL(wp) :: time !< |
---|
352 | |
---|
353 | INTEGER(iwp) :: i !< |
---|
354 | INTEGER(iwp) :: j !< |
---|
355 | INTEGER(iwp) :: k !< |
---|
356 | INTEGER(iwp) :: nt !< |
---|
357 | |
---|
358 | |
---|
359 | nt = 1 |
---|
360 | DO WHILE ( time > timenudge(nt) ) |
---|
361 | nt = nt+1 |
---|
362 | ENDDO |
---|
363 | IF ( time /= timenudge(1) ) THEN |
---|
364 | nt = nt-1 |
---|
365 | ENDIF |
---|
366 | |
---|
367 | dtm = ( time - timenudge(nt) ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
368 | dtp = ( timenudge(nt+1) - time ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
369 | |
---|
370 | SELECT CASE ( prog_var ) |
---|
371 | |
---|
372 | CASE ( 'u' ) |
---|
373 | |
---|
374 | DO i = nxl, nxr |
---|
375 | DO j = nys, nyn |
---|
376 | |
---|
377 | DO k = nzb+1, nzt |
---|
378 | |
---|
379 | tmp_tend = - ( hom(k,1,1,0) - ( unudge(k,nt) * dtp + & |
---|
380 | unudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
381 | |
---|
382 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
383 | MERGE( 1.0_wp, 0.0_wp, & |
---|
384 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
385 | |
---|
386 | sums_ls_l(k,6) = sums_ls_l(k,6) + tmp_tend * & |
---|
387 | weight_substep(intermediate_timestep_count) |
---|
388 | ENDDO |
---|
389 | |
---|
390 | sums_ls_l(nzt+1,6) = sums_ls_l(nzt,6) |
---|
391 | |
---|
392 | ENDDO |
---|
393 | ENDDO |
---|
394 | |
---|
395 | CASE ( 'v' ) |
---|
396 | |
---|
397 | DO i = nxl, nxr |
---|
398 | DO j = nys, nyn |
---|
399 | |
---|
400 | DO k = nzb+1, nzt |
---|
401 | |
---|
402 | tmp_tend = - ( hom(k,1,2,0) - ( vnudge(k,nt) * dtp + & |
---|
403 | vnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
404 | |
---|
405 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
406 | MERGE( 1.0_wp, 0.0_wp, & |
---|
407 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
408 | |
---|
409 | sums_ls_l(k,7) = sums_ls_l(k,7) + tmp_tend * & |
---|
410 | weight_substep(intermediate_timestep_count) |
---|
411 | ENDDO |
---|
412 | |
---|
413 | sums_ls_l(nzt+1,7) = sums_ls_l(nzt,7) |
---|
414 | |
---|
415 | ENDDO |
---|
416 | ENDDO |
---|
417 | |
---|
418 | CASE ( 'pt' ) |
---|
419 | |
---|
420 | DO i = nxl, nxr |
---|
421 | DO j = nys, nyn |
---|
422 | |
---|
423 | DO k = nzb+1, nzt |
---|
424 | |
---|
425 | tmp_tend = - ( hom(k,1,4,0) - ( ptnudge(k,nt) * dtp + & |
---|
426 | ptnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
427 | |
---|
428 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
429 | MERGE( 1.0_wp, 0.0_wp, & |
---|
430 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
431 | |
---|
432 | sums_ls_l(k,4) = sums_ls_l(k,4) + tmp_tend * & |
---|
433 | weight_substep(intermediate_timestep_count) |
---|
434 | ENDDO |
---|
435 | |
---|
436 | sums_ls_l(nzt+1,4) = sums_ls_l(nzt,4) |
---|
437 | |
---|
438 | ENDDO |
---|
439 | ENDDO |
---|
440 | |
---|
441 | CASE ( 'q' ) |
---|
442 | |
---|
443 | DO i = nxl, nxr |
---|
444 | DO j = nys, nyn |
---|
445 | |
---|
446 | DO k = nzb+1, nzt |
---|
447 | |
---|
448 | tmp_tend = - ( hom(k,1,41,0) - ( qnudge(k,nt) * dtp + & |
---|
449 | qnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
450 | |
---|
451 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
452 | MERGE( 1.0_wp, 0.0_wp, & |
---|
453 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
454 | |
---|
455 | sums_ls_l(k,5) = sums_ls_l(k,5) + tmp_tend * & |
---|
456 | weight_substep(intermediate_timestep_count) |
---|
457 | ENDDO |
---|
458 | |
---|
459 | sums_ls_l(nzt+1,5) = sums_ls_l(nzt,5) |
---|
460 | |
---|
461 | ENDDO |
---|
462 | ENDDO |
---|
463 | |
---|
464 | CASE DEFAULT |
---|
465 | message_string = 'unknown prognostic variable "' // prog_var // '"' |
---|
466 | CALL message( 'nudge', 'PA0367', 1, 2, 0, 6, 0 ) |
---|
467 | |
---|
468 | END SELECT |
---|
469 | |
---|
470 | END SUBROUTINE nudge |
---|
471 | |
---|
472 | |
---|
473 | !------------------------------------------------------------------------------! |
---|
474 | ! Description: |
---|
475 | ! ------------ |
---|
476 | !> Call for grid point i,j |
---|
477 | !------------------------------------------------------------------------------! |
---|
478 | |
---|
479 | SUBROUTINE nudge_ij( i, j, time, prog_var ) |
---|
480 | |
---|
481 | USE arrays_3d, & |
---|
482 | ONLY: pt, ptnudge, q, qnudge, tend, timenudge, tmp_tnudge, tnudge, & |
---|
483 | u, unudge, v, vnudge |
---|
484 | |
---|
485 | USE control_parameters, & |
---|
486 | ONLY: dt_3d, intermediate_timestep_count, message_string |
---|
487 | |
---|
488 | USE indices, & |
---|
489 | ONLY: nxl, nxr, nys, nyn, nzb, nzt, wall_flags_0 |
---|
490 | |
---|
491 | USE kinds |
---|
492 | |
---|
493 | USE statistics, & |
---|
494 | ONLY: hom, sums_ls_l, weight_substep |
---|
495 | |
---|
496 | IMPLICIT NONE |
---|
497 | |
---|
498 | |
---|
499 | CHARACTER (LEN=*) :: prog_var !< |
---|
500 | |
---|
501 | REAL(wp) :: tmp_tend !< |
---|
502 | REAL(wp) :: dtm !< |
---|
503 | REAL(wp) :: dtp !< |
---|
504 | REAL(wp) :: time !< |
---|
505 | |
---|
506 | INTEGER(iwp) :: i !< |
---|
507 | INTEGER(iwp) :: j !< |
---|
508 | INTEGER(iwp) :: k !< |
---|
509 | INTEGER(iwp) :: nt !< |
---|
510 | |
---|
511 | |
---|
512 | nt = 1 |
---|
513 | DO WHILE ( time > timenudge(nt) ) |
---|
514 | nt = nt+1 |
---|
515 | ENDDO |
---|
516 | IF ( time /= timenudge(1) ) THEN |
---|
517 | nt = nt-1 |
---|
518 | ENDIF |
---|
519 | |
---|
520 | dtm = ( time - timenudge(nt) ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
521 | dtp = ( timenudge(nt+1) - time ) / ( timenudge(nt+1) - timenudge(nt) ) |
---|
522 | |
---|
523 | SELECT CASE ( prog_var ) |
---|
524 | |
---|
525 | CASE ( 'u' ) |
---|
526 | |
---|
527 | DO k = nzb+1, nzt |
---|
528 | |
---|
529 | tmp_tend = - ( hom(k,1,1,0) - ( unudge(k,nt) * dtp + & |
---|
530 | unudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
531 | |
---|
532 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
533 | MERGE( 1.0_wp, 0.0_wp, & |
---|
534 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
535 | |
---|
536 | sums_ls_l(k,6) = sums_ls_l(k,6) + tmp_tend & |
---|
537 | * weight_substep(intermediate_timestep_count) |
---|
538 | ENDDO |
---|
539 | |
---|
540 | sums_ls_l(nzt+1,6) = sums_ls_l(nzt,6) |
---|
541 | |
---|
542 | CASE ( 'v' ) |
---|
543 | |
---|
544 | DO k = nzb+1, nzt |
---|
545 | |
---|
546 | tmp_tend = - ( hom(k,1,2,0) - ( vnudge(k,nt) * dtp + & |
---|
547 | vnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
548 | |
---|
549 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
550 | MERGE( 1.0_wp, 0.0_wp, & |
---|
551 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
552 | |
---|
553 | sums_ls_l(k,7) = sums_ls_l(k,7) + tmp_tend & |
---|
554 | * weight_substep(intermediate_timestep_count) |
---|
555 | ENDDO |
---|
556 | |
---|
557 | sums_ls_l(nzt+1,7) = sums_ls_l(nzt,7) |
---|
558 | |
---|
559 | CASE ( 'pt' ) |
---|
560 | |
---|
561 | DO k = nzb+1, nzt |
---|
562 | |
---|
563 | tmp_tend = - ( hom(k,1,4,0) - ( ptnudge(k,nt) * dtp + & |
---|
564 | ptnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
565 | |
---|
566 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
567 | MERGE( 1.0_wp, 0.0_wp, & |
---|
568 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
569 | |
---|
570 | sums_ls_l(k,4) = sums_ls_l(k,4) + tmp_tend & |
---|
571 | * weight_substep(intermediate_timestep_count) |
---|
572 | ENDDO |
---|
573 | |
---|
574 | sums_ls_l(nzt+1,4) = sums_ls_l(nzt,4) |
---|
575 | |
---|
576 | |
---|
577 | CASE ( 'q' ) |
---|
578 | |
---|
579 | DO k = nzb+1, nzt |
---|
580 | |
---|
581 | tmp_tend = - ( hom(k,1,41,0) - ( qnudge(k,nt) * dtp + & |
---|
582 | qnudge(k,nt+1) * dtm ) ) / tmp_tnudge(k) |
---|
583 | |
---|
584 | tend(k,j,i) = tend(k,j,i) + tmp_tend * & |
---|
585 | MERGE( 1.0_wp, 0.0_wp, & |
---|
586 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
587 | |
---|
588 | sums_ls_l(k,5) = sums_ls_l(k,5) + tmp_tend & |
---|
589 | * weight_substep(intermediate_timestep_count) |
---|
590 | ENDDO |
---|
591 | |
---|
592 | sums_ls_l(nzt+1,5) = sums_ls_l(nzt,5) |
---|
593 | |
---|
594 | CASE DEFAULT |
---|
595 | message_string = 'unknown prognostic variable "' // prog_var // '"' |
---|
596 | CALL message( 'nudge', 'PA0367', 1, 2, 0, 6, 0 ) |
---|
597 | |
---|
598 | END SELECT |
---|
599 | |
---|
600 | |
---|
601 | END SUBROUTINE nudge_ij |
---|
602 | |
---|
603 | |
---|
604 | !------------------------------------------------------------------------------! |
---|
605 | ! Description: |
---|
606 | ! ------------ |
---|
607 | !> @todo Missing subroutine description. |
---|
608 | !------------------------------------------------------------------------------! |
---|
609 | SUBROUTINE nudge_ref ( time ) |
---|
610 | |
---|
611 | USE arrays_3d, & |
---|
612 | ONLY: time_vert, ptnudge, pt_init, qnudge, q_init, unudge, u_init, & |
---|
613 | vnudge, v_init |
---|
614 | |
---|
615 | USE kinds |
---|
616 | |
---|
617 | |
---|
618 | IMPLICIT NONE |
---|
619 | |
---|
620 | INTEGER(iwp) :: nt !< |
---|
621 | |
---|
622 | REAL(wp) :: fac !< |
---|
623 | REAL(wp), INTENT(in) :: time !< |
---|
624 | |
---|
625 | ! |
---|
626 | !-- Interpolation in time of NUDGING_DATA for pt_init and q_init. This is |
---|
627 | !-- needed for correct upper boundary conditions for pt and q and in case that |
---|
628 | ! large scale subsidence as well as scalar Rayleigh-damping are used |
---|
629 | nt = 1 |
---|
630 | DO WHILE ( time > time_vert(nt) ) |
---|
631 | nt = nt + 1 |
---|
632 | ENDDO |
---|
633 | IF ( time /= time_vert(nt) ) THEN |
---|
634 | nt = nt - 1 |
---|
635 | ENDIF |
---|
636 | |
---|
637 | fac = ( time-time_vert(nt) ) / ( time_vert(nt+1)-time_vert(nt) ) |
---|
638 | |
---|
639 | pt_init = ptnudge(:,nt) + fac * ( ptnudge(:,nt+1) - ptnudge(:,nt) ) |
---|
640 | q_init = qnudge(:,nt) + fac * ( qnudge(:,nt+1) - qnudge(:,nt) ) |
---|
641 | u_init = unudge(:,nt) + fac * ( unudge(:,nt+1) - unudge(:,nt) ) |
---|
642 | v_init = vnudge(:,nt) + fac * ( vnudge(:,nt+1) - vnudge(:,nt) ) |
---|
643 | |
---|
644 | END SUBROUTINE nudge_ref |
---|
645 | |
---|
646 | END MODULE nudge_mod |
---|