@@ -2086,89 +2086,80 @@ bool Cylinder::checkDtype()
20862086 << " ---- We will continue...but consider remaking the cache to avoid confusion" << std::endl;
20872087 }
20882088 } else {
2089- // Check for existence of DiskType attribute
2089+ // Open existing DiskType attribute
20902090 //
2091- if (!file.hasAttribute (" DiskType" )) {
2092- if (myid==0 ) {
2093- std::cout << " ---- Cylinder::checkDtype: DiskType attribute not found in cache file <" << cachename << " >" << std::endl
2094- << " ---- This may indicate an old cache file created before DiskType metadata was added" << std::endl
2095- << " ---- We will continue...but consider remaking the cache to avoid confusion" << std::endl;
2096- }
2097- } else {
2098- // Open existing DiskType attribute
2099- //
2100- auto read_attr = file.getAttribute (" DiskType" );
2091+ auto read_attr = file.getAttribute (" DiskType" );
21012092
2102- std::string loaded_dtype;
2103- read_attr.read (loaded_dtype);
2093+ std::string loaded_dtype;
2094+ read_attr.read (loaded_dtype);
21042095
2105- // Map the loaded dtype string to a DiskType enum value
2106- //
2107- DiskType disktype = dtlookup.at (loaded_dtype);
2096+ // Map the loaded dtype string to a DiskType enum value
2097+ //
2098+ DiskType disktype = dtlookup.at (loaded_dtype);
21082099
2109- if (disktype != DTYPE) {
2100+ if (disktype != DTYPE) {
2101+ if (myid==0 ) {
2102+ std::cout << " ---- Cylinder::checkDtype: DiskType for cache file <"
2103+ << cachename << " > is <"
2104+ << loaded_dtype << " >," << std::endl
2105+ << " which does not match the requested DiskType <"
2106+ << dtype << " >" << std::endl
2107+ << " ---- Cylindrical: forcing cache recomputation"
2108+ << std::endl;
2109+ }
2110+ // Force cache recomputation
2111+ cache_status = false ;
2112+ }
2113+ else if (disktype == DiskType::python) {
2114+ // Sanity check: if DiskType is python, then the
2115+ // pythonDiskType attribute must exist
2116+ //
2117+ if (!file.hasAttribute (" pythonDiskType" )) {
21102118 if (myid==0 ) {
2111- std::cout << " ---- Cylinder::checkDtype: DiskType for cache file <"
2112- << cachename << " > is <"
2113- << loaded_dtype << " >," << std::endl
2114- << " which does not match the requested DiskType <"
2115- << dtype << " >" << std::endl
2116- << " ---- Cylindrical: forcing cache recomputation"
2117- << std::endl;
2119+ std::cout << " ---- Cylinder::checkDtype: pythonDiskType attribute not found in cache file <" << cachename << " >. " << std::endl;
2120+ std::cout << " ---- Cylindier:checkDtype: this may indicate a logic error. Forcing cache recomputation." << std::endl;
21182121 }
21192122 // Force cache recomputation
2120- cache_status = false ;
2121- }
2122- else if (disktype == DiskType::python) {
2123- // Sanity check: if DiskType is python, then the
2124- // pythonDiskType attribute must exist
2123+ cache_status = false ;
2124+ } else {
2125+ auto read_attr = file.getAttribute (" pythonDiskType" );
2126+
2127+ // Get the pyname attribute
2128+ std::vector<std::string> pyinfo;
2129+ read_attr.read (pyinfo);
2130+
2131+ std::string current_md5;
2132+
2133+ // Get the md5sum for requested Python module source file
2134+ try {
2135+ current_md5 = QuickDigest5::fileToHash (pyname);
2136+ } catch (const std::runtime_error& e) {
2137+ if (myid==0 )
2138+ std::cerr << " Cylinder::CheckDtype error: "
2139+ << e.what () << std::endl;
2140+ }
2141+
2142+ // Check that the md5sums match for the current Python
2143+ // module source files and the loaded Python module used to
2144+ // create the cache. If they do not match, force cache
2145+ // recomputation to ensure consistency with the current
2146+ // Python module.
21252147 //
2126- if (!file. hasAttribute ( " pythonDiskType " ) ) {
2148+ if (current_md5 != pyinfo[ 1 ] ) {
21272149 if (myid==0 ) {
2128- std::cout << " ---- Cylinder::checkDtype: pythonDiskType attribute not found in cache file <" << cachename << " >. " << std::endl;
2129- std::cout << " ---- Cylindier:checkDtype: this may indicate a logic error. Forcing cache recomputation." << std::endl;
2150+ std::cout << " ---- Cylinder::checkDtype: Python module for disk density has changed since cache creation." << std::endl
2151+ << " ---- Current module: <" << pyname << " >, md5sum: " << current_md5 << std::endl
2152+ << " ---- Loaded module: <" << pyinfo[0 ] << " >, md5sum: " << pyinfo[1 ] << std::endl
2153+ << " ---- Cylindrical: forcing cache recomputation to ensure consistency" << std::endl;
21302154 }
2131- // Force cache recomputation
21322155 cache_status = false ;
2133- } else {
2134- auto read_attr = file.getAttribute (" pythonDiskType" );
2135-
2136- // Get the pyname attribute
2137- std::vector<std::string> pyinfo;
2138- read_attr.read (pyinfo);
2139-
2140- std::string current_md5;
2141-
2142- // Get the md5sum for requested Python module source file
2143- try {
2144- current_md5 = QuickDigest5::fileToHash (pyname);
2145- } catch (const std::runtime_error& e) {
2146- if (myid==0 )
2147- std::cerr << " Cylinder::CheckDtype error: "
2148- << e.what () << std::endl;
2149- }
2150-
2151- // Check that the md5sums match for the current Python
2152- // module source files and the loaded Python module used to
2153- // create the cache. If they do not match, force cache
2154- // recomputation to ensure consistency with the current
2155- // Python module.
2156- //
2157- if (current_md5 != pyinfo[1 ]) {
2158- if (myid==0 ) {
2159- std::cout << " ---- Cylinder::checkDtype: Python module for disk density has changed since cache creation." << std::endl
2160- << " ---- Current module: <" << pyname << " >, md5sum: " << current_md5 << std::endl
2161- << " ---- Loaded module: <" << pyinfo[0 ] << " >, md5sum: " << pyinfo[1 ] << std::endl
2162- << " ---- Cylindrical: forcing cache recomputation to ensure consistency" << std::endl;
2163- }
2164- cache_status = false ;
2165- }
21662156 }
2167- // End: have Python disk type, check md5 hashes
21682157 }
2169- // End: Python disk type check
2158+ // End: have Python disk type, check md5 hashes
21702159 }
2171- // End: DiskType attribute exists, check value
2160+ // End: Python disk type check
2161+
2162+ // Could add deprojection checks here in the future
21722163 }
21732164 // End: DiskType attribute check
21742165
0 commit comments