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