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

Commit

Permalink
Fixed array indexing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Sep 13, 2021
1 parent 5c5d498 commit 138fb56
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile.Defines
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ GMEM = -fsanitize-address-use-after-scope -fstack-check -fsanitize=bounds-stri
GWARNINGS = -Wall -Warray-bounds -Wimplicit-interface -Wextra -Warray-temporaries
GPRODUCTION = -O2 -ffree-line-length-none $(GPAR)

#FFLAGS = $(IPRODUCTION) $(OPTREPORT)
#FFLAGS = $(IDEBUG) $(SIMDVEC) $(PAR)
#FFLAGS = $(IPRODUCTION) $(OPTREPORT) $(ADVIXE_FLAGS)
FFLAGS = -O3 $(PAR) $(OPTREPORT) $(SIMDVEC) -shared-intel -debug inline-debug-info -DTBB_DEBUG -DTBB_USE_THREADING_TOOLS -traceback -g
FFLAGS = -O3 $(PAR) $(OPTREPORT) $(SIMDVEC) # -shared-intel -debug inline-debug-info -DTBB_DEBUG -DTBB_USE_THREADING_TOOLS -traceback -g
FORTRAN = ifort
#AR = xiar

Expand Down
7 changes: 5 additions & 2 deletions src/symba/symba_encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ module function symba_encounter_check_pl(self, system, dt, irec) result(lany_enc
! Result
logical :: lany_encounter !! Returns true if there is at least one close encounter
! Internals
integer(I8B) :: k, nplplm
integer(I4B) :: i, j, nenc
integer(I8B) :: k, nplplm, kenc
integer(I4B) :: i, j, nenc, npl
logical, dimension(:), allocatable :: lencounter, loc_lvdotr, lvdotr
integer(I4B), dimension(:), allocatable :: index1, index2

if (self%nbody == 0) return

associate(pl => self)
nplplm = pl%nplplm
npl = pl%nbody
allocate(lencounter(nplplm))
allocate(loc_lvdotr(nplplm))

Expand All @@ -88,6 +89,8 @@ module function symba_encounter_check_pl(self, system, dt, irec) result(lany_enc
do k = 1, nenc
i = plplenc_list%index1(k)
j = plplenc_list%index2(k)
call util_index_eucl_ij_to_k(npl, i, j, kenc)
plplenc_list%kidx(k) = kenc
plplenc_list%id1(k) = pl%id(plplenc_list%index1(k))
plplenc_list%id2(k) = pl%id(plplenc_list%index2(k))
plplenc_list%status(k) = ACTIVE
Expand Down
17 changes: 9 additions & 8 deletions src/symba/symba_kick.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ module subroutine symba_kick_getacch_pl(self, system, param, t, lbeg)
associate(pl => self, npl => self%nbody, plplenc_list => system%plplenc_list, radius => self%radius)
! Apply kicks to all bodies (including those in the encounter list)
call helio_kick_getacch_pl(pl, system, param, t, lbeg)

! Remove kicks from bodies involved currently in the encounter list, as these are dealt with separately.
nplplenc = int(plplenc_list%nenc, kind=I8B)
allocate(k_plpl_enc(2,nplplenc))
k_plpl_enc(:,1:nplplenc) = pl%k_plpl(:,plplenc_list%kidx(1:nplplenc))
ah_enc(:,:) = 0.0_DP
call kick_getacch_int_all_pl(npl, nplplenc, k_plpl_enc, pl%xh, pl%Gmass, pl%radius, ah_enc)
pl%ah(:,1:npl) = pl%ah(:,1:npl) - ah_enc(:,1:npl)
if (plplenc_list%nenc > 0) then
! Remove kicks from bodies involved currently in the encounter list, as these are dealt with separately.
nplplenc = int(plplenc_list%nenc, kind=I8B)
allocate(k_plpl_enc(2,nplplenc))
k_plpl_enc(:,1:nplplenc) = pl%k_plpl(:,plplenc_list%kidx(1:nplplenc))
ah_enc(:,:) = 0.0_DP
call kick_getacch_int_all_pl(npl, nplplenc, k_plpl_enc, pl%xh, pl%Gmass, pl%radius, ah_enc)
pl%ah(:,1:npl) = pl%ah(:,1:npl) - ah_enc(:,1:npl)
end if

end associate
end select
Expand Down

0 comments on commit 138fb56

Please sign in to comment.