diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/grib_accessor_class_g2_mars_labeling.cc index 06163f8d2..5e2e73f64 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.cc +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.cc @@ -100,7 +100,6 @@ static int extra_set(grib_accessor* a, long val) long is_chemical_srcsink = 0; long is_aerosol = 0; long is_aerosol_optical = 0; - long is_wave = 0, is_wave_prange = 0; grib_get_long(hand, "is_chemical", &is_chemical); grib_get_long(hand, "is_chemical_srcsink", &is_chemical_srcsink); @@ -108,8 +107,8 @@ static int extra_set(grib_accessor* a, long val) grib_get_long(hand, "is_aerosol", &is_aerosol); grib_get_long(hand, "is_aerosol_optical", &is_aerosol_optical); - is_wave = grib_is_defined(hand, "waveDirectionNumber"); - is_wave_prange = grib_is_defined(hand, "typeOfWavePeriodInterval"); + const int is_wave = grib_is_defined(hand, "waveDirectionNumber"); + const int is_wave_prange = grib_is_defined(hand, "typeOfWavePeriodInterval"); switch (self->index) { case 0: diff --git a/src/accessor/grib_accessor_class_local_definition.cc b/src/accessor/grib_accessor_class_local_definition.cc index 95f671118..5fab28691 100644 --- a/src/accessor/grib_accessor_class_local_definition.cc +++ b/src/accessor/grib_accessor_class_local_definition.cc @@ -96,6 +96,9 @@ int grib_accessor_class_local_definition_t::pack_long(grib_accessor* a, const lo // if (grib2_is_PDTN_EPS(productDefinitionTemplateNumber)) // eps = 1; + // Is this a plain vanilla product? + const int is_plain = grib2_is_PDTN_Plain(productDefinitionTemplateNumber); + switch (localDefinitionNumber) { case 0: productDefinitionTemplateNumberNew = productDefinitionTemplateNumber; @@ -216,6 +219,11 @@ int grib_accessor_class_local_definition_t::pack_long(grib_accessor* a, const lo break; } + if (!is_plain) { + // ECC-1875 + productDefinitionTemplateNumberNew = -1; // disable PDT selection + } + // Adjust for atmospheric chemical constituents if (chemical == 1) { if (eps == 1) { @@ -309,9 +317,9 @@ int grib_accessor_class_local_definition_t::pack_long(grib_accessor* a, const lo } } - if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) { + if (productDefinitionTemplateNumberNew >=0 && productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) { if (a->context->debug) { - fprintf(stderr, "ECCODES DEBUG grib_accessor_local_definition_t: ldNumber=%d, newPDTN=%ld\n", + fprintf(stderr, "ECCODES DEBUG %s %s: ldNumber=%d, newPDTN=%ld\n", a->cclass->name, __func__, localDefinitionNumber, productDefinitionTemplateNumberNew); } if (tooEarly) diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 6cbb4a5bc..3ce4d0838 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -861,6 +861,7 @@ grib_string_list* grib_util_get_param_id(const char* mars_param); grib_string_list* grib_util_get_mars_param(const char* param_id); grib_handle* grib_util_set_spec(grib_handle* h, const grib_util_grid_spec* spec, const grib_util_packing_spec* packing_spec, int flags, const double* data_values, size_t data_values_count, int* err); int parse_keyval_string(const char* grib_tool, char* arg, int values_required, int default_type, grib_values values[], int* count); +int grib2_is_PDTN_Plain(long productDefinitionTemplateNumber); int grib2_is_PDTN_EPS(long productDefinitionTemplateNumber); int grib2_is_PDTN_Chemical(long productDefinitionTemplateNumber); int grib2_is_PDTN_ChemicalSourceSink(long productDefinitionTemplateNumber); diff --git a/src/grib_util.cc b/src/grib_util.cc index 9ff8e7270..9820b3028 100644 --- a/src/grib_util.cc +++ b/src/grib_util.cc @@ -1882,6 +1882,16 @@ int grib2_is_PDTN_EPS(long pdtn) return 0; } +// Return 1 if the productDefinitionTemplateNumber (GRIB2) is for plain (vanilla) products +int grib2_is_PDTN_Plain(long pdtn) +{ + return ( + pdtn == 0 || + pdtn == 1 || + pdtn == 8 || + pdtn == 11); +} + // Return 1 if the productDefinitionTemplateNumber (GRIB2) is for atmospheric chemical constituents int grib2_is_PDTN_Chemical(long pdtn) {