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