diff --git a/definitions/bufr/section.3.def b/definitions/bufr/section.3.def index 9766eb0bf..fb92f594c 100644 --- a/definitions/bufr/section.3.def +++ b/definitions/bufr/section.3.def @@ -76,26 +76,27 @@ elementScale=dict_search("element.table",elementCode,5,tablesMasterDir,tablesLoc elementReference=dict_search("element.table",elementCode,6,tablesMasterDir,tablesLocalDir) : string_type,hidden ; elementWidth=dict_search("element.table",elementCode,7,tablesMasterDir,tablesLocalDir) : string_type,hidden ; -meta expandedDescriptors expanded_descriptors(expandedDescriptors,0,unexpandedDescriptors,sequences, - elementCode,elementUnit,elementScale,elementReference,elementWidth); -meta expandedFactors expanded_descriptors(expandedDescriptors,1); -meta expandedReferences expanded_descriptors(expandedDescriptors,2); -meta expandedWidths expanded_descriptors(expandedDescriptors,3); +meta expandedCodes expanded_descriptors(expandedCodes,0,unexpandedDescriptors,sequences,elementCode, + elementUnit,elementScale,elementReference,elementWidth); +meta expandedScales expanded_descriptors(expandedCodes,1); +meta expandedReferences expanded_descriptors(expandedCodes,2); +meta expandedWidths expanded_descriptors(expandedCodes,3); +meta expandedFlags expanded_descriptors(expandedCodes,4); -meta bufrdcExpandedDescriptors bufrdc_expanded_descriptors(expandedDescriptors); +meta bufrdcExpandedDescriptors bufrdc_expanded_descriptors(expandedCodes); #smart_table NAME (VALUES,FILE_NAME,MASTER_DIRECTORY,LOCAL_DIRECTORY,WIDTH_OF_CODE_IN_BITS,EXTRA_DIRECTORY,EXTRA_FILE_NAME); -smart_table expanded (expandedDescriptors,"element.table",tablesMasterDir,tablesLocalDir,18,rootTablesDir,"operators.table") ; -meta abbreviation smart_table_column(expanded,0,1) : string_type; -meta type smart_table_column(expanded,1,0) : string_type; -meta name smart_table_column(expanded,2,0) : string_type; -meta unit smart_table_column(expanded,3,0) : string_type; -meta scale smart_table_column(expanded,4,0) : long_type; -meta reference smart_table_column(expanded,5,0) : long_type; -meta width smart_table_column(expanded,6,0) : long_type; -meta crex_unit smart_table_column(expanded,7,0) : long_type; -meta crex_scale smart_table_column(expanded,8,0) : long_type; -meta crex_width smart_table_column(expanded,9,0) : long_type; +smart_table expandedOriginalCodes (expandedCodes,"element.table",tablesMasterDir,tablesLocalDir,18,rootTablesDir,"operators.table") ; +meta expandedAbbreviations smart_table_column(expandedOriginalCodes,0,1) : string_type; +meta expandedTypes smart_table_column(expandedOriginalCodes,1,0) : string_type; +meta expandedNames smart_table_column(expandedOriginalCodes,2,0) : string_type; +meta expandedUnits smart_table_column(expandedOriginalCodes,3,0) : string_type; +meta expandedOriginalScales smart_table_column(expandedOriginalCodes,4,0) : long_type; +meta expandedOriginalReferences smart_table_column(expandedOriginalCodes,5,0) : long_type; +meta expandedOriginalWidths smart_table_column(expandedOriginalCodes,6,0) : long_type; +meta expandedCrex_units smart_table_column(expandedOriginalCodes,7,0) : long_type; +meta expandedCrex_scales smart_table_column(expandedOriginalCodes,8,0) : long_type; +meta expandedCrex_widths smart_table_column(expandedOriginalCodes,9,0) : long_type; position endDescriptors; section_padding section3Padding; diff --git a/definitions/bufr/section.4.def b/definitions/bufr/section.4.def index 34b124538..ea5fb1bd7 100644 --- a/definitions/bufr/section.4.def +++ b/definitions/bufr/section.4.def @@ -18,13 +18,11 @@ meta selectGroupNumber bufr_group_number(); transient subsetNumber=0; if (compressedData) { meta numericValues bufr_data_array(offsetSection4,offsetBeforeData,offsetEndSection4,section4Length, - numberOfDataSubsets,subsetNumber, - expanded,type,unit,reference,scale,width, + numberOfDataSubsets,subsetNumber,expandedCodes,expandedFlags, stringValues,elementsDescriptorsIndex,compressedData) ; } else { meta numericValues bufr_data_array(offsetSection4,offsetBeforeData,offsetEndSection4,section4Length, - numberOfDataSubsets,subsetNumber, - expanded,types,units,references,scales,widths, + numberOfDataSubsets,subsetNumber,expandedCodes,expandedFlags, stringValues,elementsDescriptorsIndex,compressedData) ; } diff --git a/src/action_class_section.c b/src/action_class_section.c index e3d1a9e56..ae8e306b9 100644 --- a/src/action_class_section.c +++ b/src/action_class_section.c @@ -37,11 +37,12 @@ or edit "action.class" and rerun ./make_class.pl */ -static void init_class (grib_action_class*); -static void xref (grib_action* d, FILE* f,const char* path); -static int notify_change (grib_action* a, grib_accessor* observer,grib_accessor* observed); +static void init_class (grib_action_class*); +static void xref (grib_action* d, FILE* f,const char* path); +static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed); static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit); + typedef struct grib_action_section { grib_action act; /* Members defined in section */ diff --git a/src/grib_accessor_class.h b/src/grib_accessor_class.h index abe8420a5..4c97f3e30 100644 --- a/src/grib_accessor_class.h +++ b/src/grib_accessor_class.h @@ -38,6 +38,7 @@ extern grib_accessor_class* grib_accessor_class_data_apply_bitmap; extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic; extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic_bitmap; extern grib_accessor_class* grib_accessor_class_data_apply_gdsnotpresent; +extern grib_accessor_class* grib_accessor_class_data_ccsds_packing; extern grib_accessor_class* grib_accessor_class_data_complex_packing; extern grib_accessor_class* grib_accessor_class_data_constant_field; extern grib_accessor_class* grib_accessor_class_data_dummy_field; @@ -63,7 +64,6 @@ extern grib_accessor_class* grib_accessor_class_data_sh_packed; extern grib_accessor_class* grib_accessor_class_data_sh_unpacked; extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; extern grib_accessor_class* grib_accessor_class_data_simple_packing; -extern grib_accessor_class* grib_accessor_class_data_ccsds_packing; extern grib_accessor_class* grib_accessor_class_decimal_precision; extern grib_accessor_class* grib_accessor_class_dictionary; extern grib_accessor_class* grib_accessor_class_dirty; diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index eaed7a4ab..8e7129a00 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -25,38 +25,32 @@ IMPLEMENTS = update_size IMPLEMENTS = compare IMPLEMENTS = pack_long; unpack_double; pack_double - MEMBERS= const char* offsetSection4Name - MEMBERS= const char* offsetBeforeDataName - MEMBERS= const char* offsetEndSection4Name - MEMBERS= const char* section4LengthName - MEMBERS= const char* numberOfDataSubsetsName - MEMBERS= const char* subsetNumberName - MEMBERS= const char* expandedDescriptorsName - MEMBERS= const char* typeName - MEMBERS= const char* unitsName - MEMBERS= const char* referenceName - MEMBERS= const char* scaleName - MEMBERS= const char* widthName - MEMBERS= const char* stringValuesName - MEMBERS= const char* elementsDescriptorsIndexName - MEMBERS= const char* compressedDataName - MEMBERS= long* expandedDescriptors - MEMBERS= int* type - MEMBERS= int* canBeMissing - MEMBERS= long* reference - MEMBERS= double* factor - MEMBERS= long* width - MEMBERS= long subsetNumber - MEMBERS= long numberOfDataSubsets - MEMBERS= long compressedData - MEMBERS= size_t numberOfDescriptors - MEMBERS= grib_vdarray* numericValues - MEMBERS= grib_vsarray* stringValues - MEMBERS= grib_viarray* elementsDescriptorsIndex - MEMBERS= int do_decode - MEMBERS= int bitmapStartReferredDescriptorsIndex - MEMBERS= int bitmapEndReferredDescriptorsIndex - MEMBERS= int bitmapCurrentRank + MEMBERS = const char* offsetSection4Name + MEMBERS = const char* offsetBeforeDataName + MEMBERS = const char* offsetEndSection4Name + MEMBERS = const char* section4LengthName + MEMBERS = const char* numberOfDataSubsetsName + MEMBERS = const char* subsetNumberName + MEMBERS = const char* expandedDescriptorsName + MEMBERS = const char* flagsName + MEMBERS = const char* unitsName + MEMBERS = const char* stringValuesName + MEMBERS = const char* elementsDescriptorsIndexName + MEMBERS = const char* compressedDataName + MEMBERS = bufr_descriptors_array* expanded + MEMBERS = grib_accessor* expandedAccessor + MEMBERS = int* canBeMissing + MEMBERS = long subsetNumber + MEMBERS = long numberOfDataSubsets + MEMBERS = long compressedData + MEMBERS = grib_vdarray* numericValues + MEMBERS = grib_vsarray* stringValues + MEMBERS = grib_viarray* elementsDescriptorsIndex + MEMBERS = int do_decode + MEMBERS = int bitmapStartReferredDescriptorsIndex + MEMBERS = int bitmapSize + MEMBERS = int bitmapStart + MEMBERS = int bitmapCurrent END_CLASS_DEF @@ -98,31 +92,25 @@ typedef struct grib_accessor_bufr_data_array { const char* numberOfDataSubsetsName; const char* subsetNumberName; const char* expandedDescriptorsName; - const char* typeName; + const char* flagsName; const char* unitsName; - const char* referenceName; - const char* scaleName; - const char* widthName; const char* stringValuesName; const char* elementsDescriptorsIndexName; const char* compressedDataName; - long* expandedDescriptors; - int* type; + bufr_descriptors_array* expanded; + grib_accessor* expandedAccessor; int* canBeMissing; - long* reference; - double* factor; - long* width; long subsetNumber; long numberOfDataSubsets; long compressedData; - size_t numberOfDescriptors; grib_vdarray* numericValues; grib_vsarray* stringValues; grib_viarray* elementsDescriptorsIndex; int do_decode; int bitmapStartReferredDescriptorsIndex; - int bitmapEndReferredDescriptorsIndex; - int bitmapCurrentRank; + int bitmapSize; + int bitmapStart; + int bitmapCurrent; } grib_accessor_bufr_data_array; extern grib_accessor_class* grib_accessor_class_gen; @@ -205,6 +193,12 @@ static int can_be_missing(int descriptor) { return ret; } +static void restart_bitmap(grib_accessor_bufr_data_array *self) { self->bitmapCurrent=-1; } + +static void cancel_bitmap(grib_accessor_bufr_data_array *self) { self->bitmapCurrent=-1;self->bitmapStart=-1; } + +static int is_bitmap_start_defined(grib_accessor_bufr_data_array *self) { return self->bitmapStart==-1 ? 0 : 1; } + static long init_length(grib_accessor* a) { grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a; @@ -231,11 +225,7 @@ static void init(grib_accessor* a,const long v, grib_arguments* params) self->numberOfDataSubsetsName = grib_arguments_get_name(a->parent->h,params,n++); self->subsetNumberName = grib_arguments_get_name(a->parent->h,params,n++); self->expandedDescriptorsName = grib_arguments_get_name(a->parent->h,params,n++); - self->typeName = grib_arguments_get_name(a->parent->h,params,n++); - self->unitsName = grib_arguments_get_name(a->parent->h,params,n++); - self->referenceName = grib_arguments_get_name(a->parent->h,params,n++); - self->scaleName = grib_arguments_get_name(a->parent->h,params,n++); - self->widthName = grib_arguments_get_name(a->parent->h,params,n++); + self->flagsName = grib_arguments_get_name(a->parent->h,params,n++); self->stringValuesName = grib_arguments_get_name(a->parent->h,params,n++); self->elementsDescriptorsIndexName = grib_arguments_get_name(a->parent->h,params,n++); self->compressedDataName = grib_arguments_get_name(a->parent->h,params,n++); @@ -243,7 +233,9 @@ static void init(grib_accessor* a,const long v, grib_arguments* params) self->elementsDescriptorsIndex=0; self->numericValues=0; self->stringValues=0; - self->bitmapCurrentRank=-1; + cancel_bitmap(self); + self->expanded=0; + self->expandedAccessor=0; a->parent->h->unpacked=0; a->length = init_length(a); @@ -251,13 +243,9 @@ static void init(grib_accessor* a,const long v, grib_arguments* params) /* Assert(a->length>=0); */ } + static void self_clear(grib_context* c,grib_accessor_bufr_data_array* self) { - grib_context_free(c,self->expandedDescriptors); - grib_context_free(c,self->type); grib_context_free(c,self->canBeMissing); - grib_context_free(c,self->reference); - grib_context_free(c,self->width); - grib_context_free(c,self->factor); grib_vdarray_delete(c,self->numericValues); grib_vsarray_delete(c,self->stringValues); grib_viarray_delete(c,self->elementsDescriptorsIndex); @@ -269,7 +257,6 @@ static int get_native_type(grib_accessor* a){ static long byte_count(grib_accessor* a){ return a->length; - } static long byte_offset(grib_accessor* a){ @@ -308,190 +295,26 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) return GRIB_NOT_IMPLEMENTED; } -#if 0 -static void apply_early_operators(grib_accessor *a) { - long* descriptors; - int i,j,F,X,Y,elementsToRepeat,jReplication; - int extraWidth,extraScale,localDescriptorWidth; - double referenceFactor; +static int get_descriptors(grib_accessor* a) { grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a; + int ret=0,i,numberOfDescriptors; + grib_handle* h=a->parent->h; grib_context* c=a->parent->h->context; - descriptors=grib_context_malloc_clear(c,self->numberOfDescriptors*sizeof(long)); + if (!self->expandedAccessor) + self->expandedAccessor=grib_find_accessor(a->parent->h,self->expandedDescriptorsName); + self->expanded=grib_accessor_class_expanded_descriptors_get_expanded(self->expandedAccessor,&ret); - extraWidth=0; - extraScale=0; - referenceFactor=1; - localDescriptorWidth=-1; - j=0; - elementsToRepeat=0; - for (i=0;inumberOfDescriptors;i++) { - F=self->expandedDescriptors[i]/100000; - X=(self->expandedDescriptors[i]-F*100000)/1000; - Y=(self->expandedDescriptors[i]-F*100000)%1000; - if (F==2) { - switch(X) { - case 1: - extraWidth = Y ? Y-128 : 0; - if (elementsToRepeat>0) descriptors[jReplication]-=1000; - break; - case 2: - extraScale = Y ? Y-128 : 0; - if (elementsToRepeat>0) descriptors[jReplication]-=1000; - break; - /* case 4: */ - /* associated field*/ - /* associatedFieldWidth=Y; */ - /* break; */ - case 6: - /*signify data width*/ - localDescriptorWidth=Y; - if (elementsToRepeat>0) descriptors[jReplication]-=1000; - break; - case 7: - if (Y) { - extraScale = Y; - referenceFactor=grib_power(Y,10); - extraWidth=((10*Y)+2)/3; - } else { - extraWidth=0; - extraScale=0; - referenceFactor=1; - } - if (elementsToRepeat>0) descriptors[jReplication]-=1000; - break; - default: - descriptors[j]=self->expandedDescriptors[i]; - self->type[j]=self->type[i]; - self->width[j]=self->width[i]; - self->reference[j]=self->reference[i]; - self->factor[j]=self->factor[i]; - self->canBeMissing[j]=self->canBeMissing[i]; - elementsToRepeat--; - j++; - } - } else { - if (F==1) { elementsToRepeat=X; jReplication=j; } - if (self->type[i]==BUFR_TYPE_CODETABLE || self->type[i]==BUFR_TYPE_FLAGTABLE) { - self->width[j]=self->width[i]; - self->reference[j]=self->reference[i]; - self->factor[j]=self->factor[i]; - } else { - self->width[j]= localDescriptorWidth>0 ? localDescriptorWidth : self->width[i]+extraWidth; - self->reference[j]=self->reference[i]*referenceFactor; - self->factor[j]=extraScale ? self->factor[i]*grib_power(-extraScale,10) : self->factor[i]; - } - self->canBeMissing[j]=self->canBeMissing[i]; - descriptors[j]=self->expandedDescriptors[i]; - self->type[j]=self->type[i]; - elementsToRepeat--; - j++; - } - } - self->numberOfDescriptors=j; - grib_context_free(c,self->expandedDescriptors); - self->expandedDescriptors=descriptors; + numberOfDescriptors=grib_bufr_descriptors_array_used_size(self->expanded); + self->canBeMissing=grib_context_malloc_clear(c,numberOfDescriptors*sizeof(int)); + for (i=0;icanBeMissing[i]=can_be_missing(self->expanded->v[i]->code); -} -#endif + ret=grib_get_long(h,self->numberOfDataSubsetsName,&(self->numberOfDataSubsets)); + ret=grib_get_long(h,self->compressedDataName,&(self->compressedData)); + ret=grib_get_long(h,self->subsetNumberName,&(self->subsetNumber)); -static int get_descriptors(grib_accessor* a) { - int err=0; - size_t size=0; - long* scale=0; - double* factor=0; - int i=0; - char** ctype=0; - char** cunits=0; - grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a; - grib_accessor* expandedDescriptors=0; - grib_handle* h=a->parent->h; - grib_context* c=a->parent->h->context; - - expandedDescriptors=grib_find_accessor(a->parent->h,self->expandedDescriptorsName); - if (!expandedDescriptors) { - grib_context_log(a->parent->h->context,GRIB_LOG_ERROR, - "unable to find accessor %s",self->expandedDescriptorsName); - return GRIB_NOT_FOUND; - } - - if (self->numberOfDescriptors) self_clear(c,self); - err=_grib_get_size(a->parent->h,expandedDescriptors,&(self->numberOfDescriptors)); - if (err) return err; - - self->expandedDescriptors=grib_context_malloc_clear(a->parent->h->context,sizeof(long)*self->numberOfDescriptors); - if (!self->expandedDescriptors) { - grib_context_log(a->parent->h->context,GRIB_LOG_FATAL, - "unable to allocate %ld bytes",(long)(self->numberOfDescriptors)); - return GRIB_OUT_OF_MEMORY; - } - - size=self->numberOfDescriptors; - if( (err = grib_unpack_long(expandedDescriptors,self->expandedDescriptors,&(self->numberOfDescriptors))) - != GRIB_SUCCESS) - return err; - - self->type=grib_context_malloc_clear(c,self->numberOfDescriptors*sizeof(int)); - - size=self->numberOfDescriptors; - ctype=(char**)grib_context_malloc_clear(c,size*sizeof(char*)); - err=grib_get_string_array(h,self->typeName,ctype,&size); - - size=self->numberOfDescriptors; - self->canBeMissing=grib_context_malloc_clear(c,self->numberOfDescriptors*sizeof(int)); - cunits=(char**)grib_context_malloc_clear(c,size*sizeof(char*)); - - err=grib_get_string_array(h,self->unitsName,cunits,&size); - - for (i=0;inumberOfDescriptors;i++) { - self->canBeMissing[i]=can_be_missing(self->expandedDescriptors[i]); - if (*(ctype[i]) =='s') { - self->type[i]=BUFR_TYPE_STRING; - } else { - if (strstr(cunits[i],"TABLE") ) { - if (strstr(cunits[i],"FLAG")) { - self->type[i]=BUFR_TYPE_FLAGTABLE; - } else { - self->type[i]=BUFR_TYPE_CODETABLE; - } - } else { - self->type[i]=BUFR_TYPE_DOUBLE; - } - } - } - - grib_context_free(c,ctype); - grib_context_free(c,cunits); - - size=self->numberOfDescriptors; - self->reference=grib_context_malloc_clear(c,size*sizeof(long)); - err=grib_get_long_array(h,self->referenceName,self->reference,&size); - - size=self->numberOfDescriptors; - scale=grib_context_malloc_clear(c,size*sizeof(long)); - factor=grib_context_malloc_clear(c,size*sizeof(double)); - err=grib_get_long_array(h,self->scaleName,scale,&size); - for (i=0;iexpandedDescriptors[i]<100000) { - grib_context_log(c,GRIB_LOG_FATAL,"Missing table entry for descriptor %ld",self->expandedDescriptors[i]); - return GRIB_MISSING_BUFR_ENTRY; - } - if (scale[i]!=GRIB_MISSING_LONG) factor[i]=grib_power(-scale[i],10); - } - self->factor=factor; - grib_context_free(c,scale); - - size=self->numberOfDescriptors; - self->width=grib_context_malloc_clear(c,size*sizeof(long)); - err=grib_get_long_array(h,self->widthName,self->width,&size); - - err=grib_get_long(h,self->numberOfDataSubsetsName,&(self->numberOfDataSubsets)); - err=grib_get_long(h,self->compressedDataName,&(self->compressedData)); - err=grib_get_long(h,self->subsetNumberName,&(self->subsetNumber)); - - /* apply_early_operators(a); */ - - return err; + return ret; } static grib_sarray* decode_string_array(grib_context* c,unsigned char* data,long* pos, int i, @@ -500,9 +323,9 @@ static grib_sarray* decode_string_array(grib_context* c,unsigned char* data,long char* sval=0; int j,modifiedWidth,modifiedReference,width; double modifiedFactor; - modifiedWidth= self->width[i]; - modifiedReference= self->reference[i]; - modifiedFactor= self->factor[i]; + modifiedWidth= self->expanded->v[i]->width; + modifiedReference= self->expanded->v[i]->reference; + modifiedFactor= self->expanded->v[i]->factor; ret=grib_sarray_new(c,10,10); sval=grib_context_malloc_clear(c,modifiedWidth/8+1); @@ -531,9 +354,9 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long int localReference,localWidth,modifiedWidth,modifiedReference; double modifiedFactor,dval; - modifiedReference= self->reference[i]; - modifiedFactor= self->factor[i]; - modifiedWidth= self->width[i]; + modifiedReference= self->expanded->v[i]->reference; + modifiedFactor= self->expanded->v[i]->factor; + modifiedWidth= self->expanded->v[i]->width; lval=grib_decode_unsigned_long(data,pos,modifiedWidth); localReference=(long)lval+modifiedReference; @@ -566,9 +389,9 @@ static char* decode_string_value(grib_context* c,unsigned char* data,long* pos, char* sval=0; int modifiedWidth,modifiedReference; double modifiedFactor; - modifiedWidth= self->width[i]; - modifiedReference= self->reference[i]; - modifiedFactor= self->factor[i]; + modifiedWidth= self->expanded->v[i]->width; + modifiedReference= self->expanded->v[i]->reference; + modifiedFactor= self->expanded->v[i]->factor; sval=grib_context_malloc_clear(c,modifiedWidth/8+1); grib_decode_string(data,pos,modifiedWidth/8,sval); @@ -582,9 +405,9 @@ static double decode_double_value(grib_context* c,unsigned char* data,long* pos, int modifiedWidth,modifiedReference; double modifiedFactor,dval; - modifiedReference= self->reference[i]; - modifiedFactor= self->factor[i]; - modifiedWidth= self->width[i]; + modifiedReference= self->expanded->v[i]->reference; + modifiedFactor= self->expanded->v[i]->factor; + modifiedWidth= self->expanded->v[i]->width; lval=grib_decode_unsigned_long(data,pos,modifiedWidth); if (grib_is_all_bits_one(lval,modifiedWidth) && self->canBeMissing[i]) { @@ -599,20 +422,22 @@ static void decode_element(grib_context* c,grib_accessor_bufr_data_array* self, unsigned char* data,long *pos,int i,grib_darray* dval,grib_sarray* sval) { grib_darray* dar=0; grib_sarray* sar=0; - int index=0,sar_size,ii; + int index=0,ii,idx,sar_size; char* csval=0; - double cdval=0; - if (self->type[i]==BUFR_TYPE_STRING) { + double cdval=0,x; + if (self->expanded->v[i]->flags & BUFR_DESCRIPTOR_FLAG_IS_STRING) { /* string */ if (self->compressedData) { sar=decode_string_array(c,data,pos,i,self); grib_vsarray_push(c,self->stringValues,sar); index=grib_vsarray_used_size(self->stringValues); + dar=grib_darray_new(c,self->numberOfDataSubsets,10); sar_size=grib_sarray_used_size(sar); - dar=grib_darray_new(c,sar_size,10); - for (ii=0;iiv[ii]); + for (ii=0;iinumberOfDataSubsets;ii++) { + idx = sar_size==1 ? 0 : ii; + x=index*1000+strlen(sar->v[idx]); grib_darray_push(c,dar,x); + index++; } grib_vdarray_push(c,self->numericValues,dar); } else { @@ -636,56 +461,67 @@ static void decode_element(grib_context* c,grib_accessor_bufr_data_array* self, static int build_bitmap(grib_accessor_bufr_data_array *self,unsigned char* data,long* pos,int iBitmapOperator) { int bitmapSize,iDelayedReplication=0; - int i,localReference,width; + int i,localReference,width,bitmapEndReferredDescriptorsIndex; long ppos; grib_accessor* a=(grib_accessor*)self; grib_context* c=a->parent->h->context; + bufr_descriptor** descriptors=self->expanded->v; - switch (self->expandedDescriptors[iBitmapOperator]) { + switch (descriptors[iBitmapOperator]->code) { case 236000: + cancel_bitmap(self); i=iBitmapOperator; - while (self->expandedDescriptors[i]>200000) i--; - self->bitmapEndReferredDescriptorsIndex=i; + /* while (descriptors[i]->code>200000) i--; */ + bitmapEndReferredDescriptorsIndex=i-1; i=iBitmapOperator+1; - if (self->expandedDescriptors[i]==101000) { + if (descriptors[i]->code==101000) { iDelayedReplication=iBitmapOperator+2; - Assert( self->expandedDescriptors[iDelayedReplication]==31001 || - self->expandedDescriptors[iDelayedReplication]==31002 ); + Assert( descriptors[iDelayedReplication]->code==31001 || + descriptors[iDelayedReplication]->code==31002 ); i=iDelayedReplication; if (self->compressedData) { ppos=*pos; - localReference=grib_decode_unsigned_long(data,pos,self->width[i])+self->reference[i]; + localReference=grib_decode_unsigned_long(data,pos,descriptors[i]->width)+descriptors[i]->reference; width=grib_decode_unsigned_long(data,pos,6); *pos=ppos; if (width) { /* delayed replication number is not constant. NOT IMPLEMENTED */ Assert(0); } else { - bitmapSize=localReference*self->factor[i]; + bitmapSize=localReference*descriptors[i]->factor; } } else { ppos=*pos; - bitmapSize=grib_decode_unsigned_long(data,pos,self->width[i])+self->reference[i]*self->factor[i]; + bitmapSize=grib_decode_unsigned_long(data,pos,descriptors[i]->width)+ + descriptors[i]->reference*descriptors[i]->factor; *pos=ppos; } - } else if (self->expandedDescriptors[i]==31031){ - bitmapSize=1; - while (self->expandedDescriptors[i]==31031) {bitmapSize++;i++;} + } else if (descriptors[i]->code==31031){ + bitmapSize=0; + while (descriptors[i]->code==31031) {bitmapSize++;i++;} } - self->bitmapStartReferredDescriptorsIndex=self->bitmapEndReferredDescriptorsIndex-bitmapSize; - self->bitmapCurrentRank=0; + self->bitmapStartReferredDescriptorsIndex=bitmapEndReferredDescriptorsIndex-bitmapSize+1; + restart_bitmap(self); break; default : grib_context_log(c,GRIB_LOG_ERROR,"unsupported operator %d\n", - self->expandedDescriptors[iBitmapOperator]); + descriptors[iBitmapOperator]->code); return GRIB_INTERNAL_ERROR; } return GRIB_SUCCESS; } -static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array *self) { - int ret=self->bitmapStartReferredDescriptorsIndex+self->bitmapCurrentRank; - self->bitmapCurrentRank++; +static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array *self,int isubset) { + /* isubset is not used for compressed data*/ + int ret,i; + self->bitmapCurrent++; + i=self->bitmapCurrent+self->bitmapStart; + if (self->compressedData) { + while (self->numericValues->v[i]->v[0]==1) {self->bitmapCurrent++;i++;} + } else { + while (self->numericValues->v[isubset]->v[i]==1) {self->bitmapCurrent++;i++;} + } + ret=self->bitmapStartReferredDescriptorsIndex+self->bitmapCurrent; return ret; } @@ -704,7 +540,6 @@ static void push_zero_element(grib_accessor_bufr_data_array* self,grib_darray* d static int decode_elements(grib_accessor* a) { int err=0; - int *F=0,*X=0,*Y=0; int associatedFieldWidth=0,localDescriptorWidth=0; int nn; int numberOfElementsToRepeat=0,numberOfRepetitions=0; @@ -715,6 +550,8 @@ static int decode_elements(grib_accessor* a) { long localReference=0,width=0; long pos=0; int iss,end,elementIndex,index; + long numberOfDescriptors; + bufr_descriptor** descriptors=0; grib_darray* dval = NULL; grib_sarray* sval = NULL; @@ -733,14 +570,7 @@ static int decode_elements(grib_accessor* a) { err=get_descriptors(a); if (err) return err; - F=grib_context_malloc_clear(c,sizeof(int)*self->numberOfDescriptors); - X=grib_context_malloc_clear(c,sizeof(int)*self->numberOfDescriptors); - Y=grib_context_malloc_clear(c,sizeof(int)*self->numberOfDescriptors); - for (i=0;inumberOfDescriptors;i++) { - F[i]=self->expandedDescriptors[i]/100000; - X[i]=(self->expandedDescriptors[i]-F[i]*100000)/1000; - Y[i]=(self->expandedDescriptors[i]-F[i]*100000)%1000; - } + descriptors=self->expanded->v; if (self->numericValues) { grib_vdarray_delete_content(c,self->numericValues); @@ -756,37 +586,42 @@ static int decode_elements(grib_accessor* a) { end= self->compressedData ? 1 : self->numberOfDataSubsets; + numberOfDescriptors=grib_bufr_descriptors_array_used_size(self->expanded); + for (iss=0;isscompressedData) { dval=grib_darray_new(c,100,100); sval=grib_sarray_new(c,10,10); } - for (i=0;inumberOfDescriptors;i++) { + for (i=0;iF) { case 0: /* Table B element */ grib_iarray_push(elementsDescriptorsIndex,i); + if (descriptors[i]->code==31031 && !is_bitmap_start_defined(self)) + self->bitmapStart=grib_iarray_used_size(elementsDescriptorsIndex); decode_element(c,self,data,&pos,i,dval,sval); break; case 1: /* Delayed replication */ - numberOfElementsToRepeat=X[i]; + numberOfElementsToRepeat=descriptors[i]->X; nn=numberOfElementsToRepeat; i++; if (self->compressedData) { - localReference=grib_decode_unsigned_long(data,&pos,self->width[i])+self->reference[i]; + localReference=grib_decode_unsigned_long(data,&pos,descriptors[i]->width)+descriptors[i]->reference; width=grib_decode_unsigned_long(data,&pos,6); if (width) { /* delayed replication number is not constant. NOT IMPLEMENTED */ Assert(0); } else { - numberOfRepetitions=localReference*self->factor[i]; + numberOfRepetitions=localReference*descriptors[i]->factor; startRepetition=i; } } else { - numberOfRepetitions=grib_decode_unsigned_long(data,&pos,self->width[i])+self->reference[i]*self->factor[i]; + numberOfRepetitions=grib_decode_unsigned_long(data,&pos,descriptors[i]->width)+ + descriptors[i]->reference*descriptors[i]->factor; startRepetition=i; } grib_iarray_push(elementsDescriptorsIndex,i); @@ -797,12 +632,13 @@ static int decode_elements(grib_accessor* a) { } else { grib_darray_push(c,dval,(double)numberOfRepetitions); } + if (numberOfRepetitions==0) i+=numberOfElementsToRepeat; continue; case 2: /* Operator */ associatedFieldWidth=0; localDescriptorWidth=0; - switch(X[i]) { + switch(descriptors[i]->X) { case 22: case 26: case 27: @@ -825,8 +661,8 @@ static int decode_elements(grib_accessor* a) { /*first-order statistical values marker operator*/ case 32: /*replaced/retained values marker operator*/ - if (Y[i]==255) { - index=get_next_bitmap_descriptor_index(self); + if (descriptors[i]->Y==255) { + index=get_next_bitmap_descriptor_index(self,iss); decode_element(c,self,data,&pos,index,dval,sval); grib_iarray_push(elementsDescriptorsIndex,index); } else { @@ -841,7 +677,7 @@ static int decode_elements(grib_accessor* a) { /* cancel bitmap */ grib_iarray_push(elementsDescriptorsIndex,i); push_zero_element(self,dval); - if (Y[i]==0) self->bitmapCurrentRank=-1; + if (descriptors[i]->Y==0) cancel_bitmap(self); break; case 36: /* bitmap */ @@ -853,15 +689,24 @@ static int decode_elements(grib_accessor* a) { /* reuse defined bitmap */ grib_iarray_push(elementsDescriptorsIndex,i); push_zero_element(self,dval); - if (Y[i]==0) self->bitmapCurrentRank=0; + if (descriptors[i]->Y==0) restart_bitmap(self); /* cancel reuse */ - else self->bitmapCurrentRank=-1; + else cancel_bitmap(self); break; default : - grib_context_log(c,GRIB_LOG_ERROR,"unsupported operator %d\n",X[i]); + grib_context_log(c,GRIB_LOG_ERROR,"unsupported operator %d\n",descriptors[i]->X); return GRIB_INTERNAL_ERROR; } break; + case 9: + /* associated field */ + if (descriptors[i]->X==99 && descriptors[i]->Y==999) { + grib_iarray_push(elementsDescriptorsIndex,i); + decode_element(c,self,data,&pos,i,dval,sval); + } else { + return GRIB_INTERNAL_ERROR; + } + break; default: err=GRIB_INTERNAL_ERROR; return err; @@ -874,7 +719,7 @@ static int decode_elements(grib_accessor* a) { } else { nn=numberOfElementsToRepeat; numberOfRepetitions--; - if (numberOfRepetitions) i=startRepetition; + if (numberOfRepetitions>0) i=startRepetition; } } diff --git a/src/grib_accessor_class_expanded_descriptors.c b/src/grib_accessor_class_expanded_descriptors.c index 3b8b48ffb..f1cc246c7 100644 --- a/src/grib_accessor_class_expanded_descriptors.c +++ b/src/grib_accessor_class_expanded_descriptors.c @@ -23,8 +23,9 @@ START_CLASS_DEF CLASS = accessor SUPER = grib_accessor_class_long IMPLEMENTS = unpack_long;pack_long +IMPLEMENTS = unpack_double IMPLEMENTS = init;dump;destroy -IMPLEMENTS = value_count +IMPLEMENTS = value_count; get_native_type MEMBERS = const char* unexpandedDescriptors MEMBERS = const char* sequence MEMBERS = const char* expandedName @@ -52,7 +53,9 @@ or edit "accessor.class" and rerun ./make_class.pl */ +static int get_native_type(grib_accessor*); static int pack_long(grib_accessor*, const long* val,size_t *len); +static int unpack_double(grib_accessor*, double* val,size_t *len); static int unpack_long(grib_accessor*, long* val,size_t *len); static int value_count(grib_accessor*,long*); static void destroy(grib_context*,grib_accessor*); @@ -96,14 +99,14 @@ static grib_accessor_class _grib_accessor_class_expanded_descriptors = { &value_count, /* get number of values */ 0, /* get number of bytes */ 0, /* get offset to bytes */ - 0, /* get native type */ + &get_native_type, /* get native type */ 0, /* get sub_section */ 0, /* grib_pack procedures long */ 0, /* grib_pack procedures long */ &pack_long, /* grib_pack procedures long */ &unpack_long, /* grib_unpack procedures long */ 0, /* grib_pack procedures double */ - 0, /* grib_unpack procedures double */ + &unpack_double, /* grib_unpack procedures double */ 0, /* grib_pack procedures string */ 0, /* grib_unpack procedures string */ 0, /* grib_pack array procedures string */ @@ -133,12 +136,10 @@ static void init_class(grib_accessor_class* c) c->string_length = (*(c->super))->string_length; c->byte_count = (*(c->super))->byte_count; c->byte_offset = (*(c->super))->byte_offset; - c->get_native_type = (*(c->super))->get_native_type; c->sub_section = (*(c->super))->sub_section; c->pack_missing = (*(c->super))->pack_missing; c->is_missing = (*(c->super))->is_missing; c->pack_double = (*(c->super))->pack_double; - c->unpack_double = (*(c->super))->unpack_double; c->pack_string = (*(c->super))->pack_string; c->unpack_string = (*(c->super))->unpack_string; c->pack_string_array = (*(c->super))->pack_string_array; @@ -283,18 +284,10 @@ static size_t __expand(grib_accessor* a,bufr_descriptors_array* unexpanded,bufr_ #endif grib_bufr_descriptors_array_push(expanded,u); idx=expanded->n-1; - u=grib_bufr_descriptors_array_pop_front(unexpanded); -#if MYDEBUG - for (idepth=0;idepthcode); - for (idepth=0;idepthcode); -#endif - grib_bufr_descriptors_array_push(expanded,u); size=0; inner_unexpanded=grib_bufr_descriptors_array_new(c,100,100); inner_expanded=grib_bufr_descriptors_array_new(c,100,100); - for (j=0;jX;j++) { + for (j=0;jX+1;j++) { u0=grib_bufr_descriptors_array_pop_front(unexpanded); grib_bufr_descriptors_array_push(inner_unexpanded,u0); #if MYDEBUG @@ -312,7 +305,7 @@ static size_t __expand(grib_accessor* a,bufr_descriptors_array* unexpanded,bufr_ #endif expanded=grib_bufr_descriptors_array_append(expanded,inner_expanded); uidx=grib_bufr_descriptors_array_get(expanded,idx); - grib_bufr_descriptor_set_code(uidx,size*1000+100000); + grib_bufr_descriptor_set_code(uidx,(size-1)*1000+100000); size++; } else { u=grib_bufr_descriptors_array_pop_front(unexpanded); @@ -330,9 +323,12 @@ static size_t __expand(grib_accessor* a,bufr_descriptors_array* unexpanded,bufr_ #endif } inner_unexpanded=grib_bufr_descriptors_array_new(c,100,100); - for (k=0;kY;k++) { + for (j=0;jX;j++) { + grib_bufr_descriptors_array_push(inner_unexpanded,ur[j]); + } + for (k=1;kY;k++) { for (j=0;jX;j++) { - grib_bufr_descriptors_array_push(inner_unexpanded,ur[j]); + grib_bufr_descriptors_array_push(inner_unexpanded,grib_bufr_descriptor_clone(c,ur[j])); } } inner_expanded=_expand(a,inner_unexpanded,ccp,err); @@ -390,9 +386,16 @@ static size_t __expand(grib_accessor* a,bufr_descriptors_array* unexpanded,bufr_ if ((u->flags & ( BUFR_DESCRIPTOR_FLAG_IS_FLAG | BUFR_DESCRIPTOR_FLAG_IS_TABLE | BUFR_DESCRIPTOR_FLAG_IS_STRING)) == 0) { - u->width= ccp->localDescriptorWidth>0 ? ccp->localDescriptorWidth : u->width+ccp->extraWidth; - u->reference=u->reference* ccp->referenceFactor; - u->scale=u->scale+ccp->extraScale; + if (ccp->localDescriptorWidth>0) { + u->width=ccp->localDescriptorWidth; + u->reference=0; + grib_bufr_descriptor_set_scale(u,0); + ccp->localDescriptorWidth=0; + } else { + u->width += ccp->extraWidth; + u->reference *= ccp->referenceFactor; + grib_bufr_descriptor_set_scale(u,u->scale+ccp->extraScale); + } } #if MYDEBUG printf("->(%ld %g %ld)\n",u->scale,u->reference,u->width); @@ -541,9 +544,16 @@ static int expand(grib_accessor* a) bufr_descriptors_array* unexpanded=NULL; grib_context* c=a->parent->h->context; - if (!self->dirty) return err; + if (!self->dirty) { + return err; + } self->dirty=0; + if (self->rank!=0) { + err=expand(self->expandedAccessor); + self->expanded=((grib_accessor_expanded_descriptors*)self->expandedAccessor)->expanded; + return err; + } grib_bufr_descriptors_array_delete(self->expanded); err=grib_get_size(a->parent->h,self->unexpandedDescriptors,&unexpandedSize); @@ -571,6 +581,42 @@ static int expand(grib_accessor* a) } +bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(grib_accessor* a,int* err) { + grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + *err=expand(a); + return self->expanded; +} + +static int unpack_double (grib_accessor* a, double* val, size_t *len) { + grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + int ret=0; + int i; + size_t expandedSize; + + if (self->rank!=2) { + long* lval=grib_context_malloc_clear(a->parent->h->context,*len*sizeof(long)); + ret=unpack_long(a,lval,len); + if (ret) return ret; + for (i=0;i<*len;i++) val[i]=(double)lval[i]; + grib_context_free(a->parent->h->context,lval); + } else { + ret=expand(a); + if (ret) return ret; + + expandedSize=grib_bufr_descriptors_array_used_size(self->expanded); + if(*len < expandedSize) + { + grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, + " wrong size (%ld) for %s it contains %d values ",*len, a->name , expandedSize); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + *len = expandedSize; + for (i=0;i<*len;i++) val[i]=self->expanded->v[i]->reference; + } + return ret; +} + static int unpack_long (grib_accessor* a, long* val, size_t *len) { grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; @@ -579,8 +625,8 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len) size_t i; ret=expand(a); - if (ret) return ret; rlen=grib_bufr_descriptors_array_used_size(self->expanded); + if (ret) return ret; if(*len < rlen) { @@ -591,7 +637,23 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len) } *len = rlen; - for (i=0;i<*len;i++) val[i]=self->expanded->v[i]->code; + switch (self->rank) { + case 0: + for (i=0;i<*len;i++) val[i]=self->expanded->v[i]->code; + break; + case 1: + for (i=0;i<*len;i++) val[i]=self->expanded->v[i]->scale; + break; + case 2: + return GRIB_INVALID_TYPE; + break; + case 3: + for (i=0;i<*len;i++) val[i]=self->expanded->v[i]->width; + break; + case 4: + for (i=0;i<*len;i++) val[i]=self->expanded->v[i]->flags; + break; + } return GRIB_SUCCESS; } @@ -606,23 +668,30 @@ static int pack_long (grib_accessor* a, const long* val, size_t *len) static int value_count(grib_accessor* a,long* rlen) { + grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; int ret=0; grib_context* c=a->parent->h->context; - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; *rlen=0; ret=expand(a); + *rlen=grib_bufr_descriptors_array_used_size(self->expanded); if (ret) { grib_context_log(c,GRIB_LOG_ERROR,"%s unable to compute size",a->name); return ret; } - *rlen = grib_bufr_descriptors_array_used_size(self->expanded); - return ret; } static void destroy(grib_context* c,grib_accessor* a) { grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; - grib_context_free(c,self->expanded); + if (self->rank==0 && self->expanded) grib_context_free(c,self->expanded); } + +static int get_native_type(grib_accessor* a) +{ + grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + if (self->rank==2) return GRIB_TYPE_DOUBLE; + else return GRIB_TYPE_LONG; +} + diff --git a/src/grib_accessor_factory.h b/src/grib_accessor_factory.h index 1676c4402..844b7a3f5 100644 --- a/src/grib_accessor_factory.h +++ b/src/grib_accessor_factory.h @@ -38,6 +38,7 @@ { "data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic, }, { "data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap, }, { "data_apply_gdsnotpresent", &grib_accessor_class_data_apply_gdsnotpresent, }, +{ "data_ccsds_packing", &grib_accessor_class_data_ccsds_packing, }, { "data_complex_packing", &grib_accessor_class_data_complex_packing, }, { "data_constant_field", &grib_accessor_class_data_constant_field, }, { "data_dummy_field", &grib_accessor_class_data_dummy_field, }, @@ -63,7 +64,6 @@ { "data_sh_unpacked", &grib_accessor_class_data_sh_unpacked, }, { "data_shsimple_packing", &grib_accessor_class_data_shsimple_packing, }, { "data_simple_packing", &grib_accessor_class_data_simple_packing, }, -{ "data_ccsds_packing", &grib_accessor_class_data_ccsds_packing, }, { "decimal_precision", &grib_accessor_class_decimal_precision, }, { "dictionary", &grib_accessor_class_dictionary, }, { "dirty", &grib_accessor_class_dirty, }, diff --git a/src/grib_accessor_factory_hash_list b/src/grib_accessor_factory_hash_list index b96763384..a831437b8 100644 --- a/src/grib_accessor_factory_hash_list +++ b/src/grib_accessor_factory_hash_list @@ -38,6 +38,7 @@ data_apply_bitmap, &grib_accessor_class_data_apply_bitmap data_apply_boustrophedonic, &grib_accessor_class_data_apply_boustrophedonic data_apply_boustrophedonic_bitmap, &grib_accessor_class_data_apply_boustrophedonic_bitmap data_apply_gdsnotpresent, &grib_accessor_class_data_apply_gdsnotpresent +data_ccsds_packing, &grib_accessor_class_data_ccsds_packing data_complex_packing, &grib_accessor_class_data_complex_packing data_constant_field, &grib_accessor_class_data_constant_field data_dummy_field, &grib_accessor_class_data_dummy_field @@ -67,7 +68,6 @@ data_sh_packed, &grib_accessor_class_data_sh_packed data_sh_unpacked, &grib_accessor_class_data_sh_unpacked data_shsimple_packing, &grib_accessor_class_data_shsimple_packing data_simple_packing, &grib_accessor_class_data_simple_packing -data_ccsds_packing, &grib_accessor_class_data_ccsds_packing decimal_precision, &grib_accessor_class_decimal_precision descriptors, &grib_accessor_class_descriptors dictionary, &grib_accessor_class_dictionary diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index b14743d14..961c28dd9 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -757,6 +757,7 @@ struct bufr_descriptor { int Y; int flags; long scale; + double factor; double reference; long width; } ; diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 8aa491540..c239adaca 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -150,6 +150,7 @@ bufr_descriptor *grib_bufr_descriptor_new(grib_context *c, int code); bufr_descriptor *grib_bufr_descriptor_clone(grib_context *c, bufr_descriptor *d); void grib_bufr_descriptor_set_code(bufr_descriptor *v, int code); void grib_bufr_descriptor_set_values(bufr_descriptor *v, int scale, int reference, int width); +void grib_bufr_descriptor_set_scale(bufr_descriptor *v, int scale); void grib_bufr_descriptor_delete(grib_context *c, bufr_descriptor *v); /* grib_bufr_descriptors_array.c */ @@ -495,6 +496,8 @@ int grib_get_g1_message_size(grib_handle *h, grib_accessor *tl, grib_accessor *s /* grib_accessor_class_data_simple_packing.c */ +/* grib_accessor_class_data_ccsds_packing.c */ + /* grib_accessor_class_count_missing.c */ /* grib_accessor_class_data_sh_packed.c */ @@ -546,6 +549,7 @@ second_order_packed *grib_get_second_order_groups(grib_context *c, const unsigne /* grib_accessor_class_unexpanded_descriptors.c */ /* grib_accessor_class_expanded_descriptors.c */ +bufr_descriptors_array *grib_accessor_class_expanded_descriptors_get_expanded(grib_accessor *a, int *err); /* grib_accessor_class_bufrdc_expanded_descriptors.c */ diff --git a/src/grib_bufr_descriptor.c b/src/grib_bufr_descriptor.c index 67b27e594..0cf98b03a 100644 --- a/src/grib_bufr_descriptor.c +++ b/src/grib_bufr_descriptor.c @@ -50,6 +50,13 @@ void grib_bufr_descriptor_set_values(bufr_descriptor* v,int scale,int reference, v->reference=reference; v->width=width; v->flags=BUFR_DESCRIPTOR_FLAG_HAS_VALUES; + v->factor=grib_power(-scale,10); +} + +void grib_bufr_descriptor_set_scale(bufr_descriptor* v,int scale) { + if (!v) return; + v->scale=scale; + v->factor=grib_power(-scale,10); } void grib_bufr_descriptor_delete(grib_context* c,bufr_descriptor* v) { diff --git a/tests/bufrdc_ref.sh b/tests/bufrdc_ref.sh index c1fd45945..3ac0bd406 100755 --- a/tests/bufrdc_ref.sh +++ b/tests/bufrdc_ref.sh @@ -27,7 +27,7 @@ do rm -f $res_num | true - #set +e + set +e ${tools_dir}bufr_filter bufrdc_num_ref.filter $file 2> $REDIRECT > $res_num if [ $? != 0 ] then