From d5959c122614d9255dc025ab4e670849e3aeb928 Mon Sep 17 00:00:00 2001 From: Enrico Fucile Date: Fri, 12 Feb 2016 14:27:38 +0000 Subject: [PATCH] ECC-108 --- src/grib_accessor_class_bufr_data_array.c | 61 +++++++++++------------ src/grib_value.c | 1 + tests/bufr_filter.sh | 52 +++++++++++++++++++ 3 files changed, 82 insertions(+), 32 deletions(-) diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index 1ef1d4a5e..277334a0b 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -889,39 +889,36 @@ static int encode_new_replication(grib_context* c,grib_accessor_bufr_data_array* unsigned long repetitions=1; bufr_descriptor** descriptors=self->expanded->v; - /* compressed to be implemented*/ - if (self->compressedData==0) { - switch(descriptors[i]->code) { - case 31000: - if (self->nInputShortReplications>=0) { - if (self->iInputShortReplications>=self->nInputShortReplications) { - grib_context_log(c,GRIB_LOG_FATAL,"array inputShortDelayedDescriptorReplicationFactor dimension too small"); - } - repetitions=self->inputShortReplications[self->iInputShortReplications]; - self->iInputShortReplications++; - } - break; - case 31001: - if (self->nInputReplications>=0) { - if (self->iInputReplications>=self->nInputReplications) { - grib_context_log(c,GRIB_LOG_FATAL,"array inputDelayedDescriptorReplicationFactor dimension too small"); - } - repetitions=self->inputReplications[self->iInputReplications]; - self->iInputReplications++; - } - break; - case 31002: - if (self->nInputExtendedReplications>=0) { - if (self->iInputExtendedReplications>=self->nInputExtendedReplications) { - grib_context_log(c,GRIB_LOG_FATAL,"array inputExtendedDelayedDescriptorReplicationFactor dimension too small"); - } - repetitions=self->inputExtendedReplications[self->iInputExtendedReplications]; - self->iInputExtendedReplications++; - } - break; - default: - Assert(0); + switch(descriptors[i]->code) { + case 31000: + if (self->nInputShortReplications>=0) { + if (self->iInputShortReplications>=self->nInputShortReplications) { + grib_context_log(c,GRIB_LOG_FATAL,"array inputShortDelayedDescriptorReplicationFactor dimension too small"); + } + repetitions=self->inputShortReplications[self->iInputShortReplications]; + self->iInputShortReplications++; } + break; + case 31001: + if (self->nInputReplications>=0) { + if (self->iInputReplications>=self->nInputReplications) { + grib_context_log(c,GRIB_LOG_FATAL,"array inputDelayedDescriptorReplicationFactor dimension too small"); + } + repetitions=self->inputReplications[self->iInputReplications]; + self->iInputReplications++; + } + break; + case 31002: + if (self->nInputExtendedReplications>=0) { + if (self->iInputExtendedReplications>=self->nInputExtendedReplications) { + grib_context_log(c,GRIB_LOG_FATAL,"array inputExtendedDelayedDescriptorReplicationFactor dimension too small"); + } + repetitions=self->inputExtendedReplications[self->iInputExtendedReplications]; + self->iInputExtendedReplications++; + } + break; + default: + Assert(0); } grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data encoding replication: \twidth=%ld pos=%ld ulength=%ld ulength_bits=%ld", diff --git a/src/grib_value.c b/src/grib_value.c index 784e5dd68..f7cee5e1d 100644 --- a/src/grib_value.c +++ b/src/grib_value.c @@ -628,6 +628,7 @@ static int _grib_set_double_array(grib_handle* h, const char* name, if(check && (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return GRIB_READ_ONLY; err=grib_pack_double(a, val, &length); + encoded=length; } else err=_grib_set_double_array_internal(h,a,val,length,&encoded,check); if(err == GRIB_SUCCESS && length > encoded) diff --git a/tests/bufr_filter.sh b/tests/bufr_filter.sh index 003eef019..25b314bfd 100755 --- a/tests/bufr_filter.sh +++ b/tests/bufr_filter.sh @@ -1079,3 +1079,55 @@ diff ${f}.log.ref ${f}.log rm -f ${f}.log ${f}.log.ref rm -f $fLog $fRules +#----------------------------------------------------------- +# Test: delayed replication compressed data +#----------------------------------------------------------- +cat > $fRules <> $fLog +echo "file: $f" >> $fLog +${tools_dir}bufr_filter -o $fOut $fRules $f 2>> $fLog 1>> $fLog + +cat > ${fRules} < ${f}.log + +cat > ${f}.log.ref <