Skip to content

Commit

Permalink
fix allocation blunder
Browse files Browse the repository at this point in the history
  • Loading branch information
CyprienBosserelle committed Oct 3, 2024
1 parent 6c7489d commit c5c3cbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/InitialConditions.cu
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ template <class T> void InitRivers(Param XParam, Forcing<float> &XForcing, Model
}

// Allocate XXbidir and Xridib
AllocateCPU(nribmax, nburmax, XModel.bndblk.Riverinfo.Xbidir);
AllocateCPU(nribmax, nburmax, XModel.bndblk.Riverinfo.Xridib);
ReallocArray(nribmax, nburmax, XModel.bndblk.Riverinfo.Xbidir);
ReallocArray(nribmax, nburmax, XModel.bndblk.Riverinfo.Xridib);

// Fill them with a flag value
FillCPU(nribmax, nburmax, -1, XModel.bndblk.Riverinfo.Xbidir);
Expand Down Expand Up @@ -440,14 +440,14 @@ template <class T> void InitRivers(Param XParam, Forcing<float> &XForcing, Model

if (std::find(blocksalreadyin[iribm].block.begin(), blocksalreadyin[iribm].block.end(), uniqblockforriver[bir]) != blocksalreadyin[iribm].block.end())
{
//Found;
//block found already listed in that line;

continue;
}
else
{
//not found;

// write to the array
XModel.bndblk.Riverinfo.Xbidir[iriv[iribm] + iribm * nburmax] = uniqblockforriver[bir];
XModel.bndblk.Riverinfo.Xridib[iriv[iribm] + iribm * nburmax] = Rin;

Expand All @@ -456,7 +456,8 @@ template <class T> void InitRivers(Param XParam, Forcing<float> &XForcing, Model
// add it to the list
blocksalreadyin[iribm].block.push_back(uniqblockforriver[bir]);

// write to the array


break;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/MemManagement.cu
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ void AllocateCPU(int nblk, int blksize, Param XParam, Model<T>& XModel)
//this will be eventually reallocated later
AllocateCPU(1, 1, XModel.bndblk.river);
XModel.bndblk.nblkriver = 1;

AllocateCPU(1, 1, XModel.bndblk.Riverinfo.Xbidir);
AllocateCPU(1, 1, XModel.bndblk.Riverinfo.Xridib);
}
// preallocate 1 block along all bnds
//this will be eventually reallocated later
Expand Down

0 comments on commit c5c3cbe

Please sign in to comment.