diff --git a/definitions/grib2/localConcepts/s2s/MTG2SwitchConcept.def b/definitions/grib2/localConcepts/s2s/MTG2SwitchConcept.def new file mode 100644 index 000000000..4813ddbef --- /dev/null +++ b/definitions/grib2/localConcepts/s2s/MTG2SwitchConcept.def @@ -0,0 +1,2 @@ +# This pseudocentre should remain permanently on pre-MTG2 definitions +0 = {edition=2;} \ No newline at end of file diff --git a/definitions/grib2/localConcepts/tigge/MTG2SwitchConcept.def b/definitions/grib2/localConcepts/tigge/MTG2SwitchConcept.def new file mode 100644 index 000000000..4813ddbef --- /dev/null +++ b/definitions/grib2/localConcepts/tigge/MTG2SwitchConcept.def @@ -0,0 +1,2 @@ +# This pseudocentre should remain permanently on pre-MTG2 definitions +0 = {edition=2;} \ No newline at end of file diff --git a/definitions/grib2/localConcepts/uerra/MTG2SwitchConcept.def b/definitions/grib2/localConcepts/uerra/MTG2SwitchConcept.def new file mode 100644 index 000000000..4813ddbef --- /dev/null +++ b/definitions/grib2/localConcepts/uerra/MTG2SwitchConcept.def @@ -0,0 +1,2 @@ +# This pseudocentre should remain permanently on pre-MTG2 definitions +0 = {edition=2;} \ No newline at end of file diff --git a/definitions/grib2/products_crra.def b/definitions/grib2/products_crra.def index ebf328a6f..c7708aa05 100644 --- a/definitions/grib2/products_crra.def +++ b/definitions/grib2/products_crra.def @@ -142,10 +142,11 @@ if (marsStream is "dame") { unalias mars.step; } # MTG2 support given lack of local section -if (tablesVersion <= tablesVersionMTG2Switch) { - # Pre-MTG2 - constant MTG2SwitchDefault = 0; -} else { - # All other cases we are post-MTG2 - constant MTG2SwitchDefault = 1; -} +# This comes after the paramId is already decided, so doesn't work. +# if (tablesVersion <= tablesVersionMTG2Switch) { +# # Pre-MTG2 +# constant MTG2SwitchDefault = 0; +# } else { +# # All other cases we are post-MTG2 +# constant MTG2SwitchDefault = 1; +# } diff --git a/definitions/grib2/products_s2s.def b/definitions/grib2/products_s2s.def index 3525c0db3..01fbda3ed 100644 --- a/definitions/grib2/products_s2s.def +++ b/definitions/grib2/products_s2s.def @@ -111,10 +111,11 @@ if (is_ocean3d_param) { } # MTG2 support given lack of local section -if (tablesVersion <= tablesVersionMTG2Switch) { - # Pre-MTG2 - constant MTG2SwitchDefault = 0; -} else { - # All other cases we are post-MTG2 - constant MTG2SwitchDefault = 1; -} +# This comes after the paramId is already decided, so doesn't work. +# if (tablesVersion <= tablesVersionMTG2Switch) { +# # Pre-MTG2 +# constant MTG2SwitchDefault = 0; +# } else { +# # All other cases we are post-MTG2 +# constant MTG2SwitchDefault = 1; +# } diff --git a/definitions/grib2/products_tigge.def b/definitions/grib2/products_tigge.def index c3c9a0b4b..00dcce6df 100644 --- a/definitions/grib2/products_tigge.def +++ b/definitions/grib2/products_tigge.def @@ -83,10 +83,11 @@ alias mars.stream = marsStream; alias mars.type = marsType; # MTG2 support given lack of local section -if (tablesVersion <= tablesVersionMTG2Switch) { - # Pre-MTG2 - constant MTG2SwitchDefault = 0; -} else { - # All other cases we are post-MTG2 - constant MTG2SwitchDefault = 1; -} +# This comes after the paramId is already decided, so doesn't work. +# if (tablesVersion <= tablesVersionMTG2Switch) { +# # Pre-MTG2 +# constant MTG2SwitchDefault = 0; +# } else { +# # All other cases we are post-MTG2 +# constant MTG2SwitchDefault = 1; +# } diff --git a/definitions/grib2/products_uerra.def b/definitions/grib2/products_uerra.def index 5dbbd09df..f05eb2737 100644 --- a/definitions/grib2/products_uerra.def +++ b/definitions/grib2/products_uerra.def @@ -98,10 +98,11 @@ alias mars.stream = marsStream; alias mars.type = marsType; # MTG2 support given lack of local section -if (tablesVersion <= tablesVersionMTG2Switch) { - # Pre-MTG2 - constant MTG2SwitchDefault = 0; -} else { - # All other cases we are post-MTG2 - constant MTG2SwitchDefault = 1; -} +# This comes after the paramId is already decided, so doesn't work. +# if (tablesVersion <= tablesVersionMTG2Switch) { +# # Pre-MTG2 +# constant MTG2SwitchDefault = 0; +# } else { +# # All other cases we are post-MTG2 +# constant MTG2SwitchDefault = 1; +# } diff --git a/src/accessor/grib_accessor_class_g2_concept_dir.cc b/src/accessor/grib_accessor_class_g2_concept_dir.cc index acf46afae..848c9a4c8 100644 --- a/src/accessor/grib_accessor_class_g2_concept_dir.cc +++ b/src/accessor/grib_accessor_class_g2_concept_dir.cc @@ -55,8 +55,18 @@ int grib_accessor_g2_concept_dir_t::unpack_string(char* v, size_t* len) if (err) return err; size = sizeof(datasetForLocal); + bool datasetForLocalExists = true; err = grib_get_string(h, datasetForLocal_, datasetForLocal, &size); - if (err) return err; + if (err) { + if (err == GRIB_NOT_FOUND) { + // This can happen if accessor is called before section 4 + datasetForLocalExists = false; + err = 0; + } + else { + return err; + } + } const size_t dsize = string_length() - 1; // size for destination string "v" if (preferLocal) { @@ -74,8 +84,8 @@ int grib_accessor_g2_concept_dir_t::unpack_string(char* v, size_t* len) } } - // Override if datasetForLocal is not unknown - if (!STR_EQUAL(datasetForLocal, "unknown")) { + // Override if datasetForLocal exists and is not unknown + if (datasetForLocalExists && !STR_EQUAL(datasetForLocal, "unknown")) { if (mode_ == 1) { snprintf(v, dsize, "%s", masterDir); // conceptsDir1 } else { @@ -83,17 +93,6 @@ int grib_accessor_g2_concept_dir_t::unpack_string(char* v, size_t* len) } } - // if (mode_ == 1) { - // if (STR_EQUAL(datasetForLocal, "unknown")) { - // char centre[64] = {0,}; - // size = sizeof(centre) / sizeof(*centre); - // grib_get_string(h, "centre", centre, &size); - // snprintf(v, 256, "grib2/localConcepts/%s", centre); - // } else { - // snprintf(v, 64, "grib2"); - // } - // } - size = strlen(v); ECCODES_ASSERT(size > 0); *len = size + 1;