@@ -104,7 +104,7 @@ void Hdf5Recorder::term()
104104}
105105
106106// create the dataset for constant variable and store the data to dataset
107- void Hdf5Recorder::saveSimData (const AllVertices &neurons )
107+ void Hdf5Recorder::saveSimData ()
108108{
109109 // Initialize datasets for constant variables
110110 for (auto &variableInfo : variableTable_) {
@@ -124,9 +124,11 @@ void Hdf5Recorder::saveSimData(const AllVertices &neurons)
124124}
125125
126126// Processes and updates HDF5 datasets for variables marked as DYNAMIC
127- void Hdf5Recorder::compileHistories (AllVertices &vertices )
127+ void Hdf5Recorder::compileHistories ()
128128{
129129 // Define the maximum chunk size for datasets to optimize storage and access
130+ // This defines the maximum number of elements per chunk
131+ // If the dataset size exceeds this value, HDF5 will create multiple chunks to store the data
130132 const hsize_t max_chunk_size = 1024 ;
131133
132134 // Iterate over each variableInfo object in the variable table
@@ -178,29 +180,30 @@ void Hdf5Recorder::compileHistories(AllVertices &vertices)
178180
179181 // Prepare the data buffer and write the new data to the dataset
180182 if (variableInfo.hdf5Datatype_ == PredType::NATIVE_FLOAT) {
181- std:: vector<float > dataBuffer (variableInfo.variableLocation_ .getNumElements ());
183+ vector<float > dataBuffer (variableInfo.variableLocation_ .getNumElements ());
182184 for (size_t i = 0 ; i < variableInfo.variableLocation_ .getNumElements (); ++i) {
183185 dataBuffer[i] = get<float >(variableInfo.variableLocation_ .getElement (i));
184186 }
185187 variableInfo.hdf5DataSet_ .write (dataBuffer.data (), variableInfo.hdf5Datatype_ ,
186188 memSpace, fileSpace);
187189 } else if (variableInfo.hdf5Datatype_ == PredType::NATIVE_INT) {
188- std:: vector<int > dataBuffer (variableInfo.variableLocation_ .getNumElements ());
190+ vector<int > dataBuffer (variableInfo.variableLocation_ .getNumElements ());
189191 for (size_t i = 0 ; i < variableInfo.variableLocation_ .getNumElements (); ++i) {
190192 dataBuffer[i] = get<int >(variableInfo.variableLocation_ .getElement (i));
191193 }
192194 variableInfo.hdf5DataSet_ .write (dataBuffer.data (), variableInfo.hdf5Datatype_ ,
193195 memSpace, fileSpace);
194196 } else if (variableInfo.hdf5Datatype_ == PredType::NATIVE_UINT64) {
195- std:: vector<uint64_t > dataBuffer (variableInfo.variableLocation_ .getNumElements ());
197+ vector<uint64_t > dataBuffer (variableInfo.variableLocation_ .getNumElements ());
196198 for (size_t i = 0 ; i < variableInfo.variableLocation_ .getNumElements (); ++i) {
197199 dataBuffer[i] = get<uint64_t >(variableInfo.variableLocation_ .getElement (i));
198200 }
199201 variableInfo.hdf5DataSet_ .write (dataBuffer.data (), variableInfo.hdf5Datatype_ ,
200202 memSpace, fileSpace);
201203 } else {
202204 // Throw an exception if the data type is unsupported
203- throw std::runtime_error (" Unsupported data type" );
205+ throw runtime_error (" Unsupported data type for variable: "
206+ + variableInfo.variableName_ );
204207 }
205208 }
206209 }
0 commit comments