@@ -39,7 +39,8 @@ int main()
3939 * to the openPMD standard. Creation of new elements happens on access
4040 * inside the tree-like structure. Required attributes are initialized to
4141 * reasonable defaults for every object. */
42- ParticleSpecies electrons = series.iterations [1 ].particles [" electrons" ];
42+ ParticleSpecies electrons =
43+ series.writeIterations ()[1 ].particles [" electrons" ];
4344
4445 /* Data to be moved from memory to persistent storage is structured into
4546 * Records, each holding an unbounded number of RecordComponents. If a
@@ -59,9 +60,17 @@ int main()
5960 electrons[" positionOffset" ][" x" ].resetDataset (dataset);
6061 electrons[" positionOffset" ][" x" ].makeConstant (22.0 );
6162
63+ // The iteration can be closed in order to help free up resources.
64+ // The iteration's content will be flushed automatically.
65+ // An iteration once closed cannot (yet) be reopened.
66+ series.writeIterations ()[1 ].close ();
67+
6268 /* The files in 'series' are still open until the object is destroyed, on
6369 * which it cleanly flushes and closes all open file handles.
6470 * When running out of scope on return, the 'Series' destructor is called.
71+ * Alternatively, one can call `series.close()` to the same effect as
72+ * calling the destructor, including the release of file handles.
6573 */
74+ series.close ();
6675 return 0 ;
6776}
0 commit comments