mirror of https://github.com/ecmwf/eccodes.git
made separate bufr low level decoding to be compatible with bufrdc. Made test to
compare with bufrdc real array
This commit is contained in:
parent
b6d7ea751f
commit
63b92afd0f
|
@ -206,6 +206,13 @@ ehthumbs.db
|
|||
Thumbs.db
|
||||
.directory
|
||||
|
||||
src/tags
|
||||
|
||||
data/exp
|
||||
data/bufr/*.ref
|
||||
data/bufr/*.test
|
||||
data/bufr/*.json
|
||||
data/bufr/*.no
|
||||
data/.downloaded
|
||||
data/budg
|
||||
data/*.grib
|
||||
|
@ -213,6 +220,7 @@ data/*.grib2
|
|||
data/*.grib1
|
||||
data/tigge/tigge*.grib
|
||||
data/bufr/*.bufr
|
||||
data/exp/
|
||||
|
||||
CMakeLists.txt.user*
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/ksh
|
||||
set -ex
|
||||
|
||||
decode=/var/tmp/mac/p4/bufrdc/releases/000402/examples/bufr_decode_data
|
||||
|
||||
for f in *.bufr
|
||||
do
|
||||
$decode -i $f | sed 's/MISSING/-1.00000000000000e+100/g' | sed -e '/ECMWF/,+8d' > $f.ref
|
||||
done
|
|
@ -10,6 +10,7 @@
|
|||
constant defaultSequence=0;
|
||||
constant tablesMasterDir="bufr/tables/[masterTableNumber]/wmo/[masterTablesVersionNumber]" : hidden;
|
||||
constant tablesLocalDir="bufr/tables/[masterTableNumber]/local/[localTablesVersionNumber]/[centre:l]/[subCentre]" : hidden;
|
||||
constant rootTablesDir="bufr/tables" : hidden;
|
||||
|
||||
transient tableNumber=0;
|
||||
codetable[24] codeTablesMaster '[tablesMasterDir]/codetables/[tableNumber].table' : string_type,transient;
|
||||
|
@ -68,31 +69,18 @@ meta unexpandedDescriptors unexpanded_descriptors(numberOfUnexpandedDescriptors)
|
|||
|
||||
meta expandedDescriptors expanded_descriptors(unexpandedDescriptors,sequences) ;
|
||||
|
||||
#smart_table NAME (VALUES,FILE_NAME,MASTER_DIRECTORY,LOCAL_DIRECTORY,WIDTH_OF_CODE_IN_BITS);
|
||||
smart_table elements (expandedDescriptors,"element.table",tablesMasterDir,tablesLocalDir,16) ;
|
||||
meta abbreviation smart_table_column(elements,0,1) : string_type;
|
||||
meta type smart_table_column(elements,1,0) : string_type;
|
||||
meta name smart_table_column(elements,2,0) : string_type;
|
||||
meta unit smart_table_column(elements,3,0) : string_type;
|
||||
meta scale smart_table_column(elements,4,0) : long_type;
|
||||
meta reference smart_table_column(elements,5,0) : long_type;
|
||||
meta width smart_table_column(elements,6,0) : long_type;
|
||||
meta crex_unit smart_table_column(elements,7,0) : long_type;
|
||||
meta crex_scale smart_table_column(elements,8,0) : long_type;
|
||||
meta crex_width smart_table_column(elements,9,0) : long_type;
|
||||
|
||||
meta expandedDescriptorsAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,0) : read_only;
|
||||
meta scaleAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,1) :read_only;
|
||||
meta referenceAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,2) :read_only;
|
||||
meta widthAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,3) :read_only;
|
||||
meta bitmapNumber apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,4) :read_only;
|
||||
meta associatedBitmapNumber apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,5) :read_only;
|
||||
meta associatedBitmapIndex apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,6) :read_only;
|
||||
meta abbreviationAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,7) :read_only,string_type;
|
||||
meta typeAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,8) :read_only,string_type;
|
||||
meta nameAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,9) :read_only,string_type;
|
||||
meta unitAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,10) :read_only,string_type;
|
||||
meta associatedInfoNumber apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,11) :read_only;
|
||||
#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;
|
||||
|
||||
meta hasDelayedReplication bufr_has_delayed_replication(expandedDescriptorsAfterOperators);
|
||||
|
||||
|
|
|
@ -17,22 +17,15 @@ meta selectGroupNumber bufr_group_number();
|
|||
|
||||
transient subsetNumber=0;
|
||||
if (compressedData) {
|
||||
meta values bufr_data(offsetSection4,offsetBeforeData,offsetEndSection4,section4Length,
|
||||
numberOfDataSubsets,subsetNumber,
|
||||
expandedDescriptorsAfterOperators,abbreviationAfterOperators,
|
||||
typeAfterOperators,nameAfterOperators,unitAfterOperators,
|
||||
referenceAfterOperators,scaleAfterOperators,widthAfterOperators,codeFlags,
|
||||
bitmapNumber,associatedBitmapNumber,associatedBitmapIndex,associatedInfoNumber) : dump;
|
||||
meta numericValues bufr_data_array(offsetSection4,offsetBeforeData,offsetEndSection4,section4Length,
|
||||
numberOfDataSubsets,subsetNumber,
|
||||
expandedDescriptors,type,reference,scale,width,
|
||||
stringValues,elementsFXY,compressedData) ;
|
||||
} else {
|
||||
meta values bufr_uncompressed_data(offsetSection4,offsetBeforeData,offsetEndSection4,section4Length,
|
||||
numberOfDataSubsets,subsetNumber,
|
||||
expandedDescriptorsAfterOperators,abbreviationAfterOperators,
|
||||
typeAfterOperators,nameAfterOperators,unitAfterOperators,
|
||||
referenceAfterOperators,scaleAfterOperators,widthAfterOperators,codeFlags,
|
||||
bitmapNumber,associatedBitmapNumber,associatedBitmapIndex) : dump;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
meta unpack unpack_bufr_values(values);
|
||||
meta unpack unpack_bufr_values(numericValues);
|
||||
|
||||
section_padding section4Padding;
|
||||
position offsetEndSection4;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#code|abbreviation|type|name|unit|scale|reference|width|crex_unit|crex_scale|crex_width
|
||||
222000|qualityInformationFollows|long|The values of class 33 elements which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
|
||||
223000|substitutedValuesOperator|long|The substituted values which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
|
||||
223255|substitutedValuesMarkerOperator|long|This operator shall signify a data item containing a substituted value; the element descriptor for the substituted value is obtained by the application of the data present bit-map associated with the substituted values operator|OPERATOR|0|0|0|0|0|
|
||||
224000|firstOrderStatisticalValuesFollow|long|The statistical values which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
|
||||
224555|firstOrderStatisticalValuesMarkerOperator|long|This operator shall signify a data item containing a first-order statistical value of the type indicated by the preceding 0 08 023 element descriptor; the element descriptor to which the fi-rosrtder statistic relates is obtained by the application of the data present bit-map associated with the first-order statistical values follow operator; first-order statistical values shall be represented as defined by this element descriptor |OPERATOR|0|0|0|0|0|
|
||||
225000|differenceStatisticalValuesFollow|long|The statistical values which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
|
||||
225255|differenceStatisticalValuesMarkerOperator|long|This operator shall signify a data item containing a difference statistical value of the type indicated by the preceding 0 08 024 element descriptor; the element descriptor to which the difference statistical value relates is obtained by the application of the data present bit-map associated with the difference statistical values follow operator; difference statistical values shall be represented as defined by this element descriptor, but with a reference value of –2n and a data width of (n+1), where n is the data width given by the original descriptor. This special reference value allows the statistical difference values to be centred around zero|OPERATOR|0|0|0|0|0|
|
||||
232000|replacedRetainedValuesFollow|long|The replaced/retained values which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
|
||||
232255|replacedRetainedValuesMarkerOperator|long|This operator shall signify a data item containing the original of an element which has been replaced by a substituted value. The element descriptor for the retained value is obtained by the application of the data present bit-map associated with the substituted values operator|OPERATOR|0|0|0|0|0|
|
||||
236000|defineDataPresentBitmap|long|This operator defines the data present bit-map which follows for possible re-use; only one data present bitmap may be defined between this operator and the cancel use defined data present bit-map operator|OPERATOR|0|0|0|0|0|
|
||||
236000|defineDataPresentBitmap|long|This operator defines the data present bit-map which follows for possible re-use; only one data present bitmap may be defined between this operator and the cancel use defined data present bit-map operator |OPERATOR|0|0|0|0|0|
|
||||
237000|useDefinedDataPresentBitmap|long|This operator causes the defined data present bit-map to be used again|OPERATOR|0|0|0|0|0|
|
||||
237255|cancelUseDefinedDataPresentBitmap|long|This operator cancels the re-use of the defined data present bit-map|OPERATOR|0|0|0|0|0|
|
||||
001192|modelVersionNumber|long|MODEL VERSION NUMBER|CODE TABLE 1192|0|0|8|0|0|
|
|
@ -37,10 +37,13 @@ list( APPEND grib_api_srcs
|
|||
action_class_modify.c
|
||||
grib_accessor.c
|
||||
grib_concept.c
|
||||
grib_hash_array.c
|
||||
grib_hash_array.c
|
||||
grib_darray.c
|
||||
grib_sarray.c
|
||||
grib_vdarray.c
|
||||
grib_sarray.c
|
||||
grib_vsarray.c
|
||||
grib_iarray.c
|
||||
grib_viarray.c
|
||||
grib_accessor_class_array.c
|
||||
grib_accessor_class_assert.c
|
||||
grib_accessor_class_ascii.c
|
||||
|
|
|
@ -50,6 +50,9 @@ libgrib_api_la_prototypes= \
|
|||
grib_darray.c \
|
||||
grib_sarray.c \
|
||||
grib_iarray.c \
|
||||
grib_vdarray.c \
|
||||
grib_vsarray.c \
|
||||
grib_viarray.c \
|
||||
grib_accessor_class_array.c \
|
||||
grib_accessor_class_assert.c \
|
||||
grib_accessor_class_ascii.c \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,6 +27,8 @@
|
|||
MEMBERS = const char* tablename
|
||||
MEMBERS = const char* masterDir
|
||||
MEMBERS = const char* localDir
|
||||
MEMBERS = const char* extraDir
|
||||
MEMBERS = const char* extraTable
|
||||
MEMBERS = int widthOfCode
|
||||
MEMBERS = long* tableCodes
|
||||
MEMBERS = size_t tableCodesSize
|
||||
|
@ -67,6 +69,8 @@ typedef struct grib_accessor_smart_table {
|
|||
const char* tablename;
|
||||
const char* masterDir;
|
||||
const char* localDir;
|
||||
const char* extraDir;
|
||||
const char* extraTable;
|
||||
int widthOfCode;
|
||||
long* tableCodes;
|
||||
size_t tableCodesSize;
|
||||
|
@ -181,6 +185,8 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) {
|
|||
self->masterDir = grib_arguments_get_name(a->parent->h,params,n++);
|
||||
self->localDir = grib_arguments_get_name(a->parent->h,params,n++);
|
||||
self->widthOfCode = grib_arguments_get_long(a->parent->h,params,n++);
|
||||
self->extraDir = grib_arguments_get_name(a->parent->h,params,n++);
|
||||
self->extraTable = grib_arguments_get_string(a->parent->h,params,n++);
|
||||
|
||||
a->length = 0;
|
||||
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
|
||||
|
@ -202,17 +208,28 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
|
|||
char recomposed[1024]={0,};
|
||||
char localRecomposed[1024]={0,};
|
||||
char *localFilename=0;
|
||||
char extraRecomposed[1024]={0,};
|
||||
char *extraFilename=0;
|
||||
char localName[1024]={0,};
|
||||
char masterDir[1024]={0,};
|
||||
char localDir[1024]={0,};
|
||||
char extraDir[1024]={0,};
|
||||
char extraTable[1024]={0,};
|
||||
size_t len=1024;
|
||||
|
||||
if (self->masterDir != NULL)
|
||||
if (self->masterDir != NULL) {
|
||||
grib_get_string(h,self->masterDir,masterDir,&len);
|
||||
}
|
||||
|
||||
len=1024;
|
||||
if (self->localDir != NULL)
|
||||
if (self->localDir != NULL) {
|
||||
grib_get_string(h,self->localDir,localDir,&len);
|
||||
}
|
||||
|
||||
len=1024;
|
||||
if (self->extraDir != NULL && self->extraTable!=NULL) {
|
||||
grib_get_string(h,self->extraDir,extraDir,&len);
|
||||
}
|
||||
|
||||
if (*masterDir!=0) {
|
||||
sprintf(name,"%s/%s",masterDir,self->tablename);
|
||||
|
@ -229,6 +246,12 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
|
|||
localFilename=grib_context_full_defs_path(c,localRecomposed);
|
||||
}
|
||||
|
||||
if (*extraDir!=0) {
|
||||
sprintf(extraTable,"%s/%s",extraDir,self->extraTable);
|
||||
grib_recompose_name(h, NULL,extraTable, extraRecomposed,0);
|
||||
extraFilename=grib_context_full_defs_path(c,extraRecomposed);
|
||||
}
|
||||
|
||||
next=c->smart_table;
|
||||
while(next) {
|
||||
if((filename && next->filename[0] && strcmp(filename,next->filename[0]) == 0) &&
|
||||
|
@ -249,6 +272,8 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
|
|||
|
||||
if (localFilename!=0) grib_load_smart_table(c,localFilename,localRecomposed,size,t);
|
||||
|
||||
if (extraFilename!=0) grib_load_smart_table(c,extraFilename,extraRecomposed,size,t);
|
||||
|
||||
if (t->filename[0]==NULL && t->filename[1]==NULL) {
|
||||
grib_context_free_persistent(c,t);
|
||||
return NULL;
|
||||
|
|
|
@ -148,6 +148,8 @@ typedef struct grib_accessor_smart_table {
|
|||
const char* tablename;
|
||||
const char* masterDir;
|
||||
const char* localDir;
|
||||
const char* extraDir;
|
||||
const char* extraTable;
|
||||
int widthOfCode;
|
||||
long* tableCodes;
|
||||
size_t tableCodesSize;
|
||||
|
|
|
@ -202,6 +202,9 @@ typedef struct grib_where grib_where;
|
|||
typedef struct grib_sarray grib_sarray;
|
||||
typedef struct grib_darray grib_darray;
|
||||
typedef struct grib_iarray grib_iarray;
|
||||
typedef struct grib_vdarray grib_vdarray;
|
||||
typedef struct grib_vsarray grib_vsarray;
|
||||
typedef struct grib_viarray grib_viarray;
|
||||
|
||||
grib_fieldset *grib_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, char **keys, int nkeys, char *where_string, char *order_by_string, int *err);
|
||||
|
||||
|
|
|
@ -714,6 +714,29 @@ struct grib_iarray {
|
|||
grib_context* context;
|
||||
} ;
|
||||
|
||||
struct grib_vdarray {
|
||||
grib_darray** v;
|
||||
size_t size;
|
||||
size_t n;
|
||||
size_t incsize;
|
||||
grib_context* context;
|
||||
} ;
|
||||
|
||||
struct grib_vsarray {
|
||||
grib_sarray** v;
|
||||
size_t size;
|
||||
size_t n;
|
||||
size_t incsize;
|
||||
grib_context* context;
|
||||
} ;
|
||||
|
||||
struct grib_viarray {
|
||||
grib_iarray** v;
|
||||
size_t size;
|
||||
size_t n;
|
||||
size_t incsize;
|
||||
grib_context* context;
|
||||
} ;
|
||||
|
||||
#define MAX_SET_VALUES 10
|
||||
#define MAX_ACCESSOR_CACHE 100
|
||||
|
|
|
@ -150,12 +150,17 @@ grib_darray *grib_darray_new(grib_context *c, size_t size, size_t incsize);
|
|||
grib_darray *grib_darray_resize(grib_context *c, grib_darray *v);
|
||||
grib_darray *grib_darray_push(grib_context *c, grib_darray *v, double val);
|
||||
void grib_darray_delete(grib_context *c, grib_darray *v);
|
||||
double *grib_darray_get_array(grib_context *c, grib_darray *v);
|
||||
size_t grib_darray_used_size(grib_darray *v);
|
||||
|
||||
/* grib_sarray.c */
|
||||
grib_sarray *grib_sarray_new(grib_context *c, size_t size, size_t incsize);
|
||||
grib_sarray *grib_sarray_resize(grib_context *c, grib_sarray *v);
|
||||
grib_sarray *grib_sarray_push(grib_context *c, grib_sarray *v, char *val);
|
||||
void grib_sarray_delete(grib_context *c, grib_sarray *v);
|
||||
void grib_sarray_delete_content(grib_context *c, grib_sarray *v);
|
||||
char **grib_sarray_get_array(grib_context *c, grib_sarray *v);
|
||||
size_t grib_sarray_used_size(grib_sarray *v);
|
||||
|
||||
/* grib_iarray.c */
|
||||
grib_iarray *grib_iarray_new_from_array(grib_context *c, long *a, size_t size);
|
||||
|
@ -174,6 +179,33 @@ void grib_iarray_delete_array(grib_iarray *v);
|
|||
long *grib_iarray_get_array(grib_iarray *v);
|
||||
size_t grib_iarray_get_used_size(grib_iarray *v);
|
||||
|
||||
/* grib_vdarray.c */
|
||||
grib_vdarray *grib_vdarray_new(grib_context *c, size_t size, size_t incsize);
|
||||
grib_vdarray *grib_vdarray_resize(grib_context *c, grib_vdarray *v);
|
||||
grib_vdarray *grib_vdarray_push(grib_context *c, grib_vdarray *v, grib_darray *val);
|
||||
void grib_vdarray_delete(grib_context *c, grib_vdarray *v);
|
||||
void grib_vdarray_delete_content(grib_context *c, grib_vdarray *v);
|
||||
grib_darray **grib_vdarray_get_array(grib_context *c, grib_vdarray *v);
|
||||
size_t grib_vdarray_used_size(grib_vdarray *v);
|
||||
|
||||
/* grib_vsarray.c */
|
||||
grib_vsarray *grib_vsarray_new(grib_context *c, size_t size, size_t incsize);
|
||||
grib_vsarray *grib_vsarray_resize(grib_context *c, grib_vsarray *v);
|
||||
grib_vsarray *grib_vsarray_push(grib_context *c, grib_vsarray *v, grib_sarray *val);
|
||||
void grib_vsarray_delete(grib_context *c, grib_vsarray *v);
|
||||
void grib_vsarray_delete_content(grib_context *c, grib_vsarray *v);
|
||||
grib_sarray **grib_vsarray_get_array(grib_context *c, grib_vsarray *v);
|
||||
size_t grib_vsarray_used_size(grib_vsarray *v);
|
||||
|
||||
/* grib_viarray.c */
|
||||
grib_viarray *grib_viarray_new(grib_context *c, size_t size, size_t incsize);
|
||||
grib_viarray *grib_viarray_resize(grib_context *c, grib_viarray *v);
|
||||
grib_viarray *grib_viarray_push(grib_context *c, grib_viarray *v, grib_iarray *val);
|
||||
void grib_viarray_delete(grib_context *c, grib_viarray *v);
|
||||
void grib_viarray_delete_content(grib_context *c, grib_viarray *v);
|
||||
grib_iarray **grib_viarray_get_array(grib_context *c, grib_viarray *v);
|
||||
size_t grib_viarray_used_size(grib_viarray *v);
|
||||
|
||||
/* grib_accessor_class_array.c */
|
||||
|
||||
/* grib_accessor_class_assert.c */
|
||||
|
@ -190,6 +222,8 @@ size_t grib_iarray_get_used_size(grib_iarray *v);
|
|||
|
||||
/* grib_accessor_class_bufr_data.c */
|
||||
|
||||
/* grib_accessor_class_bufr_data_array.c */
|
||||
|
||||
/* grib_accessor_class_bufr_data_element.c */
|
||||
|
||||
/* grib_accessor_class_bufr_group.c */
|
||||
|
|
|
@ -70,3 +70,13 @@ void grib_darray_delete(grib_context* c,grib_darray* v) {
|
|||
grib_context_free(c,v);
|
||||
}
|
||||
|
||||
double* grib_darray_get_array(grib_context* c,grib_darray* v) {
|
||||
double* ret;
|
||||
int i;
|
||||
if (!v) return NULL;
|
||||
ret=grib_context_malloc_clear(c,sizeof(double)*v->n);
|
||||
for (i=0;i<v->n;i++) ret[i]=v->v[i];
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t grib_darray_used_size(grib_darray* v) { return v->n;}
|
||||
|
|
|
@ -70,3 +70,25 @@ void grib_sarray_delete(grib_context* c,grib_sarray* v) {
|
|||
grib_context_free(c,v);
|
||||
}
|
||||
|
||||
void grib_sarray_delete_content(grib_context* c,grib_sarray* v) {
|
||||
int i;
|
||||
if (!v | !v->v) return;
|
||||
if (!c) grib_context_get_default();
|
||||
for (i=0;i<v->n;i++) {
|
||||
grib_context_free(c,v->v[i]);
|
||||
v->v[i]=0;
|
||||
}
|
||||
v->n=0;
|
||||
}
|
||||
|
||||
|
||||
char** grib_sarray_get_array(grib_context* c,grib_sarray* v) {
|
||||
char** ret;
|
||||
int i;
|
||||
if (!v) return NULL;
|
||||
ret=grib_context_malloc_clear(c,sizeof(char*)*v->n);
|
||||
for (i=0;i<v->n;i++) ret[i]=v->v[i];
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t grib_sarray_used_size(grib_sarray* v) { return v->n;}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* Enrico Fucile
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
grib_vdarray* grib_vdarray_new(grib_context* c,size_t size,size_t incsize) {
|
||||
grib_vdarray* v=NULL;
|
||||
if (!c) c=grib_context_get_default();
|
||||
v=(grib_vdarray*)grib_context_malloc_clear(c,sizeof(grib_vdarray));
|
||||
if (!v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_vdarray_new unable to allocate %d bytes\n",sizeof(grib_vdarray));
|
||||
return NULL;
|
||||
}
|
||||
v->size=size;
|
||||
v->n=0;
|
||||
v->incsize=incsize;
|
||||
v->v=(grib_darray**)grib_context_malloc_clear(c,sizeof(grib_darray*)*size);
|
||||
if (!v->v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_vdarray_new unable to allocate %d bytes\n",sizeof(grib_darray*)*size);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
grib_vdarray* grib_vdarray_resize(grib_context* c,grib_vdarray* v) {
|
||||
int newsize=v->incsize+v->size;
|
||||
|
||||
if (!c) c=grib_context_get_default();
|
||||
|
||||
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_darray*));
|
||||
v->size=newsize;
|
||||
if (!v->v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_vdarray_resize unable to allocate %d bytes\n",sizeof(grib_darray*)*newsize);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
grib_vdarray* grib_vdarray_push(grib_context* c,grib_vdarray* v,grib_darray* val) {
|
||||
size_t start_size=100;
|
||||
size_t start_incsize=100;
|
||||
if (!v) v=grib_vdarray_new(c,start_size,start_incsize);
|
||||
|
||||
if (v->n >= v->size) v=grib_vdarray_resize(c,v);
|
||||
v->v[v->n]=val;
|
||||
v->n++;
|
||||
return v;
|
||||
}
|
||||
|
||||
void grib_vdarray_delete(grib_context* c,grib_vdarray* v) {
|
||||
if (!v) return;
|
||||
if (!c) grib_context_get_default();
|
||||
if (v->v) grib_context_free(c,v->v);
|
||||
grib_context_free(c,v);
|
||||
}
|
||||
|
||||
void grib_vdarray_delete_content(grib_context* c,grib_vdarray* v) {
|
||||
int i;
|
||||
if (!v | !v->v) return;
|
||||
if (!c) grib_context_get_default();
|
||||
for (i=0;i<v->n;i++) {
|
||||
grib_darray_delete(c,v->v[i]);
|
||||
v->v[i]=0;
|
||||
}
|
||||
v->n=0;
|
||||
}
|
||||
|
||||
grib_darray** grib_vdarray_get_array(grib_context* c,grib_vdarray* v) {
|
||||
grib_darray** ret;
|
||||
int i;
|
||||
if (!v) return NULL;
|
||||
ret=grib_context_malloc_clear(c,sizeof(grib_darray*)*v->n);
|
||||
for (i=0;i<v->n;i++) ret[i]=v->v[i];
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t grib_vdarray_used_size(grib_vdarray* v) { return v->n;}
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* Enrico Fucile
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
grib_viarray* grib_viarray_new(grib_context* c,size_t size,size_t incsize) {
|
||||
grib_viarray* v=NULL;
|
||||
if (!c) c=grib_context_get_default();
|
||||
v=(grib_viarray*)grib_context_malloc_clear(c,sizeof(grib_viarray));
|
||||
if (!v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_viarray_new unable to allocate %d bytes\n",sizeof(grib_viarray));
|
||||
return NULL;
|
||||
}
|
||||
v->size=size;
|
||||
v->n=0;
|
||||
v->incsize=incsize;
|
||||
v->v=(grib_iarray**)grib_context_malloc_clear(c,sizeof(grib_iarray*)*size);
|
||||
if (!v->v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_viarray_new unable to allocate %d bytes\n",sizeof(grib_iarray*)*size);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
grib_viarray* grib_viarray_resize(grib_context* c,grib_viarray* v) {
|
||||
int newsize=v->incsize+v->size;
|
||||
|
||||
if (!c) c=grib_context_get_default();
|
||||
|
||||
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_iarray*));
|
||||
v->size=newsize;
|
||||
if (!v->v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_viarray_resize unable to allocate %d bytes\n",sizeof(grib_iarray*)*newsize);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
grib_viarray* grib_viarray_push(grib_context* c,grib_viarray* v,grib_iarray* val) {
|
||||
size_t start_size=100;
|
||||
size_t start_incsize=100;
|
||||
if (!v) v=grib_viarray_new(c,start_size,start_incsize);
|
||||
|
||||
if (v->n >= v->size) v=grib_viarray_resize(c,v);
|
||||
v->v[v->n]=val;
|
||||
v->n++;
|
||||
return v;
|
||||
}
|
||||
|
||||
void grib_viarray_delete(grib_context* c,grib_viarray* v) {
|
||||
if (!v) return;
|
||||
if (!c) grib_context_get_default();
|
||||
if (v->v) grib_context_free(c,v->v);
|
||||
grib_context_free(c,v);
|
||||
}
|
||||
|
||||
void grib_viarray_delete_content(grib_context* c,grib_viarray* v) {
|
||||
int i;
|
||||
if (!v | !v->v) return;
|
||||
if (!c) grib_context_get_default();
|
||||
for (i=0;i<v->n;i++) {
|
||||
grib_iarray_delete(v->v[i]);
|
||||
v->v[i]=0;
|
||||
}
|
||||
v->n=0;
|
||||
}
|
||||
|
||||
grib_iarray** grib_viarray_get_array(grib_context* c,grib_viarray* v) {
|
||||
grib_iarray** ret;
|
||||
int i;
|
||||
if (!v) return NULL;
|
||||
ret=grib_context_malloc_clear(c,sizeof(grib_iarray*)*v->n);
|
||||
for (i=0;i<v->n;i++) ret[i]=v->v[i];
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t grib_viarray_used_size(grib_viarray* v) { return v->n;}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* Enrico Fucile
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
grib_vsarray* grib_vsarray_new(grib_context* c,size_t size,size_t incsize) {
|
||||
grib_vsarray* v=NULL;
|
||||
if (!c) c=grib_context_get_default();
|
||||
v=(grib_vsarray*)grib_context_malloc_clear(c,sizeof(grib_vsarray));
|
||||
if (!v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_vsarray_new unable to allocate %d bytes\n",sizeof(grib_vsarray));
|
||||
return NULL;
|
||||
}
|
||||
v->size=size;
|
||||
v->n=0;
|
||||
v->incsize=incsize;
|
||||
v->v=(grib_sarray**)grib_context_malloc_clear(c,sizeof(grib_sarray*)*size);
|
||||
if (!v->v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_vsarray_new unable to allocate %d bytes\n",sizeof(grib_sarray*)*size);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
grib_vsarray* grib_vsarray_resize(grib_context* c,grib_vsarray* v) {
|
||||
int newsize=v->incsize+v->size;
|
||||
|
||||
if (!c) c=grib_context_get_default();
|
||||
|
||||
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_sarray*));
|
||||
v->size=newsize;
|
||||
if (!v->v) {
|
||||
grib_context_log(c,GRIB_LOG_ERROR,
|
||||
"grib_vsarray_resize unable to allocate %d bytes\n",sizeof(grib_sarray*)*newsize);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
grib_vsarray* grib_vsarray_push(grib_context* c,grib_vsarray* v,grib_sarray* val) {
|
||||
size_t start_size=100;
|
||||
size_t start_incsize=100;
|
||||
if (!v) v=grib_vsarray_new(c,start_size,start_incsize);
|
||||
|
||||
if (v->n >= v->size) v=grib_vsarray_resize(c,v);
|
||||
v->v[v->n]=val;
|
||||
v->n++;
|
||||
return v;
|
||||
}
|
||||
|
||||
void grib_vsarray_delete(grib_context* c,grib_vsarray* v) {
|
||||
if (!v) return;
|
||||
if (!c) grib_context_get_default();
|
||||
if (v->v) grib_context_free(c,v->v);
|
||||
grib_context_free(c,v);
|
||||
}
|
||||
|
||||
void grib_vsarray_delete_content(grib_context* c,grib_vsarray* v) {
|
||||
int i;
|
||||
if (!v | !v->v) return;
|
||||
if (!c) grib_context_get_default();
|
||||
for (i=0;i<v->n;i++) {
|
||||
grib_sarray_delete_content(c,v->v[i]);
|
||||
grib_sarray_delete(c,v->v[i]);
|
||||
v->v[i]=0;
|
||||
}
|
||||
v->n=0;
|
||||
}
|
||||
|
||||
grib_sarray** grib_vsarray_get_array(grib_context* c,grib_vsarray* v) {
|
||||
grib_sarray** ret;
|
||||
int i;
|
||||
if (!v) return NULL;
|
||||
ret=grib_context_malloc_clear(c,sizeof(grib_sarray*)*v->n);
|
||||
for (i=0;i<v->n;i++) ret[i]=v->v[i];
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t grib_vsarray_used_size(grib_vsarray* v) { return v->n;}
|
|
@ -9,7 +9,7 @@ TESTS = definitions.sh \
|
|||
bitmap.sh list.sh second_order.sh \
|
||||
multi_from_message.sh change_scanning.sh \
|
||||
julian.sh statistics.sh tigge.sh tigge_conversions.sh \
|
||||
read_any.sh padding.sh lamb_az_eq_area.sh grib_to_netcdf.sh bufr_dump.sh debug.sh $(JPEG_TEST)
|
||||
read_any.sh padding.sh lamb_az_eq_area.sh grib_to_netcdf.sh bufrdc_ref.sh bufr_dump.sh debug.sh $(JPEG_TEST)
|
||||
|
||||
noinst_PROGRAMS = packing_check gauss_sub read_any double_cmp packing pack_unpack \
|
||||
multi_from_message julian read_index index gribex_perf\
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2005-2014 ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
|
||||
. ./include.sh
|
||||
|
||||
REDIRECT=/dev/null
|
||||
|
||||
cat > bufrdc_ref.filter<<EOF
|
||||
set subsetNumber=0;
|
||||
print "[numericValues!1%23.14e]";
|
||||
EOF
|
||||
|
||||
for file in ${data_dir}/bufr/*.bufr
|
||||
do
|
||||
REDIRECT=stdout
|
||||
|
||||
${tools_dir}bufr_filter bufrdc_ref.filter $file 2> $REDIRECT > $file.test
|
||||
|
||||
numdiff $file.ref $file.test
|
||||
|
||||
|
||||
done
|
||||
|
Loading…
Reference in New Issue