mirror of https://github.com/ecmwf/eccodes.git
fixed problem in nested delayed replication (passing test for all BUFR samples!)
This commit is contained in:
parent
b391de3a18
commit
642e843a91
|
@ -579,7 +579,7 @@ static int decode_elements(grib_accessor* a) {
|
|||
long numberOfElementsToRepeat[MAX_NESTED_REPLICATIONS]={0,};
|
||||
long numberOfRepetitions[MAX_NESTED_REPLICATIONS]={0,};
|
||||
long startRepetition[MAX_NESTED_REPLICATIONS]={0,};
|
||||
long numberOfNestedRepetions=0;
|
||||
long numberOfNestedRepetitions=0;
|
||||
unsigned char* data=0;
|
||||
int i;
|
||||
grib_iarray* elementsDescriptorsIndex=0;
|
||||
|
@ -642,9 +642,9 @@ static int decode_elements(grib_accessor* a) {
|
|||
break;
|
||||
case 1:
|
||||
/* Delayed replication */
|
||||
inr=numberOfNestedRepetions;
|
||||
numberOfNestedRepetions++;
|
||||
Assert(numberOfNestedRepetions<=MAX_NESTED_REPLICATIONS);
|
||||
inr=numberOfNestedRepetitions;
|
||||
numberOfNestedRepetitions++;
|
||||
Assert(numberOfNestedRepetitions<=MAX_NESTED_REPLICATIONS);
|
||||
numberOfElementsToRepeat[inr]=descriptors[i]->X;
|
||||
n[inr]=numberOfElementsToRepeat[inr];
|
||||
i++;
|
||||
|
@ -672,7 +672,11 @@ static int decode_elements(grib_accessor* a) {
|
|||
} else {
|
||||
grib_darray_push(c,dval,(double)numberOfRepetitions[inr]);
|
||||
}
|
||||
if (numberOfRepetitions[inr]==0) i+=numberOfElementsToRepeat[inr];
|
||||
if (numberOfRepetitions[inr]==0) {
|
||||
i+=numberOfElementsToRepeat[inr];
|
||||
if (inr>0) n[inr-1]-=numberOfElementsToRepeat[inr]+2;
|
||||
numberOfNestedRepetitions--;
|
||||
}
|
||||
continue;
|
||||
case 2:
|
||||
/* Operator */
|
||||
|
@ -753,7 +757,7 @@ static int decode_elements(grib_accessor* a) {
|
|||
}
|
||||
|
||||
/* delayed repetition check */
|
||||
innr=numberOfNestedRepetions-1;
|
||||
innr=numberOfNestedRepetitions-1;
|
||||
for (ir=innr;ir>=0;ir--) {
|
||||
if (nn[ir]) {
|
||||
if (n[ir]>1) {
|
||||
|
@ -767,18 +771,21 @@ static int decode_elements(grib_accessor* a) {
|
|||
break;
|
||||
} else {
|
||||
if (ir>0) {
|
||||
n[ir-1]-=numberOfElementsToRepeat[ir]+1;
|
||||
i=startRepetition[ir-1];
|
||||
n[ir-1]-=numberOfElementsToRepeat[ir]+2;
|
||||
/* i=startRepetition[ir-1]; */
|
||||
i=startRepetition[ir]+numberOfElementsToRepeat[ir];
|
||||
} else {
|
||||
i=startRepetition[ir]+numberOfElementsToRepeat[ir];
|
||||
}
|
||||
numberOfNestedRepetions--;
|
||||
numberOfNestedRepetitions--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ir==0) {
|
||||
i=startRepetition[ir]+numberOfElementsToRepeat[ir]+1;
|
||||
numberOfNestedRepetions=0;
|
||||
numberOfNestedRepetitions=0;
|
||||
} else {
|
||||
numberOfNestedRepetitions--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
. ./include.sh
|
||||
|
||||
REDIRECT=/dev/null
|
||||
|
@ -26,22 +28,11 @@ do
|
|||
|
||||
rm -f $res_num | true
|
||||
|
||||
set +e
|
||||
${tools_dir}bufr_filter bufrdc_num_ref.filter $file 2> $REDIRECT > $res_num
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
cp $file $file.no
|
||||
fi
|
||||
|
||||
# Cannot use plain diff. We need to compare FLOAT NUMBERS with a tolerance
|
||||
#perl number_compare.pl $ref_num $res_num >$REDIRECT 2> $REDIRECT
|
||||
numdiff $ref_num $res_num > $diff_num 2> $diff_num
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
cp $file $file.no
|
||||
fi
|
||||
perl number_compare.pl $ref_num $res_num >$REDIRECT 2> $REDIRECT
|
||||
|
||||
#rm -f $res_num $diff_num
|
||||
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in New Issue