Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
More tweaks to encounter check subroutines for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 9, 2021
1 parent b958476 commit 688511f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/encounter/encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -868,17 +868,18 @@ module subroutine encounter_check_collapse_ragged_list(ragged_list, n1, nenc, in
end subroutine encounter_check_collapse_ragged_list


pure subroutine encounter_check_make_ragged_list(lencounteri, ind_arr, lenci)
pure subroutine encounter_check_make_ragged_list(lencounteri, ind_arr, nenc,index2)
implicit none
! Arguments
logical, dimension(:), intent(in) :: lencounteri
integer(I4B), dimension(:), intent(in) :: ind_arr
type(encounter_list), intent(out) :: lenci
integer(I4B), intent(out) :: nenc
integer(I4B), dimension(:), allocatable, intent(out) :: index2

lenci%nenc = count(lencounteri(:))
if (lenci%nenc > 0) then
allocate(lenci%index2(lenci%nenc))
lenci%index2(:) = pack(ind_arr(:), lencounteri(:))
nenc = count(lencounteri(:))
if (nenc > 0) then
allocate(index2(nenc))
index2(:) = pack(ind_arr(:), lencounteri(:))
end if

return
Expand Down Expand Up @@ -1017,7 +1018,7 @@ subroutine encounter_check_sweep_aabb_all_double_list(n1, n2, ext_ind, ibegx, ie
ibegyi = ibegy(i)
iendyi = iendy(i)
call encounter_check_sweep_aabb_one_double_list(i, n1, n2, ntot, ext_ind(:), ibegxi, iendxi, ibegyi, iendyi, ibegx(:), iendx(:), ibegy(:), iendy(:), lencounteri(:))
call encounter_check_make_ragged_list(lencounteri(:), ind_arr(:), lenc(i))
call encounter_check_make_ragged_list(lencounteri(:), ind_arr(:), lenc(i)%nenc, lenc(i)%index2)
else
lenc(i)%nenc = 0
end if
Expand Down Expand Up @@ -1055,7 +1056,7 @@ subroutine encounter_check_sweep_aabb_all_single_list(n, ext_ind, ibegx, iendx,
ibegyi = ibegy(i)
iendyi = iendy(i)
call encounter_check_sweep_aabb_one_single_list(n, ext_ind(:), ibegxi, iendxi, ibegyi, iendyi, ibegx(:), iendx(:), ibegy(:), iendy(:), lencounteri(:))
call encounter_check_make_ragged_list(lencounteri(:), ind_arr(:), lenc(i))
call encounter_check_make_ragged_list(lencounteri(:), ind_arr(:), lenc(i)%nenc, lenc(i)%index2)
else
lenc(i)%nenc = 0
end if
Expand Down
2 changes: 1 addition & 1 deletion src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module subroutine encounter_check_collapse_ragged_list(ragged_list, n1, nenc, in
logical, dimension(:), allocatable, intent(out), optional :: lvdotr !! Array indicating which bodies are approaching
end subroutine encounter_check_collapse_ragged_list

module pure subroutine encounter_check_sort_aabb_1D(self, n, extent_arr)
module subroutine encounter_check_sort_aabb_1D(self, n, extent_arr)
implicit none
class(encounter_bounding_box_1D), intent(inout) :: self !! Bounding box structure along a single dimension
integer(I4B), intent(in) :: n !! Number of bodies with extents
Expand Down

0 comments on commit 688511f

Please sign in to comment.