From 0d4afe1d2d8ba858b4f1774f57030910d33e8cfc Mon Sep 17 00:00:00 2001 From: Manas Rachh Date: Thu, 20 Jul 2023 15:48:45 -0400 Subject: [PATCH] fixing memory leak in l3dtrans --- src/Laplace/l3dtrans.f | 22 ++++++++++++++-------- test/Laplace/test_laprouts3d.f | 4 ++-- test/Laplace/test_laprouts3d.make | 4 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Laplace/l3dtrans.f b/src/Laplace/l3dtrans.f index 44fb9fbf..a076ba57 100644 --- a/src/Laplace/l3dtrans.f +++ b/src/Laplace/l3dtrans.f @@ -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: @@ -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)* @@ -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) @@ -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 diff --git a/test/Laplace/test_laprouts3d.f b/test/Laplace/test_laprouts3d.f index b4c0fe8a..d2703283 100644 --- a/test/Laplace/test_laprouts3d.f +++ b/test/Laplace/test_laprouts3d.f @@ -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)) @@ -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) diff --git a/test/Laplace/test_laprouts3d.make b/test/Laplace/test_laprouts3d.make index 89a4cebf..053d623e 100644 --- a/test/Laplace/test_laprouts3d.make +++ b/test/Laplace/test_laprouts3d.make @@ -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