diff --git a/src/grib_accessor_class_bufr_extract_area_subsets.cc b/src/grib_accessor_class_bufr_extract_area_subsets.cc index 5659ace91..473a5148d 100644 --- a/src/grib_accessor_class_bufr_extract_area_subsets.cc +++ b/src/grib_accessor_class_bufr_extract_area_subsets.cc @@ -119,20 +119,21 @@ grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets = &_grib_acce static void init(grib_accessor* a, const long len, grib_arguments* arg) { - int n = 0; grib_accessor_bufr_extract_area_subsets* self = (grib_accessor_bufr_extract_area_subsets*)a; + grib_handle* h = grib_handle_of_accessor(a); + int n = 0; a->length = 0; - self->doExtractSubsets = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->numberOfSubsets = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractSubsetList = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractAreaWestLongitude = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractAreaEastLongitude = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractAreaNorthLatitude = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractAreaSouthLatitude = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractAreaLongitudeRank = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractAreaLatitudeRank = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractedAreaNumberOfSubsets = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); + self->numberOfSubsets = grib_arguments_get_name(h, arg, n++); + self->extractSubsetList = grib_arguments_get_name(h, arg, n++); + self->extractAreaWestLongitude = grib_arguments_get_name(h, arg, n++); + self->extractAreaEastLongitude = grib_arguments_get_name(h, arg, n++); + self->extractAreaNorthLatitude = grib_arguments_get_name(h, arg, n++); + self->extractAreaSouthLatitude = grib_arguments_get_name(h, arg, n++); + self->extractAreaLongitudeRank = grib_arguments_get_name(h, arg, n++); + self->extractAreaLatitudeRank = grib_arguments_get_name(h, arg, n++); + self->extractedAreaNumberOfSubsets = grib_arguments_get_name(h, arg, n++); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } @@ -152,11 +153,12 @@ static void fill_in(double a[], long length) static int select_area(grib_accessor* a) { - int ret = 0; - long compressed = 0; grib_accessor_bufr_extract_area_subsets* self = (grib_accessor_bufr_extract_area_subsets*)a; - grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = h->context; + + int ret = 0; + long compressed = 0; + grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = h->context; double* lat = NULL; double* lon = NULL; diff --git a/src/grib_accessor_class_bufr_simple_thinning.cc b/src/grib_accessor_class_bufr_simple_thinning.cc index e4d110262..b457d0e9e 100644 --- a/src/grib_accessor_class_bufr_simple_thinning.cc +++ b/src/grib_accessor_class_bufr_simple_thinning.cc @@ -111,16 +111,17 @@ grib_accessor_class* grib_accessor_class_bufr_simple_thinning = &_grib_accessor_ static void init(grib_accessor* a, const long len, grib_arguments* arg) { - int n = 0; grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a; + grib_handle* h = grib_handle_of_accessor(a); + int n = 0; a->length = 0; - self->doExtractSubsets = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->numberOfSubsets = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->extractSubsetList = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->simpleThinningStart = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->simpleThinningMissingRadius = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->simpleThinningSkip = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); + self->numberOfSubsets = grib_arguments_get_name(h, arg, n++); + self->extractSubsetList = grib_arguments_get_name(h, arg, n++); + self->simpleThinningStart = grib_arguments_get_name(h, arg, n++); + self->simpleThinningMissingRadius = grib_arguments_get_name(h, arg, n++); + self->simpleThinningSkip = grib_arguments_get_name(h, arg, n++); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } diff --git a/src/grib_accessor_class_change_scanning_direction.cc b/src/grib_accessor_class_change_scanning_direction.cc index 91e597135..88fbc35fb 100644 --- a/src/grib_accessor_class_change_scanning_direction.cc +++ b/src/grib_accessor_class_change_scanning_direction.cc @@ -117,17 +117,18 @@ grib_accessor_class* grib_accessor_class_change_scanning_direction = &_grib_acce static void init(grib_accessor* a, const long len, grib_arguments* args) { - int n = 0; grib_accessor_change_scanning_direction* self = (grib_accessor_change_scanning_direction*)a; + grib_handle* h = grib_handle_of_accessor(a); + int n = 0; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->Ni = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->Nj = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->i_scans_negatively = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->j_scans_positively = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->first = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->last = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->axis = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->values = grib_arguments_get_name(h, args, n++); + self->Ni = grib_arguments_get_name(h, args, n++); + self->Nj = grib_arguments_get_name(h, args, n++); + self->i_scans_negatively = grib_arguments_get_name(h, args, n++); + self->j_scans_positively = grib_arguments_get_name(h, args, n++); + self->first = grib_arguments_get_name(h, args, n++); + self->last = grib_arguments_get_name(h, args, n++); + self->axis = grib_arguments_get_name(h, args, n++); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->length = 0; @@ -150,7 +151,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) const char* cclass_name = a->cclass->name; if (*val == 0) - return 0; + return GRIB_SUCCESS; /* Make sure Ni / Nj are not missing */ if (grib_is_missing(h, self->Ni, &err) && !err) { diff --git a/src/grib_accessor_class_data_png_packing.cc b/src/grib_accessor_class_data_png_packing.cc index 44e9b41f6..41c90617b 100644 --- a/src/grib_accessor_class_data_png_packing.cc +++ b/src/grib_accessor_class_data_png_packing.cc @@ -136,26 +136,25 @@ grib_accessor_class* grib_accessor_class_data_png_packing = &_grib_accessor_clas static void init(grib_accessor* a, const long v, grib_arguments* args) { grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; + grib_handle* h = grib_handle_of_accessor(a); - self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->reference_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->binary_scale_factor = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->decimal_scale_factor = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - - self->ni = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->nj = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - - self->list_defining_points = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->number_of_data_points = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->scanning_mode = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->number_of_values = grib_arguments_get_name(h, args, self->carg++); + self->reference_value = grib_arguments_get_name(h, args, self->carg++); + self->binary_scale_factor = grib_arguments_get_name(h, args, self->carg++); + self->decimal_scale_factor = grib_arguments_get_name(h, args, self->carg++); + self->bits_per_value = grib_arguments_get_name(h, args, self->carg++); + self->ni = grib_arguments_get_name(h, args, self->carg++); + self->nj = grib_arguments_get_name(h, args, self->carg++); + self->list_defining_points = grib_arguments_get_name(h, args, self->carg++); + self->number_of_data_points = grib_arguments_get_name(h, args, self->carg++); + self->scanning_mode = grib_arguments_get_name(h, args, self->carg++); a->flags |= GRIB_ACCESSOR_FLAG_DATA; } static int value_count(grib_accessor* a, long* n_vals) { grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; - *n_vals = 0; + *n_vals = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); } @@ -228,10 +227,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) self->dirty = 0; - err = grib_value_count(a, &nn); + err = grib_value_count(a, &nn); n_vals = nn; - if (err) - return err; + if (err) return err; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) return err; diff --git a/src/grib_accessor_class_simple_packing_error.cc b/src/grib_accessor_class_simple_packing_error.cc index 3f5038a78..64f96eeea 100644 --- a/src/grib_accessor_class_simple_packing_error.cc +++ b/src/grib_accessor_class_simple_packing_error.cc @@ -8,11 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - **************************************/ - - #include "grib_scaling.h" #include "grib_api_internal.h" /* @@ -116,13 +111,14 @@ grib_accessor_class* grib_accessor_class_simple_packing_error = &_grib_accessor_ static void init(grib_accessor* a, const long l, grib_arguments* c) { grib_accessor_simple_packing_error* self = (grib_accessor_simple_packing_error*)a; - int n = 0; + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); - self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->binaryScaleFactor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->decimalScaleFactor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->referenceValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->floatType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->bitsPerValue = grib_arguments_get_name(h, c, n++); + self->binaryScaleFactor = grib_arguments_get_name(h, c, n++); + self->decimalScaleFactor = grib_arguments_get_name(h, c, n++); + self->referenceValue = grib_arguments_get_name(h, c, n++); + self->floatType = grib_arguments_get_name(h, c, n++); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; @@ -131,25 +127,23 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) static int unpack_double(grib_accessor* a, double* val, size_t* len) { grib_accessor_simple_packing_error* self = (grib_accessor_simple_packing_error*)a; - int ret = 0; - long binaryScaleFactor = 0; - long bitsPerValue = 0; - long decimalScaleFactor = 0; - double referenceValue = 0; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), - self->binaryScaleFactor, &binaryScaleFactor)) != GRIB_SUCCESS) + int ret = 0; + long binaryScaleFactor = 0; + long bitsPerValue = 0; + long decimalScaleFactor = 0; + double referenceValue = 0; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(h, self->binaryScaleFactor, &binaryScaleFactor)) != GRIB_SUCCESS) return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), - self->bitsPerValue, &bitsPerValue)) != GRIB_SUCCESS) + if ((ret = grib_get_long_internal(h, self->bitsPerValue, &bitsPerValue)) != GRIB_SUCCESS) return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), - self->decimalScaleFactor, &decimalScaleFactor)) != GRIB_SUCCESS) + if ((ret = grib_get_long_internal(h, self->decimalScaleFactor, &decimalScaleFactor)) != GRIB_SUCCESS) return ret; - if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), - self->referenceValue, &referenceValue)) != GRIB_SUCCESS) + if ((ret = grib_get_double_internal(h, self->referenceValue, &referenceValue)) != GRIB_SUCCESS) return ret; if (!strcmp(self->floatType, "ibm")) diff --git a/tests/wrap.sh b/tests/wrap.sh index 9f9221e9c..c8bf966e1 100755 --- a/tests/wrap.sh +++ b/tests/wrap.sh @@ -22,5 +22,7 @@ ${tools_dir}/grib_dump -TA -O $input id=`${tools_dir}/grib_get -TA -p identifier $input` [ "$id" = "WRAP" ] +echo 'print "[data]";' | ${tools_dir}/grib_filter -TA - $input + # Clean up rm -f $tempOut $tempRef $tempTxt