Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstall Norbert's BP5Deserializer opts #3327

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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