diff --git a/definitions/grib1/section.1.def b/definitions/grib1/section.1.def index 974977dfd..25829af6c 100644 --- a/definitions/grib1/section.1.def +++ b/definitions/grib1/section.1.def @@ -112,6 +112,10 @@ if( indicatorOfTypeOfLevel == 109 || { alias mars.levelist = level; } +if (indicatorOfTypeOfLevel == 117) { + # See ECC-1081 + constant levelFactor = 6; +} unsigned[1] yearOfCentury : edition_specific; unsigned[1] month; diff --git a/src/grib_accessor_class_g2level.cc b/src/grib_accessor_class_g2level.cc index 4931f2f2b..d62152f53 100644 --- a/src/grib_accessor_class_g2level.cc +++ b/src/grib_accessor_class_g2level.cc @@ -292,6 +292,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) long value_first = *val; long scale_first = 0; long type_first = 0; + long levelFactor = 1; char pressure_units[10] = {0,}; size_t pressure_units_len = 10; @@ -324,6 +325,13 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) if (!strcmp(pressure_units, "hPa")) value_first *= 100; break; + case 109: + //printf("type1 = 109\n"); + if ((ret = grib_get_long(hand, "levelFactor", &levelFactor)) == GRIB_SUCCESS) { + // See ECC-1081 + // printf(" Special case - change scale_first to %ld\n", levelFactor); + scale_first = levelFactor; + } default: break; diff --git a/tests/grib_level.sh b/tests/grib_level.sh index 822882a8a..2847c64fd 100755 --- a/tests/grib_level.sh +++ b/tests/grib_level.sh @@ -82,6 +82,13 @@ ${tools_dir}/grib_set -s scaledValueOfFirstFixedSurface=15,scaleFactorOfFirstFix res=`${tools_dir}/grib_get -p level:d $temp` [ "$res" = "1.5" ] +# ECC-1081: 'level' is not edition-independent for potential vorticity levels +${tools_dir}/grib_set -s typeOfLevel=potentialVorticity,shortName=q,level=1500 $sample_g1 $temp +${tools_dir}/grib_set -s edition=2 $temp $temp2 +grib_check_key_equals $temp2 'mars.levelist,level,typeOfLevel' '1500 1500 potentialVorticity' +grib_check_key_equals $temp2 'scaleFactorOfFirstFixedSurface,scaledValueOfFirstFixedSurface' '6 1500' + + # GRIB-637 grib2 Potential vorticity surface input=${data_dir}/tigge_pf_ecmwf.grib2 res=`${tools_dir}/grib_get -wcount=7 -F%.20f -p level:d $input`