Skip to content

Commit

Permalink
fixing memory leak in l3dtrans
Browse files Browse the repository at this point in the history
  • Loading branch information
mrachh committed Jul 20, 2023
1 parent b83b6ec commit 0d4afe1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
22 changes: 14 additions & 8 deletions src/Laplace/l3dtrans.f
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ subroutine l3dmpmpzshift(nd,scale,mpole,lmp,nterms,scale2,mpolen,
c***********************************************************************
c
c This subroutine converts a multipole expansion centered at the
c origin to a multipole expansion centered at (0,0,zhift).
c origin to a multipole expansion centered at (0,0,zshift).
c The expansion is rescaled to that of the shifted expansion.
c
c INPUT:
Expand Down Expand Up @@ -208,9 +208,9 @@ subroutine l3dmpmpzshift(nd,scale,mpole,lmp,nterms,scale2,mpolen,
l0 = max(0,jnew-nterms)
do knew = -jnew,jnew
do idim=1,nd
mpolen(idim,jnew,knew) = 0.0d0
mpolen(idim,jnew,knew) = 0.0d0
enddo
do l=l0,jnew-iabs(knew)
do l=l0,jnew-iabs(knew)
do idim=1,nd
mpolen(idim,jnew,knew)=mpolen(idim,jnew,knew)+
1 mpole(idim,jnew-l,knew)*fr(l)*dc(jnew-knew,l)*
Expand Down Expand Up @@ -423,7 +423,7 @@ subroutine l3dmploczshift(nd,mpole,scale,lmp,nterms,local,
do jnew = 0,nterms2
do knew = -jnew,jnew
do idim=1,nd
local(idim,jnew,knew) = 0.0d0
local(idim,jnew,knew) = 0.0d0
enddo
kk =iabs(knew)
msign = (-1)**(jnew+knew)
Expand Down Expand Up @@ -639,15 +639,21 @@ subroutine l3dlocloczshift(nd,scale,locold,lmp,nterms,scale2,

d = scale2/scale
rscpow(1) = d
do l=2,nterms
do l=2,nterms2
rscpow(l) = rscpow(l-1)*d
enddo

do jnew = 0,nterms2
do knew = -jnew,jnew
do idim=1,nd
local(idim,jnew,knew) = locold(idim,jnew,knew)
enddo
if(jnew.le.nterms) then
do idim=1,nd
local(idim,jnew,knew) = locold(idim,jnew,knew)
enddo
else
do idim=1,nd
local(idim,jnew,knew) = 0.0d0
enddo
endif

do l=1,nterms-jnew
ll = l+jnew
Expand Down
4 changes: 2 additions & 2 deletions test/Laplace/test_laprouts3d.f
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
write(*,*) "=========================================="
write(*,*) "Testing suite for laprouts3d"

lw7 = 100000
lw7 = 200000
ll = lw7
allocate(wlege(ll))
allocate(scarray_mp(ll),scarray_loc(ll))
Expand Down Expand Up @@ -173,7 +173,7 @@
call l3dterms(eps, nterms2)
call l3dterms(eps, nterms3)

nterms2 = nterms + 5
nterms2 = nterms - 5
nterms3 = nterms + 10

nmax = max(nterms,nterms2)
Expand Down
4 changes: 2 additions & 2 deletions test/Laplace/test_laprouts3d.make
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ PROJECT = int2-laprouts3d

ifeq ($(HOST),gcc)
FC=gfortran
FFLAGS=-fPIC -O3 -funroll-loops -march=native -std=legacy
FFLAGS=-fPIC -O3 -funroll-loops -march=x86-64 -std=legacy
endif

ifeq ($(HOST),gcc-openmp)
FC = gfortran
FFLAGS=-fPIC -O3 -funroll-loops -march=native -fopenmp -std=legacy
FFLAGS=-fPIC -O3 -funroll-loops -march=x86-64 -fopenmp -std=legacy
endif

# Test objects
Expand Down

0 comments on commit 0d4afe1

Please sign in to comment.