20 #include "sll_assert.h"
21 #include "sll_memory.h"
22 #include "sll_working_precision.h"
50 sll_int32,
dimension(:),
pointer :: pa
51 sll_int32,
dimension(:),
pointer :: pa_save
53 sll_int32 :: num_cells
69 if (.not.
associated(mesh))
then
70 print *,
'ERROR, sll_f_new_particle_sorter_2d(): passed mesh is not ', &
78 sll_allocate(res, ierr)
79 sll_allocate(res%pa(ncx*ncy + 1), ierr)
80 sll_allocate(res%pa_save(ncx*ncy + 1), ierr)
83 res%num_cells = ncx*ncy
93 sll_int32 :: num_cells
94 sll_int32 :: current_cell
96 sll_int32 :: index_out
97 sll_int32 :: index_stop
100 sll_int32,
dimension(:),
pointer :: pa
101 sll_int32,
dimension(:),
pointer :: pa_save
103 if (.not.
associated(sorter%mesh,
target=group%mesh))
then
104 print *,
'ERROR, sll_s_sort_particles_2d(): mesh passed to sorter ', &
105 'and particle group mesh are not the same. Code will not stop ', &
106 'but bad things may happen...'
109 n = group%number_particles
110 num_cells = sorter%num_cells
113 pa_save => sorter%pa_save(:)
118 pa(p(i)%ic) = pa(p(i)%ic) + 1
126 do i = 1, num_cells + 1
134 do while (i < num_cells + 1)
135 if (pa(i) >= pa_save(i + 1))
then
143 index_stop = pa(i) + 1
147 current_cell = p(index_in)%ic
148 pa(current_cell) = pa(current_cell) + 1
149 index_out = pa(current_cell)
150 if (index_out .ne. index_stop)
then
152 p(index_out) = p(index_in)
169 sll_int32 :: num_cells
170 sll_int32 :: current_cell
171 sll_int32 :: index_in
172 sll_int32 :: index_out
173 sll_int32 :: index_stop
176 sll_int32,
dimension(:),
pointer :: pa
177 sll_int32,
dimension(:),
pointer :: pa_save
179 if (.not.
associated(sorter%mesh,
target=group%mesh))
then
180 print *,
'ERROR, sll_s_sort_particles_2d(): mesh passed to sorter ', &
181 'and particle group mesh are not the same. Code will not stop ', &
182 'but bad things may happen...'
185 n = group%number_particles
186 num_cells = sorter%num_cells
189 pa_save => sorter%pa_save(:)
194 pa(p(i)%ic) = pa(p(i)%ic) + 1
202 do i = 1, num_cells + 1
210 do while (i < num_cells + 1)
211 if (pa(i) >= pa_save(i + 1))
then
219 index_stop = pa(i) + 1
223 current_cell = p(index_in)%ic
224 pa(current_cell) = pa(current_cell) + 1
225 index_out = pa(current_cell)
226 if (index_out .ne. index_stop)
then
228 p(index_out) = p(index_in)
240 sll_assert(
associated(sorter))
Cartesian mesh basic types.
type(sll_t_particle_sorter_2d) function, pointer, public sll_f_new_particle_sorter_2d(mesh)
subroutine, public sll_s_sort_particles_2d(sorter, group)
subroutine, public sll_s_sort_gc_particles_2d(sorter, group)
subroutine delete_particle_sorter_2d(sorter)