Skip to content

Commit

Permalink
Some fixes for Mike's suggested code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed May 22, 2024
1 parent a46897a commit aef851a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
6 changes: 0 additions & 6 deletions expui/Coefficients.H
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ namespace CoefClasses
//! Verbose debugging output
bool verbose;

//! Backward compatibility flag for HighFive
static bool H5BackCompat;

//! Time vector
std::vector<double> times;

Expand Down Expand Up @@ -201,9 +198,6 @@ namespace CoefClasses
//! Set maximum grid interpolation offset
void setDeltaT(double dT) { deltaT = dT; }

//! Override backward compatibility for HighFive
static void setNewH5() { H5BackCompat = false; }

class CoefsError : public std::runtime_error
{
public:
Expand Down
22 changes: 16 additions & 6 deletions expui/Coefficients.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
namespace CoefClasses
{

bool Coefs::H5BackCompat = true;

void Coefs::copyfields(std::shared_ptr<Coefs> p)
{
// These variables will copy data, not pointers
Expand Down Expand Up @@ -93,8 +91,11 @@ namespace CoefClasses
file.getAttribute("geometry").read(geometry);
file.getAttribute("forceID" ).read(forceID );

// Look for Coef output version to toggle backward compatibility
// with legacy storage order
//
bool H5back = true;
if (file.hasAttribute("Version")) H5back = false;
if (file.hasAttribute("CoefficientOutputVersion")) H5back = false;

// Open the snapshot group
//
Expand All @@ -121,7 +122,10 @@ namespace CoefClasses

auto in = stanza.getDataSet("coefficients").read<Eigen::MatrixXcd>();

if (H5back and H5BackCompat) {
// If we have a legacy set of coefficients, re-order the
// coefficients to match the new HighFive/Eigen ordering
//
if (H5back) {

auto in2 = stanza.getDataSet("coefficients").read<Eigen::MatrixXcd>();
in2.transposeInPlace();
Expand Down Expand Up @@ -794,6 +798,9 @@ namespace CoefClasses
file.getAttribute("config" ).read(config);
file.getDataSet ("count" ).read(count );

// Look for Coef output version to toggle backward compatibility
// with legacy storage order
//
bool H5back = true;
if (file.hasAttribute("CoefficientOutputVersion")) H5back = false;

Expand Down Expand Up @@ -821,8 +828,11 @@ namespace CoefClasses
if (Time < Tmin or Time > Tmax) continue;

auto in = stanza.getDataSet("coefficients").read<Eigen::MatrixXcd>();
// If an older version of the coefficients and backwards compatibility is desired, re-order the coefficients to match the cache.
if (H5back and H5BackCompat) {

// If we have a legacy set of coefficients, re-order the
// coefficients to match the new HighFive/Eigen ordering
//
if (H5back) {

auto in2 = stanza.getDataSet("coefficients").read<Eigen::MatrixXcd>();
in2.transposeInPlace();
Expand Down
13 changes: 0 additions & 13 deletions pyEXP/CoefWrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -867,19 +867,6 @@ void CoefficientClasses(py::module &m) {
are found at the requested time
)",
py::arg("time"))
.def("newH5",
&CoefClasses::Coefs::setNewH5,
R"(
Override backwards compatibility flag for HighFive API change
Parameters
----------
None
Returns
-------
None
)")
.def("setData",
&CoefClasses::Coefs::setData,
R"(
Expand Down

0 comments on commit aef851a

Please sign in to comment.