From 9d4a9f4cd89a90a1151713b9e4aedc06d559d24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 19 May 2022 17:29:24 +0200 Subject: [PATCH] Extend example --- examples/14_toml_template.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/14_toml_template.cpp b/examples/14_toml_template.cpp index 284db9ee84..366323ee21 100644 --- a/examples/14_toml_template.cpp +++ b/examples/14_toml_template.cpp @@ -1,3 +1,4 @@ +#include #include std::string backendEnding() @@ -97,7 +98,23 @@ void read() "../samples/tomlTemplate." + backendEnding(), openPMD::Access::READ_LINEAR); read.readIterations(); // @todo change to read.parseBase() - openPMD::helper::listSeries(read); + + std::string jsonConfig = R"( +{ + "iteration_encoding": "variable_based", + "json": { + "mode": "template" + } +} +)"; + openPMD::Series cloned( + "../samples/jsonTemplate.json", openPMD::Access::CREATE, jsonConfig); + openPMD::auxiliary::initializeFromTemplate(cloned, read, 0); + // Have to define the dataset for E/z as it is not defined in the template + // @todo check that the dataset is defined only upon destruction, not at + // flushing already + cloned.writeIterations()[0].meshes["E"]["z"].resetDataset( + {openPMD::Datatype::INT}); } int main()