diff --git a/src/grib_accessor_class_data_complex_packing.c b/src/grib_accessor_class_data_complex_packing.c index 97c9c4a98..0721c2b52 100644 --- a/src/grib_accessor_class_data_complex_packing.c +++ b/src/grib_accessor_class_data_complex_packing.c @@ -294,7 +294,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len) != GRIB_SUCCESS) return ret; - if((ret = grib_get_long_internal(gh,self->ieee_floats,&ieee_floats)) != GRIB_SUCCESS) + /* ECC-774: don't use grib_get_long_internal */ + if((ret = grib_get_long(gh,self->ieee_floats,&ieee_floats)) != GRIB_SUCCESS) return ret; if((ret = grib_get_double_internal(gh,self->laplacianOperator,&laplacianOperator)) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6d9874d23..32523ec6b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -62,6 +62,7 @@ list( APPEND tests_no_data_reqd # These tests do require data downloads list( APPEND tests_data_reqd grib_double_cmp + change_packing bufr_dump_data bufr_dump_decode_filter bufr_dump_encode_filter diff --git a/tests/change_packing.sh b/tests/change_packing.sh index 94b18c18e..4624ca003 100755 --- a/tests/change_packing.sh +++ b/tests/change_packing.sh @@ -11,48 +11,64 @@ grib1=${data_dir}/reduced_latlon_surface_constant.grib1 grib2=${data_dir}/reduced_latlon_surface_constant.grib2 packing1=" - grid_ieee - grid_simple - grid_simple_matrix" + grid_ieee + grid_simple + grid_simple_matrix" packing2=" - grid_ieee - grid_jpeg - grid_simple - grid_simple_log_preprocessing - grid_simple_matrix" + grid_ieee + grid_jpeg + grid_simple + grid_simple_matrix" +#TODO: grid_simple_log_preprocessing -temp=temp.grib_ +temp=temp.change_packing.grib rm -f $temp # --- test changing the packing # arg 1 : input grib file # arg 2-n : packing types to test function test_packing() { - grib=$1 + grib=$1 - if [ ! -f $grib ]; then - echo "Input data missing" - exit 1 - fi + if [ ! -f $grib ]; then + echo "Input data missing" + exit 1 + fi - shift - while [ $# -gt 0 ]; do - packing=$1 + shift + while [ $# -gt 0 ]; do + packing=$1 - ${tools_dir}/grib_set -r -s packingType=$packing $grib $temp - result=`${tools_dir}/grib_get -p packingType $temp` - - if [ "$result" != "$packing" ]; then - echo "Setting packing did not go right" - exit 1 - fi + ${tools_dir}/grib_set -r -s packingType=$packing $grib $temp + result=`${tools_dir}/grib_get -p packingType $temp` + + if [ "$result" != "$packing" ]; then + echo "Setting packing did not go right" + exit 1 + fi - shift - done + shift + done - rm -f $temp + rm -f $temp } +# ECC-774 +# ------------ +input=${data_dir}/spherical_model_level.grib2 +output=`${tools_dir}/grib_set -r -s packingType=spectral_simple $input $temp 2>&1` +# Check no error was posted i.e. output string is empty +[ -z "$output" ] +res1=`${tools_dir}/grib_get '-F%.1f' -p avg,enorm $input` +res2=`${tools_dir}/grib_get '-F%.1f' -p avg,enorm $temp` +[ "$res1" = "$res2" ] +rm -f $temp + + +# Change grib packing test +# ------------------------- test_packing $grib1 $packing1 test_packing $grib2 $packing2 + +rm -f $temp