Skip to content

Commit 6cb7958

Browse files
committed
Update field_utils.hpp
1 parent effa1fb commit 6cb7958

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

components/eamxx/src/share/field/field_utils.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,22 @@ void print_field_hyperslab (const Field& f,
313313
{
314314
const auto dt = f.data_type();
315315
const auto rank = f.rank();
316+
const auto& fl = f.get_header().get_identifier().get_layout();
316317

317318
EKAT_REQUIRE_MSG (rank>=static_cast<int>(tags.size()),
318319
"Error! Requested location incompatible with field rank.\n"
319320
" - field name: " + f.name() + "\n"
320321
" - field rank: " + std::to_string(rank) + "\n"
321-
" - requested indices: (" + ekat::join(indices,",") + "\n");
322+
" - requested indices: (" + ekat::join(indices,",") + ")\n");
323+
324+
const int num_indices = indices.size();
325+
for (int i=0; i<num_indices; ++i) {
326+
EKAT_REQUIRE_MSG ( indices[i]>=0 && indices[i]<fl.dim(i),
327+
"Error! Requested index is invalid.\n"
328+
" - field name: " + f.name() + "\n"
329+
" - field layout: " + fl.to_string() + "\n"
330+
" - requested indices: (" + ekat::join(indices,",") + ")\n");
331+
}
322332

323333
switch (dt) {
324334
case DataType::IntType:

0 commit comments

Comments
 (0)