From cbc36bdfcfb6e664c93515cfc9536cae33f1b13c Mon Sep 17 00:00:00 2001 From: Ben Ryan Date: Wed, 13 Nov 2024 09:42:19 -0700 Subject: [PATCH 1/6] Modify how we loop through packages to enroll history outputs --- src/outputs/history.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/outputs/history.cpp b/src/outputs/history.cpp index 2e1310062d48..41ab26a516f8 100644 --- a/src/outputs/history.cpp +++ b/src/outputs/history.cpp @@ -93,8 +93,14 @@ void HistoryOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin, SimTime *tm, md_base->Initialize(pm->block_list, pm); } - // Loop over all packages of the application - for (const auto &pkg : packages) { + // Loop over all packages of the application in alphabetical order + std::vector keys; + for (const auto& pair : packages) { + keys.push_back(pair.first); + } + std::sort(keys.begin(), keys.end()); + for (const auto &key : keys) { + const auto &pkg = packages[key]; const auto ¶ms = pkg.second->AllParams(); // Check if the package has enrolled scalar history functions which are stored in the From 37929e9cfa8edce8d03f4957619196b76bbaa6fb Mon Sep 17 00:00:00 2001 From: Ben Ryan Date: Wed, 13 Nov 2024 09:45:56 -0700 Subject: [PATCH 2/6] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d361fc0567f..a4e0a5ca9cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - [[PR 1161]](https://github.com/parthenon-hpc-lab/parthenon/pull/1161) Make flux field Metadata accessible, add Metadata::CellMemAligned flag, small perfomance upgrades ### Changed (changing behavior/API/variables/...) +- [[PR 1209]](https://github.com/parthenon-hpc-lab/parthenon/pull/1209) Ordered history output - [[PR 1206]](https://github.com/parthenon-hpc-lab/parthenon/pull/1206) Leapfrog fix - [[PR1203]](https://github.com/parthenon-hpc-lab/parthenon/pull/1203) Pin Ubuntu CI image - [[PR1177]](https://github.com/parthenon-hpc-lab/parthenon/pull/1177) Make mesh-level boundary conditions usable without the "user" flag From cf158716c75ea74aec5b325906c23bf912c0c594 Mon Sep 17 00:00:00 2001 From: Ben Ryan Date: Wed, 13 Nov 2024 09:47:36 -0700 Subject: [PATCH 3/6] formatting --- src/outputs/history.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/outputs/history.cpp b/src/outputs/history.cpp index 41ab26a516f8..51b4e523e7f0 100644 --- a/src/outputs/history.cpp +++ b/src/outputs/history.cpp @@ -95,8 +95,8 @@ void HistoryOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin, SimTime *tm, // Loop over all packages of the application in alphabetical order std::vector keys; - for (const auto& pair : packages) { - keys.push_back(pair.first); + for (const auto &pair : packages) { + keys.push_back(pair.first); } std::sort(keys.begin(), keys.end()); for (const auto &key : keys) { From 6939da2a07c34ae2366c45fae5d1d0fa429d38c6 Mon Sep 17 00:00:00 2001 From: Ben Ryan Date: Wed, 13 Nov 2024 09:58:34 -0700 Subject: [PATCH 4/6] Oops key vs pair --- src/outputs/history.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/outputs/history.cpp b/src/outputs/history.cpp index 51b4e523e7f0..2aade658fe00 100644 --- a/src/outputs/history.cpp +++ b/src/outputs/history.cpp @@ -101,7 +101,7 @@ void HistoryOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin, SimTime *tm, std::sort(keys.begin(), keys.end()); for (const auto &key : keys) { const auto &pkg = packages[key]; - const auto ¶ms = pkg.second->AllParams(); + const auto ¶ms = pkg->AllParams(); // Check if the package has enrolled scalar history functions which are stored in the // Params under the `hist_param_key` name. From 0968c3ea8c4e0877041b2c5ee154fa8c15c5ec92 Mon Sep 17 00:00:00 2001 From: Ben Ryan Date: Wed, 13 Nov 2024 10:01:15 -0700 Subject: [PATCH 5/6] Add note to docs about ordering of history outputs h/t AMD --- doc/sphinx/src/outputs.rst | 4 +++- src/outputs/history.cpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/sphinx/src/outputs.rst b/doc/sphinx/src/outputs.rst index 7196e4777bb3..fa44e27da298 100644 --- a/doc/sphinx/src/outputs.rst +++ b/doc/sphinx/src/outputs.rst @@ -194,7 +194,9 @@ block might look like This will produce a text file (``.hst``) output file every 1 units of simulation time. The content of the file is determined by the functions -enrolled by specific packages, see :ref:`state history output`. +enrolled by specific packages, see :ref:`state history output`. Per-package history +outputs will always be in alphabetical order by package name, which may not match +the order in which packages were added to a simulation. Histograms ---------- diff --git a/src/outputs/history.cpp b/src/outputs/history.cpp index 2aade658fe00..913a722496a7 100644 --- a/src/outputs/history.cpp +++ b/src/outputs/history.cpp @@ -93,7 +93,8 @@ void HistoryOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin, SimTime *tm, md_base->Initialize(pm->block_list, pm); } - // Loop over all packages of the application in alphabetical order + // Loop over all packages of the application in alphabetical order to ensure consistency + // of ordering of data in columns. std::vector keys; for (const auto &pair : packages) { keys.push_back(pair.first); From 817ea62fefd9bb31dd1a62d9e8ccf4111ad3ce16 Mon Sep 17 00:00:00 2001 From: Ben Ryan Date: Wed, 13 Nov 2024 11:16:33 -0700 Subject: [PATCH 6/6] Oops include_what_you_use --- src/outputs/history.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/outputs/history.cpp b/src/outputs/history.cpp index 913a722496a7..074bea4feb0c 100644 --- a/src/outputs/history.cpp +++ b/src/outputs/history.cpp @@ -18,6 +18,7 @@ // \brief writes history output data, volume-averaged quantities that are output // frequently in time to trace their history. +#include #include #include #include