From 547c5a356c09a91c8cabb92369d5205e9c75e76a Mon Sep 17 00:00:00 2001 From: Philipp Grete Date: Mon, 16 Dec 2024 11:52:35 +0100 Subject: [PATCH] Only rank0 writes energy timings --- inputs/exacb_turbulence.in | 2 +- src/hydro/hydro.cpp | 8 ++++---- src/hydro/hydro_driver.cpp | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/inputs/exacb_turbulence.in b/inputs/exacb_turbulence.in index ad856774..0f010999 100644 --- a/inputs/exacb_turbulence.in +++ b/inputs/exacb_turbulence.in @@ -7,7 +7,7 @@ problem_id = turbulence cycle_start = 50 -cycle_end = 250 +cycle_stop = 250 cfl = 0.3 # The Courant, Friedrichs, & Lewy (CFL) Number diff --git a/src/hydro/hydro.cpp b/src/hydro/hydro.cpp index 18dd56b8..80e1c5a5 100644 --- a/src/hydro/hydro.cpp +++ b/src/hydro/hydro.cpp @@ -681,14 +681,14 @@ std::shared_ptr Initialize(ParameterInput *pin) { // EXACB custom modifications for power measurements if (pin->DoesBlockExist("exacb/power")) { const auto start = pin->GetOrAddInteger("exacb/power", "cycle_start", 50); - const auto end = pin->GetOrAddInteger("exacb/power", "cycle_stop", 250); - PARTHENON_REQUIRE_THROWS(end > start, "Measuring backwards does not make sense."); + const auto stop = pin->GetOrAddInteger("exacb/power", "cycle_stop", 250); + PARTHENON_REQUIRE_THROWS(stop > start, "Measuring backwards does not make sense."); const auto nlim = pin->GetInteger("parthenon/time", "nlim"); - PARTHENON_REQUIRE_THROWS(nlim < 0 || nlim >= end, "end must be within nlim"); + PARTHENON_REQUIRE_THROWS(nlim < 0 || nlim >= stop, "stop must be within nlim"); pkg->AddParam("exacb/power/start", start); - pkg->AddParam("exacb/power/end", end); + pkg->AddParam("exacb/power/stop", stop); } if (ProblemInitPackageData != nullptr) { diff --git a/src/hydro/hydro_driver.cpp b/src/hydro/hydro_driver.cpp index 46a55b71..2337495f 100644 --- a/src/hydro/hydro_driver.cpp +++ b/src/hydro/hydro_driver.cpp @@ -13,6 +13,7 @@ // Parthenon headers #include "amr_criteria/refinement_package.hpp" #include "bvals/comms/bvals_in_one.hpp" +#include "globals.hpp" #include "prolong_restrict/prolong_restrict.hpp" #include // AthenaPK headers @@ -396,15 +397,16 @@ TaskCollection HydroDriver::MakeTaskCollection(BlockList_t &blocks, int stage) { const int num_partitions = pmesh->DefaultNumPartitions(); // EXACB custom modifications for power measurements - if (stage == 1 && hydro_pkg->AllParams().hasKey("exacb/power/start")) { + if (stage == 1 && parthenon::Globals::my_rank == 0 && + hydro_pkg->AllParams().hasKey("exacb/power/start")) { const auto start = hydro_pkg->Param("exacb/power/start"); - const auto end = hydro_pkg->Param("exacb/power/end"); + const auto stop = hydro_pkg->Param("exacb/power/stop"); std::ofstream outfile; if (start == tm.ncycle) { outfile.open("energy.times"); outfile << "energy_start:"; } - if (end == tm.ncycle) { + if (stop == tm.ncycle) { outfile.open("energy.times", std::ios_base::app); outfile << "energy_stop:"; }