@@ -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