Skip to content

Commit 8cba2a7

Browse files
author
Martin D. Weinberg
committed
Additional comments [no CI]
1 parent e02eb78 commit 8cba2a7

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

expui/BiorthBasis.cc

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,11 @@ namespace BasisClasses
16461646
// Sanity: check that the DiskType attribute exists
16471647
//
16481648
if (!file.hasAttribute("DiskType")) {
1649+
// If the DiskType attribute is missing, this may indicate
1650+
// an old cache file created before the DiskType metadata
1651+
// was added. We will continue with a warning, but trigger
1652+
// cache recomputation to ensure consistency with the
1653+
// current DiskType.
16491654
if (myid==0) {
16501655
std::cout << "---- Cylindrical: DiskType attribute not found in cache file <" << cachename << ">. " << std::endl
16511656
<< "---- This may indicate an old cache file created before DiskType metadata was added. " << std::endl
@@ -1676,10 +1681,17 @@ namespace BasisClasses
16761681
}
16771682
else if (disktype == DiskType::python) {
16781683

1684+
// If the DiskType is python, we also need to check that
1685+
// the Python module used to create the cache matches the
1686+
// current Python module to ensure consistency. This tag
1687+
// should be present in the cache if it was created with a
1688+
// recent version of the code, but if it is missing we
1689+
// will trigger cache recomputation to ensure consistency
1690+
// with the current Python module.
16791691
if (file.hasAttribute("pythonDiskType") == false) {
16801692
if (myid==0) {
16811693
std::cout << "---- Cylindrical: pythonDiskType attribute not found in cache file <" << cachename << ">. " << std::endl;
1682-
std::cout << "---- This may indicate an old cache file created before pythonDiskType metadata was added. " << std::endl;
1694+
std::cout << "---- Cylindrical: this may be a logic error, trigger recomputation." << std::endl;
16831695
}
16841696
cache_status = 0;
16851697
} else {
@@ -1718,9 +1730,13 @@ namespace BasisClasses
17181730
// Get the deproject attribute
17191731
//
17201732
if (!file.hasAttribute("deproject")) {
1733+
// We should not be able to get here since the deproject
1734+
// attribute is required for cache creation, but if it is
1735+
// missing we will trigger cache recomputation to ensure
1736+
// consistency.
17211737
if (myid==0) {
17221738
std::cout << "---- Cylindrical: deproject attribute not found in cache file <" << cachename << ">. " << std::endl;
1723-
std::cout << "---- This may indicate an old cache file created before deproject metadata was added. " << std::endl;
1739+
std::cout << "---- Cylindrical: this may be a logic error, trigger recomputation." << std::endl;
17241740
}
17251741
cache_status = 0;
17261742
} else {
@@ -1767,9 +1783,11 @@ namespace BasisClasses
17671783
// Get the Python info
17681784
//
17691785
if (!file.hasAttribute("pythonProjType")) {
1786+
// We should not be able to get here since the pythonProjType
1787+
// attribute is required for cache creation with the Python
17701788
if (myid==0) {
17711789
std::cout << "---- Cylindrical: pythonProjType attribute not found in cache file <" << cachename << ">. " << std::endl;
1772-
std::cout << "---- This may indicate an old cache file created before pythonProjType metadata was added. " << std::endl;
1790+
std::cout << "---- Cylindrical: this may be a logic error, trigger recomputation." << std::endl;
17731791
}
17741792

17751793
cache_status = 0;

src/Cylinder.cc

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,19 +2055,27 @@ bool Cylinder::checkDtype()
20552055
<< cachename << "> is <"
20562056
<< loaded_dtype << ">," << std::endl
20572057
<< "which does not match the requested DiskType <"
2058-
<< dtype << ">, disktype="
2059-
<< (int)disktype << ", DTYPE="
2060-
<< (int)DTYPE << std::endl
2058+
<< dtype << ">" << std::endl
20612059
<< "---- Cylindrical: forcing cache recomputation"
20622060
<< std::endl;
20632061
}
20642062
// Force cache recomputation
20652063
cache_status = false;
20662064
}
20672065
else if (disktype == DiskType::python) {
2066+
// Sanity check: if DiskType is python, then the pythonDiskType
2067+
// attribute must exist
2068+
if (!file.hasAttribute("pythonDiskType")) {
2069+
if (myid==0) {
2070+
std::cout << "---- Cylinder: pythonDiskType attribute not found in cache file <" << cachename << ">. " << std::endl;
2071+
std::cout << "---- Cylindier: this may indicate a logic error. Forcing cache recomputation." << std::endl;
2072+
}
2073+
// Force cache recomputation
2074+
cache_status = false;
2075+
}
2076+
auto read_attr = file.getAttribute("pythonDiskType");
20682077
// Get the pyname attribute
20692078
std::vector<std::string> pyinfo;
2070-
auto read_attr = file.getAttribute("pythonDiskType");
20712079
read_attr.read(pyinfo);
20722080

20732081
std::string current_md5;
@@ -2101,7 +2109,7 @@ bool Cylinder::checkDtype()
21012109

21022110
void Cylinder::saveDtype()
21032111
{
2104-
// Only one process needs to write the dtype metadata
2112+
// Only one process must write the dtype metadata
21052113
if (myid) return;
21062114

21072115
std::string dtype = dtstring.at(DTYPE);
@@ -2111,11 +2119,15 @@ void Cylinder::saveDtype()
21112119
//
21122120
HighFive::File file(cachename, HighFive::File::ReadWrite);
21132121

2122+
// Write the DiskType attribute (as a string for human readability)
21142123
file.createAttribute<std::string>
21152124
("DiskType",
21162125
HighFive::DataSpace::From(dtype)).write(dtype);
21172126

2118-
// Write the md5sum for the Python module
2127+
// Write the md5sum for the Python module, if Python disk type is
2128+
// used. This will allow us to check for consistency between the
2129+
// Python module used to create the cache and the current Python
2130+
// module, and force cache recomputation if they do not match.
21192131
if (DTYPE == DiskType::python) {
21202132
try {
21212133
std::vector<std::string> pyinfo =

0 commit comments

Comments
 (0)