49 for (
const auto &
s : labels) {
60 bool desc,
bool formulas)
61 : fname(file), timeChunk(chunking),
62 enableDescriptions(desc), enableFormula(formulas),
68 H5::Exception::dontPrint();
81 dumpCount > 0 ? H5F_ACC_RDWR : H5F_ACC_TRUNC);
109 group =
base.openGroup(name);
110 }
catch (
const H5::FileIException&
e) {
111 group =
base.createGroup(name);
112 }
catch (
const H5::GroupIException& e) {
113 group =
base.createGroup(name);
122 assert(!
path.empty());
132 hsize_t fdims[1] = { 0, };
147 warn_once(
"HDF5 stat files don't support distributions.\n");
153 warn_once(
"HDF5 stat files don't support vector distributions.\n");
162 hsize_t fdims[3] = { 0, info.
x, info.
y };
163 H5::DataSet data_set =
appendStat(info, 3, fdims, info.
cvec.data());
192 warn_once(
"HDF5 stat files don't support sparse histograms.\n");
202 hsize_t fdims[2] = { 0, vr.size() };
203 H5::DataSet data_set =
appendStat(info, 2, fdims, vr.data());
219 H5::Group group =
path.top();
220 H5::DataSet data_set;
221 H5::DataSpace fspace;
228 data_set = group.openDataSet(info.
name);
229 data_set.extend(dims);
230 fspace = data_set.getSpace();
234 H5::DSetCreatPropList props;
238 std::copy(dims, dims + rank, max_dims.begin());
239 max_dims[0] = H5S_UNLIMITED;
243 std::copy(dims, dims + rank, chunk_dims.begin());
245 props.setChunk(rank, chunk_dims.data());
250 fspace = H5::DataSpace(rank, dims, max_dims.data());
251 data_set = group.createDataSet(info.
name, H5::PredType::NATIVE_DOUBLE,
261 H5::DataSpace mspace(rank, dims);
265 fspace.selectHyperslab(H5S_SELECT_SET, dims, foffset.data());
266 data_set.write(data, H5::PredType::NATIVE_DOUBLE, mspace, fspace);
275 H5::StrType
type(H5::PredType::C_S1, H5T_VARIABLE);
276 hsize_t dims[1] = { values.size(), };
277 H5::DataSpace space(1, dims);
278 H5::Attribute attribute = loc.createAttribute(name, type, space);
279 attribute.write(type, values.data());
287 for (
int i = 0;
i < values.size(); ++
i)
288 cstrs[
i] = values[
i].c_str();
295 const std::string &value)
297 H5::StrType
type(H5::PredType::C_S1, value.length() + 1);
298 hsize_t dims[1] = { 1, };
299 H5::DataSpace space(1, dims);
300 H5::Attribute attribute = loc.createAttribute(name,
type, space);
301 attribute.write(
type, value.c_str());
307 hsize_t dims[1] = { 1, };
308 H5::DataSpace space(1, dims);
309 H5::Attribute attribute = loc.createAttribute(
310 name, H5::PredType::NATIVE_DOUBLE, space);
311 attribute.write(H5::PredType::NATIVE_DOUBLE, &value);
315 std::unique_ptr<Output>
316 initHDF5(
const std::string &filename,
unsigned chunking,
317 bool desc,
bool formulas)
319 return std::unique_ptr<Output>(
std::string resolve(const std::string &name) const
Returns relative file names prepended with name of this directory.
bool emptyStrings(const T &labels)
Check if all strings in a container are empty.
std::string name
The name of the stat.
std::vector< std::string > subdescs
const std::string & name()
std::vector< std::string > subnames
Names and descriptions of subfields.
std::vector< std::string > y_subnames
virtual Result result() const =0
std::vector< std::string > subnames
Names and descriptions of subfields.
void addMetaData(H5::DataSet &loc, const char *name, const std::vector< const char *> &values)
Helper function to add a string vector attribute to a stat.
void beginGroup(const char *name) override
virtual const VResult & result() const =0
VCounter cvec
Local storage for the entry values, used for printing.
H5::DataSet appendVectorInfo(const VectorInfo &info)
Helper function to append vector stats and set their metadata.
H5::DataSet appendStat(const Info &info, int rank, hsize_t *dims, const double *data)
Helper function to append an n-dimensional double stat to the file.
std::vector< std::string > subdescs
void visit(const ScalarInfo &info) override
const bool enableDescriptions
std::stack< H5::Group > path
bool valid() const override
std::unique_ptr< Output > initHDF5(const std::string &filename, unsigned chunking, bool desc, bool formulas)
std::string desc
The description of the stat.