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