Skip to content

Commit dd3cbbf

Browse files
authored
Merge pull request #597 from jeffriley/switchlog_hdf5_fix
Defect repair: Add HDF5 support to logging code for SSE/BSE switch log files
2 parents 7bfe143 + 26484a9 commit dd3cbbf

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

src/Log.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,13 +2517,17 @@ LogfileDetailsT Log::StandardLogFileDetails(const LOGFILE p_Logfile, const strin
25172517
// option.
25182518

25192519
if (p_Logfile == LOGFILE::BSE_SWITCH_LOG) { // BSE Switch Log
2520+
fileDetails.propertyTypes.push_back(TYPENAME::INT); // append property typename
25202521
fileDetails.hdrStrings.push_back("STAR_SWITCHING"); // append header string for field
25212522
fileDetails.unitsStrings.push_back("-"); // append units string for field
25222523
fileDetails.typeStrings.push_back("INT"); // append type string for field
2523-
fileDetails.fmtStrings.push_back("14.1"); // append format string for field (size accomodates header string)
2524+
fileDetails.fmtStrings.push_back("4.1"); // append format string for field (size accomodates header string)
25242525
}
25252526

25262527
if (p_Logfile == LOGFILE::BSE_SWITCH_LOG || p_Logfile == LOGFILE::SSE_SWITCH_LOG) { // BSE Switch Log or SSE Switch Log
2528+
fileDetails.propertyTypes.push_back(TYPENAME::STELLAR_TYPE); // append property typename
2529+
fileDetails.propertyTypes.push_back(TYPENAME::STELLAR_TYPE); // append property typename
2530+
25272531
fileDetails.hdrStrings.push_back("SWITCHING_FROM"); // append header string for field
25282532
fileDetails.hdrStrings.push_back("SWITCHING_TO"); // append header string for field
25292533

@@ -2533,8 +2537,8 @@ LogfileDetailsT Log::StandardLogFileDetails(const LOGFILE p_Logfile, const strin
25332537
fileDetails.typeStrings.push_back("INT"); // append type string for field
25342538
fileDetails.typeStrings.push_back("INT"); // append type string for field
25352539

2536-
fileDetails.fmtStrings.push_back("14.1"); // append fromat string for field (size accomodates header string)
2537-
fileDetails.fmtStrings.push_back("12.1"); // append format string for field (size accomodates header string)
2540+
fileDetails.fmtStrings.push_back("4.1"); // append fromat string for field (size accomodates header string)
2541+
fileDetails.fmtStrings.push_back("4.1"); // append format string for field (size accomodates header string)
25382542
}
25392543
}
25402544

src/Log.h

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -802,18 +802,39 @@ class Log {
802802
// ( ii) the stellar type from which the star is switching
803803
// (iii) the stellar type to which the star is switching
804804

805-
string fmt = "%4.1d"; // format - all integers here
805+
string fmtStr = "%4.1d"; // format - all integers here
806+
806807
if (p_LogFile == LOGFILE::BSE_SWITCH_LOG) {
807808
int starSwitching = m_PrimarySwitching ? 1 : 2; // primary (1) or secondary (2)
808-
logRecord += utils::vFormat(fmt.c_str(), starSwitching) + delimiter; // star switching
809+
if (m_Logfiles[fileDetails.id].filetype == LOGFILETYPE::HDF5) { // yes - HDF5 file?
810+
logRecordValues.push_back(starSwitching); // add value to vector of values
811+
}
812+
else { // no - CSV, TSV, or TXT file
813+
logRecord += utils::vFormat(fmtStr.c_str(), starSwitching) + delimiter; // add value string to log record - with delimiter
814+
}
809815
}
810816

811817
if (p_LogFile == LOGFILE::BSE_SWITCH_LOG || p_LogFile == LOGFILE::SSE_SWITCH_LOG) {
812-
logRecord += utils::vFormat(fmt.c_str(), m_TypeSwitchingFrom) + delimiter; // switching from
813-
logRecord += utils::vFormat(fmt.c_str(), m_TypeSwitchingTo) + delimiter; // switching to
818+
STELLAR_TYPE switchingFrom = m_TypeSwitchingFrom; // switching from (stellar type)
819+
if (m_Logfiles[fileDetails.id].filetype == LOGFILETYPE::HDF5) { // HDF5 file?
820+
logRecordValues.push_back(switchingFrom); // yes - add value to vector of values
821+
}
822+
else { // no - CSV, TSV, or TXT file
823+
logRecord += utils::vFormat(fmtStr.c_str(), switchingFrom) + delimiter; // add value string to log record - with delimiter
824+
}
825+
826+
STELLAR_TYPE switchingTo = m_TypeSwitchingTo; // switching to (stellar type)
827+
if (m_Logfiles[fileDetails.id].filetype == LOGFILETYPE::HDF5) { // HDF5 file?
828+
logRecordValues.push_back(switchingTo); // yes - add value to vector of values
829+
}
830+
else { // no - CSV, TSV, or TXT file
831+
logRecord += utils::vFormat(fmtStr.c_str(), switchingTo) + delimiter; // add value string to log record - with delimiter
832+
}
814833
}
815834

816-
logRecord = logRecord.substr(0, logRecord.size()-1); // remove the last character - extraneous delimiter
835+
if (m_Logfiles[fileDetails.id].filetype != LOGFILETYPE::HDF5) { // HDF5 file?
836+
logRecord = logRecord.substr(0, logRecord.size()-1); // no - remove the last character - extraneous delimiter
837+
}
817838
}
818839
}
819840
else { // logfile record passed in is not empty

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ endif
4343
CXXFLAGS := -std=c++11 -Wall $(OPTFLAGS)
4444
ICFLAGS := -I$(GSLINCDIR) -I$(BOOSTINCDIR) -I$(HDF5INCDIR) -I.
4545

46-
LIBS := -lm -lz -ldl -lsz -lpthread
46+
LIBS := -lm -lz -ldl -lpthread
4747
GSLLIBS := -lgsl -lgslcblas
4848
BOOSTLIBS := -lboost_filesystem -lboost_program_options -lboost_system
4949
HDF5LIBS := -lhdf5_hl_cpp -lhdf5_cpp -lhdf5_hl -lhdf5

src/changelog.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,9 @@
754754
// - Minor fixes (e.g., documentation)
755755
// 02.20.01 JR - June 21, 2021 - Defect repair:
756756
// - Fix for issue #585: add formatted value and delimiter to logrecord string in Log.h (defect introduced in v02.18.00; only affected SSE_Supernovae logfile)
757+
// 02.20.02 JR - July 26, 2021 - Defect repair:
758+
// - Add HDF5 support to logging code for SSE/BSE switch log files. Support for HDF5 files was inadvertently not added when HDF5 file support as added in v02.18.00 for all standard log files. Switch log files are 'special' (they have extra columns, not part of the 'standard' log file functionality), and that was missed.
757759

758-
759-
const std::string VERSION_STRING = "02.20.01";
760+
const std::string VERSION_STRING = "02.20.02";
760761

761762
# endif // __changelog_h__

0 commit comments

Comments
 (0)