[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 | ! |
---|
| 17 | ! Copyright 1997-2012 Leibniz University Hannover |
---|
| 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1053] | 22 | ! exchange of ghost points for nr, qr added |
---|
[392] | 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: time_integration.f90 1053 2012-11-13 17:11:03Z hoffmann $ |
---|
| 27 | ! |
---|
[1037] | 28 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 29 | ! code put under GPL (PALM 3.9) |
---|
| 30 | ! |
---|
[1020] | 31 | ! 1019 2012-09-28 06:46:45Z raasch |
---|
| 32 | ! non-optimized version of prognostic_equations removed |
---|
| 33 | ! |
---|
[1017] | 34 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 35 | ! +call of prognostic_equations_acc |
---|
| 36 | ! |
---|
[1002] | 37 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 38 | ! all actions concerning leapfrog- and upstream-spline-scheme removed |
---|
| 39 | ! |
---|
[850] | 40 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 41 | ! advec_particles renamed lpm, first_call_advec_particles renamed first_call_lpm |
---|
| 42 | ! |
---|
[826] | 43 | ! 825 2012-02-19 03:03:44Z raasch |
---|
| 44 | ! wang_collision_kernel renamed wang_kernel |
---|
| 45 | ! |
---|
[791] | 46 | ! 790 2011-11-29 03:11:20Z raasch |
---|
| 47 | ! exchange of ghostpoints for array diss |
---|
| 48 | ! |
---|
[708] | 49 | ! 707 2011-03-29 11:39:40Z raasch |
---|
| 50 | ! bc_lr/ns replaced by bc_lr/ns_cyc, calls of exchange_horiz are modified, |
---|
| 51 | ! adaption to sloping surface |
---|
| 52 | ! |
---|
[668] | 53 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
| 54 | ! Calls of exchange_horiz are modified. |
---|
| 55 | ! Adaption to slooping surface. |
---|
| 56 | ! |
---|
[482] | 57 | ! 449 2010-02-02 11:23:59Z raasch |
---|
| 58 | ! Bugfix: exchange of ghost points for prho included |
---|
| 59 | ! |
---|
[449] | 60 | ! 410 2009-12-04 17:05:40Z letzel |
---|
| 61 | ! masked data output |
---|
| 62 | ! |
---|
[392] | 63 | ! 388 2009-09-23 09:40:33Z raasch |
---|
[388] | 64 | ! Using prho instead of rho in diffusvities. |
---|
[291] | 65 | ! Coupling with independent precursor runs. |
---|
| 66 | ! Bugfix: output of particle time series only if particle advection is switched |
---|
[253] | 67 | ! on |
---|
[110] | 68 | ! |
---|
[198] | 69 | ! 151 2008-03-07 13:42:18Z raasch |
---|
| 70 | ! inflow turbulence is imposed by calling new routine inflow_turbulence |
---|
| 71 | ! |
---|
[110] | 72 | ! 108 2007-08-24 15:10:38Z letzel |
---|
[106] | 73 | ! Call of new routine surface_coupler, |
---|
| 74 | ! presure solver is called after the first Runge-Kutta substep instead of the |
---|
| 75 | ! last in case that call_psolver_at_all_substeps = .F.; for this case, the |
---|
| 76 | ! random perturbation has to be added to the velocity fields also after the |
---|
| 77 | ! first substep |
---|
[77] | 78 | ! |
---|
[98] | 79 | ! 97 2007-06-21 08:23:15Z raasch |
---|
| 80 | ! diffusivities is called with argument rho in case of ocean runs, |
---|
| 81 | ! new argument pt_/prho_reference in calls of diffusivities, |
---|
| 82 | ! ghostpoint exchange for salinity and density |
---|
| 83 | ! |
---|
[90] | 84 | ! 87 2007-05-22 15:46:47Z raasch |
---|
| 85 | ! var_hom renamed pr_palm |
---|
| 86 | ! |
---|
[77] | 87 | ! 75 2007-03-22 09:54:05Z raasch |
---|
[46] | 88 | ! Move call of user_actions( 'after_integration' ) below increment of times |
---|
[63] | 89 | ! and counters, |
---|
| 90 | ! calls of prognostic_equations_.. changed to .._noopt, .._cache, and |
---|
[75] | 91 | ! .._vector, these calls are now controlled by switch loop_optimization, |
---|
| 92 | ! uxrp, vynp eliminated, 2nd+3rd argument removed from exchange horiz, |
---|
| 93 | ! moisture renamed humidity |
---|
[1] | 94 | ! |
---|
[3] | 95 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
| 96 | ! |
---|
[1] | 97 | ! Revision 1.8 2006/08/22 14:16:05 raasch |
---|
| 98 | ! Disturbances are imposed only for the last Runge-Kutta-substep |
---|
| 99 | ! |
---|
| 100 | ! Revision 1.2 2004/04/30 13:03:40 raasch |
---|
| 101 | ! decalpha-specific warning removed, routine name changed to time_integration, |
---|
| 102 | ! particle advection is carried out only once during the intermediate steps, |
---|
| 103 | ! impulse_advec renamed momentum_advec |
---|
| 104 | ! |
---|
| 105 | ! Revision 1.1 1997/08/11 06:19:04 raasch |
---|
| 106 | ! Initial revision |
---|
| 107 | ! |
---|
| 108 | ! |
---|
| 109 | ! Description: |
---|
| 110 | ! ------------ |
---|
| 111 | ! Integration in time of the model equations, statistical analysis and graphic |
---|
| 112 | ! output |
---|
| 113 | !------------------------------------------------------------------------------! |
---|
| 114 | |
---|
| 115 | USE arrays_3d |
---|
| 116 | USE averaging |
---|
| 117 | USE control_parameters |
---|
| 118 | USE cpulog |
---|
| 119 | #if defined( __dvrp_graphics ) |
---|
| 120 | USE DVRP |
---|
| 121 | #endif |
---|
| 122 | USE grid_variables |
---|
| 123 | USE indices |
---|
| 124 | USE interaction_droplets_ptq_mod |
---|
| 125 | USE interfaces |
---|
| 126 | USE particle_attributes |
---|
| 127 | USE pegrid |
---|
| 128 | USE prognostic_equations_mod |
---|
| 129 | USE statistics |
---|
| 130 | USE user_actions_mod |
---|
| 131 | |
---|
| 132 | IMPLICIT NONE |
---|
| 133 | |
---|
| 134 | CHARACTER (LEN=9) :: time_to_string |
---|
| 135 | INTEGER :: i, j, k |
---|
| 136 | |
---|
| 137 | ! |
---|
| 138 | !-- At the beginning of a simulation determine the time step as well as |
---|
| 139 | !-- determine and print out the run control parameters |
---|
| 140 | IF ( simulated_time == 0.0 ) CALL timestep |
---|
[667] | 141 | |
---|
[1] | 142 | CALL run_control |
---|
| 143 | |
---|
[667] | 144 | |
---|
[108] | 145 | ! |
---|
| 146 | !-- Data exchange between coupled models in case that a call has been omitted |
---|
| 147 | !-- at the end of the previous run of a job chain. |
---|
[291] | 148 | IF ( coupling_mode /= 'uncoupled' .AND. run_coupled ) THEN |
---|
[108] | 149 | ! |
---|
| 150 | !-- In case of model termination initiated by the local model the coupler |
---|
| 151 | !-- must not be called because this would again cause an MPI hang. |
---|
| 152 | DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 ) |
---|
| 153 | CALL surface_coupler |
---|
| 154 | time_coupling = time_coupling - dt_coupling |
---|
| 155 | ENDDO |
---|
[348] | 156 | IF (time_coupling == 0.0 .AND. time_since_reference_point < dt_coupling)& |
---|
| 157 | THEN |
---|
| 158 | time_coupling = time_since_reference_point |
---|
| 159 | ENDIF |
---|
[108] | 160 | ENDIF |
---|
| 161 | |
---|
| 162 | |
---|
[1] | 163 | #if defined( __dvrp_graphics ) |
---|
| 164 | ! |
---|
| 165 | !-- Time measurement with dvrp software |
---|
| 166 | CALL DVRP_LOG_EVENT( 2, current_timestep_number ) |
---|
| 167 | #endif |
---|
| 168 | |
---|
| 169 | ! |
---|
| 170 | !-- Start of the time loop |
---|
| 171 | DO WHILE ( simulated_time < end_time .AND. .NOT. stop_dt .AND. & |
---|
| 172 | .NOT. terminate_run ) |
---|
| 173 | |
---|
| 174 | CALL cpu_log( log_point_s(10), 'timesteps', 'start' ) |
---|
| 175 | ! |
---|
| 176 | !-- Determine size of next time step |
---|
| 177 | IF ( simulated_time /= 0.0 ) CALL timestep |
---|
| 178 | ! |
---|
| 179 | !-- Execute the user-defined actions |
---|
| 180 | CALL user_actions( 'before_timestep' ) |
---|
| 181 | |
---|
| 182 | ! |
---|
| 183 | !-- Start of intermediate step loop |
---|
| 184 | intermediate_timestep_count = 0 |
---|
| 185 | DO WHILE ( intermediate_timestep_count < & |
---|
| 186 | intermediate_timestep_count_max ) |
---|
| 187 | |
---|
| 188 | intermediate_timestep_count = intermediate_timestep_count + 1 |
---|
| 189 | |
---|
| 190 | ! |
---|
| 191 | !-- Set the steering factors for the prognostic equations which depend |
---|
| 192 | !-- on the timestep scheme |
---|
| 193 | CALL timestep_scheme_steering |
---|
| 194 | |
---|
| 195 | ! |
---|
| 196 | !-- Solve the prognostic equations. A fast cache optimized version with |
---|
| 197 | !-- only one single loop is used in case of Piascek-Williams advection |
---|
| 198 | !-- scheme. NEC vector machines use a different version, because |
---|
| 199 | !-- in the other versions a good vectorization is prohibited due to |
---|
| 200 | !-- inlining problems. |
---|
[1019] | 201 | IF ( loop_optimization == 'cache' ) THEN |
---|
| 202 | CALL prognostic_equations_cache |
---|
| 203 | ELSEIF ( loop_optimization == 'vector' ) THEN |
---|
[63] | 204 | CALL prognostic_equations_vector |
---|
[1015] | 205 | ELSEIF ( loop_optimization == 'acc' ) THEN |
---|
| 206 | CALL prognostic_equations_acc |
---|
[1] | 207 | ENDIF |
---|
| 208 | |
---|
| 209 | ! |
---|
[849] | 210 | !-- Particle transport/physics with the Lagrangian particle model |
---|
| 211 | !-- (only once during intermediate steps, because it uses an Euler-step) |
---|
[63] | 212 | IF ( particle_advection .AND. & |
---|
| 213 | simulated_time >= particle_advection_start .AND. & |
---|
[1] | 214 | intermediate_timestep_count == 1 ) THEN |
---|
[849] | 215 | CALL lpm |
---|
| 216 | first_call_lpm = .FALSE. |
---|
[1] | 217 | ENDIF |
---|
| 218 | |
---|
| 219 | ! |
---|
| 220 | !-- Interaction of droplets with temperature and specific humidity. |
---|
| 221 | !-- Droplet condensation and evaporation is calculated within |
---|
| 222 | !-- advec_particles. |
---|
| 223 | IF ( cloud_droplets .AND. & |
---|
| 224 | intermediate_timestep_count == intermediate_timestep_count_max )& |
---|
| 225 | THEN |
---|
| 226 | CALL interaction_droplets_ptq |
---|
| 227 | ENDIF |
---|
| 228 | |
---|
| 229 | ! |
---|
| 230 | !-- Exchange of ghost points (lateral boundary conditions) |
---|
| 231 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'start' ) |
---|
[667] | 232 | CALL exchange_horiz( u_p, nbgp ) |
---|
| 233 | CALL exchange_horiz( v_p, nbgp ) |
---|
| 234 | CALL exchange_horiz( w_p, nbgp ) |
---|
| 235 | CALL exchange_horiz( pt_p, nbgp ) |
---|
| 236 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e_p, nbgp ) |
---|
[95] | 237 | IF ( ocean ) THEN |
---|
[667] | 238 | CALL exchange_horiz( sa_p, nbgp ) |
---|
| 239 | CALL exchange_horiz( rho, nbgp ) |
---|
| 240 | CALL exchange_horiz( prho, nbgp ) |
---|
[95] | 241 | ENDIF |
---|
[1053] | 242 | IF (humidity .OR. passive_scalar) THEN |
---|
| 243 | CALL exchange_horiz( q_p, nbgp ) |
---|
| 244 | IF ( cloud_physics .AND. icloud_scheme == 0 ) THEN |
---|
| 245 | CALL exchange_horiz( qr_p, nbgp ) |
---|
| 246 | CALL exchange_horiz( nr_p, nbgp ) |
---|
| 247 | ENDIF |
---|
| 248 | ENDIF |
---|
[1] | 249 | IF ( cloud_droplets ) THEN |
---|
[667] | 250 | CALL exchange_horiz( ql, nbgp ) |
---|
| 251 | CALL exchange_horiz( ql_c, nbgp ) |
---|
| 252 | CALL exchange_horiz( ql_v, nbgp ) |
---|
| 253 | CALL exchange_horiz( ql_vp, nbgp ) |
---|
[1] | 254 | ENDIF |
---|
[825] | 255 | IF ( wang_kernel ) CALL exchange_horiz( diss, nbgp ) |
---|
[1] | 256 | |
---|
| 257 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' ) |
---|
| 258 | |
---|
| 259 | ! |
---|
| 260 | !-- Boundary conditions for the prognostic quantities (except of the |
---|
| 261 | !-- velocities at the outflow in case of a non-cyclic lateral wall) |
---|
| 262 | CALL boundary_conds( 'main' ) |
---|
| 263 | |
---|
| 264 | ! |
---|
[73] | 265 | !-- Swap the time levels in preparation for the next time step. |
---|
| 266 | CALL swap_timelevel |
---|
| 267 | |
---|
| 268 | ! |
---|
[1] | 269 | !-- Temperature offset must be imposed at cyclic boundaries in x-direction |
---|
| 270 | !-- when a sloping surface is used |
---|
| 271 | IF ( sloping_surface ) THEN |
---|
[707] | 272 | IF ( nxl == 0 ) pt(:,:,nxlg:nxl-1) = pt(:,:,nxlg:nxl-1) - & |
---|
| 273 | pt_slope_offset |
---|
| 274 | IF ( nxr == nx ) pt(:,:,nxr+1:nxrg) = pt(:,:,nxr+1:nxrg) + & |
---|
| 275 | pt_slope_offset |
---|
[1] | 276 | ENDIF |
---|
| 277 | |
---|
| 278 | ! |
---|
[151] | 279 | !-- Impose a turbulent inflow using the recycling method |
---|
| 280 | IF ( turbulent_inflow ) CALL inflow_turbulence |
---|
| 281 | |
---|
| 282 | ! |
---|
[1] | 283 | !-- Impose a random perturbation on the horizontal velocity field |
---|
[106] | 284 | IF ( create_disturbances .AND. & |
---|
| 285 | ( call_psolver_at_all_substeps .AND. & |
---|
[1] | 286 | intermediate_timestep_count == intermediate_timestep_count_max )& |
---|
[106] | 287 | .OR. ( .NOT. call_psolver_at_all_substeps .AND. & |
---|
| 288 | intermediate_timestep_count == 1 ) ) & |
---|
[1] | 289 | THEN |
---|
| 290 | time_disturb = time_disturb + dt_3d |
---|
| 291 | IF ( time_disturb >= dt_disturb ) THEN |
---|
[87] | 292 | IF ( hom(nzb+5,1,pr_palm,0) < disturbance_energy_limit ) THEN |
---|
[75] | 293 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
| 294 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
[707] | 295 | ELSEIF ( .NOT. bc_lr_cyc .OR. .NOT. bc_ns_cyc ) THEN |
---|
[1] | 296 | ! |
---|
| 297 | !-- Runs with a non-cyclic lateral wall need perturbations |
---|
| 298 | !-- near the inflow throughout the whole simulation |
---|
| 299 | dist_range = 1 |
---|
[75] | 300 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
| 301 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
[1] | 302 | dist_range = 0 |
---|
| 303 | ENDIF |
---|
| 304 | time_disturb = time_disturb - dt_disturb |
---|
| 305 | ENDIF |
---|
| 306 | ENDIF |
---|
| 307 | |
---|
| 308 | ! |
---|
| 309 | !-- Reduce the velocity divergence via the equation for perturbation |
---|
| 310 | !-- pressure. |
---|
[106] | 311 | IF ( intermediate_timestep_count == 1 .OR. & |
---|
| 312 | call_psolver_at_all_substeps ) THEN |
---|
[1] | 313 | CALL pres |
---|
| 314 | ENDIF |
---|
[1015] | 315 | ! |
---|
| 316 | !-- Update device memory for calculating diffusion quantities and for next |
---|
| 317 | !-- timestep |
---|
| 318 | !$acc update device( e, pt, u, v, w ) |
---|
| 319 | !$acc update device( q ) if ( allocated( q ) ) |
---|
[1] | 320 | |
---|
| 321 | ! |
---|
| 322 | !-- If required, compute virtuell potential temperature |
---|
[1015] | 323 | IF ( humidity ) THEN |
---|
| 324 | CALL compute_vpt |
---|
| 325 | !$acc update device( vpt ) |
---|
| 326 | ENDIF |
---|
[1] | 327 | |
---|
| 328 | ! |
---|
| 329 | !-- If required, compute liquid water content |
---|
[1015] | 330 | IF ( cloud_physics ) THEN |
---|
| 331 | CALL calc_liquid_water_content |
---|
| 332 | !$acc update device( ql ) |
---|
| 333 | ENDIF |
---|
[1] | 334 | |
---|
| 335 | ! |
---|
| 336 | !-- Compute the diffusion quantities |
---|
| 337 | IF ( .NOT. constant_diffusion ) THEN |
---|
| 338 | |
---|
| 339 | ! |
---|
| 340 | !-- First the vertical fluxes in the Prandtl layer are being computed |
---|
| 341 | IF ( prandtl_layer ) THEN |
---|
| 342 | CALL cpu_log( log_point(19), 'prandtl_fluxes', 'start' ) |
---|
| 343 | CALL prandtl_fluxes |
---|
| 344 | CALL cpu_log( log_point(19), 'prandtl_fluxes', 'stop' ) |
---|
[1015] | 345 | ! |
---|
| 346 | !++ Statistics still require updates on host |
---|
| 347 | !$acc update host( qs, qsws, rif, shf, ts ) |
---|
[1] | 348 | ENDIF |
---|
| 349 | |
---|
| 350 | ! |
---|
| 351 | !-- Compute the diffusion coefficients |
---|
| 352 | CALL cpu_log( log_point(17), 'diffusivities', 'start' ) |
---|
[75] | 353 | IF ( .NOT. humidity ) THEN |
---|
[97] | 354 | IF ( ocean ) THEN |
---|
[388] | 355 | CALL diffusivities( prho, prho_reference ) |
---|
[97] | 356 | ELSE |
---|
| 357 | CALL diffusivities( pt, pt_reference ) |
---|
| 358 | ENDIF |
---|
[1] | 359 | ELSE |
---|
[97] | 360 | CALL diffusivities( vpt, pt_reference ) |
---|
[1] | 361 | ENDIF |
---|
| 362 | CALL cpu_log( log_point(17), 'diffusivities', 'stop' ) |
---|
[1015] | 363 | ! |
---|
| 364 | !++ Statistics still require update of diffusivities on host |
---|
| 365 | !$acc update host( kh, km ) |
---|
[1] | 366 | |
---|
| 367 | ENDIF |
---|
| 368 | |
---|
| 369 | ENDDO ! Intermediate step loop |
---|
| 370 | |
---|
| 371 | ! |
---|
| 372 | !-- Increase simulation time and output times |
---|
[291] | 373 | current_timestep_number = current_timestep_number + 1 |
---|
| 374 | simulated_time = simulated_time + dt_3d |
---|
| 375 | simulated_time_chr = time_to_string( simulated_time ) |
---|
| 376 | time_since_reference_point = simulated_time - coupling_start_time |
---|
| 377 | |
---|
[1] | 378 | IF ( simulated_time >= skip_time_data_output_av ) THEN |
---|
| 379 | time_do_av = time_do_av + dt_3d |
---|
| 380 | ENDIF |
---|
| 381 | IF ( simulated_time >= skip_time_do2d_xy ) THEN |
---|
| 382 | time_do2d_xy = time_do2d_xy + dt_3d |
---|
| 383 | ENDIF |
---|
| 384 | IF ( simulated_time >= skip_time_do2d_xz ) THEN |
---|
| 385 | time_do2d_xz = time_do2d_xz + dt_3d |
---|
| 386 | ENDIF |
---|
| 387 | IF ( simulated_time >= skip_time_do2d_yz ) THEN |
---|
| 388 | time_do2d_yz = time_do2d_yz + dt_3d |
---|
| 389 | ENDIF |
---|
| 390 | IF ( simulated_time >= skip_time_do3d ) THEN |
---|
| 391 | time_do3d = time_do3d + dt_3d |
---|
| 392 | ENDIF |
---|
[410] | 393 | DO mid = 1, masks |
---|
| 394 | IF ( simulated_time >= skip_time_domask(mid) ) THEN |
---|
| 395 | time_domask(mid)= time_domask(mid) + dt_3d |
---|
| 396 | ENDIF |
---|
| 397 | ENDDO |
---|
[1] | 398 | time_dvrp = time_dvrp + dt_3d |
---|
| 399 | IF ( simulated_time >= skip_time_dosp ) THEN |
---|
| 400 | time_dosp = time_dosp + dt_3d |
---|
| 401 | ENDIF |
---|
| 402 | time_dots = time_dots + dt_3d |
---|
[849] | 403 | IF ( .NOT. first_call_lpm ) THEN |
---|
[1] | 404 | time_dopts = time_dopts + dt_3d |
---|
| 405 | ENDIF |
---|
| 406 | IF ( simulated_time >= skip_time_dopr ) THEN |
---|
| 407 | time_dopr = time_dopr + dt_3d |
---|
| 408 | ENDIF |
---|
| 409 | time_dopr_listing = time_dopr_listing + dt_3d |
---|
| 410 | time_run_control = time_run_control + dt_3d |
---|
| 411 | |
---|
| 412 | ! |
---|
[102] | 413 | !-- Data exchange between coupled models |
---|
[291] | 414 | IF ( coupling_mode /= 'uncoupled' .AND. run_coupled ) THEN |
---|
[102] | 415 | time_coupling = time_coupling + dt_3d |
---|
[343] | 416 | |
---|
[108] | 417 | ! |
---|
| 418 | !-- In case of model termination initiated by the local model |
---|
| 419 | !-- (terminate_coupled > 0), the coupler must be skipped because it would |
---|
| 420 | !-- cause an MPI intercomminucation hang. |
---|
| 421 | !-- If necessary, the coupler will be called at the beginning of the |
---|
| 422 | !-- next restart run. |
---|
| 423 | DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 ) |
---|
[102] | 424 | CALL surface_coupler |
---|
| 425 | time_coupling = time_coupling - dt_coupling |
---|
| 426 | ENDDO |
---|
| 427 | ENDIF |
---|
| 428 | |
---|
| 429 | ! |
---|
[46] | 430 | !-- Execute user-defined actions |
---|
| 431 | CALL user_actions( 'after_integration' ) |
---|
| 432 | |
---|
| 433 | ! |
---|
[1] | 434 | !-- If Galilei transformation is used, determine the distance that the |
---|
| 435 | !-- model has moved so far |
---|
| 436 | IF ( galilei_transformation ) THEN |
---|
| 437 | advected_distance_x = advected_distance_x + u_gtrans * dt_3d |
---|
| 438 | advected_distance_y = advected_distance_y + v_gtrans * dt_3d |
---|
| 439 | ENDIF |
---|
| 440 | |
---|
| 441 | ! |
---|
| 442 | !-- Check, if restart is necessary (because cpu-time is expiring or |
---|
| 443 | !-- because it is forced by user) and set stop flag |
---|
[108] | 444 | !-- This call is skipped if the remote model has already initiated a restart. |
---|
| 445 | IF ( .NOT. terminate_run ) CALL check_for_restart |
---|
[1] | 446 | |
---|
| 447 | ! |
---|
| 448 | !-- Carry out statistical analysis and output at the requested output times. |
---|
| 449 | !-- The MOD function is used for calculating the output time counters (like |
---|
| 450 | !-- time_dopr) in order to regard a possible decrease of the output time |
---|
| 451 | !-- interval in case of restart runs |
---|
| 452 | |
---|
| 453 | ! |
---|
| 454 | !-- Set a flag indicating that so far no statistics have been created |
---|
| 455 | !-- for this time step |
---|
| 456 | flow_statistics_called = .FALSE. |
---|
| 457 | |
---|
| 458 | ! |
---|
| 459 | !-- If required, call flow_statistics for averaging in time |
---|
| 460 | IF ( averaging_interval_pr /= 0.0 .AND. & |
---|
| 461 | ( dt_dopr - time_dopr ) <= averaging_interval_pr .AND. & |
---|
| 462 | simulated_time >= skip_time_dopr ) THEN |
---|
| 463 | time_dopr_av = time_dopr_av + dt_3d |
---|
| 464 | IF ( time_dopr_av >= dt_averaging_input_pr ) THEN |
---|
| 465 | do_sum = .TRUE. |
---|
| 466 | time_dopr_av = MOD( time_dopr_av, & |
---|
| 467 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
| 468 | ENDIF |
---|
| 469 | ENDIF |
---|
| 470 | IF ( do_sum ) CALL flow_statistics |
---|
| 471 | |
---|
| 472 | ! |
---|
[410] | 473 | !-- Sum-up 3d-arrays for later output of time-averaged 2d/3d/masked data |
---|
[1] | 474 | IF ( averaging_interval /= 0.0 .AND. & |
---|
| 475 | ( dt_data_output_av - time_do_av ) <= averaging_interval .AND. & |
---|
| 476 | simulated_time >= skip_time_data_output_av ) & |
---|
| 477 | THEN |
---|
| 478 | time_do_sla = time_do_sla + dt_3d |
---|
| 479 | IF ( time_do_sla >= dt_averaging_input ) THEN |
---|
| 480 | CALL sum_up_3d_data |
---|
| 481 | average_count_3d = average_count_3d + 1 |
---|
| 482 | time_do_sla = MOD( time_do_sla, MAX( dt_averaging_input, dt_3d ) ) |
---|
| 483 | ENDIF |
---|
| 484 | ENDIF |
---|
| 485 | |
---|
| 486 | ! |
---|
| 487 | !-- Calculate spectra for time averaging |
---|
| 488 | IF ( averaging_interval_sp /= 0.0 .AND. & |
---|
| 489 | ( dt_dosp - time_dosp ) <= averaging_interval_sp .AND. & |
---|
| 490 | simulated_time >= skip_time_dosp ) THEN |
---|
| 491 | time_dosp_av = time_dosp_av + dt_3d |
---|
| 492 | IF ( time_dosp_av >= dt_averaging_input_pr ) THEN |
---|
| 493 | CALL calc_spectra |
---|
| 494 | time_dosp_av = MOD( time_dosp_av, & |
---|
| 495 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
| 496 | ENDIF |
---|
| 497 | ENDIF |
---|
| 498 | |
---|
| 499 | ! |
---|
| 500 | !-- Computation and output of run control parameters. |
---|
[1001] | 501 | !-- This is also done whenever perturbations have been imposed |
---|
[1] | 502 | IF ( time_run_control >= dt_run_control .OR. & |
---|
[1001] | 503 | timestep_scheme(1:5) /= 'runge' .OR. disturbance_created ) & |
---|
[1] | 504 | THEN |
---|
| 505 | CALL run_control |
---|
| 506 | IF ( time_run_control >= dt_run_control ) THEN |
---|
| 507 | time_run_control = MOD( time_run_control, & |
---|
| 508 | MAX( dt_run_control, dt_3d ) ) |
---|
| 509 | ENDIF |
---|
| 510 | ENDIF |
---|
| 511 | |
---|
| 512 | ! |
---|
| 513 | !-- Profile output (ASCII) on file |
---|
| 514 | IF ( time_dopr_listing >= dt_dopr_listing ) THEN |
---|
| 515 | CALL print_1d |
---|
| 516 | time_dopr_listing = MOD( time_dopr_listing, MAX( dt_dopr_listing, & |
---|
| 517 | dt_3d ) ) |
---|
| 518 | ENDIF |
---|
| 519 | |
---|
| 520 | ! |
---|
| 521 | !-- Graphic output for PROFIL |
---|
| 522 | IF ( time_dopr >= dt_dopr ) THEN |
---|
| 523 | IF ( dopr_n /= 0 ) CALL data_output_profiles |
---|
| 524 | time_dopr = MOD( time_dopr, MAX( dt_dopr, dt_3d ) ) |
---|
| 525 | time_dopr_av = 0.0 ! due to averaging (see above) |
---|
| 526 | ENDIF |
---|
| 527 | |
---|
| 528 | ! |
---|
| 529 | !-- Graphic output for time series |
---|
| 530 | IF ( time_dots >= dt_dots ) THEN |
---|
[48] | 531 | CALL data_output_tseries |
---|
[1] | 532 | time_dots = MOD( time_dots, MAX( dt_dots, dt_3d ) ) |
---|
| 533 | ENDIF |
---|
| 534 | |
---|
| 535 | ! |
---|
| 536 | !-- Output of spectra (formatted for use with PROFIL), in case of no |
---|
| 537 | !-- time averaging, spectra has to be calculated before |
---|
| 538 | IF ( time_dosp >= dt_dosp ) THEN |
---|
| 539 | IF ( average_count_sp == 0 ) CALL calc_spectra |
---|
| 540 | CALL data_output_spectra |
---|
| 541 | time_dosp = MOD( time_dosp, MAX( dt_dosp, dt_3d ) ) |
---|
| 542 | ENDIF |
---|
| 543 | |
---|
| 544 | ! |
---|
| 545 | !-- 2d-data output (cross-sections) |
---|
| 546 | IF ( time_do2d_xy >= dt_do2d_xy ) THEN |
---|
| 547 | CALL data_output_2d( 'xy', 0 ) |
---|
| 548 | time_do2d_xy = MOD( time_do2d_xy, MAX( dt_do2d_xy, dt_3d ) ) |
---|
| 549 | ENDIF |
---|
| 550 | IF ( time_do2d_xz >= dt_do2d_xz ) THEN |
---|
| 551 | CALL data_output_2d( 'xz', 0 ) |
---|
| 552 | time_do2d_xz = MOD( time_do2d_xz, MAX( dt_do2d_xz, dt_3d ) ) |
---|
| 553 | ENDIF |
---|
| 554 | IF ( time_do2d_yz >= dt_do2d_yz ) THEN |
---|
| 555 | CALL data_output_2d( 'yz', 0 ) |
---|
| 556 | time_do2d_yz = MOD( time_do2d_yz, MAX( dt_do2d_yz, dt_3d ) ) |
---|
| 557 | ENDIF |
---|
| 558 | |
---|
| 559 | ! |
---|
| 560 | !-- 3d-data output (volume data) |
---|
| 561 | IF ( time_do3d >= dt_do3d ) THEN |
---|
| 562 | CALL data_output_3d( 0 ) |
---|
| 563 | time_do3d = MOD( time_do3d, MAX( dt_do3d, dt_3d ) ) |
---|
| 564 | ENDIF |
---|
| 565 | |
---|
| 566 | ! |
---|
[410] | 567 | !-- masked data output |
---|
| 568 | DO mid = 1, masks |
---|
| 569 | IF ( time_domask(mid) >= dt_domask(mid) ) THEN |
---|
| 570 | CALL data_output_mask( 0 ) |
---|
| 571 | time_domask(mid) = MOD( time_domask(mid), & |
---|
| 572 | MAX( dt_domask(mid), dt_3d ) ) |
---|
| 573 | ENDIF |
---|
| 574 | ENDDO |
---|
| 575 | |
---|
| 576 | ! |
---|
| 577 | !-- Output of time-averaged 2d/3d/masked data |
---|
[1] | 578 | IF ( time_do_av >= dt_data_output_av ) THEN |
---|
| 579 | CALL average_3d_data |
---|
| 580 | CALL data_output_2d( 'xy', 1 ) |
---|
| 581 | CALL data_output_2d( 'xz', 1 ) |
---|
| 582 | CALL data_output_2d( 'yz', 1 ) |
---|
| 583 | CALL data_output_3d( 1 ) |
---|
[410] | 584 | DO mid = 1, masks |
---|
| 585 | CALL data_output_mask( 1 ) |
---|
| 586 | ENDDO |
---|
[1] | 587 | time_do_av = MOD( time_do_av, MAX( dt_data_output_av, dt_3d ) ) |
---|
| 588 | ENDIF |
---|
| 589 | |
---|
| 590 | ! |
---|
| 591 | !-- Output of particle time series |
---|
[253] | 592 | IF ( particle_advection ) THEN |
---|
| 593 | IF ( time_dopts >= dt_dopts .OR. & |
---|
| 594 | ( simulated_time >= particle_advection_start .AND. & |
---|
[849] | 595 | first_call_lpm ) ) THEN |
---|
[253] | 596 | CALL data_output_ptseries |
---|
| 597 | time_dopts = MOD( time_dopts, MAX( dt_dopts, dt_3d ) ) |
---|
| 598 | ENDIF |
---|
[1] | 599 | ENDIF |
---|
| 600 | |
---|
| 601 | ! |
---|
| 602 | !-- Output of dvrp-graphics (isosurface, particles, slicer) |
---|
| 603 | #if defined( __dvrp_graphics ) |
---|
| 604 | CALL DVRP_LOG_EVENT( -2, current_timestep_number-1 ) |
---|
| 605 | #endif |
---|
| 606 | IF ( time_dvrp >= dt_dvrp ) THEN |
---|
| 607 | CALL data_output_dvrp |
---|
| 608 | time_dvrp = MOD( time_dvrp, MAX( dt_dvrp, dt_3d ) ) |
---|
| 609 | ENDIF |
---|
| 610 | #if defined( __dvrp_graphics ) |
---|
| 611 | CALL DVRP_LOG_EVENT( 2, current_timestep_number ) |
---|
| 612 | #endif |
---|
| 613 | |
---|
| 614 | ! |
---|
| 615 | !-- If required, set the heat flux for the next time step at a random value |
---|
| 616 | IF ( constant_heatflux .AND. random_heatflux ) CALL disturb_heatflux |
---|
| 617 | |
---|
| 618 | ! |
---|
| 619 | !-- Execute user-defined actions |
---|
| 620 | CALL user_actions( 'after_timestep' ) |
---|
| 621 | |
---|
| 622 | CALL cpu_log( log_point_s(10), 'timesteps', 'stop' ) |
---|
| 623 | |
---|
[667] | 624 | |
---|
[1] | 625 | ENDDO ! time loop |
---|
| 626 | |
---|
| 627 | #if defined( __dvrp_graphics ) |
---|
| 628 | CALL DVRP_LOG_EVENT( -2, current_timestep_number ) |
---|
| 629 | #endif |
---|
| 630 | |
---|
| 631 | END SUBROUTINE time_integration |
---|