Skip to content

Commit 1c3c9fa

Browse files
authored
Merge pull request #3306 from boutproject/more-debug
Improve saveParallel
2 parents 78bbcd1 + a164799 commit 1c3c9fa

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/sys/options.cxx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,18 @@ void saveParallel(Options& opt, const std::string& name, const Field3D& tosave)
364364
Field3D tmp;
365365
tmp.allocate();
366366
const auto& fpar = tosave.ynext(i);
367-
for (auto j : fpar.getValidRegionWithDefault("RGN_NO_BOUNDARY")) {
368-
tmp[j.yp(-i)] = fpar[j];
367+
if (fpar.isAllocated()) {
368+
for (auto j : tmp.getRegion("RGN_NOY")) {
369+
tmp[j] = fpar[j.yp(i)];
370+
}
371+
opt[fmt::format("{}_y{:+d}", name, i)] = tmp;
372+
} else {
373+
if (tosave.isFci()) { // likely an error
374+
throw BoutException(
375+
"Tried to save parallel fields - but parallel field {} is not allocated",
376+
i);
377+
}
369378
}
370-
opt[fmt::format("{}_y{:+d}", name, i)] = tmp;
371379
}
372380
}
373381
}

0 commit comments

Comments
 (0)