[1682] | 1 | !> @file time_integration.f90 |
---|
[1036] | 2 | !--------------------------------------------------------------------------------! |
---|
| 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
| 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 8 | ! |
---|
| 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | ! |
---|
| 13 | ! You should have received a copy of the GNU General Public License along with |
---|
| 14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | ! |
---|
[1691] | 16 | ! Copyright 1997-2015 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[1092] | 20 | ! ------------------ |
---|
[1737] | 21 | ! |
---|
[1763] | 22 | ! |
---|
[1366] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: time_integration.f90 1763 2016-02-25 13:00:19Z hellstea $ |
---|
| 26 | ! |
---|
[1763] | 27 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
| 28 | ! Introduction of nested domain feature |
---|
| 29 | ! |
---|
[1737] | 30 | ! 1736 2015-12-04 08:56:33Z raasch |
---|
| 31 | ! no perturbations added to total domain if energy limit has been set zero |
---|
| 32 | ! |
---|
[1692] | 33 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
| 34 | ! Added option for spin-ups without land surface and radiation models. Moved calls |
---|
| 35 | ! for radiation and lan surface schemes. |
---|
| 36 | ! |
---|
[1683] | 37 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 38 | ! Code annotations made doxygen readable |
---|
| 39 | ! |
---|
[1672] | 40 | ! 1671 2015-09-25 03:29:37Z raasch |
---|
| 41 | ! bugfix: ghostpoint exchange for array diss in case that sgs velocities are used |
---|
| 42 | ! for particles |
---|
| 43 | ! |
---|
[1586] | 44 | ! 1585 2015-04-30 07:05:52Z maronga |
---|
| 45 | ! Moved call of radiation scheme. Added support for RRTM |
---|
| 46 | ! |
---|
[1552] | 47 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
| 48 | ! Added interface for different radiation schemes. |
---|
| 49 | ! |
---|
[1497] | 50 | ! 1496 2014-12-02 17:25:50Z maronga |
---|
| 51 | ! Added calls for the land surface model and radiation scheme |
---|
| 52 | ! |
---|
[1403] | 53 | ! 1402 2014-05-09 14:25:13Z raasch |
---|
| 54 | ! location messages modified |
---|
| 55 | ! |
---|
[1385] | 56 | ! 1384 2014-05-02 14:31:06Z raasch |
---|
| 57 | ! location messages added |
---|
| 58 | ! |
---|
[1381] | 59 | ! 1380 2014-04-28 12:40:45Z heinze |
---|
| 60 | ! CALL of nudge_ref added |
---|
| 61 | ! bc_pt_t_val and bc_q_t_val are updated in case nudging is used |
---|
| 62 | ! |
---|
[1366] | 63 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
[1365] | 64 | ! Reset sums_ls_l to zero at each timestep |
---|
| 65 | ! +sums_ls_l |
---|
| 66 | ! Calculation of reference state (previously in subroutine calc_mean_profile) |
---|
| 67 | |
---|
[1343] | 68 | ! 1342 2014-03-26 17:04:47Z kanani |
---|
| 69 | ! REAL constants defined as wp-kind |
---|
| 70 | ! |
---|
[1321] | 71 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 72 | ! ONLY-attribute added to USE-statements, |
---|
| 73 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 74 | ! kinds are defined in new module kinds, |
---|
| 75 | ! old module precision_kind is removed, |
---|
| 76 | ! revision history before 2012 removed, |
---|
| 77 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 78 | ! all variable declaration statements |
---|
[1319] | 79 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 80 | ! module interfaces removed |
---|
| 81 | ! |
---|
[1309] | 82 | ! 1308 2014-03-13 14:58:42Z fricke |
---|
| 83 | ! +netcdf_data_format_save |
---|
| 84 | ! For masked data, parallel netcdf output is not tested so far, hence |
---|
| 85 | ! netcdf_data_format is switched back to non-paralell output. |
---|
| 86 | ! |
---|
[1277] | 87 | ! 1276 2014-01-15 13:40:41Z heinze |
---|
| 88 | ! Use LSF_DATA also in case of Dirichlet bottom boundary condition for scalars |
---|
| 89 | ! |
---|
[1258] | 90 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
| 91 | ! acc-update-host directive for timestep removed |
---|
| 92 | ! |
---|
[1242] | 93 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
| 94 | ! Generalize calc_mean_profile for wider use |
---|
| 95 | ! Determine shf and qsws in dependence on data from LSF_DATA |
---|
| 96 | ! Determine ug and vg in dependence on data from LSF_DATA |
---|
[1222] | 97 | ! 1221 2013-09-10 08:59:13Z raasch |
---|
| 98 | ! host update of arrays before timestep is called |
---|
| 99 | ! |
---|
[1182] | 100 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
| 101 | ! mean profiles for reference state are only calculated if required, |
---|
| 102 | ! small bugfix for background communication |
---|
| 103 | ! |
---|
[1172] | 104 | ! 1171 2013-05-30 11:27:45Z raasch |
---|
| 105 | ! split of prognostic_equations deactivated (comment lines), for the time being |
---|
| 106 | ! |
---|
[1132] | 107 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
[1128] | 108 | ! asynchronous transfer of ghost point data realized for acc-optimized version: |
---|
| 109 | ! prognostic_equations are first called two times for those points required for |
---|
| 110 | ! the left-right and north-south exchange, respectively, and then for the |
---|
| 111 | ! remaining points, |
---|
| 112 | ! those parts requiring global communication moved from prognostic_equations to |
---|
| 113 | ! here |
---|
[392] | 114 | ! |
---|
[1116] | 115 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
| 116 | ! calculation of qr and nr is restricted to precipitation |
---|
| 117 | ! |
---|
[1114] | 118 | ! 1113 2013-03-10 02:48:14Z raasch |
---|
| 119 | ! GPU-porting of boundary conditions, |
---|
| 120 | ! openACC directives updated |
---|
| 121 | ! formal parameter removed from routine boundary_conds |
---|
| 122 | ! |
---|
[1112] | 123 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
| 124 | ! +internal timestep counter for cpu statistics added, |
---|
| 125 | ! openACC directives updated |
---|
| 126 | ! |
---|
[1093] | 127 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 128 | ! unused variables removed |
---|
| 129 | ! |
---|
[1066] | 130 | ! 1065 2012-11-22 17:42:36Z hoffmann |
---|
| 131 | ! exchange of diss (dissipation rate) in case of turbulence = .TRUE. added |
---|
| 132 | ! |
---|
[1054] | 133 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
| 134 | ! exchange of ghost points for nr, qr added |
---|
| 135 | ! |
---|
[1037] | 136 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 137 | ! code put under GPL (PALM 3.9) |
---|
| 138 | ! |
---|
[1020] | 139 | ! 1019 2012-09-28 06:46:45Z raasch |
---|
| 140 | ! non-optimized version of prognostic_equations removed |
---|
| 141 | ! |
---|
[1017] | 142 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 143 | ! +call of prognostic_equations_acc |
---|
| 144 | ! |
---|
[1002] | 145 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 146 | ! all actions concerning leapfrog- and upstream-spline-scheme removed |
---|
| 147 | ! |
---|
[850] | 148 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 149 | ! advec_particles renamed lpm, first_call_advec_particles renamed first_call_lpm |
---|
| 150 | ! |
---|
[826] | 151 | ! 825 2012-02-19 03:03:44Z raasch |
---|
| 152 | ! wang_collision_kernel renamed wang_kernel |
---|
| 153 | ! |
---|
[1] | 154 | ! Revision 1.1 1997/08/11 06:19:04 raasch |
---|
| 155 | ! Initial revision |
---|
| 156 | ! |
---|
| 157 | ! |
---|
| 158 | ! Description: |
---|
| 159 | ! ------------ |
---|
[1682] | 160 | !> Integration in time of the model equations, statistical analysis and graphic |
---|
| 161 | !> output |
---|
[1] | 162 | !------------------------------------------------------------------------------! |
---|
[1682] | 163 | SUBROUTINE time_integration |
---|
| 164 | |
---|
[1] | 165 | |
---|
[1320] | 166 | USE advec_ws, & |
---|
| 167 | ONLY: ws_statistics |
---|
| 168 | |
---|
| 169 | USE arrays_3d, & |
---|
[1762] | 170 | ONLY: diss, dzu, e, e_p, nr_p, prho, pt, pt_p, pt_init, q_init, q, & |
---|
| 171 | ql, ql_c, ql_v, ql_vp, qr_p, q_p, ref_state, rho, sa_p, tend, & |
---|
| 172 | u, u_p, v, vpt, v_p, w, w_p |
---|
[1320] | 173 | |
---|
[1365] | 174 | USE calc_mean_profile_mod, & |
---|
[1320] | 175 | ONLY: calc_mean_profile |
---|
| 176 | |
---|
| 177 | USE control_parameters, & |
---|
| 178 | ONLY: advected_distance_x, advected_distance_y, average_count_3d, & |
---|
| 179 | average_count_sp, averaging_interval, averaging_interval_pr, & |
---|
[1380] | 180 | averaging_interval_sp, bc_lr_cyc, bc_ns_cyc, bc_pt_t_val, & |
---|
| 181 | bc_q_t_val, call_psolver_at_all_substeps, cloud_droplets, & |
---|
[1691] | 182 | cloud_physics, constant_flux_layer, constant_heatflux, & |
---|
| 183 | create_disturbances, dopr_n, constant_diffusion, coupling_mode, & |
---|
| 184 | coupling_start_time, current_timestep_number, & |
---|
| 185 | disturbance_created, disturbance_energy_limit, dist_range, & |
---|
| 186 | do_sum, dt_3d, dt_averaging_input, dt_averaging_input_pr, & |
---|
| 187 | dt_coupling, dt_data_output_av, dt_disturb, dt_do2d_xy, & |
---|
| 188 | dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_domask,dt_dopts, dt_dopr, & |
---|
[1320] | 189 | dt_dopr_listing, dt_dosp, dt_dots, dt_dvrp, dt_run_control, & |
---|
| 190 | end_time, first_call_lpm, galilei_transformation, humidity, & |
---|
| 191 | icloud_scheme, intermediate_timestep_count, & |
---|
| 192 | intermediate_timestep_count_max, large_scale_forcing, & |
---|
[1762] | 193 | loop_optimization, lsf_surf, lsf_vert, masks, mid, nest_domain, & |
---|
[1365] | 194 | netcdf_data_format, neutral, nr_timesteps_this_run, nudging, & |
---|
[1691] | 195 | ocean, on_device, passive_scalar, precipitation, & |
---|
[1320] | 196 | prho_reference, pt_reference, pt_slope_offset, random_heatflux, & |
---|
| 197 | run_coupled, simulated_time, simulated_time_chr, & |
---|
| 198 | skip_time_do2d_xy, skip_time_do2d_xz, skip_time_do2d_yz, & |
---|
| 199 | skip_time_do3d, skip_time_domask, skip_time_dopr, & |
---|
| 200 | skip_time_dosp, skip_time_data_output_av, sloping_surface, & |
---|
| 201 | stop_dt, terminate_coupled, terminate_run, timestep_scheme, & |
---|
| 202 | time_coupling, time_do2d_xy, time_do2d_xz, time_do2d_yz, & |
---|
| 203 | time_do3d, time_domask, time_dopr, time_dopr_av, & |
---|
| 204 | time_dopr_listing, time_dopts, time_dosp, time_dosp_av, & |
---|
| 205 | time_dots, time_do_av, time_do_sla, time_disturb, time_dvrp, & |
---|
[1496] | 206 | time_run_control, time_since_reference_point, & |
---|
| 207 | turbulence, & |
---|
[1320] | 208 | turbulent_inflow, use_initial_profile_as_reference, & |
---|
| 209 | use_single_reference_value, u_gtrans, v_gtrans, ws_scheme_mom, & |
---|
| 210 | ws_scheme_sca |
---|
| 211 | |
---|
| 212 | USE cpulog, & |
---|
| 213 | ONLY: cpu_log, log_point, log_point_s |
---|
| 214 | |
---|
| 215 | USE indices, & |
---|
| 216 | ONLY: i_left, i_right, j_north, j_south, nbgp, nx, nxl, nxlg, nxr, & |
---|
[1380] | 217 | nxrg, nyn, nys, nzb, nzt, nzb_u_inner, nzb_v_inner |
---|
[1320] | 218 | |
---|
| 219 | USE interaction_droplets_ptq_mod, & |
---|
| 220 | ONLY: interaction_droplets_ptq |
---|
| 221 | |
---|
| 222 | USE kinds |
---|
| 223 | |
---|
[1496] | 224 | USE land_surface_model_mod, & |
---|
[1691] | 225 | ONLY: land_surface, lsm_energy_balance, lsm_soil_model, & |
---|
| 226 | skip_time_do_lsm |
---|
[1496] | 227 | |
---|
[1320] | 228 | USE ls_forcing_mod, & |
---|
| 229 | ONLY: ls_forcing_surf, ls_forcing_vert |
---|
| 230 | |
---|
[1365] | 231 | USE nudge_mod, & |
---|
[1380] | 232 | ONLY: calc_tnudge, nudge_ref |
---|
[1365] | 233 | |
---|
[1320] | 234 | USE particle_attributes, & |
---|
[1671] | 235 | ONLY: particle_advection, particle_advection_start, & |
---|
| 236 | use_sgs_for_particles, wang_kernel |
---|
[1320] | 237 | |
---|
[1] | 238 | USE pegrid |
---|
| 239 | |
---|
[1762] | 240 | #if defined( PMC_ACTIVE ) |
---|
| 241 | USE pmc_interface, & |
---|
| 242 | ONLY: client_to_server, nesting_mode, & |
---|
| 243 | pmci_ensure_nest_mass_conservation, pmci_client_datatrans, & |
---|
| 244 | pmci_client_initialize, pmci_client_synchronize, & |
---|
| 245 | pmci_server_datatrans, pmci_server_initialize, & |
---|
| 246 | pmci_server_synchronize, pmci_update_new, server_to_client |
---|
| 247 | #endif |
---|
| 248 | |
---|
[1320] | 249 | USE production_e_mod, & |
---|
| 250 | ONLY: production_e_init |
---|
| 251 | |
---|
[1402] | 252 | USE progress_bar, & |
---|
| 253 | ONLY: finish_progress_bar, output_progress_bar |
---|
| 254 | |
---|
[1320] | 255 | USE prognostic_equations_mod, & |
---|
| 256 | ONLY: prognostic_equations_acc, prognostic_equations_cache, & |
---|
| 257 | prognostic_equations_vector |
---|
| 258 | |
---|
[1496] | 259 | USE radiation_model_mod, & |
---|
[1691] | 260 | ONLY: dt_radiation, force_radiation_call, radiation, & |
---|
| 261 | radiation_clearsky, radiation_rrtmg, radiation_scheme, & |
---|
| 262 | skip_time_do_radiation, time_radiation |
---|
[1496] | 263 | |
---|
[1320] | 264 | USE statistics, & |
---|
[1365] | 265 | ONLY: flow_statistics_called, hom, pr_palm, sums_ls_l |
---|
[1320] | 266 | |
---|
[1691] | 267 | USE surface_layer_fluxes_mod, & |
---|
| 268 | ONLY: surface_layer_fluxes |
---|
| 269 | |
---|
[1320] | 270 | USE user_actions_mod, & |
---|
| 271 | ONLY: user_actions |
---|
| 272 | |
---|
[1] | 273 | IMPLICIT NONE |
---|
| 274 | |
---|
[1682] | 275 | CHARACTER (LEN=9) :: time_to_string !< |
---|
[1] | 276 | |
---|
[1682] | 277 | INTEGER(iwp) :: netcdf_data_format_save !< |
---|
[1320] | 278 | |
---|
[1] | 279 | ! |
---|
| 280 | !-- At the beginning of a simulation determine the time step as well as |
---|
| 281 | !-- determine and print out the run control parameters |
---|
[1342] | 282 | IF ( simulated_time == 0.0_wp ) CALL timestep |
---|
[667] | 283 | |
---|
[1] | 284 | CALL run_control |
---|
| 285 | |
---|
[667] | 286 | |
---|
[108] | 287 | ! |
---|
| 288 | !-- Data exchange between coupled models in case that a call has been omitted |
---|
| 289 | !-- at the end of the previous run of a job chain. |
---|
[291] | 290 | IF ( coupling_mode /= 'uncoupled' .AND. run_coupled ) THEN |
---|
[108] | 291 | ! |
---|
| 292 | !-- In case of model termination initiated by the local model the coupler |
---|
| 293 | !-- must not be called because this would again cause an MPI hang. |
---|
| 294 | DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 ) |
---|
| 295 | CALL surface_coupler |
---|
| 296 | time_coupling = time_coupling - dt_coupling |
---|
| 297 | ENDDO |
---|
[1342] | 298 | IF (time_coupling == 0.0_wp .AND. time_since_reference_point < dt_coupling)& |
---|
[348] | 299 | THEN |
---|
| 300 | time_coupling = time_since_reference_point |
---|
| 301 | ENDIF |
---|
[108] | 302 | ENDIF |
---|
| 303 | |
---|
[1762] | 304 | #if defined( PMC_ACTIVE ) |
---|
| 305 | ! |
---|
| 306 | !-- TO_DO: try to give more meaningful comments here |
---|
| 307 | !-- Domain nesting: From server to client commmunication |
---|
| 308 | !-- ( direction=SERVER_TO_CLIENT ) |
---|
| 309 | !-- Nest initial conditions |
---|
| 310 | ! |
---|
| 311 | !-- Send initial condition data from server to client |
---|
| 312 | CALL pmci_server_initialize |
---|
| 313 | ! |
---|
| 314 | !-- Receive and interpolate initial data on client |
---|
| 315 | CALL pmci_client_initialize |
---|
| 316 | ! |
---|
| 317 | !-- TO_DO, maybe removed |
---|
| 318 | !-- Obs. Nesting may be unnecessary at this point. |
---|
| 319 | ! |
---|
| 320 | !-- Nest boundary conditions |
---|
| 321 | CALL pmci_server_datatrans( server_to_client ) |
---|
| 322 | CALL pmci_client_datatrans( server_to_client ) |
---|
[108] | 323 | |
---|
[1762] | 324 | IF ( nesting_mode == 'two-way' ) THEN |
---|
| 325 | CALL pmci_server_datatrans( client_to_server ) |
---|
| 326 | CALL pmci_client_datatrans( client_to_server ) |
---|
| 327 | ! |
---|
| 328 | !-- Exchange_horiz is needed for all server-domains after the anterpolation |
---|
| 329 | CALL exchange_horiz( u, nbgp ) |
---|
| 330 | CALL exchange_horiz( v, nbgp ) |
---|
| 331 | CALL exchange_horiz( w, nbgp ) |
---|
| 332 | CALL exchange_horiz( pt, nbgp ) |
---|
| 333 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e, nbgp ) |
---|
| 334 | intermediate_timestep_count = 0 |
---|
| 335 | CALL pres |
---|
| 336 | ENDIF |
---|
| 337 | ! |
---|
| 338 | !-- Correct the w top-BC in nest domains to ensure mass conservation. |
---|
| 339 | !-- Copy the interpolated/anterpolated boundary values to the _p |
---|
| 340 | !-- arrays, too, to make sure the interpolated/anterpolated boundary |
---|
| 341 | !-- values are carried over from one RK inner step to another. |
---|
| 342 | !-- These actions must not be done for the root domain. |
---|
| 343 | IF ( nest_domain ) THEN |
---|
| 344 | CALL pmci_ensure_nest_mass_conservation |
---|
| 345 | CALL pmci_update_new |
---|
| 346 | ENDIF |
---|
| 347 | #endif |
---|
| 348 | |
---|
[1] | 349 | #if defined( __dvrp_graphics ) |
---|
| 350 | ! |
---|
| 351 | !-- Time measurement with dvrp software |
---|
| 352 | CALL DVRP_LOG_EVENT( 2, current_timestep_number ) |
---|
| 353 | #endif |
---|
| 354 | |
---|
[1402] | 355 | CALL location_message( 'start with time-stepping', .TRUE. ) |
---|
[1] | 356 | ! |
---|
| 357 | !-- Start of the time loop |
---|
| 358 | DO WHILE ( simulated_time < end_time .AND. .NOT. stop_dt .AND. & |
---|
| 359 | .NOT. terminate_run ) |
---|
| 360 | |
---|
| 361 | CALL cpu_log( log_point_s(10), 'timesteps', 'start' ) |
---|
[1221] | 362 | |
---|
[1] | 363 | ! |
---|
| 364 | !-- Determine size of next time step |
---|
[1342] | 365 | IF ( simulated_time /= 0.0_wp ) THEN |
---|
[1221] | 366 | CALL timestep |
---|
[1762] | 367 | |
---|
| 368 | #if defined( PMC_ACTIVE ) |
---|
| 369 | ! |
---|
| 370 | !-- TO_DO: try to give more detailed and meaningful comments here |
---|
| 371 | !-- Server side must be called first |
---|
| 372 | CALL pmci_server_synchronize |
---|
| 373 | CALL pmci_client_synchronize |
---|
| 374 | #endif |
---|
[1221] | 375 | ENDIF |
---|
| 376 | |
---|
[1762] | 377 | |
---|
[1] | 378 | ! |
---|
[1241] | 379 | !-- Determine ug, vg and w_subs in dependence on data from external file |
---|
| 380 | !-- LSF_DATA |
---|
[1365] | 381 | IF ( large_scale_forcing .AND. lsf_vert ) THEN |
---|
[1241] | 382 | CALL ls_forcing_vert ( simulated_time ) |
---|
[1365] | 383 | sums_ls_l = 0.0_wp |
---|
[1241] | 384 | ENDIF |
---|
| 385 | |
---|
| 386 | ! |
---|
[1380] | 387 | !-- Set pt_init and q_init to the current profiles taken from |
---|
| 388 | !-- NUDGING_DATA |
---|
| 389 | IF ( nudging ) THEN |
---|
| 390 | CALL nudge_ref ( simulated_time ) |
---|
| 391 | ! |
---|
| 392 | !-- Store temperature gradient at the top boundary for possible Neumann |
---|
| 393 | !-- boundary condition |
---|
| 394 | bc_pt_t_val = ( pt_init(nzt+1) - pt_init(nzt) ) / dzu(nzt+1) |
---|
| 395 | bc_q_t_val = ( q_init(nzt+1) - q_init(nzt) ) / dzu(nzt+1) |
---|
| 396 | ENDIF |
---|
| 397 | |
---|
| 398 | ! |
---|
[1] | 399 | !-- Execute the user-defined actions |
---|
| 400 | CALL user_actions( 'before_timestep' ) |
---|
| 401 | |
---|
| 402 | ! |
---|
| 403 | !-- Start of intermediate step loop |
---|
| 404 | intermediate_timestep_count = 0 |
---|
| 405 | DO WHILE ( intermediate_timestep_count < & |
---|
| 406 | intermediate_timestep_count_max ) |
---|
| 407 | |
---|
| 408 | intermediate_timestep_count = intermediate_timestep_count + 1 |
---|
| 409 | |
---|
| 410 | ! |
---|
| 411 | !-- Set the steering factors for the prognostic equations which depend |
---|
| 412 | !-- on the timestep scheme |
---|
| 413 | CALL timestep_scheme_steering |
---|
| 414 | |
---|
| 415 | ! |
---|
[1128] | 416 | !-- Calculate those variables needed in the tendency terms which need |
---|
| 417 | !-- global communication |
---|
[1179] | 418 | IF ( .NOT. use_single_reference_value .AND. & |
---|
| 419 | .NOT. use_initial_profile_as_reference ) THEN |
---|
| 420 | ! |
---|
| 421 | !-- Horizontally averaged profiles to be used as reference state in |
---|
| 422 | !-- buoyancy terms (WARNING: only the respective last call of |
---|
| 423 | !-- calc_mean_profile defines the reference state!) |
---|
[1365] | 424 | IF ( .NOT. neutral ) THEN |
---|
| 425 | CALL calc_mean_profile( pt, 4 ) |
---|
| 426 | ref_state(:) = hom(:,1,4,0) ! this is used in the buoyancy term |
---|
| 427 | ENDIF |
---|
| 428 | IF ( ocean ) THEN |
---|
| 429 | CALL calc_mean_profile( rho, 64 ) |
---|
| 430 | ref_state(:) = hom(:,1,64,0) |
---|
| 431 | ENDIF |
---|
| 432 | IF ( humidity ) THEN |
---|
| 433 | CALL calc_mean_profile( vpt, 44 ) |
---|
| 434 | ref_state(:) = hom(:,1,44,0) |
---|
| 435 | ENDIF |
---|
| 436 | |
---|
[1179] | 437 | ENDIF |
---|
| 438 | |
---|
[1128] | 439 | IF ( .NOT. constant_diffusion ) CALL production_e_init |
---|
| 440 | IF ( ( ws_scheme_mom .OR. ws_scheme_sca ) .AND. & |
---|
| 441 | intermediate_timestep_count == 1 ) CALL ws_statistics |
---|
[1365] | 442 | ! |
---|
| 443 | !-- In case of nudging calculate current nudging time scale and horizontal |
---|
[1380] | 444 | !-- means of u, v, pt and q |
---|
[1365] | 445 | IF ( nudging ) THEN |
---|
| 446 | CALL calc_tnudge( simulated_time ) |
---|
| 447 | CALL calc_mean_profile( u, 1 ) |
---|
| 448 | CALL calc_mean_profile( v, 2 ) |
---|
| 449 | CALL calc_mean_profile( pt, 4 ) |
---|
| 450 | CALL calc_mean_profile( q, 41 ) |
---|
| 451 | ENDIF |
---|
[1128] | 452 | |
---|
| 453 | ! |
---|
[1] | 454 | !-- Solve the prognostic equations. A fast cache optimized version with |
---|
| 455 | !-- only one single loop is used in case of Piascek-Williams advection |
---|
| 456 | !-- scheme. NEC vector machines use a different version, because |
---|
| 457 | !-- in the other versions a good vectorization is prohibited due to |
---|
| 458 | !-- inlining problems. |
---|
[1019] | 459 | IF ( loop_optimization == 'cache' ) THEN |
---|
| 460 | CALL prognostic_equations_cache |
---|
| 461 | ELSEIF ( loop_optimization == 'vector' ) THEN |
---|
[63] | 462 | CALL prognostic_equations_vector |
---|
[1015] | 463 | ELSEIF ( loop_optimization == 'acc' ) THEN |
---|
[1171] | 464 | i_left = nxl; i_right = nxr |
---|
| 465 | j_south = nys; j_north = nyn |
---|
| 466 | CALL prognostic_equations_acc |
---|
| 467 | |
---|
| 468 | ! i_left = nxl; i_right = nxl+nbgp-1 |
---|
[1128] | 469 | ! j_south = nys; j_north = nyn |
---|
| 470 | ! CALL prognostic_equations_acc |
---|
[1171] | 471 | ! i_left = nxr-nbgp+1; i_right = nxr |
---|
| 472 | ! j_south = nys; j_north = nyn |
---|
| 473 | ! CALL prognostic_equations_acc |
---|
[1128] | 474 | |
---|
| 475 | ! |
---|
| 476 | !-- Exchange of ghost points (lateral boundary conditions) |
---|
| 477 | IF ( background_communication ) THEN |
---|
| 478 | |
---|
| 479 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'start' ) |
---|
| 480 | |
---|
| 481 | send_receive = 'lr' |
---|
| 482 | sendrecv_in_background = .TRUE. |
---|
| 483 | req = 0 |
---|
| 484 | req_count = 0 |
---|
| 485 | |
---|
| 486 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
| 487 | on_device = .TRUE. ! to be removed after complete porting |
---|
| 488 | ELSE ! of ghost point exchange |
---|
| 489 | !$acc update host( e_p, pt_p, u_p, v_p, w_p ) |
---|
| 490 | ENDIF |
---|
| 491 | |
---|
| 492 | CALL exchange_horiz( u_p, nbgp ) |
---|
| 493 | CALL exchange_horiz( v_p, nbgp ) |
---|
| 494 | CALL exchange_horiz( w_p, nbgp ) |
---|
| 495 | CALL exchange_horiz( pt_p, nbgp ) |
---|
| 496 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e_p, nbgp ) |
---|
| 497 | IF ( ocean ) THEN |
---|
| 498 | CALL exchange_horiz( sa_p, nbgp ) |
---|
| 499 | CALL exchange_horiz( rho, nbgp ) |
---|
| 500 | CALL exchange_horiz( prho, nbgp ) |
---|
| 501 | ENDIF |
---|
| 502 | IF (humidity .OR. passive_scalar) THEN |
---|
| 503 | CALL exchange_horiz( q_p, nbgp ) |
---|
| 504 | IF ( cloud_physics .AND. icloud_scheme == 0 ) THEN |
---|
| 505 | CALL exchange_horiz( qr_p, nbgp ) |
---|
| 506 | CALL exchange_horiz( nr_p, nbgp ) |
---|
| 507 | ENDIF |
---|
| 508 | ENDIF |
---|
| 509 | IF ( cloud_droplets ) THEN |
---|
| 510 | CALL exchange_horiz( ql, nbgp ) |
---|
| 511 | CALL exchange_horiz( ql_c, nbgp ) |
---|
| 512 | CALL exchange_horiz( ql_v, nbgp ) |
---|
| 513 | CALL exchange_horiz( ql_vp, nbgp ) |
---|
| 514 | ENDIF |
---|
[1671] | 515 | IF ( wang_kernel .OR. turbulence .OR. use_sgs_for_particles ) & |
---|
| 516 | THEN |
---|
| 517 | CALL exchange_horiz( diss, nbgp ) |
---|
| 518 | ENDIF |
---|
[1128] | 519 | |
---|
| 520 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
| 521 | on_device = .FALSE. ! to be removed after complete porting |
---|
| 522 | ELSE ! of ghost point exchange |
---|
| 523 | !$acc update device( e_p, pt_p, u_p, v_p, w_p ) |
---|
| 524 | ENDIF |
---|
| 525 | |
---|
| 526 | sendrecv_in_background = .FALSE. |
---|
| 527 | |
---|
| 528 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'pause' ) |
---|
| 529 | |
---|
| 530 | ENDIF |
---|
| 531 | |
---|
[1171] | 532 | ! i_left = nxl+nbgp; i_right = nxr-nbgp |
---|
| 533 | ! j_south = nys; j_north = nys+nbgp-1 |
---|
| 534 | ! CALL prognostic_equations_acc |
---|
| 535 | ! i_left = nxl+nbgp; i_right = nxr-nbgp |
---|
| 536 | ! j_south = nyn-nbgp+1; j_north = nyn |
---|
| 537 | ! CALL prognostic_equations_acc |
---|
[1128] | 538 | |
---|
| 539 | IF ( background_communication ) THEN |
---|
| 540 | CALL cpu_log( log_point(41), 'exchange-horiz-wait', 'start' ) |
---|
| 541 | #if defined( __parallel ) |
---|
| 542 | CALL MPI_WAITALL( req_count, req, wait_stat, ierr ) |
---|
| 543 | #endif |
---|
| 544 | CALL cpu_log( log_point(41), 'exchange-horiz-wait', 'pause' ) |
---|
| 545 | |
---|
| 546 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'continue' ) |
---|
| 547 | |
---|
| 548 | send_receive = 'ns' |
---|
| 549 | sendrecv_in_background = .TRUE. |
---|
| 550 | req = 0 |
---|
| 551 | req_count = 0 |
---|
| 552 | |
---|
| 553 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
| 554 | on_device = .TRUE. ! to be removed after complete porting |
---|
| 555 | ELSE ! of ghost point exchange |
---|
| 556 | !$acc update host( e_p, pt_p, u_p, v_p, w_p ) |
---|
| 557 | ENDIF |
---|
| 558 | |
---|
| 559 | CALL exchange_horiz( u_p, nbgp ) |
---|
| 560 | CALL exchange_horiz( v_p, nbgp ) |
---|
| 561 | CALL exchange_horiz( w_p, nbgp ) |
---|
| 562 | CALL exchange_horiz( pt_p, nbgp ) |
---|
| 563 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e_p, nbgp ) |
---|
| 564 | IF ( ocean ) THEN |
---|
| 565 | CALL exchange_horiz( sa_p, nbgp ) |
---|
| 566 | CALL exchange_horiz( rho, nbgp ) |
---|
| 567 | CALL exchange_horiz( prho, nbgp ) |
---|
| 568 | ENDIF |
---|
| 569 | IF (humidity .OR. passive_scalar) THEN |
---|
| 570 | CALL exchange_horiz( q_p, nbgp ) |
---|
| 571 | IF ( cloud_physics .AND. icloud_scheme == 0 ) THEN |
---|
| 572 | CALL exchange_horiz( qr_p, nbgp ) |
---|
| 573 | CALL exchange_horiz( nr_p, nbgp ) |
---|
| 574 | ENDIF |
---|
| 575 | ENDIF |
---|
| 576 | IF ( cloud_droplets ) THEN |
---|
| 577 | CALL exchange_horiz( ql, nbgp ) |
---|
| 578 | CALL exchange_horiz( ql_c, nbgp ) |
---|
| 579 | CALL exchange_horiz( ql_v, nbgp ) |
---|
| 580 | CALL exchange_horiz( ql_vp, nbgp ) |
---|
| 581 | ENDIF |
---|
[1671] | 582 | IF ( wang_kernel .OR. turbulence .OR. use_sgs_for_particles ) & |
---|
| 583 | THEN |
---|
| 584 | CALL exchange_horiz( diss, nbgp ) |
---|
| 585 | ENDIF |
---|
[1128] | 586 | |
---|
| 587 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
| 588 | on_device = .FALSE. ! to be removed after complete porting |
---|
| 589 | ELSE ! of ghost point exchange |
---|
| 590 | !$acc update device( e_p, pt_p, u_p, v_p, w_p ) |
---|
| 591 | ENDIF |
---|
| 592 | |
---|
| 593 | sendrecv_in_background = .FALSE. |
---|
| 594 | |
---|
| 595 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' ) |
---|
| 596 | |
---|
| 597 | ENDIF |
---|
| 598 | |
---|
[1171] | 599 | ! i_left = nxl+nbgp; i_right = nxr-nbgp |
---|
| 600 | ! j_south = nys+nbgp; j_north = nyn-nbgp |
---|
| 601 | ! CALL prognostic_equations_acc |
---|
[1128] | 602 | |
---|
| 603 | IF ( background_communication ) THEN |
---|
| 604 | CALL cpu_log( log_point(41), 'exchange-horiz-wait', 'continue' ) |
---|
| 605 | #if defined( __parallel ) |
---|
| 606 | CALL MPI_WAITALL( req_count, req, wait_stat, ierr ) |
---|
| 607 | #endif |
---|
| 608 | send_receive = 'al' |
---|
| 609 | CALL cpu_log( log_point(41), 'exchange-horiz-wait', 'stop' ) |
---|
| 610 | ENDIF |
---|
| 611 | |
---|
[1] | 612 | ENDIF |
---|
| 613 | |
---|
| 614 | ! |
---|
[849] | 615 | !-- Particle transport/physics with the Lagrangian particle model |
---|
| 616 | !-- (only once during intermediate steps, because it uses an Euler-step) |
---|
[1128] | 617 | !-- ### particle model should be moved before prognostic_equations, in order |
---|
| 618 | !-- to regard droplet interactions directly |
---|
[63] | 619 | IF ( particle_advection .AND. & |
---|
| 620 | simulated_time >= particle_advection_start .AND. & |
---|
[1] | 621 | intermediate_timestep_count == 1 ) THEN |
---|
[849] | 622 | CALL lpm |
---|
| 623 | first_call_lpm = .FALSE. |
---|
[1] | 624 | ENDIF |
---|
| 625 | |
---|
| 626 | ! |
---|
| 627 | !-- Interaction of droplets with temperature and specific humidity. |
---|
| 628 | !-- Droplet condensation and evaporation is calculated within |
---|
| 629 | !-- advec_particles. |
---|
| 630 | IF ( cloud_droplets .AND. & |
---|
| 631 | intermediate_timestep_count == intermediate_timestep_count_max )& |
---|
| 632 | THEN |
---|
| 633 | CALL interaction_droplets_ptq |
---|
| 634 | ENDIF |
---|
| 635 | |
---|
| 636 | ! |
---|
| 637 | !-- Exchange of ghost points (lateral boundary conditions) |
---|
[1128] | 638 | IF ( .NOT. background_communication ) THEN |
---|
[1113] | 639 | |
---|
[1128] | 640 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'start' ) |
---|
[1113] | 641 | |
---|
[1128] | 642 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
| 643 | on_device = .TRUE. ! to be removed after complete porting |
---|
| 644 | ELSE ! of ghost point exchange |
---|
| 645 | !$acc update host( e_p, pt_p, u_p, v_p, w_p ) |
---|
[1053] | 646 | ENDIF |
---|
[1] | 647 | |
---|
[1128] | 648 | CALL exchange_horiz( u_p, nbgp ) |
---|
| 649 | CALL exchange_horiz( v_p, nbgp ) |
---|
| 650 | CALL exchange_horiz( w_p, nbgp ) |
---|
| 651 | CALL exchange_horiz( pt_p, nbgp ) |
---|
| 652 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e_p, nbgp ) |
---|
| 653 | IF ( ocean ) THEN |
---|
| 654 | CALL exchange_horiz( sa_p, nbgp ) |
---|
| 655 | CALL exchange_horiz( rho, nbgp ) |
---|
| 656 | CALL exchange_horiz( prho, nbgp ) |
---|
| 657 | ENDIF |
---|
| 658 | IF (humidity .OR. passive_scalar) THEN |
---|
| 659 | CALL exchange_horiz( q_p, nbgp ) |
---|
[1179] | 660 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
| 661 | precipitation ) THEN |
---|
[1128] | 662 | CALL exchange_horiz( qr_p, nbgp ) |
---|
| 663 | CALL exchange_horiz( nr_p, nbgp ) |
---|
| 664 | ENDIF |
---|
| 665 | ENDIF |
---|
| 666 | IF ( cloud_droplets ) THEN |
---|
| 667 | CALL exchange_horiz( ql, nbgp ) |
---|
| 668 | CALL exchange_horiz( ql_c, nbgp ) |
---|
| 669 | CALL exchange_horiz( ql_v, nbgp ) |
---|
| 670 | CALL exchange_horiz( ql_vp, nbgp ) |
---|
| 671 | ENDIF |
---|
[1671] | 672 | IF ( wang_kernel .OR. turbulence .OR. use_sgs_for_particles ) & |
---|
| 673 | THEN |
---|
| 674 | CALL exchange_horiz( diss, nbgp ) |
---|
| 675 | ENDIF |
---|
[1128] | 676 | |
---|
| 677 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
| 678 | on_device = .FALSE. ! to be removed after complete porting |
---|
| 679 | ELSE ! of ghost point exchange |
---|
| 680 | !$acc update device( e_p, pt_p, u_p, v_p, w_p ) |
---|
| 681 | ENDIF |
---|
| 682 | |
---|
| 683 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' ) |
---|
| 684 | |
---|
[1113] | 685 | ENDIF |
---|
| 686 | |
---|
[1] | 687 | ! |
---|
| 688 | !-- Boundary conditions for the prognostic quantities (except of the |
---|
| 689 | !-- velocities at the outflow in case of a non-cyclic lateral wall) |
---|
[1113] | 690 | CALL boundary_conds |
---|
[1] | 691 | |
---|
| 692 | ! |
---|
[73] | 693 | !-- Swap the time levels in preparation for the next time step. |
---|
| 694 | CALL swap_timelevel |
---|
| 695 | |
---|
[1762] | 696 | #if defined( PMC_ACTIVE ) |
---|
[73] | 697 | ! |
---|
[1762] | 698 | !-- TO_DO: try to give more meaningful comments here |
---|
| 699 | !-- Domain nesting |
---|
| 700 | !-- Note that the nesting operations are omitted intentionally on the |
---|
| 701 | !-- first two RK-substeps. |
---|
| 702 | CALL cpu_log( log_point(60), 'nesting', 'start' ) |
---|
| 703 | ! |
---|
| 704 | !-- From server to client commmunication ( direction=SERVER_TO_CLIENT ) |
---|
| 705 | CALL pmci_server_datatrans( server_to_client ) |
---|
| 706 | CALL pmci_client_datatrans( server_to_client ) |
---|
| 707 | |
---|
| 708 | IF ( nesting_mode == 'two-way' ) THEN |
---|
| 709 | ! |
---|
| 710 | !-- From client to server commmunication ( direction=CLIENT_TO_SERVER ) |
---|
| 711 | CALL pmci_server_datatrans( client_to_server ) |
---|
| 712 | CALL pmci_client_datatrans( client_to_server ) |
---|
| 713 | ! |
---|
| 714 | !-- Exchange_horiz is needed for all server-domains after the |
---|
| 715 | !-- anterpolation |
---|
| 716 | CALL exchange_horiz( u, nbgp ) |
---|
| 717 | CALL exchange_horiz( v, nbgp ) |
---|
| 718 | CALL exchange_horiz( w, nbgp ) |
---|
| 719 | CALL exchange_horiz( pt, nbgp ) |
---|
| 720 | IF ( humidity .OR. passive_scalar ) THEN |
---|
| 721 | CALL exchange_horiz( q, nbgp ) |
---|
| 722 | ENDIF |
---|
| 723 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e, nbgp ) |
---|
| 724 | ENDIF |
---|
| 725 | ! |
---|
| 726 | !-- Correct the w top-BC in nest domains to ensure mass conservation. |
---|
| 727 | !-- This action must never be done for the root domain. |
---|
| 728 | IF ( nest_domain ) THEN |
---|
| 729 | CALL pmci_ensure_nest_mass_conservation |
---|
| 730 | ! |
---|
| 731 | !-- pmc_update_new is not necessary if nesting is made at each substep. |
---|
| 732 | CALL pmci_update_new |
---|
| 733 | ENDIF |
---|
| 734 | |
---|
| 735 | CALL cpu_log( log_point(60), 'nesting', 'stop' ) |
---|
| 736 | #endif |
---|
| 737 | |
---|
| 738 | ! |
---|
[1] | 739 | !-- Temperature offset must be imposed at cyclic boundaries in x-direction |
---|
| 740 | !-- when a sloping surface is used |
---|
| 741 | IF ( sloping_surface ) THEN |
---|
[707] | 742 | IF ( nxl == 0 ) pt(:,:,nxlg:nxl-1) = pt(:,:,nxlg:nxl-1) - & |
---|
| 743 | pt_slope_offset |
---|
| 744 | IF ( nxr == nx ) pt(:,:,nxr+1:nxrg) = pt(:,:,nxr+1:nxrg) + & |
---|
| 745 | pt_slope_offset |
---|
[1] | 746 | ENDIF |
---|
| 747 | |
---|
| 748 | ! |
---|
[151] | 749 | !-- Impose a turbulent inflow using the recycling method |
---|
| 750 | IF ( turbulent_inflow ) CALL inflow_turbulence |
---|
| 751 | |
---|
| 752 | ! |
---|
[1] | 753 | !-- Impose a random perturbation on the horizontal velocity field |
---|
[106] | 754 | IF ( create_disturbances .AND. & |
---|
| 755 | ( call_psolver_at_all_substeps .AND. & |
---|
[1] | 756 | intermediate_timestep_count == intermediate_timestep_count_max )& |
---|
[106] | 757 | .OR. ( .NOT. call_psolver_at_all_substeps .AND. & |
---|
| 758 | intermediate_timestep_count == 1 ) ) & |
---|
[1] | 759 | THEN |
---|
| 760 | time_disturb = time_disturb + dt_3d |
---|
| 761 | IF ( time_disturb >= dt_disturb ) THEN |
---|
[1111] | 762 | !$acc update host( u, v ) |
---|
[1113] | 763 | IF ( numprocs == 1 ) on_device = .FALSE. ! workaround, remove later |
---|
[1736] | 764 | IF ( disturbance_energy_limit /= 0.0_wp .AND. & |
---|
| 765 | hom(nzb+5,1,pr_palm,0) < disturbance_energy_limit ) THEN |
---|
[75] | 766 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
| 767 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
[707] | 768 | ELSEIF ( .NOT. bc_lr_cyc .OR. .NOT. bc_ns_cyc ) THEN |
---|
[1] | 769 | ! |
---|
| 770 | !-- Runs with a non-cyclic lateral wall need perturbations |
---|
| 771 | !-- near the inflow throughout the whole simulation |
---|
| 772 | dist_range = 1 |
---|
[75] | 773 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
| 774 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
[1] | 775 | dist_range = 0 |
---|
| 776 | ENDIF |
---|
[1113] | 777 | IF ( numprocs == 1 ) on_device = .TRUE. ! workaround, remove later |
---|
[1111] | 778 | !$acc update device( u, v ) |
---|
[1] | 779 | time_disturb = time_disturb - dt_disturb |
---|
| 780 | ENDIF |
---|
| 781 | ENDIF |
---|
| 782 | |
---|
| 783 | ! |
---|
| 784 | !-- Reduce the velocity divergence via the equation for perturbation |
---|
| 785 | !-- pressure. |
---|
[106] | 786 | IF ( intermediate_timestep_count == 1 .OR. & |
---|
| 787 | call_psolver_at_all_substeps ) THEN |
---|
[1] | 788 | CALL pres |
---|
| 789 | ENDIF |
---|
| 790 | |
---|
| 791 | ! |
---|
| 792 | !-- If required, compute liquid water content |
---|
[1015] | 793 | IF ( cloud_physics ) THEN |
---|
| 794 | CALL calc_liquid_water_content |
---|
| 795 | !$acc update device( ql ) |
---|
| 796 | ENDIF |
---|
[1115] | 797 | ! |
---|
| 798 | !-- If required, compute virtual potential temperature |
---|
| 799 | IF ( humidity ) THEN |
---|
| 800 | CALL compute_vpt |
---|
| 801 | !$acc update device( vpt ) |
---|
| 802 | ENDIF |
---|
[1585] | 803 | |
---|
[1] | 804 | ! |
---|
| 805 | !-- Compute the diffusion quantities |
---|
| 806 | IF ( .NOT. constant_diffusion ) THEN |
---|
| 807 | |
---|
| 808 | ! |
---|
[1276] | 809 | !-- Determine surface fluxes shf and qsws and surface values |
---|
| 810 | !-- pt_surface and q_surface in dependence on data from external |
---|
| 811 | !-- file LSF_DATA respectively |
---|
| 812 | IF ( ( large_scale_forcing .AND. lsf_surf ) .AND. & |
---|
| 813 | intermediate_timestep_count == intermediate_timestep_count_max )& |
---|
| 814 | THEN |
---|
| 815 | CALL ls_forcing_surf ( simulated_time ) |
---|
| 816 | ENDIF |
---|
| 817 | |
---|
| 818 | ! |
---|
[1691] | 819 | !-- First the vertical fluxes in the surface (constant flux) layer are computed |
---|
| 820 | IF ( constant_flux_layer ) THEN |
---|
| 821 | CALL cpu_log( log_point(19), 'surface_layer_fluxes', 'start' ) |
---|
| 822 | CALL surface_layer_fluxes |
---|
| 823 | CALL cpu_log( log_point(19), 'surface_layer_fluxes', 'stop' ) |
---|
[1] | 824 | ENDIF |
---|
[1241] | 825 | |
---|
[1] | 826 | ! |
---|
[1691] | 827 | !-- If required, solve the energy balance for the surface and run soil |
---|
| 828 | !-- model |
---|
| 829 | IF ( land_surface .AND. simulated_time > skip_time_do_lsm) THEN |
---|
| 830 | |
---|
| 831 | CALL cpu_log( log_point(54), 'land_surface', 'start' ) |
---|
| 832 | CALL lsm_energy_balance |
---|
| 833 | CALL lsm_soil_model |
---|
| 834 | CALL cpu_log( log_point(54), 'land_surface', 'stop' ) |
---|
| 835 | ENDIF |
---|
| 836 | ! |
---|
[1] | 837 | !-- Compute the diffusion coefficients |
---|
| 838 | CALL cpu_log( log_point(17), 'diffusivities', 'start' ) |
---|
[75] | 839 | IF ( .NOT. humidity ) THEN |
---|
[97] | 840 | IF ( ocean ) THEN |
---|
[388] | 841 | CALL diffusivities( prho, prho_reference ) |
---|
[97] | 842 | ELSE |
---|
| 843 | CALL diffusivities( pt, pt_reference ) |
---|
| 844 | ENDIF |
---|
[1] | 845 | ELSE |
---|
[97] | 846 | CALL diffusivities( vpt, pt_reference ) |
---|
[1] | 847 | ENDIF |
---|
| 848 | CALL cpu_log( log_point(17), 'diffusivities', 'stop' ) |
---|
| 849 | |
---|
| 850 | ENDIF |
---|
| 851 | |
---|
[1691] | 852 | ! |
---|
| 853 | !-- If required, calculate radiative fluxes and heating rates |
---|
| 854 | IF ( radiation .AND. intermediate_timestep_count & |
---|
| 855 | == intermediate_timestep_count_max .AND. simulated_time > & |
---|
| 856 | skip_time_do_radiation ) THEN |
---|
| 857 | |
---|
| 858 | time_radiation = time_radiation + dt_3d |
---|
| 859 | |
---|
| 860 | IF ( time_radiation >= dt_radiation .OR. force_radiation_call ) & |
---|
| 861 | THEN |
---|
| 862 | |
---|
| 863 | CALL cpu_log( log_point(50), 'radiation', 'start' ) |
---|
| 864 | |
---|
| 865 | IF ( .NOT. force_radiation_call ) THEN |
---|
| 866 | time_radiation = time_radiation - dt_radiation |
---|
| 867 | ELSE |
---|
| 868 | WRITE(9,*) "Unscheduled radiation call at ", simulated_time |
---|
| 869 | CALL LOCAL_FLUSH ( 9 ) |
---|
| 870 | ENDIF |
---|
| 871 | |
---|
| 872 | IF ( radiation_scheme == 'clear-sky' ) THEN |
---|
| 873 | CALL radiation_clearsky |
---|
| 874 | ELSEIF ( radiation_scheme == 'rrtmg' ) THEN |
---|
| 875 | CALL radiation_rrtmg |
---|
| 876 | ENDIF |
---|
| 877 | |
---|
| 878 | CALL cpu_log( log_point(50), 'radiation', 'stop' ) |
---|
| 879 | ENDIF |
---|
| 880 | ENDIF |
---|
| 881 | |
---|
[1] | 882 | ENDDO ! Intermediate step loop |
---|
| 883 | |
---|
| 884 | ! |
---|
| 885 | !-- Increase simulation time and output times |
---|
[1111] | 886 | nr_timesteps_this_run = nr_timesteps_this_run + 1 |
---|
[291] | 887 | current_timestep_number = current_timestep_number + 1 |
---|
| 888 | simulated_time = simulated_time + dt_3d |
---|
| 889 | simulated_time_chr = time_to_string( simulated_time ) |
---|
| 890 | time_since_reference_point = simulated_time - coupling_start_time |
---|
| 891 | |
---|
[1] | 892 | IF ( simulated_time >= skip_time_data_output_av ) THEN |
---|
| 893 | time_do_av = time_do_av + dt_3d |
---|
| 894 | ENDIF |
---|
| 895 | IF ( simulated_time >= skip_time_do2d_xy ) THEN |
---|
| 896 | time_do2d_xy = time_do2d_xy + dt_3d |
---|
| 897 | ENDIF |
---|
| 898 | IF ( simulated_time >= skip_time_do2d_xz ) THEN |
---|
| 899 | time_do2d_xz = time_do2d_xz + dt_3d |
---|
| 900 | ENDIF |
---|
| 901 | IF ( simulated_time >= skip_time_do2d_yz ) THEN |
---|
| 902 | time_do2d_yz = time_do2d_yz + dt_3d |
---|
| 903 | ENDIF |
---|
| 904 | IF ( simulated_time >= skip_time_do3d ) THEN |
---|
| 905 | time_do3d = time_do3d + dt_3d |
---|
| 906 | ENDIF |
---|
[410] | 907 | DO mid = 1, masks |
---|
| 908 | IF ( simulated_time >= skip_time_domask(mid) ) THEN |
---|
| 909 | time_domask(mid)= time_domask(mid) + dt_3d |
---|
| 910 | ENDIF |
---|
| 911 | ENDDO |
---|
[1] | 912 | time_dvrp = time_dvrp + dt_3d |
---|
| 913 | IF ( simulated_time >= skip_time_dosp ) THEN |
---|
| 914 | time_dosp = time_dosp + dt_3d |
---|
| 915 | ENDIF |
---|
| 916 | time_dots = time_dots + dt_3d |
---|
[849] | 917 | IF ( .NOT. first_call_lpm ) THEN |
---|
[1] | 918 | time_dopts = time_dopts + dt_3d |
---|
| 919 | ENDIF |
---|
| 920 | IF ( simulated_time >= skip_time_dopr ) THEN |
---|
| 921 | time_dopr = time_dopr + dt_3d |
---|
| 922 | ENDIF |
---|
| 923 | time_dopr_listing = time_dopr_listing + dt_3d |
---|
| 924 | time_run_control = time_run_control + dt_3d |
---|
| 925 | |
---|
| 926 | ! |
---|
[102] | 927 | !-- Data exchange between coupled models |
---|
[291] | 928 | IF ( coupling_mode /= 'uncoupled' .AND. run_coupled ) THEN |
---|
[102] | 929 | time_coupling = time_coupling + dt_3d |
---|
[343] | 930 | |
---|
[108] | 931 | ! |
---|
| 932 | !-- In case of model termination initiated by the local model |
---|
| 933 | !-- (terminate_coupled > 0), the coupler must be skipped because it would |
---|
| 934 | !-- cause an MPI intercomminucation hang. |
---|
| 935 | !-- If necessary, the coupler will be called at the beginning of the |
---|
| 936 | !-- next restart run. |
---|
| 937 | DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 ) |
---|
[102] | 938 | CALL surface_coupler |
---|
| 939 | time_coupling = time_coupling - dt_coupling |
---|
| 940 | ENDDO |
---|
| 941 | ENDIF |
---|
| 942 | |
---|
| 943 | ! |
---|
[46] | 944 | !-- Execute user-defined actions |
---|
| 945 | CALL user_actions( 'after_integration' ) |
---|
| 946 | |
---|
| 947 | ! |
---|
[1] | 948 | !-- If Galilei transformation is used, determine the distance that the |
---|
| 949 | !-- model has moved so far |
---|
| 950 | IF ( galilei_transformation ) THEN |
---|
| 951 | advected_distance_x = advected_distance_x + u_gtrans * dt_3d |
---|
| 952 | advected_distance_y = advected_distance_y + v_gtrans * dt_3d |
---|
| 953 | ENDIF |
---|
| 954 | |
---|
| 955 | ! |
---|
| 956 | !-- Check, if restart is necessary (because cpu-time is expiring or |
---|
| 957 | !-- because it is forced by user) and set stop flag |
---|
[108] | 958 | !-- This call is skipped if the remote model has already initiated a restart. |
---|
| 959 | IF ( .NOT. terminate_run ) CALL check_for_restart |
---|
[1] | 960 | |
---|
| 961 | ! |
---|
| 962 | !-- Carry out statistical analysis and output at the requested output times. |
---|
| 963 | !-- The MOD function is used for calculating the output time counters (like |
---|
| 964 | !-- time_dopr) in order to regard a possible decrease of the output time |
---|
| 965 | !-- interval in case of restart runs |
---|
| 966 | |
---|
| 967 | ! |
---|
| 968 | !-- Set a flag indicating that so far no statistics have been created |
---|
| 969 | !-- for this time step |
---|
| 970 | flow_statistics_called = .FALSE. |
---|
| 971 | |
---|
| 972 | ! |
---|
| 973 | !-- If required, call flow_statistics for averaging in time |
---|
[1342] | 974 | IF ( averaging_interval_pr /= 0.0_wp .AND. & |
---|
[1] | 975 | ( dt_dopr - time_dopr ) <= averaging_interval_pr .AND. & |
---|
| 976 | simulated_time >= skip_time_dopr ) THEN |
---|
| 977 | time_dopr_av = time_dopr_av + dt_3d |
---|
| 978 | IF ( time_dopr_av >= dt_averaging_input_pr ) THEN |
---|
| 979 | do_sum = .TRUE. |
---|
| 980 | time_dopr_av = MOD( time_dopr_av, & |
---|
| 981 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
| 982 | ENDIF |
---|
| 983 | ENDIF |
---|
| 984 | IF ( do_sum ) CALL flow_statistics |
---|
| 985 | |
---|
| 986 | ! |
---|
[410] | 987 | !-- Sum-up 3d-arrays for later output of time-averaged 2d/3d/masked data |
---|
[1342] | 988 | IF ( averaging_interval /= 0.0_wp .AND. & |
---|
[1] | 989 | ( dt_data_output_av - time_do_av ) <= averaging_interval .AND. & |
---|
| 990 | simulated_time >= skip_time_data_output_av ) & |
---|
| 991 | THEN |
---|
| 992 | time_do_sla = time_do_sla + dt_3d |
---|
| 993 | IF ( time_do_sla >= dt_averaging_input ) THEN |
---|
| 994 | CALL sum_up_3d_data |
---|
| 995 | average_count_3d = average_count_3d + 1 |
---|
| 996 | time_do_sla = MOD( time_do_sla, MAX( dt_averaging_input, dt_3d ) ) |
---|
| 997 | ENDIF |
---|
| 998 | ENDIF |
---|
| 999 | |
---|
| 1000 | ! |
---|
| 1001 | !-- Calculate spectra for time averaging |
---|
[1342] | 1002 | IF ( averaging_interval_sp /= 0.0_wp .AND. & |
---|
[1] | 1003 | ( dt_dosp - time_dosp ) <= averaging_interval_sp .AND. & |
---|
| 1004 | simulated_time >= skip_time_dosp ) THEN |
---|
| 1005 | time_dosp_av = time_dosp_av + dt_3d |
---|
| 1006 | IF ( time_dosp_av >= dt_averaging_input_pr ) THEN |
---|
| 1007 | CALL calc_spectra |
---|
| 1008 | time_dosp_av = MOD( time_dosp_av, & |
---|
| 1009 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
| 1010 | ENDIF |
---|
| 1011 | ENDIF |
---|
| 1012 | |
---|
| 1013 | ! |
---|
| 1014 | !-- Computation and output of run control parameters. |
---|
[1001] | 1015 | !-- This is also done whenever perturbations have been imposed |
---|
[1] | 1016 | IF ( time_run_control >= dt_run_control .OR. & |
---|
[1001] | 1017 | timestep_scheme(1:5) /= 'runge' .OR. disturbance_created ) & |
---|
[1] | 1018 | THEN |
---|
| 1019 | CALL run_control |
---|
| 1020 | IF ( time_run_control >= dt_run_control ) THEN |
---|
| 1021 | time_run_control = MOD( time_run_control, & |
---|
| 1022 | MAX( dt_run_control, dt_3d ) ) |
---|
| 1023 | ENDIF |
---|
| 1024 | ENDIF |
---|
| 1025 | |
---|
| 1026 | ! |
---|
| 1027 | !-- Profile output (ASCII) on file |
---|
| 1028 | IF ( time_dopr_listing >= dt_dopr_listing ) THEN |
---|
| 1029 | CALL print_1d |
---|
| 1030 | time_dopr_listing = MOD( time_dopr_listing, MAX( dt_dopr_listing, & |
---|
| 1031 | dt_3d ) ) |
---|
| 1032 | ENDIF |
---|
| 1033 | |
---|
| 1034 | ! |
---|
| 1035 | !-- Graphic output for PROFIL |
---|
| 1036 | IF ( time_dopr >= dt_dopr ) THEN |
---|
| 1037 | IF ( dopr_n /= 0 ) CALL data_output_profiles |
---|
| 1038 | time_dopr = MOD( time_dopr, MAX( dt_dopr, dt_3d ) ) |
---|
[1342] | 1039 | time_dopr_av = 0.0_wp ! due to averaging (see above) |
---|
[1] | 1040 | ENDIF |
---|
| 1041 | |
---|
| 1042 | ! |
---|
| 1043 | !-- Graphic output for time series |
---|
| 1044 | IF ( time_dots >= dt_dots ) THEN |
---|
[48] | 1045 | CALL data_output_tseries |
---|
[1] | 1046 | time_dots = MOD( time_dots, MAX( dt_dots, dt_3d ) ) |
---|
| 1047 | ENDIF |
---|
| 1048 | |
---|
| 1049 | ! |
---|
| 1050 | !-- Output of spectra (formatted for use with PROFIL), in case of no |
---|
| 1051 | !-- time averaging, spectra has to be calculated before |
---|
| 1052 | IF ( time_dosp >= dt_dosp ) THEN |
---|
| 1053 | IF ( average_count_sp == 0 ) CALL calc_spectra |
---|
| 1054 | CALL data_output_spectra |
---|
| 1055 | time_dosp = MOD( time_dosp, MAX( dt_dosp, dt_3d ) ) |
---|
| 1056 | ENDIF |
---|
| 1057 | |
---|
| 1058 | ! |
---|
| 1059 | !-- 2d-data output (cross-sections) |
---|
| 1060 | IF ( time_do2d_xy >= dt_do2d_xy ) THEN |
---|
| 1061 | CALL data_output_2d( 'xy', 0 ) |
---|
| 1062 | time_do2d_xy = MOD( time_do2d_xy, MAX( dt_do2d_xy, dt_3d ) ) |
---|
| 1063 | ENDIF |
---|
| 1064 | IF ( time_do2d_xz >= dt_do2d_xz ) THEN |
---|
| 1065 | CALL data_output_2d( 'xz', 0 ) |
---|
| 1066 | time_do2d_xz = MOD( time_do2d_xz, MAX( dt_do2d_xz, dt_3d ) ) |
---|
| 1067 | ENDIF |
---|
| 1068 | IF ( time_do2d_yz >= dt_do2d_yz ) THEN |
---|
| 1069 | CALL data_output_2d( 'yz', 0 ) |
---|
| 1070 | time_do2d_yz = MOD( time_do2d_yz, MAX( dt_do2d_yz, dt_3d ) ) |
---|
| 1071 | ENDIF |
---|
| 1072 | |
---|
| 1073 | ! |
---|
| 1074 | !-- 3d-data output (volume data) |
---|
| 1075 | IF ( time_do3d >= dt_do3d ) THEN |
---|
| 1076 | CALL data_output_3d( 0 ) |
---|
| 1077 | time_do3d = MOD( time_do3d, MAX( dt_do3d, dt_3d ) ) |
---|
| 1078 | ENDIF |
---|
| 1079 | |
---|
| 1080 | ! |
---|
[410] | 1081 | !-- masked data output |
---|
[1308] | 1082 | !-- Parallel netcdf output is not tested so far for masked data, hence |
---|
| 1083 | !-- netcdf_data_format is switched back to non-paralell output. |
---|
| 1084 | netcdf_data_format_save = netcdf_data_format |
---|
| 1085 | IF ( netcdf_data_format == 5 ) netcdf_data_format = 3 |
---|
| 1086 | IF ( netcdf_data_format == 6 ) netcdf_data_format = 4 |
---|
[410] | 1087 | DO mid = 1, masks |
---|
| 1088 | IF ( time_domask(mid) >= dt_domask(mid) ) THEN |
---|
| 1089 | CALL data_output_mask( 0 ) |
---|
| 1090 | time_domask(mid) = MOD( time_domask(mid), & |
---|
| 1091 | MAX( dt_domask(mid), dt_3d ) ) |
---|
| 1092 | ENDIF |
---|
| 1093 | ENDDO |
---|
[1308] | 1094 | netcdf_data_format = netcdf_data_format_save |
---|
[410] | 1095 | |
---|
| 1096 | ! |
---|
| 1097 | !-- Output of time-averaged 2d/3d/masked data |
---|
[1] | 1098 | IF ( time_do_av >= dt_data_output_av ) THEN |
---|
| 1099 | CALL average_3d_data |
---|
| 1100 | CALL data_output_2d( 'xy', 1 ) |
---|
| 1101 | CALL data_output_2d( 'xz', 1 ) |
---|
| 1102 | CALL data_output_2d( 'yz', 1 ) |
---|
| 1103 | CALL data_output_3d( 1 ) |
---|
[1308] | 1104 | !-- Parallel netcdf output is not tested so far for masked data, hence |
---|
| 1105 | !-- netcdf_data_format is switched back to non-paralell output. |
---|
| 1106 | netcdf_data_format_save = netcdf_data_format |
---|
| 1107 | IF ( netcdf_data_format == 5 ) netcdf_data_format = 3 |
---|
| 1108 | IF ( netcdf_data_format == 6 ) netcdf_data_format = 4 |
---|
[410] | 1109 | DO mid = 1, masks |
---|
| 1110 | CALL data_output_mask( 1 ) |
---|
| 1111 | ENDDO |
---|
[1308] | 1112 | netcdf_data_format = netcdf_data_format_save |
---|
[1] | 1113 | time_do_av = MOD( time_do_av, MAX( dt_data_output_av, dt_3d ) ) |
---|
| 1114 | ENDIF |
---|
| 1115 | |
---|
| 1116 | ! |
---|
| 1117 | !-- Output of particle time series |
---|
[253] | 1118 | IF ( particle_advection ) THEN |
---|
| 1119 | IF ( time_dopts >= dt_dopts .OR. & |
---|
| 1120 | ( simulated_time >= particle_advection_start .AND. & |
---|
[849] | 1121 | first_call_lpm ) ) THEN |
---|
[253] | 1122 | CALL data_output_ptseries |
---|
| 1123 | time_dopts = MOD( time_dopts, MAX( dt_dopts, dt_3d ) ) |
---|
| 1124 | ENDIF |
---|
[1] | 1125 | ENDIF |
---|
| 1126 | |
---|
| 1127 | ! |
---|
| 1128 | !-- Output of dvrp-graphics (isosurface, particles, slicer) |
---|
| 1129 | #if defined( __dvrp_graphics ) |
---|
| 1130 | CALL DVRP_LOG_EVENT( -2, current_timestep_number-1 ) |
---|
| 1131 | #endif |
---|
| 1132 | IF ( time_dvrp >= dt_dvrp ) THEN |
---|
| 1133 | CALL data_output_dvrp |
---|
| 1134 | time_dvrp = MOD( time_dvrp, MAX( dt_dvrp, dt_3d ) ) |
---|
| 1135 | ENDIF |
---|
| 1136 | #if defined( __dvrp_graphics ) |
---|
| 1137 | CALL DVRP_LOG_EVENT( 2, current_timestep_number ) |
---|
| 1138 | #endif |
---|
| 1139 | |
---|
| 1140 | ! |
---|
| 1141 | !-- If required, set the heat flux for the next time step at a random value |
---|
| 1142 | IF ( constant_heatflux .AND. random_heatflux ) CALL disturb_heatflux |
---|
| 1143 | |
---|
| 1144 | ! |
---|
| 1145 | !-- Execute user-defined actions |
---|
| 1146 | CALL user_actions( 'after_timestep' ) |
---|
| 1147 | |
---|
[1402] | 1148 | ! |
---|
| 1149 | !-- Output elapsed simulated time in form of a progress bar on stdout |
---|
[1762] | 1150 | !-- TO_DO: should be done by root domain later |
---|
| 1151 | #if ! defined( PMC_ACTIVE ) |
---|
[1402] | 1152 | IF ( myid == 0 ) CALL output_progress_bar |
---|
[1762] | 1153 | #endif |
---|
[1402] | 1154 | |
---|
[1] | 1155 | CALL cpu_log( log_point_s(10), 'timesteps', 'stop' ) |
---|
| 1156 | |
---|
[667] | 1157 | |
---|
[1] | 1158 | ENDDO ! time loop |
---|
| 1159 | |
---|
[1762] | 1160 | !-- TO_DO: should be done by root domain later |
---|
| 1161 | #if ! defined( PMC_ACTIVE ) |
---|
[1402] | 1162 | IF ( myid == 0 ) CALL finish_progress_bar |
---|
[1762] | 1163 | #endif |
---|
[1402] | 1164 | |
---|
[1] | 1165 | #if defined( __dvrp_graphics ) |
---|
| 1166 | CALL DVRP_LOG_EVENT( -2, current_timestep_number ) |
---|
| 1167 | #endif |
---|
| 1168 | |
---|
[1402] | 1169 | CALL location_message( 'finished time-stepping', .TRUE. ) |
---|
[1384] | 1170 | |
---|
[1] | 1171 | END SUBROUTINE time_integration |
---|