Skip to content

Commit d3f7e9f

Browse files
author
Martin D. Weinberg
committed
Option to add metadata to all HDF5 files
1 parent 53c2e8e commit d3f7e9f

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/OutHDF5.H

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@param checkpt sets checkpoint mode: write a real8 snapshot with a unique filename
1717
@param preserve prevents overwrite of snapshot files
1818
@param expconfig set to true stashes the YAML configuration file in the HDF5 file
19-
19+
@param allmeta set to true writes all meta data to each HDF5 file
2020
*/
2121
class OutHDF5 : public Output
2222
{
@@ -25,7 +25,7 @@ private:
2525

2626
std::string filename;
2727
bool real4=true, real8=false, ids=true, gadget4=false, chkpt=false;
28-
bool overwrite=false, expconfig=true, timer;
28+
bool overwrite=false, expconfig=true, allmeta=false, timer;
2929
unsigned write_flags;
3030
int nbeg;
3131
void initialize(void);
@@ -63,6 +63,7 @@ public:
6363
\param checkpt set to true for checkpoint mode
6464
\param preserve set to true prevents overwrite of snapshot files
6565
\param expconfig set to true stashes the YAML configuration file in the HDF5 file
66+
\param allmeta set to true writes all meta data to each HDF5 file
6667
*/
6768
void Run(int nstep, int mstep, bool last);
6869

src/OutHDF5.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ OutHDF5::valid_keys = {
3535
"preserve",
3636
"H5compress",
3737
"H5chunk",
38-
"expconfig"
38+
"expconfig",
39+
"allmeta"
3940
};
4041

4142
OutHDF5::OutHDF5(const YAML::Node& conf) : Output(conf)
@@ -124,6 +125,9 @@ void OutHDF5::initialize()
124125
if (Output::conf["expconfig"])
125126
expconfig = Output::conf["expconfig"].as<bool>();
126127

128+
if (Output::conf["allmeta"])
129+
allmeta = Output::conf["allmeta"].as<bool>();
130+
127131
// Default HDF5 compression is no compression. By default,
128132
// shuffle is on unless turned off manually.
129133
//
@@ -298,7 +302,7 @@ void OutHDF5::RunGadget4(const std::string& path)
298302

299303
// Only attach metadata to the first file
300304
//
301-
if (myid==0) {
305+
if (allmeta or myid==0) {
302306

303307
int dp = 1;
304308
header.createAttribute("Flag_DoublePrecision", dp);
@@ -535,7 +539,7 @@ void OutHDF5::RunPSP(const std::string& path)
535539

536540
// Only attach metadata to first process
537541
//
538-
if (myid==0) {
542+
if (allmeta or myid==0) {
539543
int dp = real4 ? 0 : 1;
540544
writeScalar(header, "Flag_DoublePrecision", dp);
541545

0 commit comments

Comments
 (0)