Skip to content

Commit

Permalink
Merge pull request #3327 from eisenhauer/DeSer
Browse files Browse the repository at this point in the history
Reinstall Norbert's BP5Deserializer opts
  • Loading branch information
dmitry-ganyushin authored Aug 26, 2022
2 parents 6ff7fc3 + 8c3e922 commit 8552472
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
43 changes: 24 additions & 19 deletions source/adios2/toolkit/format/bp5/BP5Deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,22 @@ DataType BP5Deserializer::TranslateFFSType2ADIOS(const char *Type, int size)
return DataType::None;
}

void BP5Deserializer::BreakdownVarName(const char *Name, char **base_name_p,
DataType *type_p, int *element_size_p)
const char *BP5Deserializer::BreakdownVarName(const char *Name,
DataType *type_p,
int *element_size_p)
{
int Type;
int ElementSize;
const char *NameStart = strchr(strchr(Name + 4, '_') + 1, '_') + 1;
// + 4 to skip BP5_ or bp5_ prefix
sscanf(Name + 4, "%d_%d_", &ElementSize, &Type);
*element_size_p = ElementSize;
// const char *NameStart = strchr(strchr(Name + 4, '_') + 1, '_') + 1;
// sscanf(Name + 4, "%d_%d", &ElementSize, &Type);
/* string formatted as bp5_%d_%d_actualname */
char *p;
// + 3 to skip BP5_ or bp5_ prefix
long n = strtol(Name + 4, &p, 10);
*element_size_p = static_cast<int>(n);
++p; // skip '_'
long Type = strtol(p, &p, 10);
*type_p = (DataType)Type;
*base_name_p = strdup(NameStart);
++p; // skip '_'
return p;
}

void BP5Deserializer::BreakdownFieldType(const char *FieldType, bool &Operator,
Expand Down Expand Up @@ -232,14 +237,16 @@ void BP5Deserializer::BreakdownV1ArrayName(const char *Name, char **base_name_p,
void BP5Deserializer::BreakdownArrayName(const char *Name, char **base_name_p,
DataType *type_p, int *element_size_p)
{
int Type;
int ElementSize;
const char *NameStart = strchr(strchr(Name + 4, '_') + 1, '_') + 1;
/* string formatted as bp5_%d_%d_actualname */
char *p;
// + 3 to skip BP5_ or bp5_ prefix
sscanf(Name + 4, "%d_%d", &ElementSize, &Type);
*element_size_p = ElementSize;
long n = strtol(Name + 4, &p, 10);
*element_size_p = static_cast<int>(n);
++p; // skip '_'
long Type = strtol(p, &p, 10);
*type_p = (DataType)Type;
*base_name_p = strdup(NameStart);
++p; // skip '_'
*base_name_p = strdup(p);
}

BP5Deserializer::BP5VarRec *BP5Deserializer::LookupVarByKey(void *Key) const
Expand Down Expand Up @@ -852,15 +859,14 @@ void BP5Deserializer::InstallAttributesV1(FFSTypeHandle FFSformat,
int i = 0;
while (FieldList[i].field_name)
{
char *FieldName;
void *field_data = (char *)BaseData + FieldList[i].field_offset;

if (!NameIndicatesAttrArray(FieldList[i].field_name))
{
DataType Type;
int ElemSize;
BreakdownVarName(FieldList[i].field_name, &FieldName, &Type,
&ElemSize);
const char *FieldName =
BreakdownVarName(FieldList[i].field_name, &Type, &ElemSize);
if (Type == adios2::DataType::Struct)
{
return;
Expand All @@ -884,7 +890,6 @@ void BP5Deserializer::InstallAttributesV1(FFSTypeHandle FFSformat,
std::cout << "Loading attribute matched no type "
<< ToString(Type) << std::endl;
}
free(FieldName);
i++;
}
else
Expand Down
4 changes: 2 additions & 2 deletions source/adios2/toolkit/format/bp5/BP5Deserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ class BP5Deserializer : virtual public BP5Base
BP5VarRec *LookupVarByName(const char *Name);
BP5VarRec *CreateVarRec(const char *ArrayName);
void ReverseDimensions(size_t *Dimensions, size_t count, size_t times);
void BreakdownVarName(const char *Name, char **base_name_p,
DataType *type_p, int *element_size_p);
const char *BreakdownVarName(const char *Name, DataType *type_p,
int *element_size_p);
void BreakdownFieldType(const char *FieldType, bool &Operator,
bool &MinMax);
void BreakdownArrayName(const char *Name, char **base_name_p,
Expand Down

0 comments on commit 8552472

Please sign in to comment.