Skip to content

Commit dacc060

Browse files
authored
Merge pull request #598 from TeamCOMPAS/switchlog_hdf5_fix
Defect repair: Add HDF5 support to logging code for SSE/BSE switch log files.
2 parents 7bfe143 + 15bc89b commit dacc060

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
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/Makefile.docker

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

49-
LIBS := -lm -lz -ldl -lsz -lpthread
49+
LIBS := -lm -lz -ldl -lpthread
5050
GSLLIBS := -lgsl -lgslcblas
5151
BOOSTLIBS := -lboost_filesystem -lboost_program_options -lboost_system
5252
HDF5LIBS := -lhdf5_hl_cpp -lhdf5_cpp -lhdf5_hl -lhdf5

src/changelog.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,10 @@
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 switch 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.
759+
// - Also removed '-lsz' from Makefile and Makefile.docker - library not required
757760

758-
759-
const std::string VERSION_STRING = "02.20.01";
761+
const std::string VERSION_STRING = "02.20.02";
760762

761763
# endif // __changelog_h__

0 commit comments

Comments
 (0)