From db77e659417c4a61fc0c44e9dd8c6e8cacba1775 Mon Sep 17 00:00:00 2001 From: Anders Kvellestad Date: Fri, 9 Feb 2024 13:14:49 +0100 Subject: [PATCH 1/4] Trying to fix faulty if-else logic related resuming jobs with the hdf5_v1 printer. --- .../src/printers/hdf5printer/hdf5printer.cpp | 82 ++++++++++--------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/Printers/src/printers/hdf5printer/hdf5printer.cpp b/Printers/src/printers/hdf5printer/hdf5printer.cpp index 65792494a5..5b588d8882 100644 --- a/Printers/src/printers/hdf5printer/hdf5printer.cpp +++ b/Printers/src/printers/hdf5printer/hdf5printer.cpp @@ -420,50 +420,54 @@ namespace Gambit #endif if(HDF5::checkFileReadable(finalfile, msg_finalfile)) { - if(overwrite_file and not get_resume()) + // Note: "not resume" means "start or restart" + if(not get_resume()) { - // Note: "not resume" means "start or restart" - // Delete existing output file - std::ostringstream command; - command << "rm -f "< Date: Fri, 9 Feb 2024 13:38:44 +0100 Subject: [PATCH 2/4] Moved comment in hdf5printer_v2.cpp --- Printers/src/printers/hdf5printer_v2/hdf5printer_v2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Printers/src/printers/hdf5printer_v2/hdf5printer_v2.cpp b/Printers/src/printers/hdf5printer_v2/hdf5printer_v2.cpp index fbb8fbbd92..3b366c69b6 100644 --- a/Printers/src/printers/hdf5printer_v2/hdf5printer_v2.cpp +++ b/Printers/src/printers/hdf5printer_v2/hdf5printer_v2.cpp @@ -1478,9 +1478,9 @@ namespace Gambit std::string msg_finalfile; if(HDF5::checkFileReadable(file, msg_finalfile)) { + // Note: "not resume" means "start or restart" if(not get_resume()) { - // Note: "not resume" means "start or restart" if(overwrite_file) { // Delete existing output file From f561f7296bd0970be0efdeb8beb4fcdb7ffc94dc Mon Sep 17 00:00:00 2001 From: Anders Kvellestad Date: Fri, 9 Feb 2024 14:43:44 +0100 Subject: [PATCH 3/4] Changed file suffix of expected combined hdf5 file, from '_combined_temp' to '_combined'. This way a user don't risk deleting both the combined file and all the temporary files if they do e.g. 'rm *.hdf5_temp_*' after running the combine script. --- Printers/src/printers/hdf5printer/hdf5printer.cpp | 4 ++-- Printers/standalone/manual_hdf5_combine.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Printers/src/printers/hdf5printer/hdf5printer.cpp b/Printers/src/printers/hdf5printer/hdf5printer.cpp index 5b588d8882..415d20cf27 100644 --- a/Printers/src/printers/hdf5printer/hdf5printer.cpp +++ b/Printers/src/printers/hdf5printer/hdf5printer.cpp @@ -389,7 +389,7 @@ namespace Gambit // Name of file where combined results from previous (unfinished) runs end up std::ostringstream rename; - rename << finalfile << "_temp_combined"; + rename << finalfile << "_combined"; tmp_comb_file = rename.str(); // HDF5 group (virtual "folder") inside output file in which to store datasets @@ -1089,7 +1089,7 @@ namespace Gambit // follow a fixed format and they all exist. We check for this before // running this function, so this should be fine. - // If we set the second last flag 'true' then Greg's code will assume that a '_temp_combined' output file + // If we set the second last flag 'true' then Greg's code will assume that a '_combined' output file // exists, and it will crash if it doesn't. So we need to first check if such a file exists. bool combined_file_exists = Utils::file_exists(tmp_comb_file); // We already check this externally; pass in as flag? logger() << LogTags::printers << LogTags::info << "combined_file_exists? " << combined_file_exists << EOM; diff --git a/Printers/standalone/manual_hdf5_combine.cpp b/Printers/standalone/manual_hdf5_combine.cpp index 4da0d2a14b..21a96201e8 100644 --- a/Printers/standalone/manual_hdf5_combine.cpp +++ b/Printers/standalone/manual_hdf5_combine.cpp @@ -61,7 +61,7 @@ void usage() "\n them from . Filenames are to be supplied in a single" "\n ascii file, on separate lines." "\n In this mode will only be used for naming the output" - "\n file (Note: WITHOUT the usual addition of '_temp_combined'!!!)." + "\n file (Note: WITHOUT the usual addition of '_combined'!!!)." "\n All files must have the same ." "\n Note: Auxilliary ('RA') datasets will be IGNORED! These should" "\n be combined during 'normal' combination of results from a single" @@ -196,7 +196,7 @@ int main(int argc, char* argv[]) // Name of temporary combined file, if one exists std::ostringstream name; - name << finalfile << "_temp_combined"; + name << finalfile << "_combined"; tmp_comb_file = name.str(); combined_file_exists = Utils::file_exists(tmp_comb_file); From fb18fabbb9c283c21e2900fcf23b4acdced7466e Mon Sep 17 00:00:00 2001 From: Anders Kvellestad Date: Fri, 9 Feb 2024 15:14:48 +0100 Subject: [PATCH 4/4] Edited some error and log messages for clarity. --- .../src/printers/hdf5printer/hdf5printer.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Printers/src/printers/hdf5printer/hdf5printer.cpp b/Printers/src/printers/hdf5printer/hdf5printer.cpp index 415d20cf27..e5c84fdbad 100644 --- a/Printers/src/printers/hdf5printer/hdf5printer.cpp +++ b/Printers/src/printers/hdf5printer/hdf5printer.cpp @@ -494,7 +494,7 @@ namespace Gambit { // There is no combined output either, so disable resume mode std::ostringstream msg; - msg<<"No temporary output from a previous scan found (or it is unreadable); this will be treated as a NEW scan"; + msg<<"No combined output file " << tmp_comb_file << " from a previous scan found (or it is unreadable); this will be treated as a NEW scan"; std::cout<