Skip to content

Commit 8d049e2

Browse files
committed
Check only one component can make final write
1 parent c546b48 commit 8d049e2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/component_scheduler.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ sortComponents(std::vector<std::unique_ptr<Component>>&& components) {
203203
// Components which do a final write on a variable depend on all
204204
// components which do non-final writes on that variable
205205
for (const auto& [var, comp_indices] : final_writes) {
206+
if (comp_indices.size() > 1) {
207+
throw BoutException(
208+
"Multiple components have permission to make final write to variable {}", var);
209+
}
206210
for (size_t i : comp_indices) {
207211
const auto item = nonfinal_writes.find(var);
208212
if (item != nonfinal_writes.end()) {

tests/unit/test_component_scheduler.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ INSTANTIATE_TEST_SUITE_P(
276276
{"b",
277277
{{"type", "orderchecker"},
278278
{"permissions", toString(Permissions({readWrite("3")}))}}}}),
279+
// Multiple final writes
280+
Options({{"components", "a,b"},
281+
{"a",
282+
{{"type", "orderchecker"},
283+
{"permissions", toString(Permissions({writeFinal("1")}))}}},
284+
{"b",
285+
{{"type", "orderchecker"},
286+
{"permissions", toString(Permissions({writeFinal("1")}))}}}}),
279287
// Circular dependency
280288
Options({{"components", "a,b"},
281289
{"a",

0 commit comments

Comments
 (0)