diff --git a/definitions/grib2/template.5.42.def b/definitions/grib2/template.5.42.def index 21bcb3e20..f8e9229e2 100644 --- a/definitions/grib2/template.5.42.def +++ b/definitions/grib2/template.5.42.def @@ -15,7 +15,7 @@ include "grib2/template.5.original_values.def"; unsigned[1] ccsdsFlags : dump; flagbit AEC_DATA_SIGNED_OPTION_MASK(ccsdsFlags,0) = 0; -flagbit AEC_DATA_3BYTE_OPTION_MASK(ccsdsFlags,1) = 0; +flagbit AEC_DATA_3BYTE_OPTION_MASK(ccsdsFlags,1) = 1; flagbit AEC_DATA_MSB_OPTION_MASK(ccsdsFlags,2) = 1; flagbit AEC_DATA_PREPROCESS_OPTION_MASK(ccsdsFlags,3) = 1; flagbit AEC_RESTRICTED_OPTION_MASK(ccsdsFlags,4) = 0; diff --git a/src/grib_accessor_class_data_ccsds_packing.c b/src/grib_accessor_class_data_ccsds_packing.c index 00f7d969f..c97fe1fcf 100644 --- a/src/grib_accessor_class_data_ccsds_packing.c +++ b/src/grib_accessor_class_data_ccsds_packing.c @@ -275,7 +275,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len) */ bits8 = ((bits_per_value + 7)/8)*8; - size = n_vals * (bits_per_value + 7)/8; + size = n_vals * ((bits_per_value + 7)/8); decoded = grib_context_buffer_malloc_clear(a->context,size); if(!decoded) { err = GRIB_OUT_OF_MEMORY; diff --git a/tests/ccsds.sh b/tests/ccsds.sh index 795526ffa..8cd7ddca2 100755 --- a/tests/ccsds.sh +++ b/tests/ccsds.sh @@ -69,3 +69,13 @@ res3=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $outfile2` [ "$res1" = "$res3" ] rm -f $outfile1 $outfile2 || true + +infile=${data_dir}/tigge_ecmwf.grib2 +outfile1=$infile.tmp_ccsds.1 +outfile2=$infile.tmp_ccsds.2 + +${tools_dir}grib_set -r -s bitsPerValue=17 $infile $outfile1 +${tools_dir}grib_set -r -s packingType=grid_ccsds $outfile1 $outfile2 +${tools_dir}grib_compare -P -c data:n $outfile1 $outfile2 + +rm -f $outfile1 $outfile2