mirror of https://github.com/ecmwf/eccodes.git
ECC-1897: GRIB2: Print a warning if the packing type template is experimental or deprecated
This commit is contained in:
parent
6f3f99beb3
commit
fe5a4b168c
|
@ -410,7 +410,7 @@ int grib_set_string_internal(grib_handle* h, const char* name,
|
|||
/* Return 1 if we dealt with specific packing type changes and nothing more needs doing.
|
||||
* Return 0 if further action is needed
|
||||
*/
|
||||
static int process_packingType_change(grib_handle* h, const char* keyname, const char* keyval)
|
||||
static int preprocess_packingType_change(grib_handle* h, const char* keyname, const char* keyval)
|
||||
{
|
||||
int err = 0;
|
||||
char input_packing_type[100] = {0,};
|
||||
|
@ -456,24 +456,37 @@ static int process_packingType_change(grib_handle* h, const char* keyname, const
|
|||
if (strcmp(input_packing_type, "grid_ieee") == 0) {
|
||||
const long max_bpv = 32; /* Cannot do any higher */
|
||||
grib_set_long(h, "bitsPerValue", max_bpv);
|
||||
/*
|
||||
long accuracy = 0;
|
||||
err = grib_get_long(h, "accuracy", &accuracy);
|
||||
if (!err) {
|
||||
grib_set_long(h, "bitsPerValue", accuracy);
|
||||
} */
|
||||
//long accuracy = 0;
|
||||
//err = grib_get_long(h, "accuracy", &accuracy);
|
||||
//if (!err) grib_set_long(h, "bitsPerValue", accuracy);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; /* Further action is needed */
|
||||
}
|
||||
|
||||
static void postprocess_packingType_change(grib_handle* h, const char* keyname, const char* keyval)
|
||||
{
|
||||
if (grib_inline_strcmp(keyname, "packingType") == 0) {
|
||||
long is_experimental = 0, is_deprecated = 0;
|
||||
if (grib_get_long(h, "isTemplateExperimental", &is_experimental) == GRIB_SUCCESS && is_experimental == 1) {
|
||||
fprintf(stderr, "ECCODES WARNING : The template for %s=%s is experimental. "
|
||||
"This template was not validated at the time of publication.\n",
|
||||
keyname, keyval);
|
||||
return;
|
||||
}
|
||||
if (grib_get_long(h, "isTemplateDeprecated", &is_deprecated) == GRIB_SUCCESS && is_deprecated == 1) {
|
||||
fprintf(stderr, "ECCODES WARNING : The template for %s=%s is deprecated.\n", keyname, keyval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int grib_set_string(grib_handle* h, const char* name, const char* val, size_t* length)
|
||||
{
|
||||
int ret = 0;
|
||||
grib_accessor* a = NULL;
|
||||
|
||||
int processed = process_packingType_change(h, name, val);
|
||||
int processed = preprocess_packingType_change(h, name, val);
|
||||
if (processed)
|
||||
return GRIB_SUCCESS; /* Dealt with - no further action needed */
|
||||
|
||||
|
@ -492,6 +505,7 @@ int grib_set_string(grib_handle* h, const char* name, const char* val, size_t* l
|
|||
|
||||
ret = a->pack_string(val, length);
|
||||
if (ret == GRIB_SUCCESS) {
|
||||
postprocess_packingType_change(h, name, val);
|
||||
return grib_dependency_notify_change(a);
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -144,9 +144,15 @@ fi
|
|||
# grid_simple_log_preprocessing
|
||||
# -----------------------------
|
||||
input=${data_dir}/sample.grib2
|
||||
${tools_dir}/grib_set -r -s packingType=grid_simple_log_preprocessing $input $temp
|
||||
${tools_dir}/grib_set -r -s packingType=grid_simple_log_preprocessing $input $temp 2> $temp_err
|
||||
grib_check_key_equals $temp packingType 'grid_simple_log_preprocessing'
|
||||
${tools_dir}/grib_compare -c data:n -R packedValues=2e-6 $input $temp
|
||||
# ECC-1897
|
||||
grep -q "ECCODES WARNING.*is experimental" $temp_err
|
||||
|
||||
${tools_dir}/grib_set -r -s packingType=grid_simple_matrix $input $temp 2> $temp_err
|
||||
grep -q "ECCODES WARNING.*is experimental" $temp_err
|
||||
|
||||
|
||||
# Large constant fields
|
||||
# -----------------------
|
||||
|
|
Loading…
Reference in New Issue