Skip to content

Commit 604c553

Browse files
committed
Extend example
1 parent 2cdf424 commit 604c553

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

examples/14_toml_template.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <openPMD/auxiliary/TemplateFile.hpp>
12
#include <openPMD/openPMD.hpp>
23

34
std::string backendEnding()
@@ -97,7 +98,23 @@ void read()
9798
"../samples/tomlTemplate." + backendEnding(),
9899
openPMD::Access::READ_LINEAR);
99100
read.readIterations(); // @todo change to read.parseBase()
100-
openPMD::helper::listSeries(read);
101+
102+
std::string jsonConfig = R"(
103+
{
104+
"iteration_encoding": "variable_based",
105+
"json": {
106+
"mode": "template"
107+
}
108+
}
109+
)";
110+
openPMD::Series cloned(
111+
"../samples/jsonTemplate.json", openPMD::Access::CREATE, jsonConfig);
112+
openPMD::auxiliary::initializeFromTemplate(cloned, read, 0);
113+
// Have to define the dataset for E/z as it is not defined in the template
114+
// @todo check that the dataset is defined only upon destruction, not at
115+
// flushing already
116+
cloned.writeIterations()[0].meshes["E"]["z"].resetDataset(
117+
{openPMD::Datatype::INT});
101118
}
102119

103120
int main()

0 commit comments

Comments
 (0)