1 | !> @file prognostic_equations.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 terms of the GNU General |
---|
6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
7 | ! (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
11 | ! Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
14 | ! <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: prognostic_equations.f90 4671 2020-09-09 20:27:58Z raasch $ |
---|
27 | ! Implementation of downward facing USM and LSM surfaces |
---|
28 | ! |
---|
29 | ! 4649 2020-08-25 12:11:17Z raasch |
---|
30 | ! File re-formatted to follow the PALM coding standard |
---|
31 | ! |
---|
32 | ! |
---|
33 | ! 4370 2020-01-10 14:00:44Z raasch |
---|
34 | ! Vector directives added to force vectorization on Intel19 compiler |
---|
35 | ! |
---|
36 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
37 | ! Introduction of wall_flags_total_0, which currently sets bits based on static topography |
---|
38 | ! information used in wall_flags_static_0 |
---|
39 | ! |
---|
40 | ! 4329 2019-12-10 15:46:36Z motisi |
---|
41 | ! Renamed wall_flags_0 to wall_flags_static_0 |
---|
42 | ! |
---|
43 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
44 | ! Corrected "Former revisions" section |
---|
45 | ! |
---|
46 | ! 4110 2019-07-22 17:05:21Z suehring |
---|
47 | ! Pass integer flag array to WS scalar advection routine which is now necessary as the flags may |
---|
48 | ! differ for scalars, e.g. pt can be cyclic while chemical species may be non-cyclic. Further, |
---|
49 | ! pass boundary flags. |
---|
50 | ! |
---|
51 | ! 4109 2019-07-22 17:00:34Z suehring |
---|
52 | ! Application of monotonic flux limiter for the vertical scalar advection up to the topography top |
---|
53 | ! (only for the cache-optimized version at the moment). Please note, at the moment the limiter is |
---|
54 | ! only applied for passive scalars. |
---|
55 | ! |
---|
56 | ! 4048 2019-06-21 21:00:21Z knoop |
---|
57 | ! Moved tcm_prognostic_equations to module_interface |
---|
58 | ! |
---|
59 | ! 3987 2019-05-22 09:52:13Z kanani |
---|
60 | ! Introduce alternative switch for debug output during timestepping |
---|
61 | ! |
---|
62 | ! 3956 2019-05-07 12:32:52Z monakurppa |
---|
63 | ! Removed salsa calls. |
---|
64 | ! |
---|
65 | ! 3931 2019-04-24 16:34:28Z schwenkel |
---|
66 | ! Correct/complete module_interface introduction for chemistry model |
---|
67 | ! |
---|
68 | ! 3899 2019-04-16 14:05:27Z monakurppa |
---|
69 | ! Corrections in the OpenMP version of salsa |
---|
70 | ! |
---|
71 | ! 3887 2019 -04-12 08:47:41Z schwenkel |
---|
72 | ! Implicit Bugfix for chemistry model, loop for non_transport_physics over ghost points is avoided. |
---|
73 | ! Instead introducing module_interface_exchange_horiz. |
---|
74 | ! |
---|
75 | ! 3885 2019-04-11 11:29:34Z kanani |
---|
76 | ! Changes related to global restructuring of location messages and introduction of additional debug |
---|
77 | ! messages |
---|
78 | ! |
---|
79 | ! 3881 2019-04-10 09:31:22Z suehring |
---|
80 | ! Bugfix in OpenMP directive |
---|
81 | ! |
---|
82 | ! 3880 2019-04-08 21:43:02Z knoop |
---|
83 | ! Moved wtm_tendencies to module_interface_actions |
---|
84 | ! |
---|
85 | ! 3874 2019-04-08 16:53:48Z knoop |
---|
86 | ! Added non_transport_physics module interfaces and moved bcm code into it |
---|
87 | ! |
---|
88 | ! 3872 2019-04-08 15:03:06Z knoop |
---|
89 | ! Moving prognostic equations of bcm into bulk_cloud_model_mod |
---|
90 | ! |
---|
91 | ! 3864 2019-04-05 09:01:56Z monakurppa |
---|
92 | ! Modifications made for salsa: |
---|
93 | ! - salsa_prognostic_equations moved to salsa_mod (and the call to module_interface_mod) |
---|
94 | ! - Renamed nbins --> nbins_aerosol, ncc_tot --> ncomponents_mass and ngast --> ngases_salsa and |
---|
95 | ! loop indices b, c and sg to ib, ic and ig |
---|
96 | ! |
---|
97 | ! 3840 2019-03-29 10:35:52Z knoop |
---|
98 | ! Added USE chem_gasphase_mod for nspec, nspec and spc_names |
---|
99 | ! |
---|
100 | ! 3820 2019-03-27 11:53:41Z forkel |
---|
101 | ! Renamed do_depo to deposition_dry (ecc) |
---|
102 | ! |
---|
103 | ! 3797 2019-03-15 11:15:38Z forkel |
---|
104 | ! Call chem_integegrate in OpenMP loop (ketelsen) |
---|
105 | ! |
---|
106 | ! |
---|
107 | ! 3771 2019-02-28 12:19:33Z raasch |
---|
108 | ! Preprocessor directivs fro rrtmg added |
---|
109 | ! |
---|
110 | ! 3761 2019-02-25 15:31:42Z raasch |
---|
111 | ! Unused variable removed |
---|
112 | ! |
---|
113 | ! 3719 2019-02-06 13:10:18Z kanani |
---|
114 | ! Cleaned up chemistry cpu measurements |
---|
115 | ! |
---|
116 | ! 3684 2019-01-20 20:20:58Z knoop |
---|
117 | ! OpenACC port for SPEC |
---|
118 | ! |
---|
119 | ! Revision 1.1 2000/04/13 14:56:27 schroeter |
---|
120 | ! Initial revision |
---|
121 | ! |
---|
122 | !--------------------------------------------------------------------------------------------------! |
---|
123 | ! Description: |
---|
124 | ! ------------ |
---|
125 | !> Solving the prognostic equations. |
---|
126 | !--------------------------------------------------------------------------------------------------! |
---|
127 | MODULE prognostic_equations_mod |
---|
128 | |
---|
129 | USE advec_s_bc_mod, & |
---|
130 | ONLY: advec_s_bc |
---|
131 | |
---|
132 | USE advec_s_pw_mod, & |
---|
133 | ONLY: advec_s_pw |
---|
134 | |
---|
135 | USE advec_s_up_mod, & |
---|
136 | ONLY: advec_s_up |
---|
137 | |
---|
138 | USE advec_u_pw_mod, & |
---|
139 | ONLY: advec_u_pw |
---|
140 | |
---|
141 | USE advec_u_up_mod, & |
---|
142 | ONLY: advec_u_up |
---|
143 | |
---|
144 | USE advec_v_pw_mod, & |
---|
145 | ONLY: advec_v_pw |
---|
146 | |
---|
147 | USE advec_v_up_mod, & |
---|
148 | ONLY: advec_v_up |
---|
149 | |
---|
150 | USE advec_w_pw_mod, & |
---|
151 | ONLY: advec_w_pw |
---|
152 | |
---|
153 | USE advec_w_up_mod, & |
---|
154 | ONLY: advec_w_up |
---|
155 | |
---|
156 | USE advec_ws, & |
---|
157 | ONLY: advec_s_ws, & |
---|
158 | advec_u_ws, & |
---|
159 | advec_v_ws, & |
---|
160 | advec_w_ws |
---|
161 | |
---|
162 | USE arrays_3d, & |
---|
163 | ONLY: diss_l_e, & |
---|
164 | diss_l_pt, & |
---|
165 | diss_l_q, & |
---|
166 | diss_l_s, & |
---|
167 | diss_l_sa, & |
---|
168 | diss_s_e, & |
---|
169 | diss_s_pt, & |
---|
170 | diss_s_q, & |
---|
171 | diss_s_s, & |
---|
172 | diss_s_sa, & |
---|
173 | e, & |
---|
174 | e_p, & |
---|
175 | flux_s_e, & |
---|
176 | flux_s_pt, & |
---|
177 | flux_s_q, & |
---|
178 | flux_s_s, & |
---|
179 | flux_s_sa, & |
---|
180 | flux_l_e, & |
---|
181 | flux_l_pt, & |
---|
182 | flux_l_q, & |
---|
183 | flux_l_s, & |
---|
184 | flux_l_sa, & |
---|
185 | pt, & |
---|
186 | ptdf_x, & |
---|
187 | ptdf_y, & |
---|
188 | pt_init, & |
---|
189 | pt_p, & |
---|
190 | prho, & |
---|
191 | q, & |
---|
192 | q_init, & |
---|
193 | q_p, & |
---|
194 | rdf, & |
---|
195 | rdf_sc, & |
---|
196 | ref_state, & |
---|
197 | rho_ocean, & |
---|
198 | s, & |
---|
199 | s_init, & |
---|
200 | s_p, & |
---|
201 | tend, & |
---|
202 | te_m, & |
---|
203 | tpt_m, & |
---|
204 | tq_m, & |
---|
205 | ts_m, & |
---|
206 | tu_m, & |
---|
207 | tv_m, & |
---|
208 | tw_m, & |
---|
209 | u, & |
---|
210 | ug, & |
---|
211 | u_init, & |
---|
212 | u_p, & |
---|
213 | v, & |
---|
214 | vg, & |
---|
215 | vpt, & |
---|
216 | v_init, & |
---|
217 | v_p, & |
---|
218 | w, & |
---|
219 | w_p |
---|
220 | |
---|
221 | USE buoyancy_mod, & |
---|
222 | ONLY: buoyancy |
---|
223 | |
---|
224 | USE control_parameters, & |
---|
225 | ONLY: bc_dirichlet_l, & |
---|
226 | bc_dirichlet_n, & |
---|
227 | bc_dirichlet_r, & |
---|
228 | bc_dirichlet_s, & |
---|
229 | bc_radiation_l, & |
---|
230 | bc_radiation_n, & |
---|
231 | bc_radiation_r, & |
---|
232 | bc_radiation_s, & |
---|
233 | constant_diffusion, & |
---|
234 | debug_output_timestep, & |
---|
235 | dp_external, & |
---|
236 | dp_level_ind_b, & |
---|
237 | dp_smooth_factor, & |
---|
238 | dpdxy, & |
---|
239 | dt_3d, & |
---|
240 | humidity, & |
---|
241 | intermediate_timestep_count, & |
---|
242 | intermediate_timestep_count_max, & |
---|
243 | land_surface, & |
---|
244 | large_scale_forcing, & |
---|
245 | large_scale_subsidence, & |
---|
246 | monotonic_limiter_z, & |
---|
247 | neutral, & |
---|
248 | nudging, & |
---|
249 | ocean_mode, & |
---|
250 | passive_scalar, & |
---|
251 | plant_canopy, & |
---|
252 | pt_reference, & |
---|
253 | salsa, & |
---|
254 | scalar_advec, & |
---|
255 | scalar_advec, & |
---|
256 | simulated_time, & |
---|
257 | sloping_surface, & |
---|
258 | time_since_reference_point, & |
---|
259 | timestep_scheme, & |
---|
260 | tsc, & |
---|
261 | urban_surface, & |
---|
262 | use_subsidence_tendencies, & |
---|
263 | use_upstream_for_tke, & |
---|
264 | wind_turbine, & |
---|
265 | ws_scheme_mom, & |
---|
266 | ws_scheme_sca |
---|
267 | |
---|
268 | |
---|
269 | |
---|
270 | |
---|
271 | |
---|
272 | USE coriolis_mod, & |
---|
273 | ONLY: coriolis |
---|
274 | |
---|
275 | USE cpulog, & |
---|
276 | ONLY: cpu_log, & |
---|
277 | log_point, & |
---|
278 | log_point_s |
---|
279 | |
---|
280 | USE diffusion_s_mod, & |
---|
281 | ONLY: diffusion_s |
---|
282 | |
---|
283 | USE diffusion_u_mod, & |
---|
284 | ONLY: diffusion_u |
---|
285 | |
---|
286 | USE diffusion_v_mod, & |
---|
287 | ONLY: diffusion_v |
---|
288 | |
---|
289 | USE diffusion_w_mod, & |
---|
290 | ONLY: diffusion_w |
---|
291 | |
---|
292 | USE indices, & |
---|
293 | ONLY: advc_flags_s, & |
---|
294 | nbgp, & |
---|
295 | nxl, & |
---|
296 | nxlg, & |
---|
297 | nxlu, & |
---|
298 | nxr, & |
---|
299 | nxrg, & |
---|
300 | nyn, & |
---|
301 | nyng, & |
---|
302 | nys, & |
---|
303 | nysg, & |
---|
304 | nysv, & |
---|
305 | nzb, & |
---|
306 | nzt, & |
---|
307 | wall_flags_total_0 |
---|
308 | |
---|
309 | USE kinds |
---|
310 | |
---|
311 | USE lsf_nudging_mod, & |
---|
312 | ONLY: ls_advec, & |
---|
313 | nudge |
---|
314 | |
---|
315 | USE module_interface, & |
---|
316 | ONLY: module_interface_actions, & |
---|
317 | module_interface_exchange_horiz, & |
---|
318 | module_interface_non_advective_processes, & |
---|
319 | module_interface_prognostic_equations |
---|
320 | |
---|
321 | USE ocean_mod, & |
---|
322 | ONLY: stokes_drift_terms, & |
---|
323 | stokes_force, & |
---|
324 | wave_breaking, & |
---|
325 | wave_breaking_term |
---|
326 | |
---|
327 | USE plant_canopy_model_mod, & |
---|
328 | ONLY: cthf, & |
---|
329 | pcm_tendency |
---|
330 | |
---|
331 | #if defined( __rrtmg ) |
---|
332 | USE radiation_model_mod, & |
---|
333 | ONLY: radiation, & |
---|
334 | radiation_tendency, & |
---|
335 | skip_time_do_radiation |
---|
336 | #endif |
---|
337 | |
---|
338 | USE statistics, & |
---|
339 | ONLY: hom |
---|
340 | |
---|
341 | USE subsidence_mod, & |
---|
342 | ONLY: subsidence |
---|
343 | |
---|
344 | USE surface_mod, & |
---|
345 | ONLY : surf_def_h, & |
---|
346 | surf_def_v, & |
---|
347 | surf_lsm_h, & |
---|
348 | surf_lsm_v, & |
---|
349 | surf_usm_h, & |
---|
350 | surf_usm_v |
---|
351 | |
---|
352 | IMPLICIT NONE |
---|
353 | |
---|
354 | PRIVATE |
---|
355 | PUBLIC prognostic_equations_cache, prognostic_equations_vector |
---|
356 | |
---|
357 | INTERFACE prognostic_equations_cache |
---|
358 | MODULE PROCEDURE prognostic_equations_cache |
---|
359 | END INTERFACE prognostic_equations_cache |
---|
360 | |
---|
361 | INTERFACE prognostic_equations_vector |
---|
362 | MODULE PROCEDURE prognostic_equations_vector |
---|
363 | END INTERFACE prognostic_equations_vector |
---|
364 | |
---|
365 | |
---|
366 | CONTAINS |
---|
367 | |
---|
368 | |
---|
369 | !--------------------------------------------------------------------------------------------------! |
---|
370 | ! Description: |
---|
371 | ! ------------ |
---|
372 | !> Version with one optimized loop over all equations. It is only allowed to be called for the |
---|
373 | !> Wicker and Skamarock or Piascek-Williams advection scheme. |
---|
374 | !> |
---|
375 | !> Here the calls of most subroutines are embedded in two DO loops over i and j, so communication |
---|
376 | !> between CPUs is not allowed (does not make sense) within these loops. |
---|
377 | !> |
---|
378 | !> (Optimized to avoid cache missings, i.e. for Power4/5-architectures.) |
---|
379 | !--------------------------------------------------------------------------------------------------! |
---|
380 | |
---|
381 | SUBROUTINE prognostic_equations_cache |
---|
382 | |
---|
383 | |
---|
384 | INTEGER(iwp) :: i !< |
---|
385 | INTEGER(iwp) :: i_omp_start !< |
---|
386 | INTEGER(iwp) :: j !< |
---|
387 | INTEGER(iwp) :: k !< |
---|
388 | !$ INTEGER(iwp) :: omp_get_thread_num !< |
---|
389 | INTEGER(iwp) :: tn = 0 !< |
---|
390 | |
---|
391 | LOGICAL :: loop_start !< |
---|
392 | |
---|
393 | |
---|
394 | IF ( debug_output_timestep ) CALL debug_message( 'prognostic_equations_cache', 'start' ) |
---|
395 | ! |
---|
396 | !-- Time measurement can only be performed for the whole set of equations |
---|
397 | CALL cpu_log( log_point(32), 'all progn.equations', 'start' ) |
---|
398 | |
---|
399 | !$OMP PARALLEL PRIVATE (i,j) |
---|
400 | !$OMP DO |
---|
401 | DO i = nxl, nxr |
---|
402 | DO j = nys, nyn |
---|
403 | ! |
---|
404 | !-- Calculate non advective processes for all other modules |
---|
405 | CALL module_interface_non_advective_processes( i, j ) |
---|
406 | ENDDO |
---|
407 | ENDDO |
---|
408 | ! |
---|
409 | !-- Module Inferface for exchange horiz after non_advective_processes but before advection. |
---|
410 | !-- Therefore, non_advective_processes must not run for ghost points. |
---|
411 | !$OMP END PARALLEL |
---|
412 | CALL module_interface_exchange_horiz() |
---|
413 | ! |
---|
414 | !-- Loop over all prognostic equations |
---|
415 | !$OMP PARALLEL PRIVATE (i,i_omp_start,j,k,loop_start,tn) |
---|
416 | |
---|
417 | !$ tn = omp_get_thread_num() |
---|
418 | loop_start = .TRUE. |
---|
419 | |
---|
420 | !$OMP DO |
---|
421 | DO i = nxl, nxr |
---|
422 | |
---|
423 | ! |
---|
424 | !-- Store the first loop index. It differs for each thread and is required later in advec_ws |
---|
425 | IF ( loop_start ) THEN |
---|
426 | loop_start = .FALSE. |
---|
427 | i_omp_start = i |
---|
428 | ENDIF |
---|
429 | |
---|
430 | DO j = nys, nyn |
---|
431 | ! |
---|
432 | !-- Tendency terms for u-velocity component. Please note, in case of non-cyclic boundary |
---|
433 | !-- conditions the grid point i=0 is excluded from the prognostic equations for the |
---|
434 | !-- u-component. |
---|
435 | IF ( i >= nxlu ) THEN |
---|
436 | |
---|
437 | tend(:,j,i) = 0.0_wp |
---|
438 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
439 | IF ( ws_scheme_mom ) THEN |
---|
440 | CALL advec_u_ws( i, j, i_omp_start, tn ) |
---|
441 | ELSE |
---|
442 | CALL advec_u_pw( i, j ) |
---|
443 | ENDIF |
---|
444 | ELSE |
---|
445 | CALL advec_u_up( i, j ) |
---|
446 | ENDIF |
---|
447 | CALL diffusion_u( i, j ) |
---|
448 | CALL coriolis( i, j, 1 ) |
---|
449 | IF ( sloping_surface .AND. .NOT. neutral ) THEN |
---|
450 | CALL buoyancy( i, j, pt, 1 ) |
---|
451 | ENDIF |
---|
452 | |
---|
453 | ! |
---|
454 | !-- Drag by plant canopy |
---|
455 | IF ( plant_canopy ) CALL pcm_tendency( i, j, 1 ) |
---|
456 | |
---|
457 | ! |
---|
458 | !-- External pressure gradient |
---|
459 | IF ( dp_external ) THEN |
---|
460 | DO k = dp_level_ind_b+1, nzt |
---|
461 | tend(k,j,i) = tend(k,j,i) - dpdxy(1) * dp_smooth_factor(k) |
---|
462 | ENDDO |
---|
463 | ENDIF |
---|
464 | |
---|
465 | ! |
---|
466 | !-- Nudging |
---|
467 | IF ( nudging ) CALL nudge( i, j, simulated_time, 'u' ) |
---|
468 | |
---|
469 | ! |
---|
470 | !-- Effect of Stokes drift (in ocean mode only) |
---|
471 | IF ( stokes_force ) CALL stokes_drift_terms( i, j, 1 ) |
---|
472 | |
---|
473 | CALL module_interface_actions( i, j, 'u-tendency' ) |
---|
474 | ! |
---|
475 | !-- Prognostic equation for u-velocity component |
---|
476 | DO k = nzb+1, nzt |
---|
477 | |
---|
478 | u_p(k,j,i) = u(k,j,i) + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tu_m(k,j,i) ) & |
---|
479 | - tsc(5) * rdf(k) * ( u(k,j,i) - u_init(k) ) ) & |
---|
480 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) |
---|
481 | ENDDO |
---|
482 | |
---|
483 | ! |
---|
484 | !-- Add turbulence generated by wave breaking (in ocean mode only) |
---|
485 | IF ( wave_breaking .AND. & |
---|
486 | intermediate_timestep_count == intermediate_timestep_count_max ) THEN |
---|
487 | CALL wave_breaking_term( i, j, 1 ) |
---|
488 | ENDIF |
---|
489 | |
---|
490 | ! |
---|
491 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
492 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
493 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
494 | DO k = nzb+1, nzt |
---|
495 | tu_m(k,j,i) = tend(k,j,i) |
---|
496 | ENDDO |
---|
497 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
498 | DO k = nzb+1, nzt |
---|
499 | tu_m(k,j,i) = -9.5625_wp * tend(k,j,i) + 5.3125_wp * tu_m(k,j,i) |
---|
500 | ENDDO |
---|
501 | ENDIF |
---|
502 | ENDIF |
---|
503 | |
---|
504 | ENDIF |
---|
505 | ! |
---|
506 | !-- Tendency terms for v-velocity component. Please note, in case of non-cyclic boundary |
---|
507 | !-- conditions the grid point j=0 is excluded from the prognostic equations for the |
---|
508 | !-- v-component. |
---|
509 | IF ( j >= nysv ) THEN |
---|
510 | |
---|
511 | tend(:,j,i) = 0.0_wp |
---|
512 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
513 | IF ( ws_scheme_mom ) THEN |
---|
514 | CALL advec_v_ws( i, j, i_omp_start, tn ) |
---|
515 | ELSE |
---|
516 | CALL advec_v_pw( i, j ) |
---|
517 | ENDIF |
---|
518 | ELSE |
---|
519 | CALL advec_v_up( i, j ) |
---|
520 | ENDIF |
---|
521 | CALL diffusion_v( i, j ) |
---|
522 | CALL coriolis( i, j, 2 ) |
---|
523 | |
---|
524 | ! |
---|
525 | !-- Drag by plant canopy |
---|
526 | IF ( plant_canopy ) CALL pcm_tendency( i, j, 2 ) |
---|
527 | |
---|
528 | ! |
---|
529 | !-- External pressure gradient |
---|
530 | IF ( dp_external ) THEN |
---|
531 | DO k = dp_level_ind_b+1, nzt |
---|
532 | tend(k,j,i) = tend(k,j,i) - dpdxy(2) * dp_smooth_factor(k) |
---|
533 | ENDDO |
---|
534 | ENDIF |
---|
535 | |
---|
536 | ! |
---|
537 | !-- Nudging |
---|
538 | IF ( nudging ) CALL nudge( i, j, simulated_time, 'v' ) |
---|
539 | |
---|
540 | ! |
---|
541 | !-- Effect of Stokes drift (in ocean mode only) |
---|
542 | IF ( stokes_force ) CALL stokes_drift_terms( i, j, 2 ) |
---|
543 | |
---|
544 | CALL module_interface_actions( i, j, 'v-tendency' ) |
---|
545 | ! |
---|
546 | !-- Prognostic equation for v-velocity component |
---|
547 | DO k = nzb+1, nzt |
---|
548 | v_p(k,j,i) = v(k,j,i) + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tv_m(k,j,i) ) & |
---|
549 | - tsc(5) * rdf(k) * ( v(k,j,i) - v_init(k) ) ) & |
---|
550 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) |
---|
551 | ENDDO |
---|
552 | |
---|
553 | ! |
---|
554 | !-- Add turbulence generated by wave breaking (in ocean mode only) |
---|
555 | IF ( wave_breaking .AND. & |
---|
556 | intermediate_timestep_count == intermediate_timestep_count_max ) THEN |
---|
557 | CALL wave_breaking_term( i, j, 2 ) |
---|
558 | ENDIF |
---|
559 | |
---|
560 | ! |
---|
561 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
562 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
563 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
564 | DO k = nzb+1, nzt |
---|
565 | tv_m(k,j,i) = tend(k,j,i) |
---|
566 | ENDDO |
---|
567 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
568 | DO k = nzb+1, nzt |
---|
569 | tv_m(k,j,i) = -9.5625_wp * tend(k,j,i) + 5.3125_wp * tv_m(k,j,i) |
---|
570 | ENDDO |
---|
571 | ENDIF |
---|
572 | ENDIF |
---|
573 | |
---|
574 | ENDIF |
---|
575 | |
---|
576 | ! |
---|
577 | !-- Tendency terms for w-velocity component |
---|
578 | tend(:,j,i) = 0.0_wp |
---|
579 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
580 | IF ( ws_scheme_mom ) THEN |
---|
581 | CALL advec_w_ws( i, j, i_omp_start, tn ) |
---|
582 | ELSE |
---|
583 | CALL advec_w_pw( i, j ) |
---|
584 | END IF |
---|
585 | ELSE |
---|
586 | CALL advec_w_up( i, j ) |
---|
587 | ENDIF |
---|
588 | CALL diffusion_w( i, j ) |
---|
589 | CALL coriolis( i, j, 3 ) |
---|
590 | |
---|
591 | IF ( .NOT. neutral ) THEN |
---|
592 | IF ( ocean_mode ) THEN |
---|
593 | CALL buoyancy( i, j, rho_ocean, 3 ) |
---|
594 | ELSE |
---|
595 | IF ( .NOT. humidity ) THEN |
---|
596 | CALL buoyancy( i, j, pt, 3 ) |
---|
597 | ELSE |
---|
598 | CALL buoyancy( i, j, vpt, 3 ) |
---|
599 | ENDIF |
---|
600 | ENDIF |
---|
601 | ENDIF |
---|
602 | |
---|
603 | ! |
---|
604 | !-- Drag by plant canopy |
---|
605 | IF ( plant_canopy ) CALL pcm_tendency( i, j, 3 ) |
---|
606 | |
---|
607 | ! |
---|
608 | !-- Effect of Stokes drift (in ocean mode only) |
---|
609 | IF ( stokes_force ) CALL stokes_drift_terms( i, j, 3 ) |
---|
610 | |
---|
611 | CALL module_interface_actions( i, j, 'w-tendency' ) |
---|
612 | ! |
---|
613 | !-- Prognostic equation for w-velocity component |
---|
614 | DO k = nzb+1, nzt-1 |
---|
615 | w_p(k,j,i) = w(k,j,i) + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tw_m(k,j,i) ) & |
---|
616 | - tsc(5) * rdf(k) * w(k,j,i) ) & |
---|
617 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) ) |
---|
618 | ENDDO |
---|
619 | |
---|
620 | ! |
---|
621 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
622 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
623 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
624 | DO k = nzb+1, nzt-1 |
---|
625 | tw_m(k,j,i) = tend(k,j,i) |
---|
626 | ENDDO |
---|
627 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
628 | DO k = nzb+1, nzt-1 |
---|
629 | tw_m(k,j,i) = -9.5625_wp * tend(k,j,i) + 5.3125_wp * tw_m(k,j,i) |
---|
630 | ENDDO |
---|
631 | ENDIF |
---|
632 | ENDIF |
---|
633 | |
---|
634 | ! |
---|
635 | !-- If required, compute prognostic equation for potential temperature |
---|
636 | IF ( .NOT. neutral ) THEN |
---|
637 | ! |
---|
638 | !-- Tendency terms for potential temperature |
---|
639 | tend(:,j,i) = 0.0_wp |
---|
640 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
641 | IF ( ws_scheme_sca ) THEN |
---|
642 | CALL advec_s_ws( advc_flags_s, i, j, pt, 'pt', flux_s_pt, diss_s_pt, & |
---|
643 | flux_l_pt, diss_l_pt, i_omp_start, tn, & |
---|
644 | bc_dirichlet_l .OR. bc_radiation_l, & |
---|
645 | bc_dirichlet_n .OR. bc_radiation_n, & |
---|
646 | bc_dirichlet_r .OR. bc_radiation_r, & |
---|
647 | bc_dirichlet_s .OR. bc_radiation_s ) |
---|
648 | ELSE |
---|
649 | CALL advec_s_pw( i, j, pt ) |
---|
650 | ENDIF |
---|
651 | ELSE |
---|
652 | CALL advec_s_up( i, j, pt ) |
---|
653 | ENDIF |
---|
654 | CALL diffusion_s( i, j, pt, surf_def_h(0)%shf, surf_def_h(1)%shf, surf_def_h(2)%shf, & |
---|
655 | surf_lsm_h(0)%shf, surf_lsm_h(1)%shf, & |
---|
656 | surf_usm_h(0)%shf, surf_usm_h(1)%shf, & |
---|
657 | surf_def_v(0)%shf, surf_def_v(1)%shf, surf_def_v(2)%shf, & |
---|
658 | surf_def_v(3)%shf, surf_lsm_v(0)%shf, surf_lsm_v(1)%shf, & |
---|
659 | surf_lsm_v(2)%shf, surf_lsm_v(3)%shf, surf_usm_v(0)%shf, & |
---|
660 | surf_usm_v(1)%shf, surf_usm_v(2)%shf, surf_usm_v(3)%shf ) |
---|
661 | |
---|
662 | ! |
---|
663 | !-- Consideration of heat sources within the plant canopy |
---|
664 | IF ( plant_canopy .AND. (cthf /= 0.0_wp .OR. urban_surface .OR. land_surface) ) & |
---|
665 | THEN |
---|
666 | CALL pcm_tendency( i, j, 4 ) |
---|
667 | ENDIF |
---|
668 | |
---|
669 | ! |
---|
670 | !-- Large scale advection |
---|
671 | IF ( large_scale_forcing ) THEN |
---|
672 | CALL ls_advec( i, j, simulated_time, 'pt' ) |
---|
673 | ENDIF |
---|
674 | |
---|
675 | ! |
---|
676 | !-- Nudging |
---|
677 | IF ( nudging ) CALL nudge( i, j, simulated_time, 'pt' ) |
---|
678 | |
---|
679 | ! |
---|
680 | !-- If required, compute effect of large-scale subsidence/ascent |
---|
681 | IF ( large_scale_subsidence .AND. .NOT. use_subsidence_tendencies ) THEN |
---|
682 | CALL subsidence( i, j, tend, pt, pt_init, 2 ) |
---|
683 | ENDIF |
---|
684 | |
---|
685 | #if defined( __rrtmg ) |
---|
686 | ! |
---|
687 | !-- If required, add tendency due to radiative heating/cooling |
---|
688 | IF ( radiation .AND. simulated_time > skip_time_do_radiation ) THEN |
---|
689 | CALL radiation_tendency ( i, j, tend ) |
---|
690 | ENDIF |
---|
691 | #endif |
---|
692 | |
---|
693 | CALL module_interface_actions( i, j, 'pt-tendency' ) |
---|
694 | ! |
---|
695 | !-- Prognostic equation for potential temperature |
---|
696 | DO k = nzb+1, nzt |
---|
697 | pt_p(k,j,i) = pt(k,j,i) + & |
---|
698 | ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tpt_m(k,j,i) ) - tsc(5) & |
---|
699 | * ( pt(k,j,i) - pt_init(k) ) * ( rdf_sc(k) + ptdf_x(i) & |
---|
700 | + ptdf_y(j) ) ) & |
---|
701 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
702 | ENDDO |
---|
703 | |
---|
704 | ! |
---|
705 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
706 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
707 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
708 | DO k = nzb+1, nzt |
---|
709 | tpt_m(k,j,i) = tend(k,j,i) |
---|
710 | ENDDO |
---|
711 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
712 | DO k = nzb+1, nzt |
---|
713 | tpt_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * tpt_m(k,j,i) |
---|
714 | ENDDO |
---|
715 | ENDIF |
---|
716 | ENDIF |
---|
717 | |
---|
718 | ENDIF |
---|
719 | |
---|
720 | ! |
---|
721 | !-- If required, compute prognostic equation for total water content |
---|
722 | IF ( humidity ) THEN |
---|
723 | |
---|
724 | ! |
---|
725 | !-- Tendency-terms for total water content / scalar |
---|
726 | tend(:,j,i) = 0.0_wp |
---|
727 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
728 | IF ( ws_scheme_sca ) THEN |
---|
729 | CALL advec_s_ws( advc_flags_s, i, j, q, 'q', flux_s_q, diss_s_q, flux_l_q, & |
---|
730 | diss_l_q, i_omp_start, tn, & |
---|
731 | bc_dirichlet_l .OR. bc_radiation_l, & |
---|
732 | bc_dirichlet_n .OR. bc_radiation_n, & |
---|
733 | bc_dirichlet_r .OR. bc_radiation_r, & |
---|
734 | bc_dirichlet_s .OR. bc_radiation_s ) |
---|
735 | ELSE |
---|
736 | CALL advec_s_pw( i, j, q ) |
---|
737 | ENDIF |
---|
738 | ELSE |
---|
739 | CALL advec_s_up( i, j, q ) |
---|
740 | ENDIF |
---|
741 | CALL diffusion_s( i, j, q, surf_def_h(0)%qsws, surf_def_h(1)%qsws, & |
---|
742 | surf_def_h(2)%qsws, surf_lsm_h(0)%qsws, surf_lsm_h(1)%qsws, & |
---|
743 | surf_usm_h(0)%qsws, surf_usm_h(1)%qsws, & |
---|
744 | surf_def_v(0)%qsws, surf_def_v(1)%qsws, surf_def_v(2)%qsws, & |
---|
745 | surf_def_v(3)%qsws, surf_lsm_v(0)%qsws, surf_lsm_v(1)%qsws, & |
---|
746 | surf_lsm_v(2)%qsws, surf_lsm_v(3)%qsws, surf_usm_v(0)%qsws, & |
---|
747 | surf_usm_v(1)%qsws, surf_usm_v(2)%qsws, surf_usm_v(3)%qsws ) |
---|
748 | |
---|
749 | ! |
---|
750 | !-- Sink or source of humidity due to canopy elements |
---|
751 | IF ( plant_canopy ) CALL pcm_tendency( i, j, 5 ) |
---|
752 | |
---|
753 | ! |
---|
754 | !-- Large scale advection |
---|
755 | IF ( large_scale_forcing ) THEN |
---|
756 | CALL ls_advec( i, j, simulated_time, 'q' ) |
---|
757 | ENDIF |
---|
758 | |
---|
759 | ! |
---|
760 | !-- Nudging |
---|
761 | IF ( nudging ) CALL nudge( i, j, simulated_time, 'q' ) |
---|
762 | |
---|
763 | ! |
---|
764 | !-- If required compute influence of large-scale subsidence/ascent |
---|
765 | IF ( large_scale_subsidence .AND. .NOT. use_subsidence_tendencies ) THEN |
---|
766 | CALL subsidence( i, j, tend, q, q_init, 3 ) |
---|
767 | ENDIF |
---|
768 | |
---|
769 | CALL module_interface_actions( i, j, 'q-tendency' ) |
---|
770 | |
---|
771 | ! |
---|
772 | !-- Prognostic equation for total water content / scalar |
---|
773 | DO k = nzb+1, nzt |
---|
774 | q_p(k,j,i) = q(k,j,i) & |
---|
775 | + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tq_m(k,j,i) ) - tsc(5) & |
---|
776 | * rdf_sc(k) * ( q(k,j,i) - q_init(k) ) ) & |
---|
777 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
778 | IF ( q_p(k,j,i) < 0.0_wp ) q_p(k,j,i) = 0.1_wp * q(k,j,i) |
---|
779 | ENDDO |
---|
780 | |
---|
781 | ! |
---|
782 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
783 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
784 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
785 | DO k = nzb+1, nzt |
---|
786 | tq_m(k,j,i) = tend(k,j,i) |
---|
787 | ENDDO |
---|
788 | ELSEIF ( intermediate_timestep_count < & |
---|
789 | intermediate_timestep_count_max ) THEN |
---|
790 | DO k = nzb+1, nzt |
---|
791 | tq_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * tq_m(k,j,i) |
---|
792 | ENDDO |
---|
793 | ENDIF |
---|
794 | ENDIF |
---|
795 | |
---|
796 | ENDIF |
---|
797 | |
---|
798 | ! |
---|
799 | !-- If required, compute prognostic equation for scalar |
---|
800 | IF ( passive_scalar ) THEN |
---|
801 | ! |
---|
802 | !-- Tendency-terms for total water content / scalar |
---|
803 | tend(:,j,i) = 0.0_wp |
---|
804 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
805 | IF ( ws_scheme_sca ) THEN |
---|
806 | ! |
---|
807 | !-- For scalar advection apply monotonic flux limiter near topography. |
---|
808 | CALL advec_s_ws( advc_flags_s, i, j, s, 's', flux_s_s, diss_s_s, flux_l_s, & |
---|
809 | diss_l_s, i_omp_start, tn, & |
---|
810 | bc_dirichlet_l .OR. bc_radiation_l, & |
---|
811 | bc_dirichlet_n .OR. bc_radiation_n, & |
---|
812 | bc_dirichlet_r .OR. bc_radiation_r, & |
---|
813 | bc_dirichlet_s .OR. bc_radiation_s, & |
---|
814 | monotonic_limiter_z ) |
---|
815 | ELSE |
---|
816 | CALL advec_s_pw( i, j, s ) |
---|
817 | ENDIF |
---|
818 | ELSE |
---|
819 | CALL advec_s_up( i, j, s ) |
---|
820 | ENDIF |
---|
821 | CALL diffusion_s( i, j, s, surf_def_h(0)%ssws, surf_def_h(1)%ssws, & |
---|
822 | surf_def_h(2)%ssws, surf_lsm_h(0)%ssws, surf_lsm_h(1)%ssws, & |
---|
823 | surf_usm_h(0)%ssws, surf_usm_h(1)%ssws, & |
---|
824 | surf_def_v(0)%ssws, surf_def_v(1)%ssws, surf_def_v(2)%ssws, & |
---|
825 | surf_def_v(3)%ssws, surf_lsm_v(0)%ssws, surf_lsm_v(1)%ssws, & |
---|
826 | surf_lsm_v(2)%ssws, surf_lsm_v(3)%ssws, surf_usm_v(0)%ssws, & |
---|
827 | surf_usm_v(1)%ssws, surf_usm_v(2)%ssws, surf_usm_v(3)%ssws ) |
---|
828 | |
---|
829 | ! |
---|
830 | !-- Sink or source of scalar concentration due to canopy elements |
---|
831 | IF ( plant_canopy ) CALL pcm_tendency( i, j, 7 ) |
---|
832 | |
---|
833 | ! |
---|
834 | !-- Large scale advection, still need to be extended for scalars |
---|
835 | ! IF ( large_scale_forcing ) THEN |
---|
836 | ! CALL ls_advec( i, j, simulated_time, 's' ) |
---|
837 | ! ENDIF |
---|
838 | |
---|
839 | ! |
---|
840 | !-- Nudging, still need to be extended for scalars |
---|
841 | ! IF ( nudging ) CALL nudge( i, j, simulated_time, 's' ) |
---|
842 | |
---|
843 | ! |
---|
844 | !-- If required compute influence of large-scale subsidence/ascent. Note, the last argument |
---|
845 | !-- is of no meaning in this case, as it is only used in conjunction with |
---|
846 | !-- large_scale_forcing, which is to date not implemented for scalars. |
---|
847 | IF ( large_scale_subsidence .AND. .NOT. use_subsidence_tendencies .AND. & |
---|
848 | .NOT. large_scale_forcing ) THEN |
---|
849 | CALL subsidence( i, j, tend, s, s_init, 3 ) |
---|
850 | ENDIF |
---|
851 | |
---|
852 | CALL module_interface_actions( i, j, 's-tendency' ) |
---|
853 | |
---|
854 | ! |
---|
855 | !-- Prognostic equation for scalar |
---|
856 | DO k = nzb+1, nzt |
---|
857 | s_p(k,j,i) = s(k,j,i) & |
---|
858 | + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * ts_m(k,j,i) ) & |
---|
859 | - tsc(5) * rdf_sc(k) * ( s(k,j,i) - s_init(k) ) ) & |
---|
860 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
861 | IF ( s_p(k,j,i) < 0.0_wp ) s_p(k,j,i) = 0.1_wp * s(k,j,i) |
---|
862 | ENDDO |
---|
863 | |
---|
864 | ! |
---|
865 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
866 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
867 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
868 | DO k = nzb+1, nzt |
---|
869 | ts_m(k,j,i) = tend(k,j,i) |
---|
870 | ENDDO |
---|
871 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
872 | DO k = nzb+1, nzt |
---|
873 | ts_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * ts_m(k,j,i) |
---|
874 | ENDDO |
---|
875 | ENDIF |
---|
876 | ENDIF |
---|
877 | |
---|
878 | ENDIF |
---|
879 | ! |
---|
880 | !-- Calculate prognostic equations for all other modules |
---|
881 | CALL module_interface_prognostic_equations( i, j, i_omp_start, tn ) |
---|
882 | |
---|
883 | ENDDO ! loop over j |
---|
884 | ENDDO ! loop over i |
---|
885 | !$OMP END PARALLEL |
---|
886 | |
---|
887 | |
---|
888 | CALL cpu_log( log_point(32), 'all progn.equations', 'stop' ) |
---|
889 | |
---|
890 | IF ( debug_output_timestep ) CALL debug_message( 'prognostic_equations_cache', 'end' ) |
---|
891 | |
---|
892 | END SUBROUTINE prognostic_equations_cache |
---|
893 | |
---|
894 | |
---|
895 | !--------------------------------------------------------------------------------------------------! |
---|
896 | ! Description: |
---|
897 | ! ------------ |
---|
898 | !> Version for vector machines |
---|
899 | !--------------------------------------------------------------------------------------------------! |
---|
900 | |
---|
901 | SUBROUTINE prognostic_equations_vector |
---|
902 | |
---|
903 | |
---|
904 | INTEGER(iwp) :: i !< |
---|
905 | INTEGER(iwp) :: j !< |
---|
906 | INTEGER(iwp) :: k !< |
---|
907 | |
---|
908 | REAL(wp) :: sbt !< |
---|
909 | |
---|
910 | |
---|
911 | IF ( debug_output_timestep ) CALL debug_message( 'prognostic_equations_vector', 'start' ) |
---|
912 | ! |
---|
913 | !-- Calculate non advective processes for all other modules |
---|
914 | CALL module_interface_non_advective_processes |
---|
915 | ! |
---|
916 | !-- Module Inferface for exchange horiz after non_advective_processes but before advection. |
---|
917 | !-- Therefore, non_advective_processes must not run for ghost points. |
---|
918 | CALL module_interface_exchange_horiz() |
---|
919 | ! |
---|
920 | !-- u-velocity component |
---|
921 | CALL cpu_log( log_point(5), 'u-equation', 'start' ) |
---|
922 | |
---|
923 | !$ACC KERNELS PRESENT(tend) |
---|
924 | tend = 0.0_wp |
---|
925 | !$ACC END KERNELS |
---|
926 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
927 | IF ( ws_scheme_mom ) THEN |
---|
928 | CALL advec_u_ws |
---|
929 | ELSE |
---|
930 | CALL advec_u_pw |
---|
931 | ENDIF |
---|
932 | ELSE |
---|
933 | CALL advec_u_up |
---|
934 | ENDIF |
---|
935 | CALL diffusion_u |
---|
936 | CALL coriolis( 1 ) |
---|
937 | IF ( sloping_surface .AND. .NOT. neutral ) THEN |
---|
938 | CALL buoyancy( pt, 1 ) |
---|
939 | ENDIF |
---|
940 | |
---|
941 | ! |
---|
942 | !-- Drag by plant canopy |
---|
943 | IF ( plant_canopy ) CALL pcm_tendency( 1 ) |
---|
944 | |
---|
945 | ! |
---|
946 | !-- External pressure gradient |
---|
947 | IF ( dp_external ) THEN |
---|
948 | DO i = nxlu, nxr |
---|
949 | DO j = nys, nyn |
---|
950 | DO k = dp_level_ind_b+1, nzt |
---|
951 | tend(k,j,i) = tend(k,j,i) - dpdxy(1) * dp_smooth_factor(k) |
---|
952 | ENDDO |
---|
953 | ENDDO |
---|
954 | ENDDO |
---|
955 | ENDIF |
---|
956 | |
---|
957 | ! |
---|
958 | !-- Nudging |
---|
959 | IF ( nudging ) CALL nudge( simulated_time, 'u' ) |
---|
960 | |
---|
961 | ! |
---|
962 | !-- Effect of Stokes drift (in ocean mode only) |
---|
963 | IF ( stokes_force ) CALL stokes_drift_terms( 1 ) |
---|
964 | |
---|
965 | CALL module_interface_actions( 'u-tendency' ) |
---|
966 | |
---|
967 | ! |
---|
968 | !-- Prognostic equation for u-velocity component |
---|
969 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
970 | !$ACC PRESENT(u, tend, tu_m, u_init, rdf, wall_flags_total_0) & |
---|
971 | !$ACC PRESENT(tsc(2:5)) & |
---|
972 | !$ACC PRESENT(u_p) |
---|
973 | DO i = nxlu, nxr |
---|
974 | DO j = nys, nyn |
---|
975 | ! |
---|
976 | !-- Following directive is required to vectorize on Intel19 |
---|
977 | !DIR$ IVDEP |
---|
978 | DO k = nzb+1, nzt |
---|
979 | u_p(k,j,i) = u(k,j,i) & |
---|
980 | + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tu_m(k,j,i) ) & |
---|
981 | - tsc(5) * rdf(k) * ( u(k,j,i) - u_init(k) ) ) & |
---|
982 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) |
---|
983 | ENDDO |
---|
984 | ENDDO |
---|
985 | ENDDO |
---|
986 | |
---|
987 | ! |
---|
988 | !-- Add turbulence generated by wave breaking (in ocean mode only) |
---|
989 | IF ( wave_breaking .AND. intermediate_timestep_count == intermediate_timestep_count_max ) THEN |
---|
990 | CALL wave_breaking_term( 1 ) |
---|
991 | ENDIF |
---|
992 | |
---|
993 | ! |
---|
994 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
995 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
996 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
997 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
998 | !$ACC PRESENT(tend, tu_m) |
---|
999 | DO i = nxlu, nxr |
---|
1000 | DO j = nys, nyn |
---|
1001 | DO k = nzb+1, nzt |
---|
1002 | tu_m(k,j,i) = tend(k,j,i) |
---|
1003 | ENDDO |
---|
1004 | ENDDO |
---|
1005 | ENDDO |
---|
1006 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
1007 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1008 | !$ACC PRESENT(tend, tu_m) |
---|
1009 | DO i = nxlu, nxr |
---|
1010 | DO j = nys, nyn |
---|
1011 | DO k = nzb+1, nzt |
---|
1012 | tu_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * tu_m(k,j,i) |
---|
1013 | ENDDO |
---|
1014 | ENDDO |
---|
1015 | ENDDO |
---|
1016 | ENDIF |
---|
1017 | ENDIF |
---|
1018 | |
---|
1019 | CALL cpu_log( log_point(5), 'u-equation', 'stop' ) |
---|
1020 | |
---|
1021 | ! |
---|
1022 | !-- v-velocity component |
---|
1023 | CALL cpu_log( log_point(6), 'v-equation', 'start' ) |
---|
1024 | |
---|
1025 | !$ACC KERNELS PRESENT(tend) |
---|
1026 | tend = 0.0_wp |
---|
1027 | !$ACC END KERNELS |
---|
1028 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1029 | IF ( ws_scheme_mom ) THEN |
---|
1030 | CALL advec_v_ws |
---|
1031 | ELSE |
---|
1032 | CALL advec_v_pw |
---|
1033 | END IF |
---|
1034 | ELSE |
---|
1035 | CALL advec_v_up |
---|
1036 | ENDIF |
---|
1037 | CALL diffusion_v |
---|
1038 | CALL coriolis( 2 ) |
---|
1039 | |
---|
1040 | ! |
---|
1041 | !-- Drag by plant canopy |
---|
1042 | IF ( plant_canopy ) CALL pcm_tendency( 2 ) |
---|
1043 | |
---|
1044 | ! |
---|
1045 | !-- External pressure gradient |
---|
1046 | IF ( dp_external ) THEN |
---|
1047 | DO i = nxl, nxr |
---|
1048 | DO j = nysv, nyn |
---|
1049 | DO k = dp_level_ind_b+1, nzt |
---|
1050 | tend(k,j,i) = tend(k,j,i) - dpdxy(2) * dp_smooth_factor(k) |
---|
1051 | ENDDO |
---|
1052 | ENDDO |
---|
1053 | ENDDO |
---|
1054 | ENDIF |
---|
1055 | |
---|
1056 | ! |
---|
1057 | !-- Nudging |
---|
1058 | IF ( nudging ) CALL nudge( simulated_time, 'v' ) |
---|
1059 | |
---|
1060 | ! |
---|
1061 | !-- Effect of Stokes drift (in ocean mode only) |
---|
1062 | IF ( stokes_force ) CALL stokes_drift_terms( 2 ) |
---|
1063 | |
---|
1064 | CALL module_interface_actions( 'v-tendency' ) |
---|
1065 | |
---|
1066 | ! |
---|
1067 | !-- Prognostic equation for v-velocity component |
---|
1068 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1069 | !$ACC PRESENT(v, tend, tv_m, v_init, rdf, wall_flags_total_0) & |
---|
1070 | !$ACC PRESENT(tsc(2:5)) & |
---|
1071 | !$ACC PRESENT(v_p) |
---|
1072 | DO i = nxl, nxr |
---|
1073 | DO j = nysv, nyn |
---|
1074 | ! |
---|
1075 | !-- Following directive is required to vectorize on Intel19 |
---|
1076 | !DIR$ IVDEP |
---|
1077 | DO k = nzb+1, nzt |
---|
1078 | v_p(k,j,i) = v(k,j,i) & |
---|
1079 | + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tv_m(k,j,i) ) - tsc(5) & |
---|
1080 | * rdf(k) * ( v(k,j,i) - v_init(k) ) ) & |
---|
1081 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) |
---|
1082 | ENDDO |
---|
1083 | ENDDO |
---|
1084 | ENDDO |
---|
1085 | |
---|
1086 | ! |
---|
1087 | !-- Add turbulence generated by wave breaking (in ocean mode only) |
---|
1088 | IF ( wave_breaking .AND. intermediate_timestep_count == intermediate_timestep_count_max ) THEN |
---|
1089 | CALL wave_breaking_term( 2 ) |
---|
1090 | ENDIF |
---|
1091 | |
---|
1092 | ! |
---|
1093 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
1094 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1095 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
1096 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1097 | !$ACC PRESENT(tend, tv_m) |
---|
1098 | DO i = nxl, nxr |
---|
1099 | DO j = nysv, nyn |
---|
1100 | DO k = nzb+1, nzt |
---|
1101 | tv_m(k,j,i) = tend(k,j,i) |
---|
1102 | ENDDO |
---|
1103 | ENDDO |
---|
1104 | ENDDO |
---|
1105 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
1106 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1107 | !$ACC PRESENT(tend, tv_m) |
---|
1108 | DO i = nxl, nxr |
---|
1109 | DO j = nysv, nyn |
---|
1110 | DO k = nzb+1, nzt |
---|
1111 | tv_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * tv_m(k,j,i) |
---|
1112 | ENDDO |
---|
1113 | ENDDO |
---|
1114 | ENDDO |
---|
1115 | ENDIF |
---|
1116 | ENDIF |
---|
1117 | |
---|
1118 | CALL cpu_log( log_point(6), 'v-equation', 'stop' ) |
---|
1119 | |
---|
1120 | ! |
---|
1121 | !-- w-velocity component |
---|
1122 | CALL cpu_log( log_point(7), 'w-equation', 'start' ) |
---|
1123 | |
---|
1124 | !$ACC KERNELS PRESENT(tend) |
---|
1125 | tend = 0.0_wp |
---|
1126 | !$ACC END KERNELS |
---|
1127 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1128 | IF ( ws_scheme_mom ) THEN |
---|
1129 | CALL advec_w_ws |
---|
1130 | ELSE |
---|
1131 | CALL advec_w_pw |
---|
1132 | ENDIF |
---|
1133 | ELSE |
---|
1134 | CALL advec_w_up |
---|
1135 | ENDIF |
---|
1136 | CALL diffusion_w |
---|
1137 | CALL coriolis( 3 ) |
---|
1138 | |
---|
1139 | IF ( .NOT. neutral ) THEN |
---|
1140 | IF ( ocean_mode ) THEN |
---|
1141 | CALL buoyancy( rho_ocean, 3 ) |
---|
1142 | ELSE |
---|
1143 | IF ( .NOT. humidity ) THEN |
---|
1144 | CALL buoyancy( pt, 3 ) |
---|
1145 | ELSE |
---|
1146 | CALL buoyancy( vpt, 3 ) |
---|
1147 | ENDIF |
---|
1148 | ENDIF |
---|
1149 | ENDIF |
---|
1150 | |
---|
1151 | ! |
---|
1152 | !-- Drag by plant canopy |
---|
1153 | IF ( plant_canopy ) CALL pcm_tendency( 3 ) |
---|
1154 | |
---|
1155 | ! |
---|
1156 | !-- Effect of Stokes drift (in ocean mode only) |
---|
1157 | IF ( stokes_force ) CALL stokes_drift_terms( 3 ) |
---|
1158 | |
---|
1159 | CALL module_interface_actions( 'w-tendency' ) |
---|
1160 | |
---|
1161 | ! |
---|
1162 | !-- Prognostic equation for w-velocity component |
---|
1163 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1164 | !$ACC PRESENT(w, tend, tw_m, v_init, rdf, wall_flags_total_0) & |
---|
1165 | !$ACC PRESENT(tsc(2:5)) & |
---|
1166 | !$ACC PRESENT(w_p) |
---|
1167 | DO i = nxl, nxr |
---|
1168 | DO j = nys, nyn |
---|
1169 | ! |
---|
1170 | !-- Following directive is required to vectorize on Intel19 |
---|
1171 | !DIR$ IVDEP |
---|
1172 | DO k = nzb+1, nzt-1 |
---|
1173 | w_p(k,j,i) = w(k,j,i) & |
---|
1174 | + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tw_m(k,j,i) ) & |
---|
1175 | - tsc(5) * rdf(k) * w(k,j,i) ) & |
---|
1176 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) ) |
---|
1177 | ENDDO |
---|
1178 | ENDDO |
---|
1179 | ENDDO |
---|
1180 | |
---|
1181 | ! |
---|
1182 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
1183 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1184 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
1185 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1186 | !$ACC PRESENT(tend, tw_m) |
---|
1187 | DO i = nxl, nxr |
---|
1188 | DO j = nys, nyn |
---|
1189 | DO k = nzb+1, nzt-1 |
---|
1190 | tw_m(k,j,i) = tend(k,j,i) |
---|
1191 | ENDDO |
---|
1192 | ENDDO |
---|
1193 | ENDDO |
---|
1194 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
1195 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1196 | !$ACC PRESENT(tend, tw_m) |
---|
1197 | DO i = nxl, nxr |
---|
1198 | DO j = nys, nyn |
---|
1199 | DO k = nzb+1, nzt-1 |
---|
1200 | tw_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * tw_m(k,j,i) |
---|
1201 | ENDDO |
---|
1202 | ENDDO |
---|
1203 | ENDDO |
---|
1204 | ENDIF |
---|
1205 | ENDIF |
---|
1206 | |
---|
1207 | CALL cpu_log( log_point(7), 'w-equation', 'stop' ) |
---|
1208 | |
---|
1209 | |
---|
1210 | ! |
---|
1211 | !-- If required, compute prognostic equation for potential temperature |
---|
1212 | IF ( .NOT. neutral ) THEN |
---|
1213 | |
---|
1214 | CALL cpu_log( log_point(13), 'pt-equation', 'start' ) |
---|
1215 | |
---|
1216 | ! |
---|
1217 | !-- pt-tendency terms with communication |
---|
1218 | sbt = tsc(2) |
---|
1219 | IF ( scalar_advec == 'bc-scheme' ) THEN |
---|
1220 | |
---|
1221 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
1222 | ! |
---|
1223 | !-- Bott-Chlond scheme always uses Euler time step. Thus: |
---|
1224 | sbt = 1.0_wp |
---|
1225 | ENDIF |
---|
1226 | tend = 0.0_wp |
---|
1227 | CALL advec_s_bc( pt, 'pt' ) |
---|
1228 | |
---|
1229 | ENDIF |
---|
1230 | |
---|
1231 | ! |
---|
1232 | !-- pt-tendency terms with no communication |
---|
1233 | IF ( scalar_advec /= 'bc-scheme' ) THEN |
---|
1234 | !$ACC KERNELS PRESENT(tend) |
---|
1235 | tend = 0.0_wp |
---|
1236 | !$ACC END KERNELS |
---|
1237 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1238 | IF ( ws_scheme_sca ) THEN |
---|
1239 | CALL advec_s_ws( advc_flags_s, pt, 'pt', & |
---|
1240 | bc_dirichlet_l .OR. bc_radiation_l, & |
---|
1241 | bc_dirichlet_n .OR. bc_radiation_n, & |
---|
1242 | bc_dirichlet_r .OR. bc_radiation_r, & |
---|
1243 | bc_dirichlet_s .OR. bc_radiation_s ) |
---|
1244 | ELSE |
---|
1245 | CALL advec_s_pw( pt ) |
---|
1246 | ENDIF |
---|
1247 | ELSE |
---|
1248 | CALL advec_s_up( pt ) |
---|
1249 | ENDIF |
---|
1250 | ENDIF |
---|
1251 | |
---|
1252 | CALL diffusion_s( pt, surf_def_h(0)%shf, surf_def_h(1)%shf, surf_def_h(2)%shf, & |
---|
1253 | surf_lsm_h(0)%shf, surf_lsm_h(1)%shf, surf_usm_h(0)%shf, & |
---|
1254 | surf_usm_h(1)%shf, surf_def_v(0)%shf, surf_def_v(1)%shf, & |
---|
1255 | surf_def_v(2)%shf, surf_def_v(3)%shf, surf_lsm_v(0)%shf, & |
---|
1256 | surf_lsm_v(1)%shf, surf_lsm_v(2)%shf, surf_lsm_v(3)%shf, & |
---|
1257 | surf_usm_v(0)%shf, surf_usm_v(1)%shf, surf_usm_v(2)%shf, & |
---|
1258 | surf_usm_v(3)%shf ) |
---|
1259 | |
---|
1260 | ! |
---|
1261 | !-- Consideration of heat sources within the plant canopy |
---|
1262 | IF ( plant_canopy .AND. (cthf /= 0.0_wp .OR. urban_surface .OR. land_surface) ) THEN |
---|
1263 | CALL pcm_tendency( 4 ) |
---|
1264 | ENDIF |
---|
1265 | |
---|
1266 | ! |
---|
1267 | !-- Large scale advection |
---|
1268 | IF ( large_scale_forcing ) THEN |
---|
1269 | CALL ls_advec( simulated_time, 'pt' ) |
---|
1270 | ENDIF |
---|
1271 | |
---|
1272 | ! |
---|
1273 | !-- Nudging |
---|
1274 | IF ( nudging ) CALL nudge( simulated_time, 'pt' ) |
---|
1275 | |
---|
1276 | ! |
---|
1277 | !-- If required compute influence of large-scale subsidence/ascent |
---|
1278 | IF ( large_scale_subsidence .AND. .NOT. use_subsidence_tendencies ) THEN |
---|
1279 | CALL subsidence( tend, pt, pt_init, 2 ) |
---|
1280 | ENDIF |
---|
1281 | |
---|
1282 | #if defined( __rrtmg ) |
---|
1283 | ! |
---|
1284 | !-- If required, add tendency due to radiative heating/cooling |
---|
1285 | IF ( radiation .AND. simulated_time > skip_time_do_radiation ) THEN |
---|
1286 | CALL radiation_tendency ( tend ) |
---|
1287 | ENDIF |
---|
1288 | #endif |
---|
1289 | |
---|
1290 | CALL module_interface_actions( 'pt-tendency' ) |
---|
1291 | |
---|
1292 | ! |
---|
1293 | !-- Prognostic equation for potential temperature |
---|
1294 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1295 | !$ACC PRESENT(pt, tend, tpt_m, wall_flags_total_0) & |
---|
1296 | !$ACC PRESENT(pt_init, rdf_sc, ptdf_x, ptdf_y) & |
---|
1297 | !$ACC PRESENT(tsc(3:5)) & |
---|
1298 | !$ACC PRESENT(pt_p) |
---|
1299 | DO i = nxl, nxr |
---|
1300 | DO j = nys, nyn |
---|
1301 | ! |
---|
1302 | !-- Following directive is required to vectorize on Intel19 |
---|
1303 | !DIR$ IVDEP |
---|
1304 | DO k = nzb+1, nzt |
---|
1305 | pt_p(k,j,i) = pt(k,j,i) & |
---|
1306 | + ( dt_3d * ( sbt * tend(k,j,i) + tsc(3) * tpt_m(k,j,i) ) & |
---|
1307 | - tsc(5) * ( pt(k,j,i) - pt_init(k) ) & |
---|
1308 | * ( rdf_sc(k) + ptdf_x(i) + ptdf_y(j) ) ) & |
---|
1309 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
1310 | ENDDO |
---|
1311 | ENDDO |
---|
1312 | ENDDO |
---|
1313 | ! |
---|
1314 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
1315 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1316 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
1317 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1318 | !$ACC PRESENT(tend, tpt_m) |
---|
1319 | DO i = nxl, nxr |
---|
1320 | DO j = nys, nyn |
---|
1321 | DO k = nzb+1, nzt |
---|
1322 | tpt_m(k,j,i) = tend(k,j,i) |
---|
1323 | ENDDO |
---|
1324 | ENDDO |
---|
1325 | ENDDO |
---|
1326 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
1327 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) & |
---|
1328 | !$ACC PRESENT(tend, tpt_m) |
---|
1329 | DO i = nxl, nxr |
---|
1330 | DO j = nys, nyn |
---|
1331 | DO k = nzb+1, nzt |
---|
1332 | tpt_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * tpt_m(k,j,i) |
---|
1333 | ENDDO |
---|
1334 | ENDDO |
---|
1335 | ENDDO |
---|
1336 | ENDIF |
---|
1337 | ENDIF |
---|
1338 | |
---|
1339 | CALL cpu_log( log_point(13), 'pt-equation', 'stop' ) |
---|
1340 | |
---|
1341 | ENDIF |
---|
1342 | |
---|
1343 | ! |
---|
1344 | !-- If required, compute prognostic equation for total water content |
---|
1345 | IF ( humidity ) THEN |
---|
1346 | |
---|
1347 | CALL cpu_log( log_point(29), 'q-equation', 'start' ) |
---|
1348 | |
---|
1349 | ! |
---|
1350 | !-- Scalar/q-tendency terms with communication |
---|
1351 | sbt = tsc(2) |
---|
1352 | IF ( scalar_advec == 'bc-scheme' ) THEN |
---|
1353 | |
---|
1354 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
1355 | ! |
---|
1356 | !-- Bott-Chlond scheme always uses Euler time step. Thus: |
---|
1357 | sbt = 1.0_wp |
---|
1358 | ENDIF |
---|
1359 | tend = 0.0_wp |
---|
1360 | CALL advec_s_bc( q, 'q' ) |
---|
1361 | |
---|
1362 | ENDIF |
---|
1363 | |
---|
1364 | ! |
---|
1365 | !-- Scalar/q-tendency terms with no communication |
---|
1366 | IF ( scalar_advec /= 'bc-scheme' ) THEN |
---|
1367 | tend = 0.0_wp |
---|
1368 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1369 | IF ( ws_scheme_sca ) THEN |
---|
1370 | CALL advec_s_ws( advc_flags_s, q, 'q', & |
---|
1371 | bc_dirichlet_l .OR. bc_radiation_l, & |
---|
1372 | bc_dirichlet_n .OR. bc_radiation_n, & |
---|
1373 | bc_dirichlet_r .OR. bc_radiation_r, & |
---|
1374 | bc_dirichlet_s .OR. bc_radiation_s ) |
---|
1375 | ELSE |
---|
1376 | CALL advec_s_pw( q ) |
---|
1377 | ENDIF |
---|
1378 | ELSE |
---|
1379 | CALL advec_s_up( q ) |
---|
1380 | ENDIF |
---|
1381 | ENDIF |
---|
1382 | |
---|
1383 | CALL diffusion_s( q, surf_def_h(0)%qsws, surf_def_h(1)%qsws, surf_def_h(2)%qsws, & |
---|
1384 | surf_lsm_h(0)%qsws, surf_lsm_h(1)%qsws, surf_usm_h(0)%qsws, & |
---|
1385 | surf_usm_h(0)%qsws, surf_def_v(0)%qsws, surf_def_v(1)%qsws, & |
---|
1386 | surf_def_v(2)%qsws, surf_def_v(3)%qsws, surf_lsm_v(0)%qsws, & |
---|
1387 | surf_lsm_v(1)%qsws, surf_lsm_v(2)%qsws, surf_lsm_v(3)%qsws, & |
---|
1388 | surf_usm_v(0)%qsws, surf_usm_v(1)%qsws, surf_usm_v(2)%qsws, & |
---|
1389 | surf_usm_v(3)%qsws ) |
---|
1390 | |
---|
1391 | ! |
---|
1392 | !-- Sink or source of humidity due to canopy elements |
---|
1393 | IF ( plant_canopy ) CALL pcm_tendency( 5 ) |
---|
1394 | |
---|
1395 | ! |
---|
1396 | !-- Large scale advection |
---|
1397 | IF ( large_scale_forcing ) THEN |
---|
1398 | CALL ls_advec( simulated_time, 'q' ) |
---|
1399 | ENDIF |
---|
1400 | |
---|
1401 | ! |
---|
1402 | !-- Nudging |
---|
1403 | IF ( nudging ) CALL nudge( simulated_time, 'q' ) |
---|
1404 | |
---|
1405 | ! |
---|
1406 | !-- If required compute influence of large-scale subsidence/ascent |
---|
1407 | IF ( large_scale_subsidence .AND. .NOT. use_subsidence_tendencies ) THEN |
---|
1408 | CALL subsidence( tend, q, q_init, 3 ) |
---|
1409 | ENDIF |
---|
1410 | |
---|
1411 | CALL module_interface_actions( 'q-tendency' ) |
---|
1412 | |
---|
1413 | ! |
---|
1414 | !-- Prognostic equation for total water content |
---|
1415 | DO i = nxl, nxr |
---|
1416 | DO j = nys, nyn |
---|
1417 | ! |
---|
1418 | !-- Following directive is required to vectorize on Intel19 |
---|
1419 | !DIR$ IVDEP |
---|
1420 | DO k = nzb+1, nzt |
---|
1421 | q_p(k,j,i) = q(k,j,i) & |
---|
1422 | + ( dt_3d * ( sbt * tend(k,j,i) + tsc(3) * tq_m(k,j,i) ) & |
---|
1423 | - tsc(5) * rdf_sc(k) * ( q(k,j,i) - q_init(k) ) ) & |
---|
1424 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
1425 | IF ( q_p(k,j,i) < 0.0_wp ) q_p(k,j,i) = 0.1_wp * q(k,j,i) |
---|
1426 | ENDDO |
---|
1427 | ENDDO |
---|
1428 | ENDDO |
---|
1429 | |
---|
1430 | ! |
---|
1431 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
1432 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1433 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
1434 | DO i = nxl, nxr |
---|
1435 | DO j = nys, nyn |
---|
1436 | DO k = nzb+1, nzt |
---|
1437 | tq_m(k,j,i) = tend(k,j,i) |
---|
1438 | ENDDO |
---|
1439 | ENDDO |
---|
1440 | ENDDO |
---|
1441 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
1442 | DO i = nxl, nxr |
---|
1443 | DO j = nys, nyn |
---|
1444 | DO k = nzb+1, nzt |
---|
1445 | tq_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * tq_m(k,j,i) |
---|
1446 | ENDDO |
---|
1447 | ENDDO |
---|
1448 | ENDDO |
---|
1449 | ENDIF |
---|
1450 | ENDIF |
---|
1451 | |
---|
1452 | CALL cpu_log( log_point(29), 'q-equation', 'stop' ) |
---|
1453 | |
---|
1454 | ENDIF |
---|
1455 | ! |
---|
1456 | !-- If required, compute prognostic equation for scalar |
---|
1457 | IF ( passive_scalar ) THEN |
---|
1458 | |
---|
1459 | CALL cpu_log( log_point(66), 's-equation', 'start' ) |
---|
1460 | |
---|
1461 | ! |
---|
1462 | !-- Scalar/q-tendency terms with communication |
---|
1463 | sbt = tsc(2) |
---|
1464 | IF ( scalar_advec == 'bc-scheme' ) THEN |
---|
1465 | |
---|
1466 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
1467 | ! |
---|
1468 | !-- Bott-Chlond scheme always uses Euler time step. Thus: |
---|
1469 | sbt = 1.0_wp |
---|
1470 | ENDIF |
---|
1471 | tend = 0.0_wp |
---|
1472 | CALL advec_s_bc( s, 's' ) |
---|
1473 | |
---|
1474 | ENDIF |
---|
1475 | |
---|
1476 | ! |
---|
1477 | !-- Scalar/q-tendency terms with no communication |
---|
1478 | IF ( scalar_advec /= 'bc-scheme' ) THEN |
---|
1479 | tend = 0.0_wp |
---|
1480 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1481 | IF ( ws_scheme_sca ) THEN |
---|
1482 | CALL advec_s_ws( advc_flags_s, s, 's', & |
---|
1483 | bc_dirichlet_l .OR. bc_radiation_l, & |
---|
1484 | bc_dirichlet_n .OR. bc_radiation_n, & |
---|
1485 | bc_dirichlet_r .OR. bc_radiation_r, & |
---|
1486 | bc_dirichlet_s .OR. bc_radiation_s ) |
---|
1487 | ELSE |
---|
1488 | CALL advec_s_pw( s ) |
---|
1489 | ENDIF |
---|
1490 | ELSE |
---|
1491 | CALL advec_s_up( s ) |
---|
1492 | ENDIF |
---|
1493 | ENDIF |
---|
1494 | |
---|
1495 | CALL diffusion_s( s, surf_def_h(0)%ssws, surf_def_h(1)%ssws, surf_def_h(2)%ssws, & |
---|
1496 | surf_lsm_h(0)%ssws, surf_lsm_h(1)%ssws, surf_usm_h(0)%ssws, & |
---|
1497 | surf_usm_h(1)%ssws, surf_def_v(0)%ssws, surf_def_v(1)%ssws, & |
---|
1498 | surf_def_v(2)%ssws, surf_def_v(3)%ssws, surf_lsm_v(0)%ssws, & |
---|
1499 | surf_lsm_v(1)%ssws, surf_lsm_v(2)%ssws, surf_lsm_v(3)%ssws, & |
---|
1500 | surf_usm_v(0)%ssws, surf_usm_v(1)%ssws, surf_usm_v(2)%ssws, & |
---|
1501 | surf_usm_v(3)%ssws ) |
---|
1502 | |
---|
1503 | ! |
---|
1504 | !-- Sink or source of humidity due to canopy elements |
---|
1505 | IF ( plant_canopy ) CALL pcm_tendency( 7 ) |
---|
1506 | |
---|
1507 | ! |
---|
1508 | !-- Large scale advection. Not implemented for scalars so far. |
---|
1509 | ! IF ( large_scale_forcing ) THEN |
---|
1510 | ! CALL ls_advec( simulated_time, 'q' ) |
---|
1511 | ! ENDIF |
---|
1512 | |
---|
1513 | ! |
---|
1514 | !-- Nudging. Not implemented for scalars so far. |
---|
1515 | ! IF ( nudging ) CALL nudge( simulated_time, 'q' ) |
---|
1516 | |
---|
1517 | ! |
---|
1518 | !-- If required compute influence of large-scale subsidence/ascent. |
---|
1519 | !-- Not implemented for scalars so far. |
---|
1520 | IF ( large_scale_subsidence .AND. .NOT. use_subsidence_tendencies .AND. & |
---|
1521 | .NOT. large_scale_forcing ) THEN |
---|
1522 | CALL subsidence( tend, s, s_init, 3 ) |
---|
1523 | ENDIF |
---|
1524 | |
---|
1525 | CALL module_interface_actions( 's-tendency' ) |
---|
1526 | |
---|
1527 | ! |
---|
1528 | !-- Prognostic equation for total water content |
---|
1529 | DO i = nxl, nxr |
---|
1530 | DO j = nys, nyn |
---|
1531 | ! |
---|
1532 | !-- Following directive is required to vectorize on Intel19 |
---|
1533 | !DIR$ IVDEP |
---|
1534 | DO k = nzb+1, nzt |
---|
1535 | s_p(k,j,i) = s(k,j,i) & |
---|
1536 | + ( dt_3d * ( sbt * tend(k,j,i) + tsc(3) * ts_m(k,j,i) ) & |
---|
1537 | - tsc(5) * rdf_sc(k) * ( s(k,j,i) - s_init(k) ) ) & |
---|
1538 | * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
1539 | IF ( s_p(k,j,i) < 0.0_wp ) s_p(k,j,i) = 0.1_wp * s(k,j,i) |
---|
1540 | ENDDO |
---|
1541 | ENDDO |
---|
1542 | ENDDO |
---|
1543 | |
---|
1544 | ! |
---|
1545 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
1546 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1547 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
1548 | DO i = nxl, nxr |
---|
1549 | DO j = nys, nyn |
---|
1550 | DO k = nzb+1, nzt |
---|
1551 | ts_m(k,j,i) = tend(k,j,i) |
---|
1552 | ENDDO |
---|
1553 | ENDDO |
---|
1554 | ENDDO |
---|
1555 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) THEN |
---|
1556 | DO i = nxl, nxr |
---|
1557 | DO j = nys, nyn |
---|
1558 | DO k = nzb+1, nzt |
---|
1559 | ts_m(k,j,i) = - 9.5625_wp * tend(k,j,i) + 5.3125_wp * ts_m(k,j,i) |
---|
1560 | ENDDO |
---|
1561 | ENDDO |
---|
1562 | ENDDO |
---|
1563 | ENDIF |
---|
1564 | ENDIF |
---|
1565 | |
---|
1566 | CALL cpu_log( log_point(66), 's-equation', 'stop' ) |
---|
1567 | |
---|
1568 | ENDIF |
---|
1569 | ! |
---|
1570 | !-- Calculate prognostic equations for all other modules |
---|
1571 | CALL module_interface_prognostic_equations() |
---|
1572 | |
---|
1573 | IF ( debug_output_timestep ) CALL debug_message( 'prognostic_equations_vector', 'end' ) |
---|
1574 | |
---|
1575 | END SUBROUTINE prognostic_equations_vector |
---|
1576 | |
---|
1577 | |
---|
1578 | END MODULE prognostic_equations_mod |
---|