@@ -257,8 +257,17 @@ RecordComponent::storeChunk(T_ContiguousContainer &data, Offset o, Extent e)
257257 // default arguments
258258 // offset = {0u}: expand to right dim {0u, 0u, ...}
259259 Offset offset = o;
260- if (o.size () == 1u && o.at (0 ) == 0u && dim > 1u )
261- offset = Offset (dim, 0u );
260+ if (o.size () == 1u && o.at (0 ) == 0u )
261+ {
262+ if (joinedDimension ().has_value ())
263+ {
264+ offset.clear ();
265+ }
266+ else if (dim > 1u )
267+ {
268+ offset = Offset (dim, 0u );
269+ }
270+ }
262271
263272 // extent = {-1u}: take full size
264273 Extent extent (dim, 1u );
@@ -276,38 +285,7 @@ template <typename T, typename F>
276285inline DynamicMemoryView<T>
277286RecordComponent::storeChunk (Offset o, Extent e, F &&createBuffer)
278287{
279- if (constant ())
280- throw std::runtime_error (
281- " Chunks cannot be written for a constant RecordComponent." );
282- if (empty ())
283- throw std::runtime_error (
284- " Chunks cannot be written for an empty RecordComponent." );
285- Datatype dtype = determineDatatype<T>();
286- if (dtype != getDatatype ())
287- {
288- std::ostringstream oss;
289- oss << " Datatypes of chunk data (" << dtype
290- << " ) and record component (" << getDatatype () << " ) do not match." ;
291- throw std::runtime_error (oss.str ());
292- }
293- uint8_t dim = getDimensionality ();
294- if (e.size () != dim || o.size () != dim)
295- {
296- std::ostringstream oss;
297- oss << " Dimensionality of chunk ("
298- << " offset=" << o.size () << " D, "
299- << " extent=" << e.size () << " D) "
300- << " and record component (" << int (dim) << " D) "
301- << " do not match." ;
302- throw std::runtime_error (oss.str ());
303- }
304- Extent dse = getExtent ();
305- for (uint8_t i = 0 ; i < dim; ++i)
306- if (dse[i] < o[i] + e[i])
307- throw std::runtime_error (
308- " Chunk does not reside inside dataset (Dimension on index " +
309- std::to_string (i) + " . DS: " + std::to_string (dse[i]) +
310- " - Chunk: " + std::to_string (o[i] + e[i]) + " )" );
288+ verifyChunk<T>(o, e);
311289
312290 /*
313291 * The openPMD backend might not yet know about this dataset.
@@ -332,6 +310,7 @@ RecordComponent::storeChunk(Offset o, Extent e, F &&createBuffer)
332310 dCreate.name = rc.m_name ;
333311 dCreate.extent = getExtent ();
334312 dCreate.dtype = getDatatype ();
313+ dCreate.joinedDimension = joinedDimension ();
335314 if (!rc.m_dataset .has_value ())
336315 {
337316 throw error::WrongAPIUsage (
@@ -372,4 +351,10 @@ RecordComponent::storeChunk(Offset offset, Extent extent)
372351#endif
373352 });
374353}
354+
355+ template <typename T>
356+ void RecordComponent::verifyChunk (Offset const &o, Extent const &e) const
357+ {
358+ verifyChunk (determineDatatype<T>(), o, e);
359+ }
375360} // namespace openPMD
0 commit comments