Skip to content

Commit 67149ba

Browse files
Change NProcs <= NStep Assert into Warning (#1386)
1 parent 1896afd commit 67149ba

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

docs/source/run/parameters.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ General parameters
188188
Note that z refers to the location of the beam particle inside the moving frame of reference
189189
(zeta) and t to the physical time of the current time step.
190190

191+
* ``hipace.ignore_noncritical_warnings`` (`bool`) optional (default `0`)
192+
Don't crash the simulation from assertions that check for suboptimal input parameters
193+
but are not needed for correctness.
194+
191195
Geometry
192196
--------
193197

src/Hipace.H

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ struct Hipace_early_init
7676

7777
/* Number of mesh refinement levels */
7878
int m_N_level = 1;
79+
80+
/* Don't stop the simulation if user inputs are potentially suboptimal */
81+
inline static bool m_ignore_noncritical_warnings = false;
7982
};
8083

8184
/** \brief Singleton class that initializes, runs and finalizes the simulation */

src/Hipace.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Hipace_early_init::Hipace_early_init (Hipace* instance)
5858
int max_level = 0;
5959
queryWithParser(pp_amr, "max_level", max_level);
6060
m_N_level = max_level + 1;
61+
queryWithParser(pph, "ignore_noncritical_warnings", m_ignore_noncritical_warnings);
6162
AnyFFT::setup();
6263
}
6364

@@ -118,8 +119,15 @@ Hipace::ReadParameters ()
118119
queryWithParser(pph, "max_time", m_max_time);
119120
queryWithParser(pph, "verbose", m_verbose);
120121
m_numprocs = amrex::ParallelDescriptor::NProcs();
121-
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_numprocs <= m_max_step+1,
122-
"Please use more or equal time steps than number of ranks");
122+
if (m_ignore_noncritical_warnings) {
123+
if (m_numprocs > m_max_step + 1 && amrex::ParallelDescriptor::IOProcessor()) {
124+
amrex::OutStream()
125+
<< "WARNING: Please use more or equal time steps than the number of MPI ranks\n";
126+
}
127+
} else {
128+
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_numprocs <= m_max_step + 1,
129+
"Please use more or equal time steps than the number of MPI ranks");
130+
}
123131
queryWithParser(pph, "predcorr_B_error_tolerance", m_predcorr_B_error_tolerance);
124132
queryWithParser(pph, "predcorr_max_iterations", m_predcorr_max_iterations);
125133
queryWithParser(pph, "predcorr_B_mixing_factor", m_predcorr_B_mixing_factor);

0 commit comments

Comments
 (0)