diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 90942b263..ce934f6ee 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -1444,6 +1444,7 @@ int grib2_select_PDTN(int is_eps, int is_instant, int is_chemical, int is_chemic size_t sum_of_pl_array(const long* pl, size_t plsize); int grib_is_earth_oblate(grib_handle* h); int grib_check_data_values_range(grib_handle* h, const double min_val, const double max_val); +int grib_producing_large_constant_fields(grib_handle* h, int edition); int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max_val); /* bufr_util.c */ diff --git a/src/grib_accessor_class_data_simple_packing.c b/src/grib_accessor_class_data_simple_packing.c index 46680a585..fe94fa738 100644 --- a/src/grib_accessor_class_data_simple_packing.c +++ b/src/grib_accessor_class_data_simple_packing.c @@ -474,27 +474,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) #undef restrict #endif -/* Return true(1) if large constant fields are to be created, otherwise false(0) */ -static int producing_large_constant_fields(grib_handle* h, int edition) -{ - /* First check if the transient key is set */ - grib_context* c = h->context; - long produceLargeConstantFields = 0; - if (grib_get_long(h, "produceLargeConstantFields", &produceLargeConstantFields) == GRIB_SUCCESS && - produceLargeConstantFields != 0) { - return 1; - } - - if (c->gribex_mode_on == 1 && edition == 1) { - return 1; - } - - /* Finally check the environment variable via the context */ - return c->large_constant_fields; -} - #if 0 -static int producing_large_constant_fields(const grib_context* c, grib_handle* h, int edition) +static int grib_producing_large_constant_fields(const grib_context* c, grib_handle* h, int edition) { /* GRIB-802: If override key is set, ignore env. var and produce compressed fields */ if (c->large_constant_fields) { /* This is set by the environment variable */ @@ -597,7 +578,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) Assert(ref == reference_value); } - large_constant_fields = producing_large_constant_fields(gh, self->edition); + large_constant_fields = grib_producing_large_constant_fields(gh, self->edition); if (large_constant_fields) { if ((err = grib_set_long_internal(gh, self->binary_scale_factor, 0)) != GRIB_SUCCESS) return err; diff --git a/src/grib_util.c b/src/grib_util.c index d9e328a82..ecd9862e9 100644 --- a/src/grib_util.c +++ b/src/grib_util.c @@ -2229,6 +2229,26 @@ int grib_check_data_values_range(grib_handle* h, const double min_val, const dou return result; } +/* Return true(1) if large constant fields are to be created, otherwise false(0) */ +int grib_producing_large_constant_fields(grib_handle* h, int edition) +{ + /* First check if the transient key is set */ + grib_context* c = h->context; + long produceLargeConstantFields = 0; + if (grib_get_long(h, "produceLargeConstantFields", &produceLargeConstantFields) == GRIB_SUCCESS && + produceLargeConstantFields != 0) { + return 1; + } + + if (c->gribex_mode_on == 1 && edition == 1) { + return 1; + } + + /* Finally check the environment variable via the context */ + return c->large_constant_fields; +} + + int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max_val) { int err = 0;