[849] | 1 | SUBROUTINE lpm |
---|
[1] | 2 | |
---|
| 3 | !------------------------------------------------------------------------------! |
---|
[230] | 4 | ! Current revisions: |
---|
[759] | 5 | ! ------------------ |
---|
[852] | 6 | ! |
---|
[829] | 7 | ! |
---|
| 8 | ! Former revisions: |
---|
| 9 | ! ----------------- |
---|
| 10 | ! $Id: lpm.f90 852 2012-03-15 14:36:44Z hoffmann $ |
---|
| 11 | ! |
---|
[852] | 12 | ! 851 2012-03-15 14:32:58Z raasch |
---|
| 13 | ! Bugfix: resetting of particle_mask and tail mask moved from routine |
---|
| 14 | ! lpm_exchange_horiz to here (end of sub-timestep loop) |
---|
| 15 | ! |
---|
[850] | 16 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 17 | ! original routine advec_particles split into several subroutines and renamed |
---|
| 18 | ! lpm |
---|
| 19 | ! |
---|
[832] | 20 | ! 831 2012-02-22 00:29:39Z raasch |
---|
| 21 | ! thermal_conductivity_l and diff_coeff_l now depend on temperature and |
---|
| 22 | ! pressure |
---|
| 23 | ! |
---|
[829] | 24 | ! 828 2012-02-21 12:00:36Z raasch |
---|
[828] | 25 | ! fast hall/wang kernels with fixed radius/dissipation classes added, |
---|
| 26 | ! particle feature color renamed class, routine colker renamed |
---|
| 27 | ! recalculate_kernel, |
---|
| 28 | ! lower limit for droplet radius changed from 1E-7 to 1E-8 |
---|
[826] | 29 | ! |
---|
[828] | 30 | ! Bugfix: transformation factor for dissipation changed from 1E5 to 1E4 |
---|
| 31 | ! |
---|
[826] | 32 | ! 825 2012-02-19 03:03:44Z raasch |
---|
[825] | 33 | ! droplet growth by condensation may include curvature and solution effects, |
---|
| 34 | ! initialisation of temporary particle array for resorting removed, |
---|
| 35 | ! particle attributes speed_x|y|z_sgs renamed rvar1|2|3, |
---|
| 36 | ! module wang_kernel_mod renamed lpm_collision_kernels_mod, |
---|
| 37 | ! wang_collision_kernel renamed wang_kernel |
---|
[482] | 38 | ! |
---|
[800] | 39 | ! 799 2011-12-21 17:48:03Z franke |
---|
| 40 | ! Implementation of Wang collision kernel and corresponding new parameter |
---|
| 41 | ! wang_collision_kernel |
---|
| 42 | ! |
---|
[799] | 43 | ! 792 2011-12-01 raasch |
---|
| 44 | ! particle arrays (particles, particles_temp) implemented as pointers in |
---|
| 45 | ! order to speed up sorting (see routine sort_particles) |
---|
| 46 | ! |
---|
[760] | 47 | ! 759 2011-09-15 13:58:31Z raasch |
---|
| 48 | ! Splitting of parallel I/O (routine write_particles) |
---|
| 49 | ! |
---|
[1] | 50 | ! Revision 1.1 1999/11/25 16:16:06 raasch |
---|
| 51 | ! Initial revision |
---|
| 52 | ! |
---|
| 53 | ! |
---|
| 54 | ! Description: |
---|
| 55 | ! ------------ |
---|
| 56 | ! Particle advection |
---|
| 57 | !------------------------------------------------------------------------------! |
---|
| 58 | |
---|
| 59 | USE arrays_3d |
---|
| 60 | USE control_parameters |
---|
| 61 | USE cpulog |
---|
| 62 | USE interfaces |
---|
| 63 | USE particle_attributes |
---|
| 64 | USE pegrid |
---|
| 65 | USE statistics |
---|
| 66 | |
---|
| 67 | IMPLICIT NONE |
---|
| 68 | |
---|
[849] | 69 | INTEGER :: m |
---|
[1] | 70 | |
---|
[60] | 71 | |
---|
[849] | 72 | CALL cpu_log( log_point(25), 'lpm', 'start' ) |
---|
[824] | 73 | |
---|
[849] | 74 | ! |
---|
| 75 | !-- Write particle data at current time on file. |
---|
| 76 | !-- This has to be done here, before particles are further processed, |
---|
| 77 | !-- because they may be deleted within this timestep (in case that |
---|
| 78 | !-- dt_write_particle_data = dt_prel = particle_maximum_age). |
---|
| 79 | time_write_particle_data = time_write_particle_data + dt_3d |
---|
| 80 | IF ( time_write_particle_data >= dt_write_particle_data ) THEN |
---|
[1] | 81 | |
---|
[849] | 82 | CALL lpm_data_output_particles |
---|
[824] | 83 | ! |
---|
[849] | 84 | !-- The MOD function allows for changes in the output interval with restart |
---|
| 85 | !-- runs. |
---|
| 86 | time_write_particle_data = MOD( time_write_particle_data, & |
---|
| 87 | MAX( dt_write_particle_data, dt_3d ) ) |
---|
| 88 | ENDIF |
---|
[1] | 89 | |
---|
[60] | 90 | |
---|
[849] | 91 | ! |
---|
| 92 | !-- Initialize arrays for marking those particles/tails to be deleted after the |
---|
| 93 | !-- (sub-) timestep |
---|
| 94 | particle_mask = .TRUE. |
---|
| 95 | deleted_particles = 0 |
---|
[60] | 96 | |
---|
[849] | 97 | IF ( use_particle_tails ) THEN |
---|
| 98 | tail_mask = .TRUE. |
---|
| 99 | ENDIF |
---|
| 100 | deleted_tails = 0 |
---|
[1] | 101 | |
---|
| 102 | |
---|
| 103 | ! |
---|
[849] | 104 | !-- Initialize variables used for accumulating the number of particles |
---|
| 105 | !-- exchanged between the subdomains during all sub-timesteps (if sgs |
---|
| 106 | !-- velocities are included). These data are output further below on the |
---|
| 107 | !-- particle statistics file. |
---|
| 108 | trlp_count_sum = 0 |
---|
| 109 | trlp_count_recv_sum = 0 |
---|
| 110 | trrp_count_sum = 0 |
---|
| 111 | trrp_count_recv_sum = 0 |
---|
| 112 | trsp_count_sum = 0 |
---|
| 113 | trsp_count_recv_sum = 0 |
---|
| 114 | trnp_count_sum = 0 |
---|
| 115 | trnp_count_recv_sum = 0 |
---|
[1] | 116 | |
---|
| 117 | |
---|
| 118 | ! |
---|
| 119 | !-- Calculate exponential term used in case of particle inertia for each |
---|
| 120 | !-- of the particle groups |
---|
| 121 | DO m = 1, number_of_particle_groups |
---|
| 122 | IF ( particle_groups(m)%density_ratio /= 0.0 ) THEN |
---|
| 123 | particle_groups(m)%exp_arg = & |
---|
| 124 | 4.5 * particle_groups(m)%density_ratio * & |
---|
| 125 | molecular_viscosity / ( particle_groups(m)%radius )**2 |
---|
| 126 | particle_groups(m)%exp_term = EXP( -particle_groups(m)%exp_arg * & |
---|
| 127 | dt_3d ) |
---|
| 128 | ENDIF |
---|
| 129 | ENDDO |
---|
| 130 | |
---|
[849] | 131 | |
---|
[1] | 132 | ! |
---|
| 133 | !-- Particle (droplet) growth by condensation/evaporation and collision |
---|
| 134 | IF ( cloud_droplets ) THEN |
---|
| 135 | |
---|
| 136 | ! |
---|
| 137 | !-- Reset summation arrays |
---|
| 138 | ql_c = 0.0; ql_v = 0.0; ql_vp = 0.0 |
---|
| 139 | |
---|
| 140 | ! |
---|
[849] | 141 | !-- Droplet growth by condensation / evaporation |
---|
| 142 | CALL lpm_droplet_condensation |
---|
[1] | 143 | |
---|
| 144 | ! |
---|
| 145 | !-- Particle growth by collision |
---|
[849] | 146 | IF ( collision_kernel /= 'none' ) CALL lpm_droplet_collision |
---|
[825] | 147 | |
---|
[849] | 148 | ENDIF |
---|
[420] | 149 | |
---|
[1] | 150 | |
---|
| 151 | ! |
---|
[849] | 152 | !-- If particle advection includes SGS velocity components, calculate the |
---|
| 153 | !-- required SGS quantities (i.e. gradients of the TKE, as well as horizontally |
---|
| 154 | !-- averaged profiles of the SGS TKE and the resolved-scale velocity variances) |
---|
| 155 | IF ( use_sgs_for_particles ) CALL lpm_init_sgs_tke |
---|
[799] | 156 | |
---|
| 157 | |
---|
| 158 | ! |
---|
[1] | 159 | !-- Initialize the variable storing the total time that a particle has advanced |
---|
| 160 | !-- within the timestep procedure |
---|
| 161 | particles(1:number_of_particles)%dt_sum = 0.0 |
---|
| 162 | |
---|
[849] | 163 | |
---|
[1] | 164 | ! |
---|
[849] | 165 | !-- Timestep loop for particle advection. |
---|
[1] | 166 | !-- This loop has to be repeated until the advection time of every particle |
---|
[849] | 167 | !-- (within the total domain!) has reached the LES timestep (dt_3d). |
---|
| 168 | !-- In case of including the SGS velocities, the particle timestep may be |
---|
| 169 | !-- smaller than the LES timestep (because of the Lagrangian timescale restric- |
---|
| 170 | !-- tion) and particles may require to undergo several particle timesteps, |
---|
| 171 | !-- before the LES timestep is reached. Because the number of these particle |
---|
| 172 | !-- timesteps to be carried out is unknown at first, these steps are carried |
---|
| 173 | !-- out in the following infinite loop with exit condition. |
---|
[1] | 174 | DO |
---|
| 175 | |
---|
[849] | 176 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'start' ) |
---|
[1] | 177 | |
---|
| 178 | ! |
---|
| 179 | !-- Initialize the switch used for the loop exit condition checked at the |
---|
| 180 | !-- end of this loop. |
---|
| 181 | !-- If at least one particle has failed to reach the LES timestep, this |
---|
| 182 | !-- switch will be set false. |
---|
| 183 | dt_3d_reached_l = .TRUE. |
---|
| 184 | |
---|
| 185 | ! |
---|
[849] | 186 | !-- Particle advection |
---|
| 187 | CALL lpm_advec |
---|
[1] | 188 | |
---|
| 189 | ! |
---|
[57] | 190 | !-- Particle reflection from walls |
---|
[849] | 191 | CALL lpm_boundary_conds( 'walls' ) |
---|
[57] | 192 | |
---|
| 193 | ! |
---|
[212] | 194 | !-- User-defined actions after the calculation of the new particle position |
---|
[849] | 195 | CALL user_lpm_advec |
---|
[57] | 196 | |
---|
| 197 | ! |
---|
[1] | 198 | !-- Find out, if all particles on every PE have completed the LES timestep |
---|
| 199 | !-- and set the switch corespondingly |
---|
| 200 | #if defined( __parallel ) |
---|
[622] | 201 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[1] | 202 | CALL MPI_ALLREDUCE( dt_3d_reached_l, dt_3d_reached, 1, MPI_LOGICAL, & |
---|
| 203 | MPI_LAND, comm2d, ierr ) |
---|
| 204 | #else |
---|
| 205 | dt_3d_reached = dt_3d_reached_l |
---|
[799] | 206 | #endif |
---|
[1] | 207 | |
---|
[849] | 208 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'stop' ) |
---|
[1] | 209 | |
---|
| 210 | ! |
---|
| 211 | !-- Increment time since last release |
---|
| 212 | IF ( dt_3d_reached ) time_prel = time_prel + dt_3d |
---|
| 213 | |
---|
| 214 | ! |
---|
| 215 | !-- If necessary, release new set of particles |
---|
| 216 | IF ( time_prel >= dt_prel .AND. end_time_prel > simulated_time .AND. & |
---|
| 217 | dt_3d_reached ) THEN |
---|
| 218 | |
---|
[849] | 219 | CALL lpm_release_set |
---|
[1] | 220 | |
---|
| 221 | ! |
---|
| 222 | !-- The MOD function allows for changes in the output interval with |
---|
| 223 | !-- restart runs. |
---|
| 224 | time_prel = MOD( time_prel, MAX( dt_prel, dt_3d ) ) |
---|
| 225 | |
---|
| 226 | ENDIF |
---|
| 227 | |
---|
| 228 | ! |
---|
[849] | 229 | !-- Horizontal boundary conditions including exchange between subdmains |
---|
| 230 | CALL lpm_exchange_horiz |
---|
[1] | 231 | |
---|
| 232 | ! |
---|
| 233 | !-- Apply boundary conditions to those particles that have crossed the top or |
---|
| 234 | !-- bottom boundary and delete those particles, which are older than allowed |
---|
[849] | 235 | CALL lpm_boundary_conds( 'bottom/top' ) |
---|
[1] | 236 | |
---|
[57] | 237 | ! |
---|
[1] | 238 | !-- Pack particles (eliminate those marked for deletion), |
---|
| 239 | !-- determine new number of particles |
---|
| 240 | IF ( number_of_particles > 0 .AND. deleted_particles > 0 ) THEN |
---|
[849] | 241 | CALL lpm_pack_arrays |
---|
[1] | 242 | ENDIF |
---|
| 243 | |
---|
[851] | 244 | ! |
---|
| 245 | !-- Initialize variables for the next (sub-) timestep, i.e. for marking those |
---|
| 246 | !-- particles to be deleted after the timestep |
---|
| 247 | particle_mask = .TRUE. |
---|
| 248 | deleted_particles = 0 |
---|
| 249 | |
---|
| 250 | IF ( use_particle_tails ) THEN |
---|
| 251 | tail_mask = .TRUE. |
---|
| 252 | ENDIF |
---|
| 253 | deleted_tails = 0 |
---|
| 254 | |
---|
| 255 | |
---|
[1] | 256 | IF ( dt_3d_reached ) EXIT |
---|
| 257 | |
---|
| 258 | ENDDO ! timestep loop |
---|
| 259 | |
---|
[849] | 260 | |
---|
[1] | 261 | ! |
---|
[116] | 262 | !-- Sort particles in the sequence the gridboxes are stored in the memory |
---|
| 263 | time_sort_particles = time_sort_particles + dt_3d |
---|
| 264 | IF ( time_sort_particles >= dt_sort_particles ) THEN |
---|
[849] | 265 | CALL lpm_sort_arrays |
---|
[116] | 266 | time_sort_particles = MOD( time_sort_particles, & |
---|
| 267 | MAX( dt_sort_particles, dt_3d ) ) |
---|
| 268 | ENDIF |
---|
| 269 | |
---|
[1] | 270 | |
---|
| 271 | ! |
---|
[849] | 272 | !-- Calculate the new liquid water content for each grid box |
---|
| 273 | IF ( cloud_droplets ) CALL lpm_calc_liquid_water_content |
---|
[1] | 274 | |
---|
| 275 | |
---|
| 276 | ! |
---|
[828] | 277 | !-- Set particle attributes. |
---|
| 278 | !-- Feature is not available if collision is activated, because the respective |
---|
| 279 | !-- particle attribute (class) is then used for storing the particle radius |
---|
| 280 | !-- class. |
---|
[849] | 281 | IF ( collision_kernel == 'none' ) CALL lpm_set_attributes |
---|
[264] | 282 | |
---|
[849] | 283 | |
---|
[264] | 284 | ! |
---|
[1] | 285 | !-- Set particle attributes defined by the user |
---|
[849] | 286 | CALL user_lpm_set_attributes |
---|
[1] | 287 | |
---|
| 288 | |
---|
| 289 | ! |
---|
[849] | 290 | !-- If required, add the current particle positions to the particle tails |
---|
| 291 | IF ( use_particle_tails ) CALL lpm_extend_tails |
---|
[1] | 292 | |
---|
| 293 | |
---|
| 294 | ! |
---|
[849] | 295 | !-- Write particle statistics (in particular the number of particles |
---|
| 296 | !-- exchanged between the subdomains) on file |
---|
| 297 | IF ( write_particle_statistics ) CALL lpm_write_exchange_statistics |
---|
[1] | 298 | |
---|
[849] | 299 | CALL cpu_log( log_point(25), 'lpm', 'stop' ) |
---|
[1] | 300 | |
---|
| 301 | |
---|
[849] | 302 | END SUBROUTINE lpm |
---|