From 6a5749ecb7c237458a89c6155842a767e7e8602c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 31 Jul 2019 18:52:53 +0100 Subject: [PATCH 01/10] ECC-428: Inconsistent number of values when decoding compressed BUFR data --- src/grib_accessor_class_bufr_data_array.c | 182 +++++++++++----------- src/grib_api_internal.h | 1 + src/grib_context.c | 11 +- tests/CMakeLists.txt | 1 + tests/bufr_ecc-428.sh | 56 +++++++ 5 files changed, 161 insertions(+), 90 deletions(-) create mode 100755 tests/bufr_ecc-428.sh diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index 29d2c5f9e..3d4175371 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -559,33 +559,33 @@ static int decode_string_array(grib_context* c, unsigned char* data, long* pos, sval=(char*)grib_context_malloc_clear(c,modifiedWidth/8+1); CHECK_END_DATA_RETURN(c, self, modifiedWidth, *err); if (*err) { - grib_sarray_push(c,sa,sval); - grib_vsarray_push(c,self->stringValues,sa); - return ret; + grib_sarray_push(c,sa,sval); + grib_vsarray_push(c,self->stringValues,sa); + return ret; } grib_decode_string(data,pos,modifiedWidth/8,sval); CHECK_END_DATA_RETURN(c, self, 6, *err); if (*err) { - grib_sarray_push(c,sa,sval); - grib_vsarray_push(c,self->stringValues,sa); - return ret; + grib_sarray_push(c,sa,sval); + grib_vsarray_push(c,self->stringValues,sa); + return ret; } width=grib_decode_unsigned_long(data,pos,6); if (width) { CHECK_END_DATA_RETURN(c, self, width*8*self->numberOfSubsets, *err); - if (*err) { - grib_sarray_push(c,sa,sval); - grib_vsarray_push(c,self->stringValues,sa); - return ret; - } - grib_context_free(c,sval); - for (j=0;jnumberOfSubsets;j++) { - sval=(char*)grib_context_malloc_clear(c,width+1); - grib_decode_string(data,pos,width,sval); - grib_sarray_push(c,sa,sval); - } + if (*err) { + grib_sarray_push(c,sa,sval); + grib_vsarray_push(c,self->stringValues,sa); + return ret; + } + grib_context_free(c,sval); + for (j=0;jnumberOfSubsets;j++) { + sval=(char*)grib_context_malloc_clear(c,width+1); + grib_decode_string(data,pos,width,sval); + grib_sarray_push(c,sa,sval); + } } else { - grib_sarray_push(c,sa,sval); + grib_sarray_push(c,sa,sval); } grib_vsarray_push(c,self->stringValues,sa); return ret; @@ -609,13 +609,13 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long CHECK_END_DATA_RETURN(c, self, modifiedWidth+6, NULL); if (*err) { - dval=GRIB_MISSING_DOUBLE; - lval=0; - grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g", modifiedWidth,lval,dval); - ret=grib_darray_new(c,DYN_ARRAY_SIZE_INIT,DYN_ARRAY_SIZE_INCR); - grib_darray_push(c,ret,dval); - *err=0; - return ret; + dval=GRIB_MISSING_DOUBLE; + lval=0; + grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g", modifiedWidth,lval,dval); + ret=grib_darray_new(c,DYN_ARRAY_SIZE_INIT,DYN_ARRAY_SIZE_INCR); + grib_darray_push(c,ret,dval); + *err=0; + return ret; } lval=grib_decode_unsigned_long(data,pos,modifiedWidth); localReference=(long)lval+modifiedReference; @@ -625,13 +625,13 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long if (localWidth) { CHECK_END_DATA_RETURN(c, self, localWidth*self->numberOfSubsets, NULL); if (*err) { - dval=GRIB_MISSING_DOUBLE; - lval=0; - grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g", modifiedWidth,lval,dval); - ret=grib_darray_new(c,DYN_ARRAY_SIZE_INIT,DYN_ARRAY_SIZE_INCR); - grib_darray_push(c,ret,dval); - *err=0; - return ret; + dval=GRIB_MISSING_DOUBLE; + lval=0; + grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g", modifiedWidth,lval,dval); + ret=grib_darray_new(c,DYN_ARRAY_SIZE_INIT,DYN_ARRAY_SIZE_INCR); + grib_darray_push(c,ret,dval); + *err=0; + return ret; } for (j=0;jnumberOfSubsets;j++) { lval=grib_decode_unsigned_long(data,pos,localWidth); @@ -643,13 +643,21 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long grib_darray_push(c,ret,dval); } } else { + // ECC-428 if (grib_is_all_bits_one(lval,modifiedWidth) && canBeMissing) { dval=GRIB_MISSING_DOUBLE; } else { dval=localReference*modifiedFactor; } - grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g", modifiedWidth,lval,dval); - grib_darray_push(c,ret,dval); + if(c->bufr_multi_element_constant_arrays) { + grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g (const array multi values)", modifiedWidth,lval,dval,bd->code); + for (j=0;jnumberOfSubsets;j++) { + grib_darray_push(c,ret,dval); + } + } else { + grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g (const array single value)", modifiedWidth,lval,dval,bd->code); + grib_darray_push(c,ret,dval); + } } return ret; @@ -671,10 +679,10 @@ static int encode_string_array(grib_context* c,grib_buffer* buff,long* pos, bufr if (n<=0) return GRIB_NO_VALUES; if (grib_sarray_used_size(stringValues)==1) { - n=1; - ival=0; + n=1; + ival=0; } else { - ival=self->iss_list->v[0]; + ival=self->iss_list->v[0]; } if (n>grib_sarray_used_size(stringValues)) @@ -708,7 +716,7 @@ static void set_missing_long_to_double(grib_darray* dvalues) /* ECC-750: The 'factor' argument is 10^-scale */ static int descriptor_get_min_max(bufr_descriptor* bd, long width, long reference, double factor, - double* minAllowed, double* maxAllowed) + double* minAllowed, double* maxAllowed) { /* Maximum value is allowed to be the largest number (all bits 1) which means it's MISSING */ unsigned long max1 = (1UL << width) - 1; /* Highest value for number with 'width' bits */ @@ -768,11 +776,11 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr if (*v > maxAllowed || *v < minAllowed) { if (dont_fail_if_out_of_range) { grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s. Value (%g) out of range (minAllowed=%g, maxAllowed=%g)." - " Setting it to missing value\n", bd->shortName, *v, minAllowed, maxAllowed); + " Setting it to missing value\n", bd->shortName, *v, minAllowed, maxAllowed); grib_set_bits_on(buff->data,pos,modifiedWidth); } else { grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s. Value (%g) out of range (minAllowed=%g, maxAllowed=%g).", - bd->shortName, *v, minAllowed, maxAllowed); + bd->shortName, *v, minAllowed, maxAllowed); return GRIB_OUT_OF_RANGE; /* ECC-611 */ } } else { @@ -790,8 +798,8 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr val0=dvalues->v[self->iss_list->v[0]]; is_constant=1; for (i=0;iv[self->iss_list->v[i]]; - if (val0 != values[i]) is_constant=0; + values[i]=dvalues->v[self->iss_list->v[i]]; + if (val0 != values[i]) is_constant=0; } v=values; @@ -822,8 +830,8 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr /* Turn out-of-range values into 'missing' */ if (*v!=GRIB_MISSING_DOUBLE && (*v < minAllowed || *v > maxAllowed)) { grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s. Value at index %ld (%g) out of range (minAllowed=%g, maxAllowed=%g)." - " Setting it to missing value\n", - bd->shortName, (long)ii, *v, minAllowed, maxAllowed); + " Setting it to missing value\n", + bd->shortName, (long)ii, *v, minAllowed, maxAllowed); *v = GRIB_MISSING_DOUBLE; } ii++; @@ -850,12 +858,12 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr } if (max>maxAllowed && max!=GRIB_MISSING_DOUBLE) { grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s. Maximum value (value[%lu]=%g) out of range (maxAllowed=%g).", - bd->shortName, index_of_max, max, maxAllowed, index_of_max); + bd->shortName, index_of_max, max, maxAllowed, index_of_max); return GRIB_OUT_OF_RANGE; } if (minshortName, index_of_min, min, minAllowed); + bd->shortName, index_of_min, min, minAllowed); return GRIB_OUT_OF_RANGE; } @@ -931,13 +939,13 @@ static int encode_double_value(grib_context* c,grib_buffer* buff,long* pos,bufr_ else if (value>maxAllowed || valueshortName, value, minAllowed, maxAllowed); + " Setting it to missing value\n", + bd->shortName, value, minAllowed, maxAllowed); value = GRIB_MISSING_DOUBLE; /* Ignore the bad value and instead use 'missing' */ grib_set_bits_on(buff->data,pos,modifiedWidth); } else { grib_context_log(c, GRIB_LOG_ERROR, "encode_double_value: %s. Value (%g) out of range (minAllowed=%g, maxAllowed=%g).", - bd->shortName, value, minAllowed, maxAllowed); + bd->shortName, value, minAllowed, maxAllowed); return GRIB_OUT_OF_RANGE; } } @@ -1109,28 +1117,28 @@ static int decode_replication(grib_context* c,grib_accessor_bufr_data_array* sel grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication localReference width=%ld", descriptors[i]->width); CHECK_END_DATA_RETURN(c, self, descriptors[i]->width+6, *err); if (*err) { - *numberOfRepetitions=0; + *numberOfRepetitions=0; } else { - localReference=grib_decode_unsigned_long(data,pos,descriptors[i]->width)+descriptors[i]->reference; - grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication localWidth width=6"); - width=grib_decode_unsigned_long(data,pos,6); - if (width) { - grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication is NOT constant for compressed data!"); - /* delayed replication number is not constant. NOT IMPLEMENTED */ - return GRIB_NOT_IMPLEMENTED; - } else { - *numberOfRepetitions=localReference*descriptors[i]->factor; - grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication value=%ld",*numberOfRepetitions); - } + localReference=grib_decode_unsigned_long(data,pos,descriptors[i]->width)+descriptors[i]->reference; + grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication localWidth width=6"); + width=grib_decode_unsigned_long(data,pos,6); + if (width) { + grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication is NOT constant for compressed data!"); + /* delayed replication number is not constant. NOT IMPLEMENTED */ + return GRIB_NOT_IMPLEMENTED; + } else { + *numberOfRepetitions=localReference*descriptors[i]->factor; + grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication value=%ld",*numberOfRepetitions); + } } } else { CHECK_END_DATA_RETURN(c, self, descriptors[i]->width, *err); if (*err) { - *numberOfRepetitions=0; + *numberOfRepetitions=0; } else { - *numberOfRepetitions=grib_decode_unsigned_long(data,pos,descriptors[i]->width)+ - descriptors[i]->reference*descriptors[i]->factor; - grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication value=%ld",*numberOfRepetitions); + *numberOfRepetitions=grib_decode_unsigned_long(data,pos,descriptors[i]->width)+ + descriptors[i]->reference*descriptors[i]->factor; + grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: \tdelayed replication value=%ld",*numberOfRepetitions); } } if (self->compressedData) { @@ -1364,7 +1372,7 @@ static int encode_element(grib_context* c,grib_accessor_bufr_data_array* self,in err=encode_double_value(c,buff,pos,bd,self,self->numericValues->v[subsetIndex]->v[elementIndex]); if (err) { grib_context_log(c,GRIB_LOG_ERROR,"Cannot encode %s=%g (subset=%d)", /*subsetIndex starts from 0*/ - bd->shortName, self->numericValues->v[subsetIndex]->v[elementIndex], subsetIndex+1); + bd->shortName, self->numericValues->v[subsetIndex]->v[elementIndex], subsetIndex+1); } } } @@ -1957,9 +1965,9 @@ static GRIB_INLINE int significanceQualifierIndex(int X,int Y) } static GRIB_INLINE void reset_deeper_qualifiers( - grib_accessor* significanceQualifierGroup[], - const int* const significanceQualifierDepth, - int numElements, int depth) + grib_accessor* significanceQualifierGroup[], + const int* const significanceQualifierDepth, + int numElements, int depth) { int i; for (i=0;iaccessor,"index"); - grib_unpack_long(anindex,index,&l); + long index[1]; + grib_accessor* anindex=grib_accessor_get_attribute(al->accessor,"index"); + grib_unpack_long(anindex,index,&l); #endif - return 1; - } + return 1; + } } return 0; } @@ -2132,7 +2140,7 @@ static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_acce } static int bitmap_init(grib_context* c, bitmap_s* bitmap, - grib_accessors_list* bitmapStart, int bitmapSize, grib_accessors_list* lastAccessorInList) + grib_accessors_list* bitmapStart, int bitmapSize, grib_accessors_list* lastAccessorInList) { int ret=0,i; bitmap->cursor=bitmapStart->next; @@ -2305,7 +2313,7 @@ static int create_keys(grib_accessor* a,long onlySubset,long startSubset,long en } elementFromBitmap=NULL; if (descriptor->F==0 && IS_QUALIFIER(descriptor->X) && - self->unpackMode==CODES_BUFR_UNPACK_STRUCTURE) { + self->unpackMode==CODES_BUFR_UNPACK_STRUCTURE) { int sidx=significanceQualifierIndex(descriptor->X,descriptor->Y); groupNumber++; @@ -2315,7 +2323,7 @@ static int create_keys(grib_accessor* a,long onlySubset,long startSubset,long en if (depth < max_depth) { /* If depth >= max_depth, then no entry will be deeper so no need for call */ reset_deeper_qualifiers(significanceQualifierGroup,significanceQualifierDepth, - number_of_qualifiers,depth); + number_of_qualifiers,depth); } } else { /* if (forceGroupClosure) { */ @@ -2362,7 +2370,7 @@ static int create_keys(grib_accessor* a,long onlySubset,long startSubset,long en groupSection=bitmapGroup[bitmapIndex]->parent; depth=bitmapDepth[bitmapIndex]; reset_deeper_qualifiers(significanceQualifierGroup,significanceQualifierDepth, - number_of_qualifiers,depth); + number_of_qualifiers,depth); /* TODO: This branch is not reached in our tests! */ reset_deeper_qualifiers(bitmapGroup,bitmapDepth,MAX_NUMBER_OF_BITMAPS,depth); } else { @@ -2470,7 +2478,7 @@ static int create_keys(grib_accessor* a,long onlySubset,long startSubset,long en case 31021: associatedFieldSignificanceAccessor=elementAccessor; break; - /*case 33007:*/ + /*case 33007:*/ /* ECC-690: See later */ /* break; */ default: @@ -2553,7 +2561,7 @@ static int set_to_missing_if_out_of_range(grib_handle* h) /* First check if the transient key is set */ long setToMissingIfOutOfRange=0; if (grib_get_long(h, "setToMissingIfOutOfRange", &setToMissingIfOutOfRange)==GRIB_SUCCESS && - setToMissingIfOutOfRange != 0) + setToMissingIfOutOfRange != 0) { return 1; } @@ -2767,10 +2775,10 @@ static int process_elements(grib_accessor* a,int flag,long onlySubset,long start while (ip>=0 && n[ip]==0) { nn[ip]--; if (nn[ip]<=0) { - numberOfNestedRepetitions--; + numberOfNestedRepetitions--; } else { - n[ip]=numberOfElementsToRepeat[ip]; - i=startRepetition[ip]; + n[ip]=numberOfElementsToRepeat[ip]; + i=startRepetition[ip]; } ip--; } diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index 285a67e8e..023b2b219 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -1053,6 +1053,7 @@ struct grib_context int ieee_packing; int bufrdc_mode; int bufr_set_to_missing_if_out_of_range; + int bufr_multi_element_constant_arrays; FILE* log_stream; grib_trie* classes; grib_trie* lists; diff --git a/src/grib_context.c b/src/grib_context.c index d8c473d75..062a2f582 100644 --- a/src/grib_context.c +++ b/src/grib_context.c @@ -335,6 +335,7 @@ static grib_context default_grib_context = { 0, /* ieee_packing */ 0, /* bufrdc_mode */ 0, /* bufr_set_to_missing_if_out_of_range */ + 0, /* bufr_multi_element_constant_arrays */ 0, /* log_stream */ 0, /* classes */ 0, /* lists */ @@ -368,6 +369,7 @@ grib_context* grib_context_get_default() const char* keep_matrix = NULL; const char* bufrdc_mode = NULL; const char* bufr_set_to_missing_if_out_of_range = NULL; + const char* bufr_multi_element_constant_arrays = NULL; const char* file_pool_max_opened_files = NULL; #ifdef ENABLE_FLOATING_POINT_EXCEPTIONS @@ -375,8 +377,9 @@ grib_context* grib_context_get_default() #endif write_on_fail = codes_getenv("ECCODES_GRIB_WRITE_ON_FAIL"); - bufrdc_mode = codes_getenv("ECCODES_BUFRDC_MODE_ON"); - bufr_set_to_missing_if_out_of_range = codes_getenv("ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE"); + bufrdc_mode = getenv("ECCODES_BUFRDC_MODE_ON"); + bufr_set_to_missing_if_out_of_range = getenv("ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE"); + bufr_multi_element_constant_arrays = getenv("ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS"); large_constant_fields = codes_getenv("ECCODES_GRIB_LARGE_CONSTANT_FIELDS"); no_abort = codes_getenv("ECCODES_NO_ABORT"); debug = codes_getenv("ECCODES_DEBUG"); @@ -387,7 +390,7 @@ grib_context* grib_context_get_default() no_big_group_split = codes_getenv("ECCODES_GRIB_NO_BIG_GROUP_SPLIT"); no_spd = codes_getenv("ECCODES_GRIB_NO_SPD"); keep_matrix = codes_getenv("ECCODES_GRIB_KEEP_MATRIX"); - file_pool_max_opened_files = codes_getenv("ECCODES_FILE_POOL_MAX_OPENED_FILES"); + file_pool_max_opened_files = getenv("ECCODES_FILE_POOL_MAX_OPENED_FILES"); /* On UNIX, when we read from a file we get exactly what is in the file on disk. * But on Windows a file can be opened in binary or text mode. In binary mode the system behaves exactly as in UNIX. @@ -473,6 +476,8 @@ grib_context* grib_context_get_default() default_grib_context.bufrdc_mode = bufrdc_mode ? atoi(bufrdc_mode) : 0; default_grib_context.bufr_set_to_missing_if_out_of_range = bufr_set_to_missing_if_out_of_range ? atoi(bufr_set_to_missing_if_out_of_range) : 0; + default_grib_context.bufr_multi_element_constant_arrays = bufr_multi_element_constant_arrays ? + atoi(bufr_multi_element_constant_arrays) : 0; default_grib_context.file_pool_max_opened_files = file_pool_max_opened_files ? atoi(file_pool_max_opened_files) : DEFAULT_FILE_POOL_MAX_OPENED_FILES; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6accedb9a..dc5c8ffda 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -87,6 +87,7 @@ list( APPEND tests_data_reqd bufr_keys_iter bufr_get_element bufr_wmo_tables + bufr_ecc-428 bufr_ecc-197 bufr_ecc-286 bufr_ecc-288 diff --git a/tests/bufr_ecc-428.sh b/tests/bufr_ecc-428.sh new file mode 100755 index 000000000..ac5b7329d --- /dev/null +++ b/tests/bufr_ecc-428.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Copyright 2005-2019 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 + +# --------------------------------------------------------- +# This is the test for the JIRA issue ECC-428 +# Decoding compressed BUFR data: +# Option to have constant arrays with multiple repeated values +# rather than a single value +# --------------------------------------------------------- +cd ${data_dir}/bufr +label="bufr_ecc_428_test" + +tempRules=temp.${label}.filter +tempText=temp.${label}.text +tempRef1=temp.${label}.ref1 +tempRef2=temp.${label}.ref2 + +# -------------------------------------------------------- +# Test 1 +# -------------------------------------------------------- +bufrFile=airs_57.bufr # this has 15 subsets +cat > $tempRules < $tempText +echo "784" > $tempRef1 +diff $tempRef1 $tempText + +export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1 +${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText +echo "784 784 784 784 784 784 784 784 784 784 784 784 784 784 784" > $tempRef2 +diff $tempRef2 $tempText + +unset ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS +${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText +diff $tempRef1 $tempText + +export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=0 +${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText +diff $tempRef1 $tempText + + + +# ------------------------ +rm -rf $tempRules $tempText $tempRef1 $tempRef2 From e7c337f9bda3dec443bd8912f5dd42ef54d18ced Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 31 Jul 2019 19:24:36 +0100 Subject: [PATCH 02/10] ECC-428: Add failing test case on search by condition --- tests/bufr_ecc-428.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/bufr_ecc-428.sh b/tests/bufr_ecc-428.sh index ac5b7329d..6fedc25df 100755 --- a/tests/bufr_ecc-428.sh +++ b/tests/bufr_ecc-428.sh @@ -51,6 +51,20 @@ ${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText diff $tempRef1 $tempText +# -------------------------------------------------------- +# Test 2 +# -------------------------------------------------------- +bufrFile=asca_139.bufr +cat > $tempRules </dev/null + +export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1 +${tools_dir}/codes_bufr_filter $tempRules $bufrFile + + +# Clean up rm -rf $tempRules $tempText $tempRef1 $tempRef2 From 53dc1659dbc75c486562c771d5143b28f15f0663 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 5 Aug 2019 18:01:55 +0100 Subject: [PATCH 03/10] ECC-428: Fix the percentConfidence problem (added test too) --- src/grib_accessor_class_bufr_data_array.c | 9 +++++++- tests/bufr_ecc-428.sh | 25 ++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index 3d4175371..aa7a9b901 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -600,6 +600,7 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long unsigned long lval; int localReference,localWidth,modifiedWidth,modifiedReference; double modifiedFactor,dval; + int bufr_multi_element_constant_arrays = c->bufr_multi_element_constant_arrays; *err=0; @@ -649,7 +650,13 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long } else { dval=localReference*modifiedFactor; } - if(c->bufr_multi_element_constant_arrays) { + + /* dataPresentIndicator is special and has to have SINGLE VALUE if constant array */ + if (bufr_multi_element_constant_arrays == 1 && bd->code == 31031) { + bufr_multi_element_constant_arrays=0; + } + + if(bufr_multi_element_constant_arrays) { grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g (const array multi values)", modifiedWidth,lval,dval,bd->code); for (j=0;jnumberOfSubsets;j++) { grib_darray_push(c,ret,dval); diff --git a/tests/bufr_ecc-428.sh b/tests/bufr_ecc-428.sh index 6fedc25df..b0706aa28 100755 --- a/tests/bufr_ecc-428.sh +++ b/tests/bufr_ecc-428.sh @@ -21,6 +21,7 @@ label="bufr_ecc_428_test" tempRules=temp.${label}.filter tempText=temp.${label}.text +tempErrs=temp.${label}.errs tempRef1=temp.${label}.ref1 tempRef2=temp.${label}.ref2 @@ -33,6 +34,7 @@ cat > $tempRules < $tempText echo "784" > $tempRef1 diff $tempRef1 $tempText @@ -54,17 +56,34 @@ diff $tempRef1 $tempText # -------------------------------------------------------- # Test 2 # -------------------------------------------------------- +bufrFile=amv2_87.bufr +cat > $tempRules <percentConfidence!0]"; +EOF +cat $tempRules + +export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1 +${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText 2>$tempErrs +grep -q '^48 54 59.*91 97' $tempText + + +# -------------------------------------------------------- +# Test 3 +# -------------------------------------------------------- bufrFile=asca_139.bufr cat > $tempRules </dev/null +echo "TODO: Searching for backscatter ... currently failing" export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1 -${tools_dir}/codes_bufr_filter $tempRules $bufrFile - +${tools_dir}/codes_bufr_filter $tempRules $bufrFile 2>$tempErrs +cat $tempErrs # Clean up -rm -rf $tempRules $tempText $tempRef1 $tempRef2 +rm -rf $tempRules $tempText $tempRef1 $tempRef2 $tempErrs From df183fc14d57d3521646a38102c76cbf408bfd30 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 8 Aug 2019 17:57:44 +0100 Subject: [PATCH 04/10] ECC-428: Fix the string array and replication issues --- src/grib_accessor_class_bufr_data_array.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index aa7a9b901..9747a0eab 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -553,6 +553,7 @@ static int decode_string_array(grib_context* c, unsigned char* data, long* pos, char* sval=0; int j,modifiedWidth,width; grib_sarray* sa=grib_sarray_new(c,self->numberOfSubsets,10); + int bufr_multi_element_constant_arrays = c->bufr_multi_element_constant_arrays; modifiedWidth= bd->width; @@ -585,7 +586,15 @@ static int decode_string_array(grib_context* c, unsigned char* data, long* pos, grib_sarray_push(c,sa,sval); } } else { - grib_sarray_push(c,sa,sval); + if (bufr_multi_element_constant_arrays) { + for (j=0;jnumberOfSubsets;j++) { + char* pStr = sval; + if (j>0) pStr = strdup(sval); + grib_sarray_push(c,sa,pStr); + } + } else { + grib_sarray_push(c,sa,sval); + } } grib_vsarray_push(c,self->stringValues,sa); return ret; @@ -1150,7 +1159,14 @@ static int decode_replication(grib_context* c,grib_accessor_bufr_data_array* sel } if (self->compressedData) { dval=grib_darray_new(c,1,100); - grib_darray_push(c,dval,(double)(*numberOfRepetitions)); + if(c->bufr_multi_element_constant_arrays) { + long j; + for (j=0;jnumberOfSubsets;j++) { + grib_darray_push(c,dval,(double)(*numberOfRepetitions)); + } + } else { + grib_darray_push(c,dval,(double)(*numberOfRepetitions)); + } grib_vdarray_push(c,self->numericValues,dval); } else { grib_darray_push(c,dval,(double)(*numberOfRepetitions)); From 888c88ab908a90f979f108bbd95b860c9608a68c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 8 Aug 2019 18:17:29 +0100 Subject: [PATCH 05/10] ECC-428: test for the string array and replication --- tests/bufr_ecc-428.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/bufr_ecc-428.sh b/tests/bufr_ecc-428.sh index b0706aa28..88bd4e2be 100755 --- a/tests/bufr_ecc-428.sh +++ b/tests/bufr_ecc-428.sh @@ -54,7 +54,7 @@ diff $tempRef1 $tempText # -------------------------------------------------------- -# Test 2 +# Test 2: percentConfidence # -------------------------------------------------------- bufrFile=amv2_87.bufr cat > $tempRules < $tempRules < $tempText 2>$tempErrs +grep -q '^LBG LBG LBG LBG.*LBG$' $tempText + + +# -------------------------------------------------------- +# Test 4: replication factors +# -------------------------------------------------------- +bufrFile=sbu8_206.bufr +cat > $tempRules < $tempText 2>$tempErrs +grep -q '^6 6 6.*24 24.*6 6' $tempText + +# -------------------------------------------------------- +# Test XX: Currently failing # -------------------------------------------------------- bufrFile=asca_139.bufr cat > $tempRules < Date: Fri, 9 Aug 2019 13:06:58 +0100 Subject: [PATCH 06/10] ECC-428: Added C and F90 API calls --- fortran/eccodes_f90_tail.f90 | 26 ++++++++++++++++++++++++++ fortran/grib_api_externals.h | 1 + fortran/grib_fortran.c | 25 +++++++++++++++++++++++++ fortran/grib_fortran_prototypes.h | 7 +++++++ src/eccodes.h | 5 +++++ src/grib_api_prototypes.h | 2 ++ src/grib_context.c | 13 +++++++++++++ 7 files changed, 79 insertions(+) diff --git a/fortran/eccodes_f90_tail.f90 b/fortran/eccodes_f90_tail.f90 index fcdbba705..f4e81d0c3 100644 --- a/fortran/eccodes_f90_tail.f90 +++ b/fortran/eccodes_f90_tail.f90 @@ -2836,4 +2836,30 @@ subroutine codes_copy_key( msgid_src, key, msgid_dest, status ) endif end subroutine codes_copy_key +subroutine codes_bufr_multi_element_constant_arrays_on (status ) + integer(kind=kindOfInt),optional, intent(out) :: status + integer(kind=kindOfInt) :: iret + + iret=codes_f_bufr_multi_element_constant_arrays_on() + if (present(status)) then + status = iret + else + call grib_check(iret,'codes_bufr_multi_element_constant_arrays_on','') + endif +end subroutine codes_bufr_multi_element_constant_arrays_on + +subroutine codes_bufr_multi_element_constant_arrays_off (status ) + integer(kind=kindOfInt),optional, intent(out) :: status + integer(kind=kindOfInt) :: iret + + iret=codes_f_bufr_multi_element_constant_arrays_off() + if (present(status)) then + status = iret + else + call grib_check(iret,'codes_bufr_multi_element_constant_arrays_off','') + endif + +end subroutine codes_bufr_multi_element_constant_arrays_off + + end module eccodes diff --git a/fortran/grib_api_externals.h b/fortran/grib_api_externals.h index bf875a24e..1cafa17c9 100644 --- a/fortran/grib_api_externals.h +++ b/fortran/grib_api_externals.h @@ -73,6 +73,7 @@ integer, external :: grib_f_set_int, grib_f_set_int_array, & grib_f_set_force_real4_array, grib_f_set_force_real8_array, & grib_f_set_string, grib_f_set_string_array, grib_f_set_missing, & grib_f_gribex_mode_on,grib_f_gribex_mode_off, & + codes_f_bufr_multi_element_constant_arrays_on,codes_f_bufr_multi_element_constant_arrays_off, & grib_f_find_nearest_single,grib_f_find_nearest_four_single,grib_f_find_nearest_multiple integer, external :: grib_f_get_message_size, grib_f_copy_message, grib_f_count_in_file integer, external :: grib_f_write, grib_f_multi_write, grib_f_multi_append diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index f77930a20..45bcaeb46 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -3472,6 +3472,31 @@ int grib_f_multi_append__(int* ingid, int* sec,int* mgid) { return grib_f_multi_append_(ingid, sec, mgid); } + +/*****************************************************************************/ +int codes_f_bufr_multi_element_constant_arrays_on_() { + codes_bufr_multi_element_constant_arrays_on(NULL); + return GRIB_SUCCESS; +} +int codes_f_bufr_multi_element_constant_arrays_on__() { + return codes_f_bufr_multi_element_constant_arrays_on_(); +} +int codes_f_bufr_multi_element_constant_arrays_on() { + return codes_f_bufr_multi_element_constant_arrays_on_(); +} + +int codes_f_bufr_multi_element_constant_arrays_off_() { + codes_bufr_multi_element_constant_arrays_off(NULL); + return GRIB_SUCCESS; +} +int codes_f_bufr_multi_element_constant_arrays_off__() { + return codes_f_bufr_multi_element_constant_arrays_off_(); +} +int codes_f_bufr_multi_element_constant_arrays_off() { + return codes_f_bufr_multi_element_constant_arrays_off_(); +} + + /*****************************************************************************/ int grib_f_set_definitions_path_(char* path, int len){ grib_context* c = grib_context_get_default(); diff --git a/fortran/grib_fortran_prototypes.h b/fortran/grib_fortran_prototypes.h index d414384da..2c3dd1698 100644 --- a/fortran/grib_fortran_prototypes.h +++ b/fortran/grib_fortran_prototypes.h @@ -374,6 +374,13 @@ int codes_f_bufr_copy_data(int* gid1,int* gid2); int codes_f_bufr_copy_data_(int* gid1,int* gid2); int codes_f_bufr_copy_data__(int* gid1,int* gid2); +int codes_f_bufr_multi_element_constant_arrays_on_(void); +int codes_f_bufr_multi_element_constant_arrays_on__(void); +int codes_f_bufr_multi_element_constant_arrays_on(void); +int codes_f_bufr_multi_element_constant_arrays_off_(void); +int codes_f_bufr_multi_element_constant_arrays_off__(void); +int codes_f_bufr_multi_element_constant_arrays_off(void); + int grib_f_set_definitions_path_(char *path, int len); int grib_f_set_definitions_path__(char *path, int len); int grib_f_set_definitions_path(char *path, int len); diff --git a/src/eccodes.h b/src/eccodes.h index 40c4c564e..89b10ade4 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -1041,6 +1041,11 @@ int codes_get_gribex_mode(codes_context* c); */ void codes_gribex_mode_off(codes_context* c); + +void codes_bufr_multi_element_constant_arrays_on(codes_context* c); +void codes_bufr_multi_element_constant_arrays_off(codes_context* c); +/*int codes_get_bufr_multi_element_constant_arrays(codes_context* c);*/ + /** * Sets the search path for definition files. * diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 208004772..ed6b93fa6 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -979,6 +979,8 @@ void grib_context_free(const grib_context *c, void *p); void grib_context_free_persistent(const grib_context *c, void *p); void grib_context_reset(grib_context *c); void grib_context_delete(grib_context *c); +void codes_bufr_multi_element_constant_arrays_on(grib_context* c); +void codes_bufr_multi_element_constant_arrays_off(grib_context* c); void grib_context_set_definitions_path(grib_context *c, const char *path); void grib_context_set_samples_path(grib_context *c, const char *path); void *grib_context_malloc_persistent(const grib_context *c, size_t size); diff --git a/src/grib_context.c b/src/grib_context.c index 062a2f582..027168792 100644 --- a/src/grib_context.c +++ b/src/grib_context.c @@ -742,6 +742,19 @@ void grib_context_delete( grib_context* c) grib_context_free_persistent(&default_grib_context,c); } +void codes_bufr_multi_element_constant_arrays_on(grib_context* c) +{ + if ( !c ) c=grib_context_get_default(); + c->bufr_multi_element_constant_arrays = 1; +} +void codes_bufr_multi_element_constant_arrays_off(grib_context* c) +{ + if ( !c ) c=grib_context_get_default(); + c->bufr_multi_element_constant_arrays = 0; +} +/*int codes_get_bufr_multi_element_constant_arrays(grib_context* c);*/ + + void grib_context_set_definitions_path(grib_context* c, const char* path) { if (!c) c=grib_context_get_default(); From 9ab0519cfef2789f9e5baa1a16a8df87c0bcd2a4 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 9 Aug 2019 14:52:12 +0100 Subject: [PATCH 07/10] ECC-428: Added Python2 API calls --- python/eccodes/eccodes.py | 3 + python/grib_interface.c | 12 + python/gribapi/gribapi.py | 23 ++ python/gribapi_swig.i | 5 + python/gribapi_swig.py | 681 ++++++++++++++++++++++++++++++++++++++ python/swig_wrap_numpy.c | 28 ++ python/swig_wrap_numpy.py | 8 + 7 files changed, 760 insertions(+) create mode 100644 python/gribapi_swig.py diff --git a/python/eccodes/eccodes.py b/python/eccodes/eccodes.py index 6399ba94c..e966a3e94 100644 --- a/python/eccodes/eccodes.py +++ b/python/eccodes/eccodes.py @@ -106,5 +106,8 @@ from gribapi import grib_new_from_message as codes_new_from_message from gribapi import grib_set_definitions_path as codes_set_definitions_path from gribapi import grib_set_samples_path as codes_set_samples_path +from gribapi import codes_bufr_multi_element_constant_arrays_on +from gribapi import codes_bufr_multi_element_constant_arrays_off + from gribapi import GribInternalError as CodesInternalError from gribapi.errors import * diff --git a/python/grib_interface.c b/python/grib_interface.c index 5c73d24f6..cb6732d42 100644 --- a/python/grib_interface.c +++ b/python/grib_interface.c @@ -2343,3 +2343,15 @@ void grib_c_set_samples_path(const char* path) grib_context *c = grib_context_get_default(); grib_context_set_samples_path(c, path); } + + +int codes_c_bufr_multi_element_constant_arrays_on(void) +{ + codes_bufr_multi_element_constant_arrays_on(NULL); + return GRIB_SUCCESS; +} +int codes_c_bufr_multi_element_constant_arrays_off(void) +{ + codes_bufr_multi_element_constant_arrays_off(NULL); + return GRIB_SUCCESS; +} diff --git a/python/gribapi/gribapi.py b/python/gribapi/gribapi.py index 406e4cf44..4070c9a3c 100644 --- a/python/gribapi/gribapi.py +++ b/python/gribapi/gribapi.py @@ -1946,3 +1946,26 @@ def grib_set_samples_path(samples_path): @param samples_path samples path """ _internal.grib_c_set_samples_path(samples_path) + + + +def codes_bufr_multi_element_constant_arrays_on(): + """ + @brief BUFR: Turn on the mode where you get multiple elements + in constant arrays + + @exception GribInternalError + """ + _internal.codes_c_bufr_multi_element_constant_arrays_on() + + +def codes_bufr_multi_element_constant_arrays_off(): + """ + @brief BUFR: Turn off the mode where you get multiple elements + in constant arrays i.e. you get a single element + + @exception GribInternalError + """ + _internal.codes_c_bufr_multi_element_constant_arrays_off() + + diff --git a/python/gribapi_swig.i b/python/gribapi_swig.i index 0224b77bf..191d545ca 100644 --- a/python/gribapi_swig.i +++ b/python/gribapi_swig.i @@ -90,6 +90,11 @@ int grib_c_gribex_mode_on(void); int grib_c_gribex_mode_off(void); // --- +// BUFR bufr_multi_element_constant_arrays mode +int codes_c_bufr_multi_element_constant_arrays_on(void); +int codes_c_bufr_multi_element_constant_arrays_off(void); +// --- + // keys iterator int grib_c_keys_iterator_next(int* iterid); int codes_c_bufr_keys_iterator_next(int* iterid); diff --git a/python/gribapi_swig.py b/python/gribapi_swig.py new file mode 100644 index 000000000..d66080a90 --- /dev/null +++ b/python/gribapi_swig.py @@ -0,0 +1,681 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.40 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. +# This file is compatible with both classic and new-style classes. + +from sys import version_info +if version_info >= (2,6,0): + def swig_import_helper(): + from os.path import dirname + import imp + fp = None + try: + fp, pathname, description = imp.find_module('_gribapi_swig', [dirname(__file__)]) + except ImportError: + import _gribapi_swig + return _gribapi_swig + if fp is not None: + try: + _mod = imp.load_module('_gribapi_swig', fp, pathname, description) + finally: + fp.close() + return _mod + _gribapi_swig = swig_import_helper() + del swig_import_helper +else: + import _gribapi_swig +del version_info +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "thisown"): return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + if (name == "thisown"): return self.this.own() + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError(name) + +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +try: + _object = object + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 + + + +def cdata(*args): + return _gribapi_swig.cdata(*args) +cdata = _gribapi_swig.cdata + +def memmove(*args): + return _gribapi_swig.memmove(*args) +memmove = _gribapi_swig.memmove +GRIB_SUCCESS = _gribapi_swig.GRIB_SUCCESS +GRIB_END_OF_FILE = _gribapi_swig.GRIB_END_OF_FILE +GRIB_INTERNAL_ERROR = _gribapi_swig.GRIB_INTERNAL_ERROR +GRIB_BUFFER_TOO_SMALL = _gribapi_swig.GRIB_BUFFER_TOO_SMALL +GRIB_NOT_IMPLEMENTED = _gribapi_swig.GRIB_NOT_IMPLEMENTED +GRIB_7777_NOT_FOUND = _gribapi_swig.GRIB_7777_NOT_FOUND +GRIB_ARRAY_TOO_SMALL = _gribapi_swig.GRIB_ARRAY_TOO_SMALL +GRIB_FILE_NOT_FOUND = _gribapi_swig.GRIB_FILE_NOT_FOUND +GRIB_CODE_NOT_FOUND_IN_TABLE = _gribapi_swig.GRIB_CODE_NOT_FOUND_IN_TABLE +GRIB_WRONG_ARRAY_SIZE = _gribapi_swig.GRIB_WRONG_ARRAY_SIZE +GRIB_NOT_FOUND = _gribapi_swig.GRIB_NOT_FOUND +GRIB_IO_PROBLEM = _gribapi_swig.GRIB_IO_PROBLEM +GRIB_INVALID_MESSAGE = _gribapi_swig.GRIB_INVALID_MESSAGE +GRIB_DECODING_ERROR = _gribapi_swig.GRIB_DECODING_ERROR +GRIB_ENCODING_ERROR = _gribapi_swig.GRIB_ENCODING_ERROR +GRIB_NO_MORE_IN_SET = _gribapi_swig.GRIB_NO_MORE_IN_SET +GRIB_GEOCALCULUS_PROBLEM = _gribapi_swig.GRIB_GEOCALCULUS_PROBLEM +GRIB_OUT_OF_MEMORY = _gribapi_swig.GRIB_OUT_OF_MEMORY +GRIB_READ_ONLY = _gribapi_swig.GRIB_READ_ONLY +GRIB_INVALID_ARGUMENT = _gribapi_swig.GRIB_INVALID_ARGUMENT +GRIB_NULL_HANDLE = _gribapi_swig.GRIB_NULL_HANDLE +GRIB_INVALID_SECTION_NUMBER = _gribapi_swig.GRIB_INVALID_SECTION_NUMBER +GRIB_VALUE_CANNOT_BE_MISSING = _gribapi_swig.GRIB_VALUE_CANNOT_BE_MISSING +GRIB_WRONG_LENGTH = _gribapi_swig.GRIB_WRONG_LENGTH +GRIB_INVALID_TYPE = _gribapi_swig.GRIB_INVALID_TYPE +GRIB_WRONG_STEP = _gribapi_swig.GRIB_WRONG_STEP +GRIB_WRONG_STEP_UNIT = _gribapi_swig.GRIB_WRONG_STEP_UNIT +GRIB_INVALID_FILE = _gribapi_swig.GRIB_INVALID_FILE +GRIB_INVALID_GRIB = _gribapi_swig.GRIB_INVALID_GRIB +GRIB_INVALID_INDEX = _gribapi_swig.GRIB_INVALID_INDEX +GRIB_INVALID_ITERATOR = _gribapi_swig.GRIB_INVALID_ITERATOR +GRIB_INVALID_KEYS_ITERATOR = _gribapi_swig.GRIB_INVALID_KEYS_ITERATOR +GRIB_INVALID_NEAREST = _gribapi_swig.GRIB_INVALID_NEAREST +GRIB_INVALID_ORDERBY = _gribapi_swig.GRIB_INVALID_ORDERBY +GRIB_MISSING_KEY = _gribapi_swig.GRIB_MISSING_KEY +GRIB_OUT_OF_AREA = _gribapi_swig.GRIB_OUT_OF_AREA +GRIB_CONCEPT_NO_MATCH = _gribapi_swig.GRIB_CONCEPT_NO_MATCH +GRIB_HASH_ARRAY_NO_MATCH = _gribapi_swig.GRIB_HASH_ARRAY_NO_MATCH +GRIB_NO_DEFINITIONS = _gribapi_swig.GRIB_NO_DEFINITIONS +GRIB_WRONG_TYPE = _gribapi_swig.GRIB_WRONG_TYPE +GRIB_END = _gribapi_swig.GRIB_END +GRIB_NO_VALUES = _gribapi_swig.GRIB_NO_VALUES +GRIB_WRONG_GRID = _gribapi_swig.GRIB_WRONG_GRID +GRIB_END_OF_INDEX = _gribapi_swig.GRIB_END_OF_INDEX +GRIB_NULL_INDEX = _gribapi_swig.GRIB_NULL_INDEX +GRIB_PREMATURE_END_OF_FILE = _gribapi_swig.GRIB_PREMATURE_END_OF_FILE +GRIB_INTERNAL_ARRAY_TOO_SMALL = _gribapi_swig.GRIB_INTERNAL_ARRAY_TOO_SMALL +GRIB_MESSAGE_TOO_LARGE = _gribapi_swig.GRIB_MESSAGE_TOO_LARGE +GRIB_CONSTANT_FIELD = _gribapi_swig.GRIB_CONSTANT_FIELD +GRIB_SWITCH_NO_MATCH = _gribapi_swig.GRIB_SWITCH_NO_MATCH +GRIB_UNDERFLOW = _gribapi_swig.GRIB_UNDERFLOW +GRIB_MESSAGE_MALFORMED = _gribapi_swig.GRIB_MESSAGE_MALFORMED +GRIB_CORRUPTED_INDEX = _gribapi_swig.GRIB_CORRUPTED_INDEX +GRIB_INVALID_BPV = _gribapi_swig.GRIB_INVALID_BPV +GRIB_DIFFERENT_EDITION = _gribapi_swig.GRIB_DIFFERENT_EDITION +GRIB_VALUE_DIFFERENT = _gribapi_swig.GRIB_VALUE_DIFFERENT +GRIB_INVALID_KEY_VALUE = _gribapi_swig.GRIB_INVALID_KEY_VALUE +GRIB_STRING_TOO_SMALL = _gribapi_swig.GRIB_STRING_TOO_SMALL +GRIB_WRONG_CONVERSION = _gribapi_swig.GRIB_WRONG_CONVERSION +GRIB_MISSING_BUFR_ENTRY = _gribapi_swig.GRIB_MISSING_BUFR_ENTRY +GRIB_NULL_POINTER = _gribapi_swig.GRIB_NULL_POINTER +GRIB_ATTRIBUTE_CLASH = _gribapi_swig.GRIB_ATTRIBUTE_CLASH +GRIB_TOO_MANY_ATTRIBUTES = _gribapi_swig.GRIB_TOO_MANY_ATTRIBUTES +GRIB_ATTRIBUTE_NOT_FOUND = _gribapi_swig.GRIB_ATTRIBUTE_NOT_FOUND +GRIB_UNSUPPORTED_EDITION = _gribapi_swig.GRIB_UNSUPPORTED_EDITION +GRIB_OUT_OF_RANGE = _gribapi_swig.GRIB_OUT_OF_RANGE +GRIB_WRONG_BITMAP_SIZE = _gribapi_swig.GRIB_WRONG_BITMAP_SIZE +class intp(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, intp, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, intp, name) + __repr__ = _swig_repr + def __init__(self): + this = _gribapi_swig.new_intp() + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _gribapi_swig.delete_intp + __del__ = lambda self : None; + def assign(self, *args): return _gribapi_swig.intp_assign(self, *args) + def value(self): return _gribapi_swig.intp_value(self) + def cast(self): return _gribapi_swig.intp_cast(self) + __swig_getmethods__["frompointer"] = lambda x: _gribapi_swig.intp_frompointer + if _newclass:frompointer = staticmethod(_gribapi_swig.intp_frompointer) +intp_swigregister = _gribapi_swig.intp_swigregister +intp_swigregister(intp) + +def intp_frompointer(*args): + return _gribapi_swig.intp_frompointer(*args) +intp_frompointer = _gribapi_swig.intp_frompointer + +class sizetp(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, sizetp, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, sizetp, name) + __repr__ = _swig_repr + def __init__(self): + this = _gribapi_swig.new_sizetp() + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _gribapi_swig.delete_sizetp + __del__ = lambda self : None; + def assign(self, *args): return _gribapi_swig.sizetp_assign(self, *args) + def value(self): return _gribapi_swig.sizetp_value(self) + def cast(self): return _gribapi_swig.sizetp_cast(self) + __swig_getmethods__["frompointer"] = lambda x: _gribapi_swig.sizetp_frompointer + if _newclass:frompointer = staticmethod(_gribapi_swig.sizetp_frompointer) +sizetp_swigregister = _gribapi_swig.sizetp_swigregister +sizetp_swigregister(sizetp) + +def sizetp_frompointer(*args): + return _gribapi_swig.sizetp_frompointer(*args) +sizetp_frompointer = _gribapi_swig.sizetp_frompointer + +class longp(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, longp, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, longp, name) + __repr__ = _swig_repr + def __init__(self): + this = _gribapi_swig.new_longp() + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _gribapi_swig.delete_longp + __del__ = lambda self : None; + def assign(self, *args): return _gribapi_swig.longp_assign(self, *args) + def value(self): return _gribapi_swig.longp_value(self) + def cast(self): return _gribapi_swig.longp_cast(self) + __swig_getmethods__["frompointer"] = lambda x: _gribapi_swig.longp_frompointer + if _newclass:frompointer = staticmethod(_gribapi_swig.longp_frompointer) +longp_swigregister = _gribapi_swig.longp_swigregister +longp_swigregister(longp) + +def longp_frompointer(*args): + return _gribapi_swig.longp_frompointer(*args) +longp_frompointer = _gribapi_swig.longp_frompointer + +class doublep(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, doublep, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, doublep, name) + __repr__ = _swig_repr + def __init__(self): + this = _gribapi_swig.new_doublep() + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _gribapi_swig.delete_doublep + __del__ = lambda self : None; + def assign(self, *args): return _gribapi_swig.doublep_assign(self, *args) + def value(self): return _gribapi_swig.doublep_value(self) + def cast(self): return _gribapi_swig.doublep_cast(self) + __swig_getmethods__["frompointer"] = lambda x: _gribapi_swig.doublep_frompointer + if _newclass:frompointer = staticmethod(_gribapi_swig.doublep_frompointer) +doublep_swigregister = _gribapi_swig.doublep_swigregister +doublep_swigregister(doublep) + +def doublep_frompointer(*args): + return _gribapi_swig.doublep_frompointer(*args) +doublep_frompointer = _gribapi_swig.doublep_frompointer + + +def new_doubleArray(*args): + return _gribapi_swig.new_doubleArray(*args) +new_doubleArray = _gribapi_swig.new_doubleArray + +def delete_doubleArray(*args): + return _gribapi_swig.delete_doubleArray(*args) +delete_doubleArray = _gribapi_swig.delete_doubleArray + +def doubleArray_getitem(*args): + return _gribapi_swig.doubleArray_getitem(*args) +doubleArray_getitem = _gribapi_swig.doubleArray_getitem + +def doubleArray_setitem(*args): + return _gribapi_swig.doubleArray_setitem(*args) +doubleArray_setitem = _gribapi_swig.doubleArray_setitem + +def new_longArray(*args): + return _gribapi_swig.new_longArray(*args) +new_longArray = _gribapi_swig.new_longArray + +def delete_longArray(*args): + return _gribapi_swig.delete_longArray(*args) +delete_longArray = _gribapi_swig.delete_longArray + +def longArray_getitem(*args): + return _gribapi_swig.longArray_getitem(*args) +longArray_getitem = _gribapi_swig.longArray_getitem + +def longArray_setitem(*args): + return _gribapi_swig.longArray_setitem(*args) +longArray_setitem = _gribapi_swig.longArray_setitem + +def new_intArray(*args): + return _gribapi_swig.new_intArray(*args) +new_intArray = _gribapi_swig.new_intArray + +def delete_intArray(*args): + return _gribapi_swig.delete_intArray(*args) +delete_intArray = _gribapi_swig.delete_intArray + +def intArray_getitem(*args): + return _gribapi_swig.intArray_getitem(*args) +intArray_getitem = _gribapi_swig.intArray_getitem + +def intArray_setitem(*args): + return _gribapi_swig.intArray_setitem(*args) +intArray_setitem = _gribapi_swig.intArray_setitem + +def new_stringArray(*args): + return _gribapi_swig.new_stringArray(*args) +new_stringArray = _gribapi_swig.new_stringArray + +def delete_stringArray(*args): + return _gribapi_swig.delete_stringArray(*args) +delete_stringArray = _gribapi_swig.delete_stringArray + +def stringArray_getitem(*args): + return _gribapi_swig.stringArray_getitem(*args) +stringArray_getitem = _gribapi_swig.stringArray_getitem + +def stringArray_setitem(*args): + return _gribapi_swig.stringArray_setitem(*args) +stringArray_setitem = _gribapi_swig.stringArray_setitem + +def grib_c_new_from_file(*args): + return _gribapi_swig.grib_c_new_from_file(*args) +grib_c_new_from_file = _gribapi_swig.grib_c_new_from_file + +def grib_c_new_any_from_file(*args): + return _gribapi_swig.grib_c_new_any_from_file(*args) +grib_c_new_any_from_file = _gribapi_swig.grib_c_new_any_from_file + +def grib_c_new_bufr_from_file(*args): + return _gribapi_swig.grib_c_new_bufr_from_file(*args) +grib_c_new_bufr_from_file = _gribapi_swig.grib_c_new_bufr_from_file + +def grib_c_new_gts_from_file(*args): + return _gribapi_swig.grib_c_new_gts_from_file(*args) +grib_c_new_gts_from_file = _gribapi_swig.grib_c_new_gts_from_file + +def grib_c_new_metar_from_file(*args): + return _gribapi_swig.grib_c_new_metar_from_file(*args) +grib_c_new_metar_from_file = _gribapi_swig.grib_c_new_metar_from_file + +def grib_c_iterator_new(*args): + return _gribapi_swig.grib_c_iterator_new(*args) +grib_c_iterator_new = _gribapi_swig.grib_c_iterator_new + +def grib_c_keys_iterator_new(*args): + return _gribapi_swig.grib_c_keys_iterator_new(*args) +grib_c_keys_iterator_new = _gribapi_swig.grib_c_keys_iterator_new + +def codes_c_bufr_keys_iterator_new(*args): + return _gribapi_swig.codes_c_bufr_keys_iterator_new(*args) +codes_c_bufr_keys_iterator_new = _gribapi_swig.codes_c_bufr_keys_iterator_new + +def grib_c_grib_new_from_samples(*args): + return _gribapi_swig.grib_c_grib_new_from_samples(*args) +grib_c_grib_new_from_samples = _gribapi_swig.grib_c_grib_new_from_samples + +def grib_c_bufr_new_from_samples(*args): + return _gribapi_swig.grib_c_bufr_new_from_samples(*args) +grib_c_bufr_new_from_samples = _gribapi_swig.grib_c_bufr_new_from_samples + +def grib_c_index_new_from_file(*args): + return _gribapi_swig.grib_c_index_new_from_file(*args) +grib_c_index_new_from_file = _gribapi_swig.grib_c_index_new_from_file + +def grib_c_index_add_file(*args): + return _gribapi_swig.grib_c_index_add_file(*args) +grib_c_index_add_file = _gribapi_swig.grib_c_index_add_file + +def grib_c_new_from_index(*args): + return _gribapi_swig.grib_c_new_from_index(*args) +grib_c_new_from_index = _gribapi_swig.grib_c_new_from_index + +def grib_c_index_write(*args): + return _gribapi_swig.grib_c_index_write(*args) +grib_c_index_write = _gribapi_swig.grib_c_index_write + +def grib_c_index_read(*args): + return _gribapi_swig.grib_c_index_read(*args) +grib_c_index_read = _gribapi_swig.grib_c_index_read + +def grib_c_new_from_message(*args): + return _gribapi_swig.grib_c_new_from_message(*args) +grib_c_new_from_message = _gribapi_swig.grib_c_new_from_message + +def grib_c_count_in_file(*args): + return _gribapi_swig.grib_c_count_in_file(*args) +grib_c_count_in_file = _gribapi_swig.grib_c_count_in_file + +def grib_c_release(*args): + return _gribapi_swig.grib_c_release(*args) +grib_c_release = _gribapi_swig.grib_c_release + +def grib_c_write(*args): + return _gribapi_swig.grib_c_write(*args) +grib_c_write = _gribapi_swig.grib_c_write + +def grib_c_get_size_long(*args): + return _gribapi_swig.grib_c_get_size_long(*args) +grib_c_get_size_long = _gribapi_swig.grib_c_get_size_long + +def grib_c_get_string_length(*args): + return _gribapi_swig.grib_c_get_string_length(*args) +grib_c_get_string_length = _gribapi_swig.grib_c_get_string_length + +def grib_c_clone(*args): + return _gribapi_swig.grib_c_clone(*args) +grib_c_clone = _gribapi_swig.grib_c_clone + +def grib_c_copy_namespace(*args): + return _gribapi_swig.grib_c_copy_namespace(*args) +grib_c_copy_namespace = _gribapi_swig.grib_c_copy_namespace + +def grib_c_get_message_size(*args): + return _gribapi_swig.grib_c_get_message_size(*args) +grib_c_get_message_size = _gribapi_swig.grib_c_get_message_size + +def grib_c_get_message_offset(*args): + return _gribapi_swig.grib_c_get_message_offset(*args) +grib_c_get_message_offset = _gribapi_swig.grib_c_get_message_offset + +def grib_c_get_native_type(*args): + return _gribapi_swig.grib_c_get_native_type(*args) +grib_c_get_native_type = _gribapi_swig.grib_c_get_native_type + +def grib_c_multi_new(): + return _gribapi_swig.grib_c_multi_new() +grib_c_multi_new = _gribapi_swig.grib_c_multi_new + +def grib_c_multi_support_on(): + return _gribapi_swig.grib_c_multi_support_on() +grib_c_multi_support_on = _gribapi_swig.grib_c_multi_support_on + +def grib_c_multi_write(*args): + return _gribapi_swig.grib_c_multi_write(*args) +grib_c_multi_write = _gribapi_swig.grib_c_multi_write + +def grib_c_multi_support_off(): + return _gribapi_swig.grib_c_multi_support_off() +grib_c_multi_support_off = _gribapi_swig.grib_c_multi_support_off + +def grib_c_multi_release(*args): + return _gribapi_swig.grib_c_multi_release(*args) +grib_c_multi_release = _gribapi_swig.grib_c_multi_release + +def grib_c_multi_append(*args): + return _gribapi_swig.grib_c_multi_append(*args) +grib_c_multi_append = _gribapi_swig.grib_c_multi_append + +def grib_c_gribex_mode_on(): + return _gribapi_swig.grib_c_gribex_mode_on() +grib_c_gribex_mode_on = _gribapi_swig.grib_c_gribex_mode_on + +def grib_c_gribex_mode_off(): + return _gribapi_swig.grib_c_gribex_mode_off() +grib_c_gribex_mode_off = _gribapi_swig.grib_c_gribex_mode_off + +def codes_c_bufr_multi_element_constant_arrays_on(): + return _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_on() +codes_c_bufr_multi_element_constant_arrays_on = _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_on + +def codes_c_bufr_multi_element_constant_arrays_off(): + return _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_off() +codes_c_bufr_multi_element_constant_arrays_off = _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_off + +def grib_c_keys_iterator_next(*args): + return _gribapi_swig.grib_c_keys_iterator_next(*args) +grib_c_keys_iterator_next = _gribapi_swig.grib_c_keys_iterator_next + +def codes_c_bufr_keys_iterator_next(*args): + return _gribapi_swig.codes_c_bufr_keys_iterator_next(*args) +codes_c_bufr_keys_iterator_next = _gribapi_swig.codes_c_bufr_keys_iterator_next + +def grib_c_keys_iterator_delete(*args): + return _gribapi_swig.grib_c_keys_iterator_delete(*args) +grib_c_keys_iterator_delete = _gribapi_swig.grib_c_keys_iterator_delete + +def codes_c_bufr_keys_iterator_delete(*args): + return _gribapi_swig.codes_c_bufr_keys_iterator_delete(*args) +codes_c_bufr_keys_iterator_delete = _gribapi_swig.codes_c_bufr_keys_iterator_delete + +def grib_c_skip_computed(*args): + return _gribapi_swig.grib_c_skip_computed(*args) +grib_c_skip_computed = _gribapi_swig.grib_c_skip_computed + +def grib_c_skip_coded(*args): + return _gribapi_swig.grib_c_skip_coded(*args) +grib_c_skip_coded = _gribapi_swig.grib_c_skip_coded + +def grib_c_skip_edition_specific(*args): + return _gribapi_swig.grib_c_skip_edition_specific(*args) +grib_c_skip_edition_specific = _gribapi_swig.grib_c_skip_edition_specific + +def grib_c_skip_duplicates(*args): + return _gribapi_swig.grib_c_skip_duplicates(*args) +grib_c_skip_duplicates = _gribapi_swig.grib_c_skip_duplicates + +def grib_c_skip_read_only(*args): + return _gribapi_swig.grib_c_skip_read_only(*args) +grib_c_skip_read_only = _gribapi_swig.grib_c_skip_read_only + +def grib_c_skip_function(*args): + return _gribapi_swig.grib_c_skip_function(*args) +grib_c_skip_function = _gribapi_swig.grib_c_skip_function + +def grib_c_keys_iterator_rewind(*args): + return _gribapi_swig.grib_c_keys_iterator_rewind(*args) +grib_c_keys_iterator_rewind = _gribapi_swig.grib_c_keys_iterator_rewind + +def codes_c_bufr_keys_iterator_rewind(*args): + return _gribapi_swig.codes_c_bufr_keys_iterator_rewind(*args) +codes_c_bufr_keys_iterator_rewind = _gribapi_swig.codes_c_bufr_keys_iterator_rewind + +def grib_c_bufr_copy_data(*args): + return _gribapi_swig.grib_c_bufr_copy_data(*args) +grib_c_bufr_copy_data = _gribapi_swig.grib_c_bufr_copy_data + +def grib_c_keys_iterator_get_name(*args): + return _gribapi_swig.grib_c_keys_iterator_get_name(*args) +grib_c_keys_iterator_get_name = _gribapi_swig.grib_c_keys_iterator_get_name + +def codes_c_bufr_keys_iterator_get_name(*args): + return _gribapi_swig.codes_c_bufr_keys_iterator_get_name(*args) +codes_c_bufr_keys_iterator_get_name = _gribapi_swig.codes_c_bufr_keys_iterator_get_name + +def grib_c_index_get_size_long(*args): + return _gribapi_swig.grib_c_index_get_size_long(*args) +grib_c_index_get_size_long = _gribapi_swig.grib_c_index_get_size_long + +def grib_c_index_get_long(*args): + return _gribapi_swig.grib_c_index_get_long(*args) +grib_c_index_get_long = _gribapi_swig.grib_c_index_get_long + +def grib_c_index_get_real8(*args): + return _gribapi_swig.grib_c_index_get_real8(*args) +grib_c_index_get_real8 = _gribapi_swig.grib_c_index_get_real8 + +def grib_c_index_get_string(*args): + return _gribapi_swig.grib_c_index_get_string(*args) +grib_c_index_get_string = _gribapi_swig.grib_c_index_get_string + +def grib_c_index_select_long(*args): + return _gribapi_swig.grib_c_index_select_long(*args) +grib_c_index_select_long = _gribapi_swig.grib_c_index_select_long + +def grib_c_index_select_real8(*args): + return _gribapi_swig.grib_c_index_select_real8(*args) +grib_c_index_select_real8 = _gribapi_swig.grib_c_index_select_real8 + +def grib_c_index_select_string(*args): + return _gribapi_swig.grib_c_index_select_string(*args) +grib_c_index_select_string = _gribapi_swig.grib_c_index_select_string + +def grib_c_index_release(*args): + return _gribapi_swig.grib_c_index_release(*args) +grib_c_index_release = _gribapi_swig.grib_c_index_release + +def grib_c_iterator_delete(*args): + return _gribapi_swig.grib_c_iterator_delete(*args) +grib_c_iterator_delete = _gribapi_swig.grib_c_iterator_delete + +def grib_c_iterator_next(*args): + return _gribapi_swig.grib_c_iterator_next(*args) +grib_c_iterator_next = _gribapi_swig.grib_c_iterator_next + +def grib_c_get_string(*args): + return _gribapi_swig.grib_c_get_string(*args) +grib_c_get_string = _gribapi_swig.grib_c_get_string + +def grib_c_get_string_array(*args): + return _gribapi_swig.grib_c_get_string_array(*args) +grib_c_get_string_array = _gribapi_swig.grib_c_get_string_array + +def grib_c_set_string(*args): + return _gribapi_swig.grib_c_set_string(*args) +grib_c_set_string = _gribapi_swig.grib_c_set_string + +def grib_c_get_long(*args): + return _gribapi_swig.grib_c_get_long(*args) +grib_c_get_long = _gribapi_swig.grib_c_get_long + +def grib_c_set_long(*args): + return _gribapi_swig.grib_c_set_long(*args) +grib_c_set_long = _gribapi_swig.grib_c_set_long + +def grib_c_get_double(*args): + return _gribapi_swig.grib_c_get_double(*args) +grib_c_get_double = _gribapi_swig.grib_c_get_double + +def grib_c_set_double(*args): + return _gribapi_swig.grib_c_set_double(*args) +grib_c_set_double = _gribapi_swig.grib_c_set_double + +def grib_c_set_real8_array(*args): + return _gribapi_swig.grib_c_set_real8_array(*args) +grib_c_set_real8_array = _gribapi_swig.grib_c_set_real8_array + +def grib_c_get_real8_array(*args): + return _gribapi_swig.grib_c_get_real8_array(*args) +grib_c_get_real8_array = _gribapi_swig.grib_c_get_real8_array + +def grib_c_get_long_array(*args): + return _gribapi_swig.grib_c_get_long_array(*args) +grib_c_get_long_array = _gribapi_swig.grib_c_get_long_array + +def grib_c_set_long_array(*args): + return _gribapi_swig.grib_c_set_long_array(*args) +grib_c_set_long_array = _gribapi_swig.grib_c_set_long_array + +def grib_c_get_real8_element(*args): + return _gribapi_swig.grib_c_get_real8_element(*args) +grib_c_get_real8_element = _gribapi_swig.grib_c_get_real8_element + +def grib_c_get_real8_elements(*args): + return _gribapi_swig.grib_c_get_real8_elements(*args) +grib_c_get_real8_elements = _gribapi_swig.grib_c_get_real8_elements + +def grib_c_set_missing(*args): + return _gribapi_swig.grib_c_set_missing(*args) +grib_c_set_missing = _gribapi_swig.grib_c_set_missing + +def grib_c_set_key_vals(*args): + return _gribapi_swig.grib_c_set_key_vals(*args) +grib_c_set_key_vals = _gribapi_swig.grib_c_set_key_vals + +def grib_c_is_missing(*args): + return _gribapi_swig.grib_c_is_missing(*args) +grib_c_is_missing = _gribapi_swig.grib_c_is_missing + +def grib_c_is_defined(*args): + return _gribapi_swig.grib_c_is_defined(*args) +grib_c_is_defined = _gribapi_swig.grib_c_is_defined + +def grib_c_set_string_array(*args): + return _gribapi_swig.grib_c_set_string_array(*args) +grib_c_set_string_array = _gribapi_swig.grib_c_set_string_array + +def grib_set_double_ndarray(*args): + return _gribapi_swig.grib_set_double_ndarray(*args) +grib_set_double_ndarray = _gribapi_swig.grib_set_double_ndarray + +def grib_set_long_ndarray(*args): + return _gribapi_swig.grib_set_long_ndarray(*args) +grib_set_long_ndarray = _gribapi_swig.grib_set_long_ndarray + +def grib_get_double_ndarray(*args): + return _gribapi_swig.grib_get_double_ndarray(*args) +grib_get_double_ndarray = _gribapi_swig.grib_get_double_ndarray + +def grib_get_long_ndarray(*args): + return _gribapi_swig.grib_get_long_ndarray(*args) +grib_get_long_ndarray = _gribapi_swig.grib_get_long_ndarray + +def grib_get_double_ndelements(*args): + return _gribapi_swig.grib_get_double_ndelements(*args) +grib_get_double_ndelements = _gribapi_swig.grib_get_double_ndelements + +def grib_c_find_nearest_single(*args): + return _gribapi_swig.grib_c_find_nearest_single(*args) +grib_c_find_nearest_single = _gribapi_swig.grib_c_find_nearest_single + +def grib_c_find_nearest_four_single(*args): + return _gribapi_swig.grib_c_find_nearest_four_single(*args) +grib_c_find_nearest_four_single = _gribapi_swig.grib_c_find_nearest_four_single + +def grib_c_get_message(*args): + return _gribapi_swig.grib_c_get_message(*args) +grib_c_get_message = _gribapi_swig.grib_c_get_message + +def grib_c_get_error_string(*args): + return _gribapi_swig.grib_c_get_error_string(*args) +grib_c_get_error_string = _gribapi_swig.grib_c_get_error_string + +def no_fail_on_wrong_length(*args): + return _gribapi_swig.no_fail_on_wrong_length(*args) +no_fail_on_wrong_length = _gribapi_swig.no_fail_on_wrong_length + +def grib_c_get_api_version(): + return _gribapi_swig.grib_c_get_api_version() +grib_c_get_api_version = _gribapi_swig.grib_c_get_api_version + +def grib_c_gts_header_on(): + return _gribapi_swig.grib_c_gts_header_on() +grib_c_gts_header_on = _gribapi_swig.grib_c_gts_header_on + +def grib_c_gts_header_off(): + return _gribapi_swig.grib_c_gts_header_off() +grib_c_gts_header_off = _gribapi_swig.grib_c_gts_header_off + +def grib_c_set_definitions_path(*args): + return _gribapi_swig.grib_c_set_definitions_path(*args) +grib_c_set_definitions_path = _gribapi_swig.grib_c_set_definitions_path + +def grib_c_set_samples_path(*args): + return _gribapi_swig.grib_c_set_samples_path(*args) +grib_c_set_samples_path = _gribapi_swig.grib_c_set_samples_path + + diff --git a/python/swig_wrap_numpy.c b/python/swig_wrap_numpy.c index dd5d0510e..846df0c24 100644 --- a/python/swig_wrap_numpy.c +++ b/python/swig_wrap_numpy.c @@ -6167,6 +6167,32 @@ fail: } +SWIGINTERN PyObject *_wrap_codes_c_bufr_multi_element_constant_arrays_on(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":codes_c_bufr_multi_element_constant_arrays_on")) SWIG_fail; + result = (int)codes_c_bufr_multi_element_constant_arrays_on(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_codes_c_bufr_multi_element_constant_arrays_off(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":codes_c_bufr_multi_element_constant_arrays_off")) SWIG_fail; + result = (int)codes_c_bufr_multi_element_constant_arrays_off(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_grib_c_keys_iterator_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int *arg1 = (int *) 0 ; @@ -9083,6 +9109,8 @@ static PyMethodDef SwigMethods[] = { { (char *)"grib_c_multi_append", _wrap_grib_c_multi_append, METH_VARARGS, NULL}, { (char *)"grib_c_gribex_mode_on", _wrap_grib_c_gribex_mode_on, METH_VARARGS, NULL}, { (char *)"grib_c_gribex_mode_off", _wrap_grib_c_gribex_mode_off, METH_VARARGS, NULL}, + { (char *)"codes_c_bufr_multi_element_constant_arrays_on", _wrap_codes_c_bufr_multi_element_constant_arrays_on, METH_VARARGS, NULL}, + { (char *)"codes_c_bufr_multi_element_constant_arrays_off", _wrap_codes_c_bufr_multi_element_constant_arrays_off, METH_VARARGS, NULL}, { (char *)"grib_c_keys_iterator_next", _wrap_grib_c_keys_iterator_next, METH_VARARGS, NULL}, { (char *)"codes_c_bufr_keys_iterator_next", _wrap_codes_c_bufr_keys_iterator_next, METH_VARARGS, NULL}, { (char *)"grib_c_keys_iterator_delete", _wrap_grib_c_keys_iterator_delete, METH_VARARGS, NULL}, diff --git a/python/swig_wrap_numpy.py b/python/swig_wrap_numpy.py index 411433758..d66080a90 100644 --- a/python/swig_wrap_numpy.py +++ b/python/swig_wrap_numpy.py @@ -438,6 +438,14 @@ def grib_c_gribex_mode_off(): return _gribapi_swig.grib_c_gribex_mode_off() grib_c_gribex_mode_off = _gribapi_swig.grib_c_gribex_mode_off +def codes_c_bufr_multi_element_constant_arrays_on(): + return _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_on() +codes_c_bufr_multi_element_constant_arrays_on = _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_on + +def codes_c_bufr_multi_element_constant_arrays_off(): + return _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_off() +codes_c_bufr_multi_element_constant_arrays_off = _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_off + def grib_c_keys_iterator_next(*args): return _gribapi_swig.grib_c_keys_iterator_next(*args) grib_c_keys_iterator_next = _gribapi_swig.grib_c_keys_iterator_next From 6750e1f68dfa5debecbd1284b0ec488cb7a22907 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 13 Aug 2019 10:47:42 +0100 Subject: [PATCH 08/10] ECC-428: fix search by condition --- src/grib_query.c | 83 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/src/grib_query.c b/src/grib_query.c index 963a535a9..67788df0e 100644 --- a/src/grib_query.c +++ b/src/grib_query.c @@ -242,19 +242,94 @@ static grib_accessor* search_by_rank(grib_handle* h, const char* name,int rank,c } } -static int condition_true(grib_accessor* a,codes_condition* condition) { +static int get_single_long_val(grib_accessor* a, long* result) +{ + grib_context* c = a->context; + int err = 0; + size_t size = 1; + if (c->bufr_multi_element_constant_arrays) { + long count=0; + grib_value_count(a,&count); + if(count>1) { + size_t i = 0; + long val0 = 0; + int is_constant=1; + long* values=(long*)grib_context_malloc_clear(c,sizeof(long)*count); + size = count; + err=grib_unpack_long(a,values,&size); + val0 = values[0]; + for (i=0;icontext; + int err = 0; + size_t size = 1; + if (c->bufr_multi_element_constant_arrays) { + long count=0; + grib_value_count(a,&count); + if(count>1) { + size_t i = 0; + double val0 = 0; + int is_constant=1; + double* values=(double*)grib_context_malloc_clear(c,sizeof(double)*count); + size = count; + err=grib_unpack_double(a,values,&size); + val0 = values[0]; + for (i=0;irightType) { case GRIB_TYPE_LONG: - err = grib_unpack_long(a,&lval,&size); + err = get_single_long_val(a, &lval); if (err) ret = 0; else ret = lval==condition->rightLong ? 1 : 0; break; case GRIB_TYPE_DOUBLE: - err = grib_unpack_double(a,&dval,&size); + err = get_single_double_val(a,&dval); if (err) ret = 0; else ret = dval==condition->rightDouble ? 1 : 0; break; From 0448bceb6ed89ed8e49b5442141c70fb617bbd6a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 14 Aug 2019 18:14:51 +0100 Subject: [PATCH 09/10] ECC-428: Python header decls --- python/grib_interface.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/grib_interface.h b/python/grib_interface.h index 4c434f497..de98ddc42 100644 --- a/python/grib_interface.h +++ b/python/grib_interface.h @@ -22,6 +22,9 @@ int codes_c_bufr_keys_iterator_get_name(int *iterid, char *name, int len); int codes_c_bufr_keys_iterator_rewind(int *kiter); int codes_c_bufr_keys_iterator_delete(int *iterid); +int codes_c_bufr_multi_element_constant_arrays_off(void); +int codes_c_bufr_multi_element_constant_arrays_on(void); + int grib_c_gribex_mode_on(void); int grib_c_gribex_mode_off(void); int grib_c_skip_computed(int *iterid); From 812b76a445d107dddba736206bb64f1a8b4a10de Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 15 Aug 2019 18:33:12 +0100 Subject: [PATCH 10/10] ECC-428: Disable encoding dump when multi element mode --- tools/bufr_dump.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/bufr_dump.c b/tools/bufr_dump.c index 9e9af431f..1f8353aa9 100644 --- a/tools/bufr_dump.c +++ b/tools/bufr_dump.c @@ -139,6 +139,11 @@ int grib_tool_init(grib_runtime_options* options) json=0; } if (grib_options_on("E:")) { + grib_context *c = grib_context_get_default(); + if (c->bufr_multi_element_constant_arrays) { + grib_context_log(c, GRIB_LOG_ERROR, "Code generation for encoding is not implemented when ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS is enabled"); + exit(1); + } options->dump_mode = grib_options_get_option("E:"); check_code_gen_dump_mode(options->dump_mode); json=0;