From 4447932d6ce99ac17473c16631c045adfa7b34c5 Mon Sep 17 00:00:00 2001 From: nscepi Date: Fri, 13 Dec 2024 15:17:08 +0100 Subject: [PATCH 1/2] Add error message when total grid size is not a multiple of nb mpi procs --- src/grid.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/grid.cpp b/src/grid.cpp index e4c6b7b4..fab84816 100644 --- a/src/grid.cpp +++ b/src/grid.cpp @@ -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) @@ -185,7 +193,7 @@ Grid::Grid(Input &input) { int ntot=1; for(int dir=0 ; dir < DIMENSIONS; dir++) { nproc[dir] = input.Get("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 From 144777830a566877049349177bbd201d21fecb25 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:41:45 +0000 Subject: [PATCH 2/2] [pre-commit.ci lite] apply automatic fixes --- src/grid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grid.cpp b/src/grid.cpp index fab84816..ace5eb0c 100644 --- a/src/grid.cpp +++ b/src/grid.cpp @@ -167,7 +167,7 @@ Grid::Grid(Input &input) { // 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 + // 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)