diff --git a/src/sys/options.cxx b/src/sys/options.cxx index 0a68bab124..7c6f36f85a 100644 --- a/src/sys/options.cxx +++ b/src/sys/options.cxx @@ -364,10 +364,18 @@ void saveParallel(Options& opt, const std::string& name, const Field3D& tosave) Field3D tmp; tmp.allocate(); const auto& fpar = tosave.ynext(i); - for (auto j : fpar.getValidRegionWithDefault("RGN_NO_BOUNDARY")) { - tmp[j.yp(-i)] = fpar[j]; + if (fpar.isAllocated()) { + for (auto j : tmp.getRegion("RGN_NOY")) { + tmp[j] = fpar[j.yp(i)]; + } + opt[fmt::format("{}_y{:+d}", name, i)] = tmp; + } else { + if (tosave.isFci()) { // likely an error + throw BoutException( + "Tried to save parallel fields - but parallel field {} is not allocated", + i); + } } - opt[fmt::format("{}_y{:+d}", name, i)] = tmp; } } }