Skip to content

Commit f017714

Browse files
committed
Extend example
1 parent 5ac3aee commit f017714

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

examples/14_toml_template.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "openPMD/Dataset.hpp"
2+
#include <openPMD/auxiliary/TemplateFile.hpp>
13
#include <openPMD/openPMD.hpp>
24

35
std::string backendEnding()
@@ -101,7 +103,23 @@ void read()
101103
"../samples/tomlTemplate." + backendEnding(),
102104
openPMD::Access::READ_LINEAR);
103105
read.parseBase();
104-
openPMD::helper::listSeries(read);
106+
107+
std::string jsonConfig = R"(
108+
{
109+
"iteration_encoding": "variable_based",
110+
"json": {
111+
"mode": "template"
112+
}
113+
}
114+
)";
115+
openPMD::Series cloned(
116+
"../samples/jsonTemplate.json", openPMD::Access::CREATE, jsonConfig);
117+
openPMD::auxiliary::initializeFromTemplate(cloned, read, 0);
118+
// Have to define the dataset for E/z as it is not defined in the template
119+
// @todo check that the dataset is defined only upon destruction, not at
120+
// flushing already
121+
cloned.writeIterations()[0].meshes["E"]["z"].resetDataset(
122+
{openPMD::Datatype::INT, {openPMD::Dataset::UNDEFINED_EXTENT}});
105123
}
106124

107125
int main()

0 commit comments

Comments
 (0)