From fa02b96692663cc6bddf593fe7c53bf2d81c737f Mon Sep 17 00:00:00 2001 From: Philipp Grete Date: Mon, 9 Sep 2024 21:36:54 +0200 Subject: [PATCH 1/3] Fix type used for array init --- src/outputs/restart_hdf5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/outputs/restart_hdf5.cpp b/src/outputs/restart_hdf5.cpp index f16bfccc52de..5e92abcbcad3 100644 --- a/src/outputs/restart_hdf5.cpp +++ b/src/outputs/restart_hdf5.cpp @@ -214,7 +214,7 @@ void RestartReaderHDF5::ReadBlocks(const std::string &name, IndexRange range, #else // HDF5 enabled auto hdl = OpenDataset(name); - const int VNDIM = info.VNDIM; + constexpr int VNDIM = info.VNDIM; /** Select hyperslab in dataset **/ int total_dim = 0; From 644fdf433b439396813f3a476c047d9d94373b33 Mon Sep 17 00:00:00 2001 From: Jonah Miller Date: Tue, 10 Sep 2024 15:05:49 -0600 Subject: [PATCH 2/3] init array with constexpr expression --- CHANGELOG.md | 1 + src/outputs/output_utils.hpp | 2 +- src/outputs/restart_hdf5.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62b1ea9c5c78..8a2d66513f69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Fixed (not changing behavior/API/variables/...) +- [[PR 1170]](https://github.com/parthenon-hpc-lab/parthenon/pull/1170) Fixed incorrect initialization of array by a const not constexpr ### Infrastructure (changes irrelevant to downstream codes) diff --git a/src/outputs/output_utils.hpp b/src/outputs/output_utils.hpp index cc65dc63f7a2..d29ec744b899 100644 --- a/src/outputs/output_utils.hpp +++ b/src/outputs/output_utils.hpp @@ -47,7 +47,7 @@ namespace OutputUtils { // Helper struct containing some information about a variable struct VarInfo { public: - static constexpr int VNDIM = MAX_VARIABLE_DIMENSION; + static constexpr const int VNDIM = MAX_VARIABLE_DIMENSION; std::string label; int num_components; int tensor_rank; // 0- to 3-D for cell-centered variables, 0- to 6-D for arbitrary shape diff --git a/src/outputs/restart_hdf5.cpp b/src/outputs/restart_hdf5.cpp index 5e92abcbcad3..339f559aa9a1 100644 --- a/src/outputs/restart_hdf5.cpp +++ b/src/outputs/restart_hdf5.cpp @@ -214,7 +214,7 @@ void RestartReaderHDF5::ReadBlocks(const std::string &name, IndexRange range, #else // HDF5 enabled auto hdl = OpenDataset(name); - constexpr int VNDIM = info.VNDIM; + constexpr int VNDIM = OutputUtils::VarInfo::VNDIM; /** Select hyperslab in dataset **/ int total_dim = 0; From 3fc5557ab6780b1865c58b6a248373b3de64d8fb Mon Sep 17 00:00:00 2001 From: Jonah Miller Date: Tue, 10 Sep 2024 15:07:00 -0600 Subject: [PATCH 3/3] CC --- src/outputs/restart_hdf5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/outputs/restart_hdf5.cpp b/src/outputs/restart_hdf5.cpp index 339f559aa9a1..60bcb4734299 100644 --- a/src/outputs/restart_hdf5.cpp +++ b/src/outputs/restart_hdf5.cpp @@ -3,7 +3,7 @@ // Copyright(C) 2020-2024 The Parthenon collaboration // Licensed under the 3-clause BSD License, see LICENSE file for details //======================================================================================== -// (C) (or copyright) 2020-2021. Triad National Security, LLC. All rights reserved. +// (C) (or copyright) 2020-2024. Triad National Security, LLC. All rights reserved. // // This program was produced under U.S. Government contract 89233218CNA000001 for Los // Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC