Fix issue #2674
This commit is contained in:
Ward Fisher 2023-04-12 15:48:10 -06:00 committed by GitHub
commit f8904d5a1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1205,12 +1205,14 @@ static int get_quantize_info(NC_VAR_INFO_T *var)
{
hid_t attid;
hid_t datasetid;
htri_t attr_exists;
/* Try to open an attribute of the correct name for quantize
* info. */
datasetid = ((NC_HDF5_VAR_INFO_T *)var->format_var_info)->hdf_datasetid;
attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITGROOM_ATT_NAME,
H5P_DEFAULT, H5P_DEFAULT);
attr_exists = H5Aexists(datasetid, NC_QUANTIZE_BITGROOM_ATT_NAME);
attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITGROOM_ATT_NAME,
H5P_DEFAULT, H5P_DEFAULT) : 0;
if (attid > 0)
{
@ -1218,16 +1220,18 @@ static int get_quantize_info(NC_VAR_INFO_T *var)
}
else
{
attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_GRANULARBR_ATT_NAME,
H5P_DEFAULT, H5P_DEFAULT);
attr_exists = H5Aexists(datasetid, NC_QUANTIZE_GRANULARBR_ATT_NAME);
attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_GRANULARBR_ATT_NAME,
H5P_DEFAULT, H5P_DEFAULT) : 0;
if (attid > 0)
{
var->quantize_mode = NC_QUANTIZE_GRANULARBR;
}
else
{
attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITROUND_ATT_NAME,
H5P_DEFAULT, H5P_DEFAULT);
attr_exists = H5Aexists(datasetid, NC_QUANTIZE_BITROUND_ATT_NAME);
attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITROUND_ATT_NAME,
H5P_DEFAULT, H5P_DEFAULT) : 0;
if (attid > 0)
var->quantize_mode = NC_QUANTIZE_BITROUND;
}