55 logical :: coag_kernel_bounds_valid
58 real(kind=
dp),
allocatable,
dimension(:,:) :: coag_kernel_min
61 real(kind=
dp),
allocatable,
dimension(:,:) :: coag_kernel_max
63 logical :: removal_rate_bounds_valid
65 real(kind=
dp),
allocatable,
dimension(:) :: removal_rate_max
123 integer,
intent(in) :: n_group
125 integer,
intent(in) :: n_class
132 aero_sorted%coag_kernel_bounds_valid = .false.
133 if (
allocated(aero_sorted%coag_kernel_min))
then
134 deallocate(aero_sorted%coag_kernel_min)
136 allocate(aero_sorted%coag_kernel_min(n_bin, n_bin))
137 if (
allocated(aero_sorted%coag_kernel_max))
then
138 deallocate(aero_sorted%coag_kernel_max)
140 allocate(aero_sorted%coag_kernel_max(n_bin, n_bin))
141 aero_sorted%removal_rate_bounds_valid = .false.
142 if (
allocated(aero_sorted%removal_rate_max))
then
143 deallocate(aero_sorted%removal_rate_max)
145 allocate(aero_sorted%removal_rate_max(n_bin))
146 aero_sorted%bin_grid = bin_grid
154 aero_particle_array, aero_data)
163 integer :: i_part, i_bin
167 do i_part = aero_particle_array%n_part,1,-1
169 aero_particle_array%particle(i_part), aero_data)
170 if ((i_bin < 1) .or. (i_bin >
bin_grid_size(aero_sorted%bin_grid)))
then
171 call warn_msg(954800836,
"particle ID " &
173 aero_particle_array%particle(i_part)%id)) &
174 //
" outside of bin_grid, discarding")
195 integer :: i_part, i_bin, i_group, i_class
200 do i_part = 1,aero_particle_array%n_part
202 aero_particle_array%particle(i_part), aero_data)
203 i_group = aero_particle_array%particle(i_part)%weight_group
204 i_class = aero_particle_array%particle(i_part)%weight_class
215 aero_data, valid_sort, n_group, n_class, bin_grid, all_procs_same)
224 logical,
intent(in) :: valid_sort
226 integer,
optional,
intent(in) :: n_group
228 integer,
optional,
intent(in) :: n_class
230 type(
bin_grid_t),
optional,
intent(in) :: bin_grid
232 logical,
optional,
intent(in) :: all_procs_same
234 integer :: i_bin, i_bin_min, i_bin_max, i_part, n_bin, use_n_group
235 integer :: use_n_class
236 real(kind=
dp) :: r, r_min, r_max, grid_r_min, grid_r_max
237 real(kind=
dp) :: local_r_min, local_r_max
238 logical :: need_new_bin_grid
241 if (
present(n_group))
then
242 call assert(267881270,
present(n_class))
243 use_n_group = n_group
244 use_n_class = n_class
246 call assert(352582858, valid_sort)
251 if (
present(bin_grid))
then
255 aero_particle_array, aero_data)
261 need_new_bin_grid = .false.
272 aero_sorted%size_class%inverse(i_bin, :))) > 0)
then
273 if (i_bin_min == 0)
then
280 if (i_bin_min == 0)
then
282 call assert(333430891, i_bin_max == 0)
285 r_min = aero_sorted%bin_grid%edges( &
287 r_max = aero_sorted%bin_grid%edges(1)
290 r_min = aero_sorted%bin_grid%edges(i_bin_min)
291 r_max = aero_sorted%bin_grid%edges(i_bin_max + 1)
295 do i_part = 1,aero_particle_array%n_part
298 if (i_part == 1)
then
302 r_min = min(r_min, r)
303 r_max = max(r_max, r)
308 if (
present(all_procs_same))
then
309 if (all_procs_same)
then
314 if (r_min == 0d0)
then
323 need_new_bin_grid = .true.
329 if (r_max == 0d0)
then
330 if (valid_sort)
return
339 need_new_bin_grid = .true.
341 grid_r_min = aero_sorted%bin_grid%edges(1)
342 grid_r_max = aero_sorted%bin_grid%edges( &
350 need_new_bin_grid = .true.
354 if (need_new_bin_grid)
then
357 n_bin = ceiling((log10(grid_r_max) - log10(grid_r_min)) &
367 if (.not. valid_sort)
then
398 aero_particle, aero_data, allow_resort)
409 logical,
optional,
intent(in) :: allow_resort
411 integer :: i_bin, i_group, i_class, n_bin, n_group, n_class
415 i_group = aero_particle%weight_group
416 i_class = aero_particle%weight_class
421 call assert(417177855, (i_group >= 1) .and. (i_group <= n_group))
422 call assert(233133947, (i_class >= 1) .and. (i_class <= n_class))
427 if ((i_bin < 1) .or. (i_bin > n_bin))
then
432 if (
present(allow_resort))
then
433 if (.not. allow_resort)
then
437 call die_msg(134572570,
"particle outside of bin_grid: " &
438 //
"try reducing the timestep del_t")
442 aero_data, valid_sort=.false., n_group=n_group, n_class=n_class)
463 integer,
intent(in) :: i_part
476 new_group, new_class)
481 integer,
intent(in) :: i_part
483 integer,
intent(in) :: new_bin
485 integer,
intent(in) :: new_group
487 integer,
intent(in) :: new_class
500 aero_data, n_group, n_class, continue_on_error)
509 integer,
optional,
intent(in) :: n_group
511 integer,
optional,
intent(in) :: n_class
513 logical,
intent(in) :: continue_on_error
515 integer :: i_part, i_bin
518 n_domain=aero_particle_array%n_part, &
519 n_range_1=
bin_grid_size(aero_sorted%bin_grid), n_range_2=n_class, &
520 continue_on_error=continue_on_error)
521 do i_part = 1,aero_particle_array%n_part
523 aero_particle_array%particle(i_part), aero_data)
524 if ((i_bin /= aero_sorted%size_class%forward1%entry(i_part)) &
525 .or. (i_bin /= aero_sorted%size_class%forward1%entry(i_part)))
then
526 write(0,*)
'ERROR aero_sorted A: ',
"size_class"
527 write(0,*)
'i_part', i_part
528 write(0,*)
'i_bin', i_bin
529 write(0,*)
'aero_sorted%size_class%forward1%entry(i_part)', &
530 aero_sorted%size_class%forward1%entry(i_part)
531 write(0,*)
'aero_sorted%size_class%forward2%entry(i_part)', &
532 aero_sorted%size_class%forward2%entry(i_part)
533 call assert(565030916, continue_on_error)
538 n_domain=aero_particle_array%n_part, &
539 n_range_1=n_group, n_range_2=n_class, &
540 continue_on_error=continue_on_error)
541 do i_part = 1,aero_particle_array%n_part
542 if ((aero_particle_array%particle(i_part)%weight_group &
543 /= aero_sorted%group_class%forward1%entry(i_part)) &
544 .or. (aero_particle_array%particle(i_part)%weight_class &
545 /= aero_sorted%group_class%forward2%entry(i_part)))
then
546 write(0,*)
'ERROR aero_sorted B: ',
"group_class"
547 write(0,*)
'i_part', i_part
548 write(0,*)
'aero_particle_array%particle(i_part)%weight_group', &
549 aero_particle_array%particle(i_part)%weight_group
550 write(0,*)
'aero_particle_array%particle(i_part)%weight_class', &
551 aero_particle_array%particle(i_part)%weight_class
552 write(0,*)
'aero_sorted%group_class%forward1%entry(i_part)', &
553 aero_sorted%group_class%forward1%entry(i_part)
554 write(0,*)
'aero_sorted%group_class%forward2%entry(i_part)', &
555 aero_sorted%group_class%forward2%entry(i_part)
556 call assert(803595412, continue_on_error)
570 integer :: total_size
586 character,
intent(inout) :: buffer(:)
588 integer,
intent(inout) :: position
593 integer :: prev_position
595 prev_position = position
611 character,
intent(inout) :: buffer(:)
613 integer,
intent(inout) :: position
618 integer :: prev_position, n_bin, n_group, n_class
620 prev_position = position