From cd98f8d91f967aa72cdb94dbd5ab6797c9617839 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 22 Sep 2016 16:52:16 +0100 Subject: [PATCH 1/2] Update the version of ecbuild needed (For Python discovery with NO_LIBS) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3cd15f50..09d72f43f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} include( ecbuild_system NO_POLICY_SCOPE ) -ecbuild_requires_macro_version( 1.9 ) +ecbuild_requires_macro_version( 2.4 ) ############################################################################### # local project From f5d5356b39c79ee46e6471288ee820ffe9704bcc Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 22 Sep 2016 16:52:56 +0100 Subject: [PATCH 2/2] ECC-335: grib_util_set_spec: Setting edition=2 and deleteLocalDefinition=1 on GRIB1 does not delete the local definition in target GRIB2 --- src/grib_util.c | 13 +++++++------ tests/grib_util_set_spec.c | 3 +++ tests/grib_util_set_spec.sh | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/grib_util.c b/src/grib_util.c index ae308ec1e..c70905c6b 100644 --- a/src/grib_util.c +++ b/src/grib_util.c @@ -686,11 +686,6 @@ grib_handle* grib_util_set_spec2(grib_handle* h, return NULL; } - if (packing_spec->deleteLocalDefinition) { - /* TODO: not working for grib2 */ - SET_LONG_VALUE("deleteLocalDefinition",1); - } - len=100; grib_get_string(h,"packingType",input_packing_type,&len); grib_get_long(h,"bitsPerValue",&input_bits_per_value); @@ -1282,8 +1277,14 @@ grib_handle* grib_util_set_spec2(grib_handle* h, } } - if(packing_spec->editionNumber && packing_spec->editionNumber!=editionNumber) + if (packing_spec->editionNumber && packing_spec->editionNumber!=editionNumber) { grib_set_long(outh,"edition", packing_spec->editionNumber); + } + + if (packing_spec->deleteLocalDefinition) { + grib_set_long(outh,"setLocalDefinition", 0); + grib_set_long(outh,"deleteLocalDefinition", 1); + } if ( (*err = check_handle_against_spec(outh, editionNumber, spec, global_grid)) != GRIB_SUCCESS) { diff --git a/tests/grib_util_set_spec.c b/tests/grib_util_set_spec.c index 8410d5c03..df7d2c880 100644 --- a/tests/grib_util_set_spec.c +++ b/tests/grib_util_set_spec.c @@ -134,6 +134,9 @@ void test_regular_ll(const char* input_filename, const char* output_filename) packing_spec.bitsPerValue = 24; packing_spec.accuracy=GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; packing_spec.packing=GRIB_UTIL_PACKING_USE_PROVIDED; + /* Convert to edition 2 and remove local use section */ + packing_spec.editionNumber = 2; + packing_spec.deleteLocalDefinition = 1; finalh = codes_grib_util_set_spec( handle, diff --git a/tests/grib_util_set_spec.sh b/tests/grib_util_set_spec.sh index 1d1449713..8a53124b9 100755 --- a/tests/grib_util_set_spec.sh +++ b/tests/grib_util_set_spec.sh @@ -18,8 +18,8 @@ rm -f $outfile ${test_dir}grib_util_set_spec $infile $outfile > /dev/null -res=`${tools_dir}grib_get -p Ni,Nj,numberOfValues,bitsPerValue $outfile` -[ "$res" = "17 14 238 24" ] +res=`${tools_dir}grib_get -p edition,section2Used,Ni,Nj,numberOfValues,bitsPerValue $outfile` +[ "$res" = "2 0 17 14 238 24" ] # Check output file geometry ${tools_dir}grib_get_data $outfile > /dev/null