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