mirror of https://github.com/ecmwf/eccodes.git
Performance: Replace multiple calls to grib_handle_of_accessor
This commit is contained in:
parent
86131db2f2
commit
ee7d5a5b11
|
@ -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,9 +153,10 @@ static void fill_in(double a[], long length)
|
|||
|
||||
static int select_area(grib_accessor* a)
|
||||
{
|
||||
grib_accessor_bufr_extract_area_subsets* self = (grib_accessor_bufr_extract_area_subsets*)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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -136,19 +136,18 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -230,8 +229,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
|
||||
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;
|
||||
|
|
|
@ -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"
|
||||
/*
|
||||
|
@ -117,12 +112,13 @@ 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;
|
||||
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;
|
||||
grib_handle* h = grib_handle_of_accessor(a);
|
||||
|
||||
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a),
|
||||
self->binaryScaleFactor, &binaryScaleFactor)) != GRIB_SUCCESS)
|
||||
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"))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue