Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error message when total grid size is not a multiple of nb mpi procs #301

Merged
merged 2 commits into from
Dec 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,16 @@ Grid::Grid(Input &input) {
for(int i=0 ; i < 3 ; i++)
period[i] = 0;

// Check if the dec option has been passed when number of procs > 1
// Check that number of procs > 1
if(idfx::psize>1) {
int ngridtot=1;
for(int dir=0 ; dir < DIMENSIONS; dir++) {
ngridtot *= np_int[dir];
}
// Check that the total grid dimension is effectively divisible by number of procs
if(ngridtot % idfx::psize)
IDEFIX_ERROR("Total grid size must be a multiple of the number of mpi process");
// Check that dec option has been passed
if(input.CheckEntry("CommandLine","dec") != DIMENSIONS) {
// No command line decomposition, make auto-decomposition if possible
// (only when nproc and dimensions are powers of 2, and in 1D)
Expand All @@ -185,7 +193,7 @@ Grid::Grid(Input &input) {
int ntot=1;
for(int dir=0 ; dir < DIMENSIONS; dir++) {
nproc[dir] = input.Get<int>("CommandLine","dec",dir);
// Check that the dimension is effectively divisible by number of procs
// Check that the dimension is effectively divisible by number of procs along each direction
if(np_int[dir] % nproc[dir])
IDEFIX_ERROR("Grid size must be a multiple of the domain decomposition");
// Count the total number of procs we'll need for the specified domain decomposition
Expand Down
Loading