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