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