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