Skip to content

Commit 480d343

Browse files
committed
Fix ADIOS1 bug: Wrong datatype reported for unitDimension
1 parent be6855e commit 480d343

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/backend/Attributable.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,29 @@ AttributableImpl::readAttributes( ReadMode mode )
207207
continue;
208208
}
209209
Attribute a(*aRead.resource);
210+
211+
auto guardUnitDimension =
212+
[ this ]( std::string const & key, auto vector )
213+
{
214+
if( key == "unitDimension" )
215+
{
216+
// Some backends may report the wrong type when reading
217+
if( vector.size() != 7 )
218+
{
219+
throw std::runtime_error(
220+
"[Attributable] "
221+
"Unexpected datatype for unitDimension." );
222+
}
223+
std::array< double, 7 > arr;
224+
std::copy_n( vector.begin(), 7, arr.begin() );
225+
setAttribute( key, std::move( arr ) );
226+
}
227+
else
228+
{
229+
setAttribute( key, std::move( vector ) );
230+
}
231+
};
232+
210233
switch( *aRead.dtype )
211234
{
212235
case DT::CHAR:
@@ -291,13 +314,13 @@ AttributableImpl::readAttributes( ReadMode mode )
291314
setAttribute(att, a.get< std::vector< unsigned long long > >());
292315
break;
293316
case DT::VEC_FLOAT:
294-
setAttribute(att, a.get< std::vector< float > >());
317+
guardUnitDimension( att, a.get< std::vector< float > >() );
295318
break;
296319
case DT::VEC_DOUBLE:
297-
setAttribute(att, a.get< std::vector< double > >());
320+
guardUnitDimension( att, a.get< std::vector< double > >() );
298321
break;
299322
case DT::VEC_LONG_DOUBLE:
300-
setAttribute(att, a.get< std::vector< long double > >());
323+
guardUnitDimension( att, a.get< std::vector< long double > >() );
301324
break;
302325
case DT::VEC_CFLOAT:
303326
setAttribute(att, a.get< std::vector< std::complex< float > > >());

0 commit comments

Comments
 (0)