Skip to content

Commit 2a395ba

Browse files
authored
Merge pull request #301 from nscepi/master
Add error message when total grid size is not a multiple of nb mpi procs
2 parents 4dd1f5a + 1447778 commit 2a395ba

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/grid.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,16 @@ Grid::Grid(Input &input) {
158158
for(int i=0 ; i < 3 ; i++)
159159
period[i] = 0;
160160

161-
// Check if the dec option has been passed when number of procs > 1
161+
// Check that number of procs > 1
162162
if(idfx::psize>1) {
163+
int ngridtot=1;
164+
for(int dir=0 ; dir < DIMENSIONS; dir++) {
165+
ngridtot *= np_int[dir];
166+
}
167+
// Check that the total grid dimension is effectively divisible by number of procs
168+
if(ngridtot % idfx::psize)
169+
IDEFIX_ERROR("Total grid size must be a multiple of the number of mpi process");
170+
// Check that dec option has been passed
163171
if(input.CheckEntry("CommandLine","dec") != DIMENSIONS) {
164172
// No command line decomposition, make auto-decomposition if possible
165173
// (only when nproc and dimensions are powers of 2, and in 1D)
@@ -185,7 +193,7 @@ Grid::Grid(Input &input) {
185193
int ntot=1;
186194
for(int dir=0 ; dir < DIMENSIONS; dir++) {
187195
nproc[dir] = input.Get<int>("CommandLine","dec",dir);
188-
// Check that the dimension is effectively divisible by number of procs
196+
// Check that the dimension is effectively divisible by number of procs along each direction
189197
if(np_int[dir] % nproc[dir])
190198
IDEFIX_ERROR("Grid size must be a multiple of the domain decomposition");
191199
// Count the total number of procs we'll need for the specified domain decomposition

0 commit comments

Comments
 (0)