Skip to content

Commit

Permalink
ParmParse: Fix assertion in new queryarr for IntVect & RealVect (#4051)
Browse files Browse the repository at this point in the history
For query functions, we should not assert the size unless the name
actually exists.

This fixes a bug in the new functions added in #4050.
  • Loading branch information
WeiqunZhang committed Jul 28, 2024
1 parent 6975ae0 commit 20e6f2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Src/Base/AMReX_ParmParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,8 +1774,8 @@ ParmParse::queryarr (const char* name, IntVect& ref) const
{
std::vector<int> v;
int exist = this->queryarr(name, v);
AMREX_ALWAYS_ASSERT(v.size() == AMREX_SPACEDIM);
if (exist) {
AMREX_ALWAYS_ASSERT(v.size() == AMREX_SPACEDIM);
for (int i = 0; i < AMREX_SPACEDIM; ++i) { ref[i] = v[i]; }
}
return exist;
Expand All @@ -1795,8 +1795,8 @@ ParmParse::queryarr (const char* name, RealVect& ref) const
{
std::vector<Real> v;
int exist = this->queryarr(name, v);
AMREX_ALWAYS_ASSERT(v.size() == AMREX_SPACEDIM);
if (exist) {
AMREX_ALWAYS_ASSERT(v.size() == AMREX_SPACEDIM);
for (int i = 0; i < AMREX_SPACEDIM; ++i) { ref[i] = v[i]; }
}
return exist;
Expand Down

0 comments on commit 20e6f2e

Please sign in to comment.