@@ -36,9 +36,10 @@ namespace custom_hierarchy
3636using namespace openPMD ;
3737
3838void write (
39- char const *filename, std::string const &json_params, IterationEncoding ie)
39+ std::string const &filename,
40+ std::string const &json_params,
41+ IterationEncoding)
4042{
41- std::cout << json_params << std::endl;
4243 Series series (filename, Access::CREATE_LINEAR, json_params);
4344 auto add_custom_hierarchy = [](Attributable &attr) {
4445 attr.customHierarchies ()[" rabimmel" ].setAttribute (" rabammel" , " rabumm" );
@@ -50,6 +51,27 @@ void write(
5051 iteration.close ();
5152}
5253
54+ void read (
55+ std::string const &filename,
56+ std::string const &json_params,
57+ IterationEncoding)
58+ {
59+ Series series (filename, Access::READ_LINEAR, json_params);
60+ auto require_custom_hierarchy = [](Attributable &attr) {
61+ auto ch = attr.customHierarchies ();
62+ REQUIRE (ch.find (" rabimmel" ) == ch.end ());
63+ ch.read (0 );
64+ REQUIRE (
65+ ch[" rabimmel" ].getAttribute (" rabammel" ).get <std::string>() ==
66+ " rabumm" );
67+ };
68+ auto iteration = series.snapshots ()[0 ];
69+
70+ require_custom_hierarchy (series);
71+ require_custom_hierarchy (iteration);
72+ iteration.close ();
73+ }
74+
5375struct test_config
5476{
5577 char const *filename;
@@ -60,13 +82,13 @@ struct test_config
6082void custom_hierarchy ()
6183{
6284 test_config configs[] = {
63- {" ../samples/custom_hierarchy/ groupbased.%E" ,
85+ {" groupbased.%E" ,
6486 R"( {"iteration_encoding": "group_based"})" ,
6587 IterationEncoding::groupBased},
66- {" ../samples/custom_hierarchy/ filebased_%T.%E" ,
88+ {" filebased_%T.%E" ,
6789 R"( {"iteration_encoding": "file_based"})" ,
6890 IterationEncoding::fileBased},
69- {" ../samples/custom_hierarchy/ variablebased.%E" ,
91+ {" variablebased.%E" ,
7092 R"( {"iteration_encoding": "variable_based"})" ,
7193 IterationEncoding::variableBased}};
7294
@@ -77,9 +99,19 @@ void custom_hierarchy()
7799 auto json_params_ = json::merge (
78100 json_params,
79101 std::string (
80- R"( {"adios2": {"engine": {"type": "file"}}, "backend": ")" ) +
102+ R"(
103+ {
104+ "adios2": {
105+ "engine": {
106+ "type": "file"
107+ }
108+ },
109+ "backend": ")" ) +
81110 backend + R"( "})" );
82- write (filename, json_params_, encoding);
111+ auto filename_ = std::string (" ../samples/custom_hierarchy/" ) +
112+ backend + " /" + filename;
113+ write (filename_, json_params_, encoding);
114+ read (filename_, json_params_, encoding);
83115 }
84116 }
85117}
0 commit comments