Skip to content

Commit 1c7f9e4

Browse files
committed
Extend example
1 parent 01cd701 commit 1c7f9e4

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

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
void write()
@@ -79,7 +80,23 @@ void read()
7980
openPMD::Series read(
8081
"../samples/tomlTemplate.toml", openPMD::Access::READ_LINEAR);
8182
read.readIterations(); // @todo change to read.parseBase()
82-
openPMD::helper::listSeries(read);
83+
84+
std::string jsonConfig = R"(
85+
{
86+
"iteration_encoding": "variable_based",
87+
"json": {
88+
"mode": "template"
89+
}
90+
}
91+
)";
92+
openPMD::Series cloned(
93+
"../samples/jsonTemplate.json", openPMD::Access::CREATE, jsonConfig);
94+
openPMD::auxiliary::initializeFromTemplate(cloned, read, 0);
95+
// Have to define the dataset for E/z as it is not defined in the template
96+
// @todo check that the dataset is defined only upon destruction, not at
97+
// flushing already
98+
cloned.writeIterations()[0].meshes["E"]["z"].resetDataset(
99+
{openPMD::Datatype::INT});
83100
}
84101

85102
int main()

0 commit comments

Comments
 (0)