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