diff --git a/src/ML-SNAP/compute_sna_grid.cpp b/src/ML-SNAP/compute_sna_grid.cpp index 62778a9e83..2def0cf6a4 100644 --- a/src/ML-SNAP/compute_sna_grid.cpp +++ b/src/ML-SNAP/compute_sna_grid.cpp @@ -37,7 +37,6 @@ ComputeSNAGrid::ComputeSNAGrid(LAMMPS *lmp, int narg, char **arg) : ComputeGrid(lmp, narg, arg), cutsq(nullptr), radelem(nullptr), wjelem(nullptr) { - double rfac0, rmin0; int twojmax, switchflag, bzeroflag, bnormflag, wselfallflag; @@ -208,21 +207,6 @@ void ComputeSNAGrid::compute_array() { invoked_array = update->ntimestep; - // // invoke full neighbor list (will copy or build if necessary) - - // neighbor->build_one(list); - - // int mynxlo = static_cast (comm->xsplit[comm->myloc[0]] * nx); - // int mynxhi = static_cast (comm->xsplit[comm->myloc[0]+1] * nx) - 1; - - // int mynylo = static_cast (comm->ysplit[comm->myloc[1]] * ny); - // int mynyhi = static_cast (comm->ysplit[comm->myloc[1]+1] * ny) - 1; - - // int mynzlo = static_cast (comm->zsplit[comm->myloc[2]] * nz); - // int mynzhi = static_cast (comm->zsplit[comm->myloc[2]+1] * nz) - 1; - - // int myngridlocal = (nxhi - nxlo + 1) * (nyhi - nylo + 1) * (nzhi - nzlo + 1); - // compute sna for each gridpoint double** const x = atom->x; @@ -285,7 +269,7 @@ void ComputeSNAGrid::compute_array() snaptr->compute_zi(); snaptr->compute_bi(ielem); - // linear contributions + // linear contributions for (int icoeff = 0; icoeff < ncoeff; icoeff++) gridlocal[size_array_cols_base+icoeff][iz][iy][ix] = snaptr->blist[icoeff]; @@ -302,16 +286,17 @@ void ComputeSNAGrid::compute_array() } } } - + for (int iz = nzlo; iz <= nzhi; iz++) for (int iy = nylo; iy <= nyhi; iy++) for (int ix = nxlo; ix <= nxhi; ix++) { - const int igrid = iz*(nx*ny) + iy*nx + ix; - for (int j = 0; j < nvalues; j++) - grid[igrid][size_array_cols_base + j] = gridlocal[size_array_cols_base + j][iz][iy][ix]; + const int igrid = iz*(nx*ny) + iy*nx + ix; + for (int j = 0; j < nvalues; j++) + grid[igrid][size_array_cols_base + j] = gridlocal[size_array_cols_base + j][iz][iy][ix]; } MPI_Allreduce(&grid[0][0],&gridall[0][0],ngrid*size_array_cols,MPI_DOUBLE,MPI_SUM,world); + } diff --git a/src/compute_grid.cpp b/src/compute_grid.cpp index 740131deda..0d880b94d5 100644 --- a/src/compute_grid.cpp +++ b/src/compute_grid.cpp @@ -207,8 +207,11 @@ void ComputeGrid::allocate() memory->destroy(local_flags); if (gridlocal_allocated) { gridlocal_allocated = 0; - // can't seem to do this without seg-fault + // MEMORY LEAK!! + // can't seem to free this memory without seg-fault + // printf("Before allocate destroy4d, proc %d %p\n",comm->me,gridlocal); // memory->destroy4d_offset(gridlocal,nzlo,nylo,nxlo); + // printf("After allocate destroy4d, proc %d %p\n",comm->me,gridlocal); } memory->create(grid,size_array_rows,size_array_cols,"grid:grid"); @@ -310,7 +313,6 @@ void ComputeGrid::set_grid_local() ngridlocal = (nxhi - nxlo + 1) * (nyhi - nylo + 1) * (nzhi - nzlo + 1); - printf("me = %d n = %d x %d %d y %d %d z %d %d \n", comm->me, ngridlocal, nxlo, nxhi, nylo, nyhi, nzlo, nzhi); } /* ----------------------------------------------------------------------