From 1c24fa08f50bf13139c52e3eaca06904611d0c02 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 13 Oct 2023 15:34:17 +0100 Subject: [PATCH] GRIB-488: Tighten the condition for ERA-CLIM data --- src/grib_accessor_class_g2end_step.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/grib_accessor_class_g2end_step.cc b/src/grib_accessor_class_g2end_step.cc index 285a30085..2a044d294 100644 --- a/src/grib_accessor_class_g2end_step.cc +++ b/src/grib_accessor_class_g2end_step.cc @@ -209,18 +209,24 @@ static const int u2s[] = { 1800 /* (15) 30 minutes */ }; -/* See GRIB-488 */ -static int is_special_expver(grib_handle* h) +// See GRIB-488 +static bool is_special_expver(const grib_handle* h) { - int ret = 0; - char strExpVer[50] = {0,}; + int ret = 0; + char strMarsExpVer[50] = {0,}; + char strMarsClass[50] = {0,}; size_t slen = 50; - ret = grib_get_string(h, "experimentVersionNumber", strExpVer, &slen); - if (ret == GRIB_SUCCESS && !strcmp(strExpVer, "1605")) { - return 1; /* Special case of expVer 1605! */ + ret = grib_get_string(h, "mars.class", strMarsClass, &slen); + if (ret == GRIB_SUCCESS && STR_EQUAL(strMarsClass, "em")) { + // em = ERA-CLIM model integration for the 20th-century (ERA-20CM) + slen = 50; + ret = grib_get_string(h, "experimentVersionNumber", strMarsExpVer, &slen); + if (ret == GRIB_SUCCESS && STR_EQUAL(strMarsExpVer, "1605")) { + return true; // Special case of expVer 1605 in class "em" + } } - return 0; + return false; } static int convert_time_range(