From 7cf12c0ca0e6a8d1c7e6a0c5b68424ee63ad4ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Wed, 17 Mar 2021 01:03:31 +0100 Subject: [PATCH] Particle Patches: Do not emplace patch records if they don't exist in the file being read (#945) * Removed from PR during backport: Test openpmd-pipe on git-sample/data%T.h5 * Only emplace particle patches in container if they exist --- src/ParticleSpecies.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ParticleSpecies.cpp b/src/ParticleSpecies.cpp index 7283e5fec6..f18179ac58 100644 --- a/src/ParticleSpecies.cpp +++ b/src/ParticleSpecies.cpp @@ -37,10 +37,12 @@ ParticleSpecies::read() Parameter< Operation::OPEN_PATH > pOpen; Parameter< Operation::LIST_ATTS > aList; + bool hasParticlePatches = false; for( auto const& record_name : *pList.paths ) { if( record_name == "particlePatches" ) { + hasParticlePatches = true; pOpen.path = "particlePatches"; IOHandler->enqueue(IOTask(&particlePatches, pOpen)); particlePatches.read(); @@ -69,6 +71,13 @@ ParticleSpecies::read() } } + if( !hasParticlePatches ) + { + auto & container = *particlePatches.m_container; + container.erase( "numParticles" ); + container.erase( "numParticlesOffset" ); + } + /* obtain all scalar records */ Parameter< Operation::LIST_DATASETS > dList; IOHandler->enqueue(IOTask(this, dList));