ECC-868: Provide key to control whether large constant fields are produced

This commit is contained in:
Shahram Najm 2019-01-14 12:32:20 +00:00
parent a12bf32911
commit b63de1609f
2 changed files with 24 additions and 3 deletions

View File

@ -53,8 +53,8 @@ transient unitsBias=0 : hidden;
constant globalDomain = "g";
transient timeRangeIndicatorFromStepRange=-1 : hidden;
# GRIB-802
transient override_large_constant_fields = 0 : hidden;
# ECC-868
transient produceLargeConstantFields = 0 : hidden;
meta libraryVersion library_version() : hidden;

View File

@ -447,6 +447,26 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
#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)
{
/* GRIB-802: If override key is set, ignore env. var and produce compressed fields */
@ -466,6 +486,7 @@ static int producing_large_constant_fields(const grib_context* c, grib_handle* h
return 0;
}
#endif
static int check_range(const double val)
{
@ -570,7 +591,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(c, gh, self->edition);
large_constant_fields = 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)