Merge branch 'develop' into bugfix/ecc-1768_pdtn8

This commit is contained in:
Eugen Betke 2024-02-21 13:16:06 +00:00
commit d80f84df59
79 changed files with 923 additions and 487 deletions

View File

@ -18,12 +18,12 @@ constant defaultTypeOfLevel="unknown" : hidden;
gribDataQualityChecks = getenv("ECCODES_GRIB_DATA_QUALITY_CHECKS","0") : hidden;
if (gribDataQualityChecks) {
template LIMITS "param_limits.def";
template LIMITS "param_limits.def";
}
# GRIBEX special boustrophedonic mode. See GRIB-472
# If the environment variable is not defined, the key will be 0
GRIBEX_boustrophedonic = getenv("ECCODES_GRIBEX_BOUSTROPHEDONIC","0") :hidden;
GRIBEX_boustrophedonic = getenv("ECCODES_GRIBEX_BOUSTROPHEDONIC","0") :hidden;
constant zero=0 : hidden;
constant one=1 : hidden;
@ -61,65 +61,65 @@ transient produceLargeConstantFields = 0 : hidden;
meta libraryVersion library_version() : hidden;
lookup[4] kindOfProduct (0,identifier) : hidden;
lookup[4] kindOfProduct (0,identifier) : hidden;
# grib templates
# `ABCD` is a number, each letter being a byte
if(kindOfProduct == `GRIB`){
lookup[1] GRIBEditionNumber (7,editionNumber) : edition_specific ;
template GRIB "grib[GRIBEditionNumber:l]/boot.def" ;
lookup[1] GRIBEditionNumber (7,editionNumber) : edition_specific;
template GRIB "grib[GRIBEditionNumber:l]/boot.def" ;
}
if(kindOfProduct == `BUDG` ){
template BUDG "budg/boot.def" ;
template BUDG "budg/boot.def" ;
}
if(kindOfProduct == `DIAG`){
template DIAG "diag/boot.def" ;
template DIAG "diag/boot.def" ;
}
if(kindOfProduct == `TIDE`){
template TIDE "tide/boot.def" ;
template TIDE "tide/boot.def" ;
}
if(kindOfProduct == `BUFR`){
template BUFR "bufr/boot.def" ;
#constant BUFRstr="BUFR"; #ECC-742
template BUFR "bufr/boot.def" ;
#constant BUFRstr="BUFR"; #ECC-742
#alias identifier=BUFRstr;
}
if(kindOfProduct == `CDFX`){
template CDF "cdf/boot.def" ;
constant CDFstr="netCDF";
template CDF "cdf/boot.def" ;
constant CDFstr="netCDF";
alias ls.identifier=CDFstr;
}
if(kindOfProduct == 17632522 ){
template GTS "gts/boot.def" ;
template GTS "gts/boot.def" ;
constant GTSstr="GTS";
alias ls.identifier=GTSstr;
}
if(kindOfProduct == `META` ){
template METAR "metar/boot.def" ;
template METAR "metar/boot.def" ;
constant METARstr="METAR";
alias identifier=METARstr;
}
if(kindOfProduct == `TAF ` ){
template TAF "taf/boot.def" ;
template TAF "taf/boot.def" ;
constant TAFstr="TAF";
alias ls.identifier=TAFstr;
}
if(kindOfProduct == 2303214662){
template HDF5 "hdf5/boot.def" ;
constant HDF5str="HDF5";
template HDF5 "hdf5/boot.def" ;
constant HDF5str="HDF5";
alias ls.identifier=HDF5str;
}
if(kindOfProduct == `WRAP`){
template WRAP "wrap/boot.def" ;
constant WRAPstr="WRAP";
template WRAP "wrap/boot.def" ;
constant WRAPstr="WRAP";
alias ls.identifier=WRAPstr;
}

View File

@ -89,7 +89,7 @@ if (horizontalCoordinateDefinition == 0) {
{
meta coordinateIndexNumber evaluate(coordinate4Flag+coordinate3Flag);
# levelist latitude longitude
# levelist latitude longitude
if (coordinateIndexNumber== 3) {
meta marsLatitude divdouble( coordinate1Start,1000000);
meta marsLongitude divdouble( coordinate2Start,1000000);
@ -145,15 +145,15 @@ if (horizontalCoordinateDefinition == 0) {
alias mars.range = marsRange;
}
}
# product
alias mars.product = coordAveragingTims;
# date
if (marsType == TYPE_OR && averaging1Flag == P_INST) {
#remove mars.date;
alias mars.date = verificationDate;
#remove mars.step;
constant stepZero = 0;
alias mars.step =stepZero;
}
# product
alias mars.product = coordAveragingTims;
# date
if (marsType == TYPE_OR && averaging1Flag == P_INST) {
#remove mars.date;
alias mars.date = verificationDate;
#remove mars.step;
constant stepZero = 0;
alias mars.step =stepZero;
}
}
}

View File

@ -16,9 +16,9 @@ constant tablesVersionLatest = 32 : edition_specific;
constant false = 0 : hidden;
constant true = 1 : hidden;
constant million = 1000000 : hidden;
constant grib2divider = 1000000;
alias extraDimensionPresent=zero;
transient angleSubdivisions=grib2divider; # micro degrees
constant grib2divider = 1000000;
alias extraDimensionPresent = zero;
transient angleSubdivisions = grib2divider; # micro degrees
transient forceStepUnits = 255 : hidden;
meta gts_header gts_header() : no_copy,hidden,read_only;
@ -26,8 +26,8 @@ meta gts_TTAAii gts_header(20,6) : no_copy,hidden,read_only;
meta gts_CCCC gts_header(27,4) : no_copy,hidden,read_only;
meta gts_ddhh00 gts_header(32,6) : no_copy,hidden,read_only;
transient missingValue = 9999;
constant ieeeFloats = 1 : edition_specific;
transient missingValue = 9999;
constant ieeeFloats = 1 : edition_specific;
constant isHindcast = 0;
include "grib2/section.0.def"

View File

@ -62,12 +62,12 @@ include "grib2/template.3.scanning_mode.def"
# Latin 1 - first latitude from the pole at which the secant cone cuts the sphere
signed[4] Latin1 : edition_specific;
alias FirstLatitude=Latin1;
alias firstLatitude=Latin1;
meta geography.Latin1InDegrees scale(Latin1,one,grib2divider,truncateDegrees) : dump;
# Latin 2 - second latitude from the pole at which the secant cone cuts the sphere
signed[4] Latin2 : dump;
alias SecondLatitude=Latin2;
alias secondLatitude=Latin2;
meta geography.Latin2InDegrees scale(Latin2,one,grib2divider,truncateDegrees) : dump;
# Latitude of the southern pole of projection

View File

@ -38,12 +38,12 @@ flags[1] projectionCentreFlag 'grib2/tables/[tablesVersion]/3.5.table' : dump;
# Latin 1 - first latitude from the pole at which the secant cone cuts the sphere
signed[4] Latin1 : edition_specific;
alias FirstLatitude=Latin1;
alias firstLatitude=Latin1;
meta geography.Latin1InDegrees scale(Latin1,one,grib2divider,truncateDegrees) : dump;
# Latin 2 - second latitude from the pole at which the secant cone cuts the sphere
signed[4] Latin2 : dump;
alias SecondLatitude=Latin2;
alias secondLatitude=Latin2;
meta geography.Latin2InDegrees scale(Latin2,one,grib2divider,truncateDegrees) : dump;
# Latitude of the southern pole of projection

View File

@ -73,12 +73,12 @@ _if (shapeOfTheEarth == 3){
# ECC-979
# The 'scale' accessor works with integers so rounds its first argument
# which is not what we want because the inputs are doubles with decimal
# expansions. So use the trick of dividing by 0.001 to multiply by 1000
# expansions.
#
# meta earthMajorAxisInMetres scale(earthMajorAxis, thousand, one, zero);
# meta earthMinorAxisInMetres scale(earthMinorAxis, thousand, one, zero);
meta earthMajorAxisInMetres divdouble(earthMajorAxis, 0.001);
meta earthMinorAxisInMetres divdouble(earthMinorAxis, 0.001);
meta earthMajorAxisInMetres multdouble(earthMajorAxis, 1000);
meta earthMinorAxisInMetres multdouble(earthMinorAxis, 1000);
}
_if (shapeOfTheEarth == 7){
# Major and minor axes specified (in m) by data producer

View File

@ -1,6 +1,7 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.1100, Hovmoller-type grid with no averaging or other statistical processing
# This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"

View File

@ -2,8 +2,26 @@
# TEMPLATE 4.1101, Hovmoller-type grid with averaging or other statistical processing
# This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests.
# (Octets 35-50 are very similar to octets 43-58 of product definition template 4.8, but the meaning of some fields differs slightly)
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"
include "grib2/template.4.forecast_time.def"
include "grib2/template.4.horizontal.def"
include "grib2/template.4.statistical.def"
unsigned[4] numberOfMissingInStatisticalProcess = 0 : edition_specific;
alias totalNumberOfDataValuesMissingInStatisticalProcess=numberOfMissingInStatisticalProcess;
codetable[1] typeOfStatisticalProcessing ('4.10.table',masterDir,localDir) : edition_specific;
codetable[1] typeOfTimeIncrement ('4.11.table',masterDir,localDir) = 2 : edition_specific;
alias typeOfTimeIncrementBetweenSuccessiveFieldsUsedInTheStatisticalProcessing=typeOfTimeIncrement;
codetable[1] indicatorOfUnitForTimeRange ('4.4.table',masterDir,localDir) =1 ;
unsigned[4] lengthOfTimeRange=0 ;
codetable[1] indicatorOfUnitForTimeIncrement ('4.4.table',masterDir,localDir)=255 ;
unsigned[4] timeIncrement=0 ;
alias timeIncrementBetweenSuccessiveFields=timeIncrement;
# include "grib2/template.4.statistical.def"

View File

@ -8,3 +8,12 @@ signed[1] scaleFactorOfFirstWavelength : dump;
signed[4] scaledValueOfFirstWavelength : dump;
signed[1] scaleFactorOfSecondWavelength = missing(): can_be_missing,dump;
signed[4] scaledValueOfSecondWavelength = missing(): can_be_missing,dump;
meta firstWavelength from_scale_factor_scaled_value(scaleFactorOfFirstWavelength, scaledValueOfFirstWavelength);
meta secondWavelength from_scale_factor_scaled_value(scaleFactorOfSecondWavelength, scaledValueOfSecondWavelength);
alias firstWavelengthInMetres = firstWavelength;
alias secondWavelengthInMetres = secondWavelength;
constant billion = 1000000000 : hidden;
meta firstWavelengthInNanometres multdouble(firstWavelength, billion);
meta secondWavelengthInNanometres multdouble(secondWavelength, billion);

View File

@ -6,13 +6,13 @@ if (bitsPerValue) {
meta groupWidths unsigned_bits(widthOfWidths,numberOfGroups) : read_only;
meta groupLengths unsigned_bits(widthOfLengths,numberOfGroups) : read_only;
meta firstOrderValues unsigned_bits(widthOfFirstOrderValues,numberOfGroups) : read_only;
meta countOfGroupLengths sum(groupLengths);
# meta countOfGroupLengths sum(groupLengths);
}
transient halfByte=0;
position offsetBeforeData;
if(bitmapPresent) {
if(bitmapPresent) {
meta codedValues data_g1second_order_general_extended_packing(
#simple_packing args
section7Length,
@ -49,7 +49,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
): read_only;
alias data.packedValues = codedValues;
@ -91,7 +90,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
) : dump;
alias codedValues=values;
alias data.packedValues = values;

View File

@ -5,12 +5,12 @@
meta groupWidths unsigned_bits(widthOfWidths,numberOfGroups) : read_only;
meta groupLengths unsigned_bits(widthOfLengths,numberOfGroups) : read_only;
meta firstOrderValues unsigned_bits(widthOfFirstOrderValues,numberOfGroups) : read_only;
meta countOfGroupLengths sum(groupLengths);
# meta countOfGroupLengths sum(groupLengths);
transient halfByte=0;
position offsetBeforeData;
if(bitmapPresent) {
if(bitmapPresent) {
meta codedValues data_g1second_order_general_extended_packing(
#simple_packing args
section7Length,
@ -47,7 +47,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
): read_only;
alias data.packedValues = codedValues;
@ -96,8 +95,7 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
) : dump;
) : dump;
meta values data_apply_boustrophedonic(codedValues,numberOfRows,numberOfColumns,numberOfPoints,pl) : dump;
@ -138,7 +136,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
) : dump;
alias codedValues=values;
}

View File

@ -73,12 +73,12 @@ _if (shapeOfTheEarth == 3){
# ECC-979
# The 'scale' accessor works with integers so rounds its first argument
# which is not what we want because the inputs are doubles with decimal
# expansions. So use the trick of dividing by 0.001 to multiply by 1000
# expansions.
#
# meta earthMajorAxisInMetres scale(earthMajorAxis, thousand, one, zero);
# meta earthMinorAxisInMetres scale(earthMinorAxis, thousand, one, zero);
meta earthMajorAxisInMetres divdouble(earthMajorAxis, 0.001);
meta earthMinorAxisInMetres divdouble(earthMinorAxis, 0.001);
meta earthMajorAxisInMetres multdouble(earthMajorAxis, 1000);
meta earthMinorAxisInMetres multdouble(earthMinorAxis, 1000);
}
_if (shapeOfTheEarth == 7){
# Major and minor axes specified (in m) by data producer

View File

@ -1,4 +1,9 @@
alias mars.step = endStep;
if (levtype is "o2d" || levtype is "o3d") {
alias mars.step = stepRange;
} else {
alias mars.step = endStep;
}
if (class is "od") { alias mars.system = systemNumber; }
if (class is "me") { alias mars.system = systemNumber; }
if (class is "en") { alias mars.system = systemNumber; }
@ -17,3 +22,4 @@ if (centre == 80 && subCentre == 98 && class is "c3") {
}
if (class is "ci") { unalias mars.method; }

View File

@ -80,6 +80,7 @@ list( APPEND eccodes_src_files
grib_accessor_class_hash_array.cc
grib_accessor_class_decimal_precision.cc
grib_accessor_class_divdouble.cc
grib_accessor_class_multdouble.cc
grib_accessor_class_budgdate.cc
grib_accessor_class_validity_date.cc
grib_accessor_class_validity_time.cc

View File

@ -128,7 +128,7 @@ grib_concept_value* action_concept_get_concept(grib_accessor* a)
int action_concept_get_nofail(grib_accessor* a)
{
grib_action_concept* self = (grib_action_concept*)a->creator;
const grib_action_concept* self = (grib_action_concept*)a->creator;
return self->nofail;
}
@ -397,9 +397,9 @@ int get_concept_condition_string(grib_handle* h, const char* key, const char* va
grib_concept_condition* concept_condition = concept_value->conditions;
if (strcmp(pValue, concept_value->name) == 0) {
while (concept_condition) {
grib_expression* expression = concept_condition->expression;
//grib_expression* expression = concept_condition->expression;
const char* condition_name = concept_condition->name;
Assert(expression);
//Assert(expression);
if (concept_condition_expression_true(h, concept_condition, exprVal) && strcmp(condition_name, "one") != 0) {
length += snprintf(result + length, 2048, "%s%s=%s",
(length == 0 ? "" : ","), condition_name, exprVal);

View File

@ -98,15 +98,14 @@ grib_action* grib_action_create_set_darray(grib_context* context,
static int execute(grib_action* a, grib_handle* h)
{
grib_action_set_darray* self = (grib_action_set_darray*)a;
const grib_action_set_darray* self = (grib_action_set_darray*)a;
return grib_set_double_array(h, self->name, self->darray->v, self->darray->n);
}
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_set_darray* self = (grib_action_set_darray*)act;
const grib_action_set_darray* self = (grib_action_set_darray*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);

View File

@ -73,8 +73,7 @@ static void init_class(grib_action_class* c)
}
/* END_CLASS_IMP */
grib_action* grib_action_create_set_missing(grib_context* context,
const char* name)
grib_action* grib_action_create_set_missing(grib_context* context, const char* name)
{
char buf[1024];
@ -98,15 +97,14 @@ grib_action* grib_action_create_set_missing(grib_context* context,
static int execute(grib_action* a, grib_handle* h)
{
grib_action_set_missing* self = (grib_action_set_missing*)a;
const grib_action_set_missing* self = (grib_action_set_missing*)a;
return grib_set_missing(h, self->name);
}
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_set_missing* self = (grib_action_set_missing*)act;
int i = 0;
const grib_action_set_missing* self = (grib_action_set_missing*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);

View File

@ -72,9 +72,7 @@ static void init_class(grib_action_class* c)
}
/* END_CLASS_IMP */
grib_action* grib_action_create_set_sarray(grib_context* context,
const char* name,
grib_sarray* sarray)
grib_action* grib_action_create_set_sarray(grib_context* context, const char* name, grib_sarray* sarray)
{
char buf[1024];
@ -100,14 +98,13 @@ grib_action* grib_action_create_set_sarray(grib_context* context,
static int execute(grib_action* a, grib_handle* h)
{
grib_action_set_sarray* self = (grib_action_set_sarray*)a;
return grib_set_string_array(h, self->name, (const char**)self->sarray->v, self->sarray->n);
}
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_set_sarray* self = (grib_action_set_sarray*)act;
int i = 0;
const grib_action_set_sarray* self = (grib_action_set_sarray*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);

View File

@ -1311,7 +1311,6 @@ const char* grib_expression_get_name(grib_expression* g);
void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f);
void grib_expression_free(grib_context* ctx, grib_expression* g);
void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer);
int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v);
grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n);
void grib_arguments_free(grib_context* c, grib_arguments* g);
void grib_arguments_print(grib_context* c, grib_arguments* g, grib_handle* f);

View File

@ -10,13 +10,12 @@
/***************************************************************************
* Jean Baptiste Filippi - 01.11.2005
* Enrico Fucile
***************************************************************************/
#include "grib_accessor.h"
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
// Note: A fast cut-down version of strcmp which does NOT return -1
// 0 means input strings are equal and 1 means not equal
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{
if (*a != *b)
@ -44,7 +43,7 @@ void grib_accessor_dump(grib_accessor* a, grib_dumper* f)
int grib_pack_missing(grib_accessor* a)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_missing) {
return c->pack_missing(a);
@ -58,7 +57,6 @@ int grib_pack_missing(grib_accessor* a)
int grib_pack_zero(grib_accessor* a)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while (c) {
if (c->clear) {
return c->clear(a);
@ -72,7 +70,8 @@ int grib_pack_zero(grib_accessor* a)
int grib_is_missing_internal(grib_accessor* a)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
// grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->is_missing) {
return c->is_missing(a);
@ -86,7 +85,7 @@ int grib_is_missing_internal(grib_accessor* a)
int grib_pack_double(grib_accessor* a, const double* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_double) {
return c->pack_double(a, v, len);
@ -113,7 +112,7 @@ int grib_pack_float(grib_accessor* a, const float* v, size_t* len)
int grib_pack_expression(grib_accessor* a, grib_expression* e)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_expression) {
return c->pack_expression(a, e);
@ -127,7 +126,7 @@ int grib_pack_expression(grib_accessor* a, grib_expression* e)
int grib_pack_string(grib_accessor* a, const char* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");*/
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");
while (c) {
if (c->pack_string) {
return c->pack_string(a, v, len);
@ -141,7 +140,7 @@ int grib_pack_string(grib_accessor* a, const char* v, size_t* len)
int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");*/
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");
while (c) {
if (c->pack_string_array) {
return c->pack_string_array(a, v, len);
@ -155,7 +154,7 @@ int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len)
int grib_pack_long(grib_accessor* a, const long* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_long) {
return c->pack_long(a, v, len);
@ -169,7 +168,7 @@ int grib_pack_long(grib_accessor* a, const long* v, size_t* len)
int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (bytes) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (bytes) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_bytes) {
return c->pack_bytes(a, v, len);
@ -183,7 +182,7 @@ int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len)
int grib_unpack_bytes(grib_accessor* a, unsigned char* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (bytes)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (bytes)",(a->parent->owner)?(a->parent->owner->name):"root", a->name);
while (c) {
if (c->unpack_bytes) {
return c->unpack_bytes(a, v, len);
@ -210,7 +209,7 @@ int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_
int grib_unpack_double(grib_accessor* a, double* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (double)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (double)",(a->parent->owner)?(a->parent->owner->name):"root", a->name);
while (c) {
if (c->unpack_double) {
return c->unpack_double(a, v, len);
@ -225,7 +224,7 @@ int grib_unpack_float(grib_accessor* a, float* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
while (c) {
/* printf("grib_accessor.c grib_unpack_float:: c->name=%s\n",c->name); */
//printf("grib_accessor.c grib_unpack_float:: c->name=%s\n",c->name);
if (c->unpack_float) {
return c->unpack_float(a, v, len);
}
@ -260,20 +259,19 @@ int grib_unpack_double_element(grib_accessor* a, size_t i, double* v)
}
int grib_unpack_float_element(grib_accessor* a, size_t i, float* v)
{
/* grib_accessor_class* c = a->cclass;
* while (c) {
* if (c->unpack_float_element) {
* return c->unpack_float_element(a, i, v);
* }
* c = c->super ? *(c->super) : NULL;
* }
*/
// grib_accessor_class* c = a->cclass;
// while (c) {
// if (c->unpack_float_element) {
// return c->unpack_float_element(a, i, v);
// }
// c = c->super ? *(c->super) : NULL;
//}
return GRIB_NOT_IMPLEMENTED;
}
/* Get the values for the indices passed in.
* The length of the 'index_array' argument should be 'len' and 'val_array' should also contain at least 'len' elements
*/
// Get the values for the indices passed in.
// The length of the 'index_array' argument should be 'len' and 'val_array' should also contain at least 'len' elements
int grib_unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array)
{
grib_accessor_class* c = a->cclass;
@ -288,23 +286,22 @@ int grib_unpack_double_element_set(grib_accessor* a, const size_t* index_array,
}
int grib_unpack_float_element_set(grib_accessor* a, const size_t* index_array, size_t len, float* val_array)
{
/*
*grib_accessor_class* c = a->cclass;
*DEBUG_ASSERT(len > 0);
*while (c) {
* if (c->unpack_float_element_set) {
* return c->unpack_float_element_set(a, index_array, len, val_array);
* }
* c = c->super ? *(c->super) : NULL;
*}
*/
// grib_accessor_class* c = a->cclass;
// DEBUG_ASSERT(len > 0);
// while (c) {
// if (c->unpack_float_element_set) {
// return c->unpack_float_element_set(a, index_array, len, val_array);
// }
// c = c->super ? *(c->super) : NULL;
// }
return GRIB_NOT_IMPLEMENTED;
}
int grib_unpack_string(grib_accessor* a, char* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/* grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (string)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (string)",(a->parent->owner)?(a->parent->owner->name):"root", a->name );
while (c) {
if (c->unpack_string) {
return c->unpack_string(a, v, len);
@ -399,7 +396,7 @@ int grib_accessors_list_unpack_string(grib_accessors_list* al, char** val, size_
int grib_unpack_long(grib_accessor* a, long* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name );
while (c) {
if (c->unpack_long) {
return c->unpack_long(a, v, len);
@ -428,7 +425,8 @@ long grib_accessor_get_native_type(grib_accessor* a)
long grib_get_next_position_offset(grib_accessor* a)
{
grib_accessor_class* c = NULL;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is checking next (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is checking next (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name );
if (a)
c = a->cclass;
@ -533,8 +531,7 @@ int grib_accessor_notify_change(grib_accessor* a, grib_accessor* changed)
return 0;
}
/* For this one, ALL init are called */
// For this one, ALL init are called
static void init_accessor(grib_accessor_class* c, grib_accessor* a, const long len, grib_arguments* args)
{
if (c) {
@ -550,27 +547,26 @@ void grib_init_accessor(grib_accessor* a, const long len, grib_arguments* args)
init_accessor(a->cclass, a, len, args);
}
/* For this one, ALL destroy are called */
// For this one, ALL destroy are called
void grib_accessor_delete(grib_context* ct, grib_accessor* a)
{
grib_accessor_class* c = a->cclass;
while (c) {
grib_accessor_class* s = c->super ? *(c->super) : NULL;
/*printf("grib_accessor_delete: before destroy a=%p c->name=%s ==> a->name=%s\n", (void*)a, c->name, a->name);*/
//printf("grib_accessor_delete: before destroy a=%p c->name=%s ==> a->name=%s\n", (void*)a, c->name, a->name);
if (c->destroy) {
c->destroy(ct, a);
}
c = s;
}
/*printf("grib_accessor_delete before free a=%p\n", (void*)a);*/
// printf("grib_accessor_delete before free a=%p\n", (void*)a);
grib_context_free(ct, a);
}
grib_accessor* grib_accessor_clone(grib_accessor* a, grib_section* s, int* err)
{
grib_accessor_class* c = a->cclass;
grib_context* ct = a->context;
const grib_context* ct = a->context;
while (c) {
grib_accessor_class* super = c->super ? *(c->super) : NULL;
grib_context_log(ct, GRIB_LOG_DEBUG, "clone %s ==> %s", c->name, a->name);
@ -585,7 +581,8 @@ grib_accessor* grib_accessor_clone(grib_accessor* a, grib_section* s, int* err)
void grib_update_size(grib_accessor* a, size_t len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->update_size) {
c->update_size(a, len);
@ -613,7 +610,8 @@ int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest)
size_t grib_preferred_size(grib_accessor* a, int from_handle)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
// grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->preferred_size) {
return c->preferred_size(a, from_handle);
@ -640,7 +638,8 @@ grib_accessor* grib_next_accessor(grib_accessor* a)
void grib_resize(grib_accessor* a, size_t new_size)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->resize) {
c->resize(a, new_size);
@ -714,7 +713,7 @@ int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_
for (id = 0; id < MAX_ACCESSOR_ATTRIBUTES; id++) {
if (aloc->attributes[id] == NULL) {
/* attr->parent=a->parent; */
// attr->parent=a->parent;
aloc->attributes[id] = attr;
attr->parent_as_attribute = aloc;
if (aloc->same)
@ -823,7 +822,7 @@ grib_accessors_list* grib_accessors_list_create(grib_context* c)
void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank)
{
grib_accessors_list* last;
grib_context* c = a->context;
const grib_context* c = a->context;
last = grib_accessors_list_last(al);
if (last && last->accessor) {
@ -842,15 +841,13 @@ void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int ran
grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al)
{
/*grib_accessors_list* last=al;*/
/*grib_accessors_list* next=al->next;*/
// grib_accessors_list* last=al;
// grib_accessors_list* next=al->next;
// while(next) {
// last=next;
// next=last->next;
// }
/*
while(next) {
last=next;
next=last->next;
}
*/
return al->last;
}
@ -875,7 +872,7 @@ void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al)
while (al) {
tmp = al->next;
/*grib_accessor_delete(c, al->accessor);*/
//grib_accessor_delete(c, al->accessor);
grib_context_free(c, al);
al = tmp;
}

View File

@ -131,6 +131,7 @@ extern grib_accessor_class* grib_accessor_class_mars_step;
extern grib_accessor_class* grib_accessor_class_md5;
extern grib_accessor_class* grib_accessor_class_message;
extern grib_accessor_class* grib_accessor_class_message_copy;
extern grib_accessor_class* grib_accessor_class_multdouble;
extern grib_accessor_class* grib_accessor_class_nearest;
extern grib_accessor_class* grib_accessor_class_non_alpha;
extern grib_accessor_class* grib_accessor_class_number_of_coded_values;

View File

@ -7,11 +7,6 @@
* 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.
*/
/*****************************************
* Enrico Fucile
****************************************/
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -108,7 +103,7 @@ grib_accessor_class* grib_accessor_class_divdouble = &_grib_accessor_class_divdo
static void init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_divdouble* self = (grib_accessor_divdouble*)a;
int n = 0;
int n = 0;
self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
self->divisor = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++);
@ -116,22 +111,17 @@ 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_divdouble* self = (grib_accessor_divdouble*)a;
int ret = GRIB_SUCCESS;
double value = 0;
if (*len < 1) {
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
const grib_accessor_divdouble* self = (grib_accessor_divdouble*)a;
int ret = GRIB_SUCCESS;
double value = 0;
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value);
if (ret != GRIB_SUCCESS)
return ret;
/* fprintf(stdout,"\nname %s %s %g/%g\n",a->name ,self->val,value,divisor);*/
Assert(self->divisor != 0);
if (self->divisor == 0) {
return GRIB_INVALID_ARGUMENT;
}
*val = value / self->divisor;
*len = 1;

View File

@ -223,7 +223,7 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_
* Its max size is X (from FXY) which is 6 bits so no need for malloc */
bufr_descriptor* ur[65] = {0,};
bufr_descriptor* urc = NULL;
int idx;
size_t idx = 0;
bufr_descriptor* u0 = NULL;
grib_context* c = a->context;
bufr_descriptor* us = NULL;

View File

@ -211,6 +211,11 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS)
return ret;
// TODO(maee): A better solution should be found
if (h->loader) { // h->loader is set only when rebuilding or reparsing
force_step_units = 255; // See ECC-1768
}
try {
std::vector<eccodes::Step> steps = parse_range(val, eccodes::Unit{force_step_units});
if (steps.size() == 0) {

View File

@ -0,0 +1,127 @@
/*
* (C) Copyright 2005- 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 "grib_api_internal.h"
/*
This is used by make_class.pl
START_CLASS_DEF
CLASS = accessor
SUPER = grib_accessor_class_double
IMPLEMENTS = unpack_double
IMPLEMENTS = init
MEMBERS = const char* val
MEMBERS = double multiplier
END_CLASS_DEF
*/
/* START_CLASS_IMP */
/*
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_double(grib_accessor*, double* val, size_t* len);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_multdouble
{
grib_accessor att;
/* Members defined in gen */
/* Members defined in double */
/* Members defined in multdouble */
const char* val;
double multiplier;
} grib_accessor_multdouble;
extern grib_accessor_class* grib_accessor_class_double;
static grib_accessor_class _grib_accessor_class_multdouble = {
&grib_accessor_class_double, /* super */
"multdouble", /* name */
sizeof(grib_accessor_multdouble), /* size */
0, /* inited */
0, /* init_class */
&init, /* init */
0, /* post_init */
0, /* destroy */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
0, /* get number of bytes */
0, /* get offset to bytes */
0, /* get native type */
0, /* get sub_section */
0, /* pack_missing */
0, /* is_missing */
0, /* pack_long */
0, /* unpack_long */
0, /* pack_double */
0, /* pack_float */
&unpack_double, /* unpack_double */
0, /* unpack_float */
0, /* pack_string */
0, /* unpack_string */
0, /* pack_string_array */
0, /* unpack_string_array */
0, /* pack_bytes */
0, /* unpack_bytes */
0, /* pack_expression */
0, /* notify_change */
0, /* update_size */
0, /* preferred_size */
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
0, /* unpack a given set of elements (float) */
0, /* unpack a subarray */
0, /* clear */
0, /* clone accessor */
};
grib_accessor_class* grib_accessor_class_multdouble = &_grib_accessor_class_multdouble;
/* END_CLASS_IMP */
static void init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_multdouble* self = (grib_accessor_multdouble*)a;
int n = 0;
self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
self->multiplier = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++);
}
static int unpack_double(grib_accessor* a, double* val, size_t* len)
{
const grib_accessor_multdouble* self = (grib_accessor_multdouble*)a;
int ret = GRIB_SUCCESS;
double value = 0;
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value);
if (ret != GRIB_SUCCESS)
return ret;
*val = value * self->multiplier;
*len = 1;
return GRIB_SUCCESS;
}

View File

@ -190,7 +190,6 @@ static int unpack_long(grib_accessor* a, long* v, size_t* len)
*v = strtol(val, &last, 10);
grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
@ -204,7 +203,6 @@ static int unpack_double(grib_accessor* a, double* v, size_t* len)
*v = strtod(val, &last);
if (*last == 0) {
grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}

View File

@ -37,7 +37,7 @@
#line 6 "accessor_class_list.gperf"
struct accessor_class_hash { char *name; grib_accessor_class **cclass;};
#define TOTAL_KEYWORDS 204
#define TOTAL_KEYWORDS 205
#define MIN_WORD_LENGTH 1
#define MAX_WORD_LENGTH 44
#define MIN_HASH_VALUE 1
@ -117,21 +117,21 @@ static const struct accessor_class_hash classes[] =
#line 9 "accessor_class_list.gperf"
{" "},
{""}, {""}, {""}, {""},
#line 178 "accessor_class_list.gperf"
#line 179 "accessor_class_list.gperf"
{"size", &grib_accessor_class_size},
#line 12 "accessor_class_list.gperf"
{"ascii", &grib_accessor_class_ascii},
#line 175 "accessor_class_list.gperf"
#line 176 "accessor_class_list.gperf"
{"signed", &grib_accessor_class_signed},
#line 155 "accessor_class_list.gperf"
#line 156 "accessor_class_list.gperf"
{"pad", &grib_accessor_class_pad},
#line 181 "accessor_class_list.gperf"
#line 182 "accessor_class_list.gperf"
{"spd", &grib_accessor_class_spd},
{""},
#line 75 "accessor_class_list.gperf"
{"dirty", &grib_accessor_class_dirty},
{""},
#line 176 "accessor_class_list.gperf"
#line 177 "accessor_class_list.gperf"
{"signed_bits", &grib_accessor_class_signed_bits},
{""},
#line 66 "accessor_class_list.gperf"
@ -141,7 +141,7 @@ static const struct accessor_class_hash classes[] =
{"data_simple_packing", &grib_accessor_class_data_simple_packing},
#line 68 "accessor_class_list.gperf"
{"data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap},
#line 169 "accessor_class_list.gperf"
#line 170 "accessor_class_list.gperf"
{"section", &grib_accessor_class_section},
#line 43 "accessor_class_list.gperf"
{"data_apply_bitmap", &grib_accessor_class_data_apply_bitmap},
@ -155,36 +155,36 @@ static const struct accessor_class_hash classes[] =
{"data_jpeg2000_packing", &grib_accessor_class_data_jpeg2000_packing},
#line 65 "accessor_class_list.gperf"
{"data_png_packing", &grib_accessor_class_data_png_packing},
#line 171 "accessor_class_list.gperf"
{"section_padding", &grib_accessor_class_section_padding},
#line 172 "accessor_class_list.gperf"
{"section_padding", &grib_accessor_class_section_padding},
#line 173 "accessor_class_list.gperf"
{"section_pointer", &grib_accessor_class_section_pointer},
#line 44 "accessor_class_list.gperf"
{"data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic},
{""}, {""}, {""}, {""},
#line 80 "accessor_class_list.gperf"
{"expanded_descriptors", &grib_accessor_class_expanded_descriptors},
#line 156 "accessor_class_list.gperf"
#line 157 "accessor_class_list.gperf"
{"padding", &grib_accessor_class_padding},
#line 45 "accessor_class_list.gperf"
{"data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap},
#line 110 "accessor_class_list.gperf"
{"gds_is_present", &grib_accessor_class_gds_is_present},
#line 168 "accessor_class_list.gperf"
#line 169 "accessor_class_list.gperf"
{"second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value},
#line 170 "accessor_class_list.gperf"
#line 171 "accessor_class_list.gperf"
{"section_length", &grib_accessor_class_section_length},
#line 113 "accessor_class_list.gperf"
{"getenv", &grib_accessor_class_getenv},
#line 57 "accessor_class_list.gperf"
{"data_g22order_packing", &grib_accessor_class_data_g22order_packing},
#line 190 "accessor_class_list.gperf"
#line 191 "accessor_class_list.gperf"
{"time", &grib_accessor_class_time},
{""},
#line 61 "accessor_class_list.gperf"
{"data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing},
{""},
#line 154 "accessor_class_list.gperf"
#line 155 "accessor_class_list.gperf"
{"packing_type", &grib_accessor_class_packing_type},
#line 62 "accessor_class_list.gperf"
{"data_g2simple_packing", &grib_accessor_class_data_g2simple_packing},
@ -198,28 +198,28 @@ static const struct accessor_class_hash classes[] =
{"g2end_step", &grib_accessor_class_g2end_step},
#line 98 "accessor_class_list.gperf"
{"g2_eps", &grib_accessor_class_g2_eps},
#line 141 "accessor_class_list.gperf"
#line 142 "accessor_class_list.gperf"
{"nearest", &grib_accessor_class_nearest},
{""},
#line 157 "accessor_class_list.gperf"
#line 158 "accessor_class_list.gperf"
{"padto", &grib_accessor_class_padto},
#line 188 "accessor_class_list.gperf"
#line 189 "accessor_class_list.gperf"
{"sum", &grib_accessor_class_sum},
{""},
#line 107 "accessor_class_list.gperf"
{"g2lon", &grib_accessor_class_g2lon},
#line 202 "accessor_class_list.gperf"
#line 203 "accessor_class_list.gperf"
{"uint8", &grib_accessor_class_uint8},
{""},
#line 187 "accessor_class_list.gperf"
#line 188 "accessor_class_list.gperf"
{"step_in_units", &grib_accessor_class_step_in_units},
#line 63 "accessor_class_list.gperf"
{"data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing},
#line 200 "accessor_class_list.gperf"
#line 201 "accessor_class_list.gperf"
{"uint64", &grib_accessor_class_uint64},
#line 47 "accessor_class_list.gperf"
{"data_complex_packing", &grib_accessor_class_data_complex_packing},
#line 198 "accessor_class_list.gperf"
#line 199 "accessor_class_list.gperf"
{"uint32", &grib_accessor_class_uint32},
#line 13 "accessor_class_list.gperf"
{"bit", &grib_accessor_class_bit},
@ -233,7 +233,7 @@ static const struct accessor_class_hash classes[] =
{"julian_day", &grib_accessor_class_julian_day},
#line 123 "accessor_class_list.gperf"
{"julian_date", &grib_accessor_class_julian_date},
#line 142 "accessor_class_list.gperf"
#line 143 "accessor_class_list.gperf"
{"non_alpha", &grib_accessor_class_non_alpha},
{""},
#line 29 "accessor_class_list.gperf"
@ -245,14 +245,14 @@ static const struct accessor_class_hash classes[] =
#line 16 "accessor_class_list.gperf"
{"bits_per_value", &grib_accessor_class_bits_per_value},
{""}, {""}, {""}, {""}, {""},
#line 166 "accessor_class_list.gperf"
#line 167 "accessor_class_list.gperf"
{"scale", &grib_accessor_class_scale},
{""},
#line 184 "accessor_class_list.gperf"
#line 185 "accessor_class_list.gperf"
{"statistics", &grib_accessor_class_statistics},
#line 102 "accessor_class_list.gperf"
{"g2date", &grib_accessor_class_g2date},
#line 144 "accessor_class_list.gperf"
#line 145 "accessor_class_list.gperf"
{"number_of_points", &grib_accessor_class_number_of_points},
#line 100 "accessor_class_list.gperf"
{"g2bitmap", &grib_accessor_class_g2bitmap},
@ -265,13 +265,13 @@ static const struct accessor_class_hash classes[] =
{"gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap},
#line 122 "accessor_class_list.gperf"
{"iterator", &grib_accessor_class_iterator},
#line 185 "accessor_class_list.gperf"
#line 186 "accessor_class_list.gperf"
{"statistics_spectral", &grib_accessor_class_statistics_spectral},
#line 46 "accessor_class_list.gperf"
{"data_ccsds_packing", &grib_accessor_class_data_ccsds_packing},
#line 145 "accessor_class_list.gperf"
#line 146 "accessor_class_list.gperf"
{"number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian},
#line 205 "accessor_class_list.gperf"
#line 206 "accessor_class_list.gperf"
{"unsigned", &grib_accessor_class_unsigned},
#line 138 "accessor_class_list.gperf"
{"md5", &grib_accessor_class_md5},
@ -280,30 +280,30 @@ static const struct accessor_class_hash classes[] =
{"g2_aerosol", &grib_accessor_class_g2_aerosol},
#line 139 "accessor_class_list.gperf"
{"message", &grib_accessor_class_message},
#line 206 "accessor_class_list.gperf"
#line 207 "accessor_class_list.gperf"
{"unsigned_bits", &grib_accessor_class_unsigned_bits},
#line 173 "accessor_class_list.gperf"
#line 174 "accessor_class_list.gperf"
{"select_step_template", &grib_accessor_class_select_step_template},
#line 136 "accessor_class_list.gperf"
{"mars_param", &grib_accessor_class_mars_param},
#line 203 "accessor_class_list.gperf"
#line 204 "accessor_class_list.gperf"
{"unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors},
#line 192 "accessor_class_list.gperf"
#line 193 "accessor_class_list.gperf"
{"to_integer", &grib_accessor_class_to_integer},
{""}, {""}, {""},
#line 177 "accessor_class_list.gperf"
#line 178 "accessor_class_list.gperf"
{"simple_packing_error", &grib_accessor_class_simple_packing_error},
#line 186 "accessor_class_list.gperf"
#line 187 "accessor_class_list.gperf"
{"step_human_readable", &grib_accessor_class_step_human_readable},
#line 140 "accessor_class_list.gperf"
{"message_copy", &grib_accessor_class_message_copy},
#line 162 "accessor_class_list.gperf"
#line 163 "accessor_class_list.gperf"
{"raw", &grib_accessor_class_raw},
{""}, {""},
#line 201 "accessor_class_list.gperf"
#line 202 "accessor_class_list.gperf"
{"uint64_little_endian", &grib_accessor_class_uint64_little_endian},
{""},
#line 199 "accessor_class_list.gperf"
#line 200 "accessor_class_list.gperf"
{"uint32_little_endian", &grib_accessor_class_uint32_little_endian},
#line 114 "accessor_class_list.gperf"
{"global_gaussian", &grib_accessor_class_global_gaussian},
@ -311,20 +311,20 @@ static const struct accessor_class_hash classes[] =
#line 76 "accessor_class_list.gperf"
{"divdouble", &grib_accessor_class_divdouble},
{""},
#line 174 "accessor_class_list.gperf"
#line 175 "accessor_class_list.gperf"
{"sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal},
#line 99 "accessor_class_list.gperf"
{"g2_mars_labeling", &grib_accessor_class_g2_mars_labeling},
#line 78 "accessor_class_list.gperf"
{"element", &grib_accessor_class_element},
#line 159 "accessor_class_list.gperf"
#line 160 "accessor_class_list.gperf"
{"padtomultiple", &grib_accessor_class_padtomultiple},
#line 127 "accessor_class_list.gperf"
{"latitudes", &grib_accessor_class_latitudes},
#line 163 "accessor_class_list.gperf"
#line 164 "accessor_class_list.gperf"
{"rdbtime_guess_date", &grib_accessor_class_rdbtime_guess_date},
{""}, {""}, {""},
#line 193 "accessor_class_list.gperf"
#line 194 "accessor_class_list.gperf"
{"to_string", &grib_accessor_class_to_string},
#line 132 "accessor_class_list.gperf"
{"long", &grib_accessor_class_long},
@ -348,20 +348,20 @@ static const struct accessor_class_hash classes[] =
{""},
#line 28 "accessor_class_list.gperf"
{"bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors},
#line 160 "accessor_class_list.gperf"
#line 161 "accessor_class_list.gperf"
{"position", &grib_accessor_class_position},
{""}, {""}, {""},
#line 17 "accessor_class_list.gperf"
{"blob", &grib_accessor_class_blob},
#line 109 "accessor_class_list.gperf"
{"gaussian_grid_name", &grib_accessor_class_gaussian_grid_name},
#line 196 "accessor_class_list.gperf"
#line 197 "accessor_class_list.gperf"
{"trim", &grib_accessor_class_trim},
{""}, {""},
#line 119 "accessor_class_list.gperf"
{"ibmfloat", &grib_accessor_class_ibmfloat},
{""}, {""},
#line 194 "accessor_class_list.gperf"
#line 195 "accessor_class_list.gperf"
{"transient", &grib_accessor_class_transient},
#line 55 "accessor_class_list.gperf"
{"data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing},
@ -370,15 +370,15 @@ static const struct accessor_class_hash classes[] =
{"data_g1simple_packing", &grib_accessor_class_data_g1simple_packing},
#line 49 "accessor_class_list.gperf"
{"data_g1complex_packing", &grib_accessor_class_data_g1complex_packing},
#line 165 "accessor_class_list.gperf"
#line 166 "accessor_class_list.gperf"
{"round", &grib_accessor_class_round},
#line 195 "accessor_class_list.gperf"
#line 196 "accessor_class_list.gperf"
{"transient_darray", &grib_accessor_class_transient_darray},
#line 18 "accessor_class_list.gperf"
{"budgdate", &grib_accessor_class_budgdate},
#line 209 "accessor_class_list.gperf"
#line 210 "accessor_class_list.gperf"
{"values", &grib_accessor_class_values},
#line 143 "accessor_class_list.gperf"
#line 144 "accessor_class_list.gperf"
{"number_of_coded_values", &grib_accessor_class_number_of_coded_values},
#line 126 "accessor_class_list.gperf"
{"label", &grib_accessor_class_label},
@ -386,30 +386,30 @@ static const struct accessor_class_hash classes[] =
#line 38 "accessor_class_list.gperf"
{"concept", &grib_accessor_class_concept},
{""},
#line 182 "accessor_class_list.gperf"
#line 183 "accessor_class_list.gperf"
{"spectral_truncation", &grib_accessor_class_spectral_truncation},
{""}, {""},
#line 83 "accessor_class_list.gperf"
{"g1_message_length", &grib_accessor_class_g1_message_length},
#line 183 "accessor_class_list.gperf"
#line 184 "accessor_class_list.gperf"
{"sprintf", &grib_accessor_class_sprintf},
#line 189 "accessor_class_list.gperf"
#line 190 "accessor_class_list.gperf"
{"suppressed", &grib_accessor_class_suppressed},
{""},
#line 212 "accessor_class_list.gperf"
#line 213 "accessor_class_list.gperf"
{"when", &grib_accessor_class_when},
{""}, {""},
#line 179 "accessor_class_list.gperf"
#line 180 "accessor_class_list.gperf"
{"smart_table", &grib_accessor_class_smart_table},
{""},
#line 39 "accessor_class_list.gperf"
{"constant", &grib_accessor_class_constant},
{""}, {""},
#line 161 "accessor_class_list.gperf"
#line 162 "accessor_class_list.gperf"
{"proj_string", &grib_accessor_class_proj_string},
#line 149 "accessor_class_list.gperf"
#line 150 "accessor_class_list.gperf"
{"octet_number", &grib_accessor_class_octet_number},
#line 180 "accessor_class_list.gperf"
#line 181 "accessor_class_list.gperf"
{"smart_table_column", &grib_accessor_class_smart_table_column},
{""},
#line 135 "accessor_class_list.gperf"
@ -426,7 +426,7 @@ static const struct accessor_class_hash classes[] =
{"data_sh_unpacked", &grib_accessor_class_data_sh_unpacked},
#line 27 "accessor_class_list.gperf"
{"bufr_string_values", &grib_accessor_class_bufr_string_values},
#line 197 "accessor_class_list.gperf"
#line 198 "accessor_class_list.gperf"
{"uint16", &grib_accessor_class_uint16},
{""}, {""},
#line 71 "accessor_class_list.gperf"
@ -439,26 +439,27 @@ static const struct accessor_class_hash classes[] =
{""},
#line 54 "accessor_class_list.gperf"
{"data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap},
#line 191 "accessor_class_list.gperf"
#line 192 "accessor_class_list.gperf"
{"to_double", &grib_accessor_class_to_double},
#line 101 "accessor_class_list.gperf"
{"g2bitmap_present", &grib_accessor_class_g2bitmap_present},
#line 120 "accessor_class_list.gperf"
{"ieeefloat", &grib_accessor_class_ieeefloat},
#line 150 "accessor_class_list.gperf"
#line 151 "accessor_class_list.gperf"
{"offset_file", &grib_accessor_class_offset_file},
#line 207 "accessor_class_list.gperf"
{"validity_date", &grib_accessor_class_validity_date},
#line 208 "accessor_class_list.gperf"
{"validity_date", &grib_accessor_class_validity_date},
#line 209 "accessor_class_list.gperf"
{"validity_time", &grib_accessor_class_validity_time},
{""},
#line 130 "accessor_class_list.gperf"
{"library_version", &grib_accessor_class_library_version},
#line 211 "accessor_class_list.gperf"
#line 212 "accessor_class_list.gperf"
{"vector", &grib_accessor_class_vector},
#line 84 "accessor_class_list.gperf"
{"g1_section4_length", &grib_accessor_class_g1_section4_length},
{""},
#line 141 "accessor_class_list.gperf"
{"multdouble", &grib_accessor_class_multdouble},
#line 52 "accessor_class_list.gperf"
{"data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing},
{""}, {""},
@ -467,7 +468,7 @@ static const struct accessor_class_hash classes[] =
{""},
#line 24 "accessor_class_list.gperf"
{"bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets},
#line 158 "accessor_class_list.gperf"
#line 159 "accessor_class_list.gperf"
{"padtoeven", &grib_accessor_class_padtoeven},
#line 50 "accessor_class_list.gperf"
{"data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing},
@ -483,7 +484,7 @@ static const struct accessor_class_hash classes[] =
#line 21 "accessor_class_list.gperf"
{"bufr_elements_table", &grib_accessor_class_bufr_elements_table},
{""}, {""}, {""}, {""},
#line 153 "accessor_class_list.gperf"
#line 154 "accessor_class_list.gperf"
{"pack_bufr_values", &grib_accessor_class_pack_bufr_values},
#line 35 "accessor_class_list.gperf"
{"codetable", &grib_accessor_class_codetable},
@ -495,7 +496,7 @@ static const struct accessor_class_hash classes[] =
{""},
#line 88 "accessor_class_list.gperf"
{"g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly},
#line 146 "accessor_class_list.gperf"
#line 147 "accessor_class_list.gperf"
{"number_of_values", &grib_accessor_class_number_of_values},
{""},
#line 116 "accessor_class_list.gperf"
@ -503,26 +504,26 @@ static const struct accessor_class_hash classes[] =
{""},
#line 33 "accessor_class_list.gperf"
{"closest_date", &grib_accessor_class_closest_date},
#line 152 "accessor_class_list.gperf"
#line 153 "accessor_class_list.gperf"
{"optimal_step_units", &grib_accessor_class_optimal_step_units},
{""},
#line 210 "accessor_class_list.gperf"
#line 211 "accessor_class_list.gperf"
{"variable", &grib_accessor_class_variable},
#line 133 "accessor_class_list.gperf"
{"long_vector", &grib_accessor_class_long_vector},
#line 167 "accessor_class_list.gperf"
#line 168 "accessor_class_list.gperf"
{"scale_values", &grib_accessor_class_scale_values},
{""}, {""}, {""},
#line 128 "accessor_class_list.gperf"
{"latlon_increment", &grib_accessor_class_latlon_increment},
{""}, {""}, {""},
#line 147 "accessor_class_list.gperf"
#line 148 "accessor_class_list.gperf"
{"number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing},
{""},
#line 79 "accessor_class_list.gperf"
{"evaluate", &grib_accessor_class_evaluate},
{""}, {""}, {""}, {""}, {""},
#line 151 "accessor_class_list.gperf"
#line 152 "accessor_class_list.gperf"
{"offset_values", &grib_accessor_class_offset_values},
#line 69 "accessor_class_list.gperf"
{"data_sh_packed", &grib_accessor_class_data_sh_packed},
@ -535,7 +536,7 @@ static const struct accessor_class_hash classes[] =
{""}, {""},
#line 41 "accessor_class_list.gperf"
{"count_missing", &grib_accessor_class_count_missing},
#line 204 "accessor_class_list.gperf"
#line 205 "accessor_class_list.gperf"
{"unpack_bufr_values", &grib_accessor_class_unpack_bufr_values},
{""}, {""},
#line 121 "accessor_class_list.gperf"
@ -569,7 +570,7 @@ static const struct accessor_class_hash classes[] =
#line 31 "accessor_class_list.gperf"
{"change_scanning_direction", &grib_accessor_class_change_scanning_direction},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 148 "accessor_class_list.gperf"
#line 149 "accessor_class_list.gperf"
{"octahedral_gaussian", &grib_accessor_class_octahedral_gaussian},
#line 10 "accessor_class_list.gperf"
{"abstract_long_vector", &grib_accessor_class_abstract_long_vector},
@ -600,7 +601,7 @@ static const struct accessor_class_hash classes[] =
#line 87 "accessor_class_list.gperf"
{"g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date},
{""}, {""}, {""}, {""}, {""},
#line 164 "accessor_class_list.gperf"
#line 165 "accessor_class_list.gperf"
{"reference_value_error", &grib_accessor_class_reference_value_error},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
@ -621,11 +622,11 @@ static const struct accessor_class_hash classes[] =
};
static const struct accessor_class_hash* grib_accessor_classes_hash(const char *str, size_t len)
{
unsigned int key = grib_accessor_classes_get_id (str, len);
{
unsigned int key = grib_accessor_classes_get_id (str, len);
#ifdef DEBUG
{
{
const char *s;
Assert( len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH );
Assert( key <= MAX_HASH_VALUE );
@ -634,5 +635,5 @@ static const struct accessor_class_hash* grib_accessor_classes_hash(const char *
}
#endif
return &classes[key];
return &classes[key];
}

View File

@ -130,6 +130,7 @@
{ "md5", &grib_accessor_class_md5, },
{ "message", &grib_accessor_class_message, },
{ "message_copy", &grib_accessor_class_message_copy, },
{ "multdouble", &grib_accessor_class_multdouble, },
{ "nearest", &grib_accessor_class_nearest, },
{ "non_alpha", &grib_accessor_class_non_alpha, },
{ "number_of_coded_values", &grib_accessor_class_number_of_coded_values, },

View File

@ -131,6 +131,7 @@ mars_step, &grib_accessor_class_mars_step
md5, &grib_accessor_class_md5
message, &grib_accessor_class_message
message_copy, &grib_accessor_class_message_copy
multdouble, &grib_accessor_class_multdouble
nearest, &grib_accessor_class_nearest
non_alpha, &grib_accessor_class_non_alpha
number_of_coded_values, &grib_accessor_class_number_of_coded_values

View File

@ -171,20 +171,6 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
if (!(a)) codes_assertion_failed(#a, __FILE__, __LINE__); \
} while (0)
#ifdef __gnu_hurd__
#define COMPILE_TIME_ASSERT(condition) \
extern int compile_time_assert[!!(condition)-1]
#else
/* Compile time assertion - Thanks to Ralf Holly */
#define COMPILE_TIME_ASSERT(condition) \
do { \
enum \
{ \
assert_static__ = 1 / (condition) \
}; \
} while (0)
#endif
#ifdef DEBUG
#define DEBUG_ASSERT(a) Assert(a)
#define DEBUG_ASSERT_ACCESS(array, index, size) \

View File

@ -408,11 +408,10 @@ static void dump_label(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
const char* secstr = "section";
int len = 0;
const char* secstr = "section";
grib_dumper_serialize* self = (grib_dumper_serialize*)d;
len = strlen(secstr);
size_t len = strlen(secstr);
if (a->name[0] == '_') {
grib_dump_accessors_block(d, block);

View File

@ -19,8 +19,7 @@ int grib_expression_native_type(grib_handle* h, grib_expression* g)
c = c->super ? *(c->super) : NULL;
}
if (g->cclass)
grib_context_log(h->context, GRIB_LOG_ERROR, "No native_type() in %s", g->cclass->name);
Assert(1 == 0);
grib_context_log(h->context, GRIB_LOG_FATAL, "%s: No native_type() in %s", __func__, g->cclass->name);
return 0;
}
@ -55,7 +54,7 @@ const char* grib_expression_evaluate_string(grib_handle* h, grib_expression* g,
c = c->super ? *(c->super) : NULL;
}
if (g->cclass)
grib_context_log(h->context, GRIB_LOG_ERROR, "No evaluate_string() in %s", g->cclass->name);
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: No evaluate_string() in %s", __func__, g->cclass->name);
*err = GRIB_INVALID_TYPE;
return 0;
@ -69,8 +68,9 @@ const char* grib_expression_get_name(grib_expression* g)
return c->get_name(g);
c = c->super ? *(c->super) : NULL;
}
if (g->cclass) printf("No expression_get_name() in %s\n", g->cclass->name);
Assert(1 == 0);
if (g->cclass) {
grib_context_log(grib_context_get_default(), GRIB_LOG_FATAL, "%s: No get_name() in %s", __func__, g->cclass->name);
}
return 0;
}
@ -84,7 +84,6 @@ void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f
}
c = c->super ? *(c->super) : NULL;
}
Assert(1 == 0);
}
void grib_expression_free(grib_context* ctx, grib_expression* g)
@ -110,43 +109,37 @@ void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer)
}
c = c->super ? *(c->super) : NULL;
}
Assert(1 == 0);
}
/*----------------------------------------*/
int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v)
{
char buffer[1024];
int ret = 0;
size_t size = sizeof(buffer);
switch (v->type = grib_expression_native_type(h, g)) {
case GRIB_TYPE_LONG:
return grib_expression_evaluate_long(h, g, &v->long_value);
break;
case GRIB_TYPE_DOUBLE:
return grib_expression_evaluate_double(h, g, &v->double_value);
break;
case GRIB_TYPE_STRING:
v->string_value = grib_expression_evaluate_string(h, g, buffer, &size, &ret);
if (ret != GRIB_SUCCESS) {
grib_context_log(h->context, GRIB_LOG_ERROR,
"grib_expression_set_value: unable to evaluate %s as string",
grib_expression_get_name(g));
return ret;
}
Assert(v->string_value != buffer);
Assert(v->string_value);
break;
default:
Assert(1 == 0);
break;
}
return 0;
}
// int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v)
// {
// char buffer[1024];
// int ret = 0;
// size_t size = sizeof(buffer);
// switch (v->type = grib_expression_native_type(h, g)) {
// case GRIB_TYPE_LONG:
// return grib_expression_evaluate_long(h, g, &v->long_value);
// break;
// case GRIB_TYPE_DOUBLE:
// return grib_expression_evaluate_double(h, g, &v->double_value);
// break;
// case GRIB_TYPE_STRING:
// v->string_value = grib_expression_evaluate_string(h, g, buffer, &size, &ret);
// if (ret != GRIB_SUCCESS) {
// grib_context_log(h->context, GRIB_LOG_ERROR,
// "grib_expression_set_value: unable to evaluate %s as string",
// grib_expression_get_name(g));
// return ret;
// }
// Assert(v->string_value != buffer);
// Assert(v->string_value);
// break;
// default:
// Assert(!"grib_expression_set_value");
// break;
// }
// return 0;
// }
/*----------------------------------------*/
grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n)

View File

@ -92,25 +92,25 @@ static void init_class(grib_expression_class* c)
static const char* get_name(grib_expression* g)
{
grib_expression_accessor* e = (grib_expression_accessor*)g;
const grib_expression_accessor* e = (grib_expression_accessor*)g;
return e->name;
}
static int evaluate_long(grib_expression* g, grib_handle* h, long* result)
{
grib_expression_accessor* e = (grib_expression_accessor*)g;
const grib_expression_accessor* e = (grib_expression_accessor*)g;
return grib_get_long_internal(h, e->name, result);
}
static int evaluate_double(grib_expression* g, grib_handle* h, double* result)
{
grib_expression_accessor* e = (grib_expression_accessor*)g;
const grib_expression_accessor* e = (grib_expression_accessor*)g;
return grib_get_double_internal(h, e->name, result);
}
static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err)
{
grib_expression_accessor* e = (grib_expression_accessor*)g;
const grib_expression_accessor* e = (grib_expression_accessor*)g;
char mybuf[1024] = {0,};
long start = e->start;
if (e->length > sizeof(mybuf)) {
@ -141,7 +141,7 @@ static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, siz
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_accessor* e = (grib_expression_accessor*)g;
const grib_expression_accessor* e = (grib_expression_accessor*)g;
printf("access('%s", e->name);
if (f) {
long s = 0;
@ -159,8 +159,8 @@ static void destroy(grib_context* c, grib_expression* g)
static void add_dependency(grib_expression* g, grib_accessor* observer)
{
grib_expression_accessor* e = (grib_expression_accessor*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name);
const grib_expression_accessor* e = (grib_expression_accessor*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name);
if (!observed) {
/* grib_context_log(observer->context, GRIB_LOG_ERROR, */

View File

@ -8,11 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/**************************************
* Enrico Fucile
**************************************/
#include "grib_api_internal.h"
/*
@ -89,7 +84,7 @@ static void init_class(grib_expression_class* c)
static const char* get_name(grib_expression* g)
{
grib_expression_column* e = (grib_expression_column*)g;
const grib_expression_column* e = (grib_expression_column*)g;
return e->name;
}
@ -131,7 +126,6 @@ static void destroy(grib_context* c, grib_expression* g)
grib_context_free_persistent(c, e->name);
}
grib_expression* new_column_expression(grib_context* c, const char* name)
{
grib_expression_column* e = grib_context_malloc_clear_persistent(c, sizeof(grib_expression_column));

View File

@ -8,11 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/**************************************
* Enrico Fucile
**************************************/
#include "grib_api_internal.h"
/*
@ -85,13 +80,13 @@ static void init_class(grib_expression_class* c)
static long evaluate(grib_expression* g, grib_handle* h)
{
grib_expression_constant* e = (grib_expression_constant*)g;
const grib_expression_constant* e = (grib_expression_constant*)g;
return e->value;
}
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_constant* e = (grib_expression_constant*)g;
const grib_expression_constant* e = (grib_expression_constant*)g;
printf("constant(%ld)", e->value);
}
@ -100,7 +95,6 @@ static void destroy(grib_context* c, grib_expression* g)
/* grib_expression_constant* e = (grib_expression_constant*)g; */
}
static void add_dependency(grib_expression* g, grib_accessor* observer)
{
/* grib_expression_constant* e = (grib_expression_constant*)g; */

View File

@ -84,21 +84,21 @@ static void init_class(grib_expression_class* c)
static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
{
grib_expression_double* e = (grib_expression_double*)g;
*lres = e->value;
const grib_expression_double* e = (grib_expression_double*)g;
*lres = e->value;
return GRIB_SUCCESS;
}
static int evaluate_double(grib_expression* g, grib_handle* h, double* dres)
{
grib_expression_double* e = (grib_expression_double*)g;
*dres = e->value;
const grib_expression_double* e = (grib_expression_double*)g;
*dres = e->value;
return GRIB_SUCCESS;
}
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_double* e = (grib_expression_double*)g;
const grib_expression_double* e = (grib_expression_double*)g;
printf("double(%g)", e->value);
}
@ -115,8 +115,8 @@ static void add_dependency(grib_expression* g, grib_accessor* observer)
grib_expression* new_double_expression(grib_context* c, double value)
{
grib_expression_double* e = (grib_expression_double*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_double));
e->base.cclass = grib_expression_class_double;
e->value = value;
e->base.cclass = grib_expression_class_double;
e->value = value;
return (grib_expression*)e;
}

View File

@ -134,7 +134,7 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
const char* p = grib_arguments_get_name(h, e->args, 0);
if (p) {
grib_accessor* a = grib_find_accessor(h, p);
const grib_accessor* a = grib_find_accessor(h, p);
*lres = a != NULL ? 1 : 0;
return GRIB_SUCCESS;
}
@ -149,7 +149,7 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
// 2. Cannot deal with string values
const char* p = grib_arguments_get_name(h, e->args, 0);
if (p) {
char* env = getenv(p);
const char* env = getenv(p);
if (env) {
long lval = 0;
if (string_to_long(env, &lval, 1) == GRIB_SUCCESS) {
@ -177,7 +177,7 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_functor* e = (grib_expression_functor*)g;
const grib_expression_functor* e = (grib_expression_functor*)g;
printf("%s(", e->name);
// grib_expression_print(c,e->args,f);
printf(")");

View File

@ -94,10 +94,10 @@ static grib_trie* load_dictionary(grib_context* c, grib_expression* e, int* err)
char* filename = NULL;
char line[1024] = {0,};
char key[1024] = {0,};
char* list = 0;
char* list = 0;
grib_trie* dictionary = NULL;
FILE* f = NULL;
int i = 0;
FILE* f = NULL;
int i = 0;
*err = GRIB_SUCCESS;
@ -148,15 +148,15 @@ static grib_trie* load_dictionary(grib_context* c, grib_expression* e, int* err)
static const char* get_name(grib_expression* g)
{
grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
const grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
return e->key;
}
static int evaluate_long(grib_expression* g, grib_handle* h, long* result)
{
grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
int err = 0;
char mybuf[1024] = {0,};
const grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
int err = 0;
char mybuf[1024] = {0,};
size_t size = 1024;
grib_trie* dict = load_dictionary(h->context, g, &err);
@ -213,7 +213,7 @@ static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, siz
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
const grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
printf("access('%s", e->key);
if (f) {
long s = 0;
@ -239,8 +239,8 @@ static int native_type(grib_expression* g, grib_handle* h)
static void add_dependency(grib_expression* g, grib_accessor* observer)
{
grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->key);
const grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->key);
if (!observed) {
/* grib_context_log(observer->context, GRIB_LOG_ERROR, */

View File

@ -147,15 +147,15 @@ static grib_trie* load_list(grib_context* c, grib_expression* e, int* err)
static const char* get_name(grib_expression* g)
{
grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
return e->name;
}
static int evaluate_long(grib_expression* g, grib_handle* h, long* result)
{
grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
int err = 0;
char mybuf[1024] = {0,};
const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
int err = 0;
char mybuf[1024] = {0,};
size_t size = 1024;
grib_trie* list = load_list(h->context, g, &err);
@ -178,24 +178,20 @@ static int evaluate_double(grib_expression* g, grib_handle* h, double* result)
// int err = 0;
// char mybuf[1024] = {0,};
// size_t size = 1024;
// grib_trie* list = load_list(h->context, g, &err);
// if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS)
// return err;
// if (grib_trie_get(list, mybuf))
// *result = 1;
// else
// *result = 0;
// return err;
}
static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err)
{
grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
char mybuf[1024] = {0,};
const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
char mybuf[1024] = {0,};
size_t sizebuf = 1024;
long result;
@ -216,7 +212,7 @@ static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, siz
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
printf("access('%s", e->name);
if (f) {
long s = 0;
@ -232,8 +228,8 @@ static void destroy(grib_context* c, grib_expression* g)
static void add_dependency(grib_expression* g, grib_accessor* observer)
{
grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name);
const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name);
if (!observed) {
/* grib_context_log(observer->context, GRIB_LOG_ERROR, */
@ -257,7 +253,7 @@ grib_expression* new_is_in_list_expression(grib_context* c, const char* name, co
static int native_type(grib_expression* g, grib_handle* h)
{
grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
int type = 0;
int type = 0;
int err;
if ((err = grib_get_native_type(h, e->name, &type)) != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_ERROR,

View File

@ -92,15 +92,15 @@ static void init_class(grib_expression_class* c)
static const char* get_name(grib_expression* g)
{
grib_expression_is_integer* e = (grib_expression_is_integer*)g;
const grib_expression_is_integer* e = (grib_expression_is_integer*)g;
return e->name;
}
static int evaluate_long(grib_expression* g, grib_handle* h, long* result)
{
grib_expression_is_integer* e = (grib_expression_is_integer*)g;
int err = 0;
char mybuf[1024] = {0,};
int err = 0;
char mybuf[1024] = {0,};
size_t size = 1024;
char* p = 0;
long val = 0;
@ -127,10 +127,10 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result)
static int evaluate_double(grib_expression* g, grib_handle* h, double* result)
{
int err = 0;
int err = 0;
long lresult = 0;
err = evaluate_long(g, h, &lresult);
err = evaluate_long(g, h, &lresult);
*result = lresult;
return err;
}
@ -174,7 +174,7 @@ static void destroy(grib_context* c, grib_expression* g)
static void add_dependency(grib_expression* g, grib_accessor* observer)
{
grib_expression_is_integer* e = (grib_expression_is_integer*)g;
const grib_expression_is_integer* e = (grib_expression_is_integer*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name);
if (!observed) {

View File

@ -92,15 +92,15 @@ static void init_class(grib_expression_class* c)
static const char* get_name(grib_expression* g)
{
grib_expression_length* e = (grib_expression_length*)g;
const grib_expression_length* e = (grib_expression_length*)g;
return e->name;
}
static int evaluate_long(grib_expression* g, grib_handle* h, long* result)
{
grib_expression_length* e = (grib_expression_length*)g;
int err = 0;
char mybuf[1024] = {0,};
const grib_expression_length* e = (grib_expression_length*)g;
int err = 0;
char mybuf[1024] = {0,};
size_t size = 1024;
if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS)
return err;
@ -111,10 +111,10 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result)
static int evaluate_double(grib_expression* g, grib_handle* h, double* result)
{
grib_expression_length* e = (grib_expression_length*)g;
char mybuf[1024] = {0,};
const grib_expression_length* e = (grib_expression_length*)g;
char mybuf[1024] = {0,};
size_t size = 1024;
int err = 0;
int err = 0;
if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS)
return err;
@ -124,8 +124,8 @@ static int evaluate_double(grib_expression* g, grib_handle* h, double* result)
static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err)
{
grib_expression_length* e = (grib_expression_length*)g;
char mybuf[1024] = {0,};
const grib_expression_length* e = (grib_expression_length*)g;
char mybuf[1024] = {0,};
Assert(buf);
if ((*err = grib_get_string_internal(h, e->name, mybuf, size)) != GRIB_SUCCESS)
return NULL;
@ -136,7 +136,7 @@ static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, siz
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_length* e = (grib_expression_length*)g;
const grib_expression_length* e = (grib_expression_length*)g;
printf("access('%s", e->name);
if (f) {
long s = 0;
@ -154,8 +154,8 @@ static void destroy(grib_context* c, grib_expression* g)
static void add_dependency(grib_expression* g, grib_accessor* observer)
{
grib_expression_length* e = (grib_expression_length*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name);
const grib_expression_length* e = (grib_expression_length*)g;
grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name);
if (!observed) {
/* grib_context_log(observer->context, GRIB_LOG_ERROR, */
@ -170,8 +170,8 @@ static void add_dependency(grib_expression* g, grib_accessor* observer)
grib_expression* new_length_expression(grib_context* c, const char* name)
{
grib_expression_length* e = (grib_expression_length*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_length));
e->base.cclass = grib_expression_class_length;
e->name = grib_context_strdup_persistent(c, name);
e->base.cclass = grib_expression_class_length;
e->name = grib_context_strdup_persistent(c, name);
return (grib_expression*)e;
}

View File

@ -84,21 +84,21 @@ static void init_class(grib_expression_class* c)
static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
{
grib_expression_long* e = (grib_expression_long*)g;
*lres = e->value;
const grib_expression_long* e = (grib_expression_long*)g;
*lres = e->value;
return GRIB_SUCCESS;
}
static int evaluate_double(grib_expression* g, grib_handle* h, double* dres)
{
grib_expression_long* e = (grib_expression_long*)g;
*dres = e->value;
const grib_expression_long* e = (grib_expression_long*)g;
*dres = e->value;
return GRIB_SUCCESS;
}
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_long* e = (grib_expression_long*)g;
const grib_expression_long* e = (grib_expression_long*)g;
printf("long(%ld)", e->value);
}
@ -115,8 +115,8 @@ static void add_dependency(grib_expression* g, grib_accessor* observer)
grib_expression* new_long_expression(grib_context* c, long value)
{
grib_expression_long* e = (grib_expression_long*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_long));
e->base.cclass = grib_expression_class_long;
e->value = value;
e->base.cclass = grib_expression_class_long;
e->value = value;
return (grib_expression*)e;
}

View File

@ -82,14 +82,14 @@ static void init_class(grib_expression_class* c)
static const char* evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err)
{
grib_expression_string* e = (grib_expression_string*)g;
*err = 0;
const grib_expression_string* e = (grib_expression_string*)g;
*err = 0;
return e->value;
}
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_string* e = (grib_expression_string*)g;
const grib_expression_string* e = (grib_expression_string*)g;
printf("string('%s')", e->value);
}

View File

@ -82,14 +82,14 @@ static void init_class(grib_expression_class* c)
static const char* evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err)
{
grib_expression_sub_string* e = (grib_expression_sub_string*)g;
*err = 0;
const grib_expression_sub_string* e = (grib_expression_sub_string*)g;
*err = 0;
return e->value;
}
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_sub_string* e = (grib_expression_sub_string*)g;
const grib_expression_sub_string* e = (grib_expression_sub_string*)g;
printf("string('%s')", e->value);
}

View File

@ -375,7 +375,7 @@ grib_handle* grib_handle_clone_headers_only(const grib_handle* h)
const int sections_to_copy = GRIB_SECTION_PRODUCT | GRIB_SECTION_LOCAL | GRIB_SECTION_GRID;
result = grib_util_sections_copy((grib_handle*)h, h_sample, sections_to_copy, &err);
if (!result || err) {
grib_context_log(c, GRIB_LOG_ERROR, "Failed to create headers_only clone: Unable to copy sections");
grib_context_log(c, GRIB_LOG_ERROR, "%s failed: Unable to copy sections (%s)", __func__, grib_get_error_message(err));
grib_handle_delete(h_sample);
return NULL;
}

View File

@ -341,8 +341,8 @@ int grib_nearest_find_generic(
double lat1 = 0, lat2 = 0; /* inlat will be between these */
const double LAT_DELTA = 10.0; /* in degrees */
*out_lons_count = nvalues; /* Maybe overestimate but safe */
*out_lats_count = nvalues;
*out_lons_count = (int)nvalues; /* Maybe overestimate but safe */
*out_lats_count = (int)nvalues;
if (*out_lats)
grib_context_free(nearest->context, *out_lats);

View File

@ -409,7 +409,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
if (values) { /* ECC-499 */
grib_get_double_element_internal(h, self->values_key, self->k[kk], &(values[kk]));
}
indexes[kk] = self->k[kk];
indexes[kk] = (int)self->k[kk];
kk++;
}
}

View File

@ -490,7 +490,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
grib_context_log(h->context, GRIB_LOG_ERROR, "grib_nearest_reduced: Unable to compute index. Value too large");
return GRIB_OUT_OF_RANGE;
} else {
indexes[kk] = self->k[kk];
indexes[kk] = (int)self->k[kk];
}
kk++;
}

View File

@ -351,7 +351,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
grib_context_log(h->context, GRIB_LOG_ERROR, "grib_nearest_regular: Unable to compute index. Value too large");
return GRIB_OUT_OF_RANGE;
} else {
indexes[kk] = self->k[kk];
indexes[kk] = (int)self->k[kk];
}
kk++;
}

View File

@ -485,7 +485,7 @@ int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* da
grib_oarray_push(t->context, t->objs, data);
/* grib_trie_with_rank_insert_in_list(t,data); */
GRIB_MUTEX_UNLOCK(&mutex);
return t->objs->n;
return (int)t->objs->n;
}
/*

View File

@ -897,6 +897,9 @@ static int get_grib_sample_name(grib_handle* h, long editionNumber,
case GRIB_UTIL_GRID_SPEC_HEALPIX:
snprintf(sample_name, sample_name_len, "GRIB%ld", editionNumber);
break;
case GRIB_UTIL_GRID_SPEC_REDUCED_LL:
snprintf(sample_name, sample_name_len, "%s_sfc_grib%ld", grid_type, editionNumber);
break;
default:
snprintf(sample_name, sample_name_len, "%s_pl_grib%ld", grid_type, editionNumber);
}

View File

@ -32,6 +32,7 @@ list(APPEND test_c_bins
gauss_sub
grib_nearest_test
grib_util_set_spec
grib_util_set_spec2
grib_check_param_concepts
grib_local_MeteoFrance
grib_2nd_order_numValues
@ -356,6 +357,7 @@ if( HAVE_BUILD_TOOLS )
endif()
if( ENABLE_EXTRA_TESTS )
list(APPEND tests_extra grib_util_set_spec)
list(APPEND tests_extra grib_util_set_spec2)
list(APPEND tests_extra grib_padding)
list(APPEND tests_extra grib_tigge_conversions1)
list(APPEND tests_extra grib_tigge_conversions2)
@ -443,20 +445,20 @@ if( HAVE_BUILD_TOOLS )
TYPE SCRIPT
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_encode_pthreads.sh )
foreach( test grib_threads_ecc-604 grib_threads_ecc-604-encode bufr_threads_ecc-604 )
foreach( test grib_encode_pthreads2 grib_threads_ecc-604-encode bufr_encode_pthreads )
ecbuild_add_executable( TARGET ${test}
NOINSTALL
SOURCES ${test}.cc
LIBS eccodes ${CMAKE_THREAD_LIBS_INIT} )
endforeach()
ecbuild_add_test( TARGET eccodes_t_grib_threads_ecc-604
ecbuild_add_test( TARGET eccodes_t_grib_encode_pthreads2
TYPE SCRIPT
TEST_DEPENDS eccodes_download_gribs
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_threads_ecc-604.sh )
ecbuild_add_test( TARGET eccodes_t_bufr_threads_ecc-604
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_encode_pthreads2.sh )
ecbuild_add_test( TARGET eccodes_t_bufr_encode_pthreads
TYPE SCRIPT
TEST_DEPENDS eccodes_download_bufrs
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_threads_ecc-604.sh )
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_encode_pthreads.sh )
endif()
if( NOT ECCODES_ON_WINDOWS )

View File

@ -351,6 +351,31 @@ set -e
[ $status -ne 0 ]
grep -q "unreadable message" $fLog
# Options
# ----------
f1="aaen_55.bufr"
f2="aaen_55.bufr"
set +e
${tools_dir}/bufr_compare -H -c edition $f1 $f2 > $fLog 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "options are incompatible" $fLog
set +e
${tools_dir}/bufr_compare -a edition $f1 $f2 > $fLog 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "a option requires -c option" $fLog
set +e
${tools_dir}/bufr_compare nosuchfile $f1 > $fLog 2>&1
status=$?
set -e
[ $status -ne 0 ]
# Clean up
# -------------

View File

@ -11,15 +11,15 @@
. ./include.ctest.sh
set -u
label="bufr_ecc-1028_test"
tempFilter=temp.$label.filt
tempFilt=temp.$label.filt
tempError=temp.$label.err
sample_bufr4=$ECCODES_SAMPLES_PATH/BUFR4.tmpl
# Incorrect replication. Encoding should fail
echo "set unexpandedDescriptors={ 101000, 31002 }; write;" > $tempFilter
echo "set unexpandedDescriptors={ 101000, 31002 }; write;" > $tempFilt
set +e
${tools_dir}/bufr_filter $tempFilter $sample_bufr4 2>$tempError
${tools_dir}/bufr_filter $tempFilt $sample_bufr4 2>$tempError
status=$?
set -e
[ $status -ne 0 ]
@ -27,4 +27,4 @@ set -e
grep -q "Delayed replication: 101000: expected 1 but only found 0 elements" $tempError
rm -f $tempFilter $tempError
rm -f $tempFilt $tempError

View File

@ -10,13 +10,13 @@
. ./include.ctest.sh
label="bufr_threads_ecc-604"
label="bufr_encode_pthreads_test"
temp_dir=tempdir.${label}
NUM_THREADS=3
NUM_ITER=5
OUTPUT=output
PROG="${test_dir}/bufr_threads_ecc-604"
PROG="${test_dir}/bufr_encode_pthreads"
validate()
{

View File

@ -13,31 +13,6 @@
#include <assert.h>
#define MAX_KEYS 100
#if 0
int main(int argc, char* argv[])
{
char *filename;
int err = 0;
int num_messages = 0, i =0;
off_t* offsets = NULL;
codes_context* c = codes_context_get_default();
const int strict_mode = 1;
/* Usage: prog file */
assert(argc == 2);
filename = argv[1];
err = codes_extract_offsets_malloc(c, filename, PRODUCT_GRIB, &offsets, &num_messages, strict_mode);
assert(!err);
for (i = 0; i < num_messages; ++i) {
printf("Message #%d: %lu\n", i, offsets[i]);
}
free(offsets);
return 0;
}
#endif
#if 1
int main(int argc, char* argv[])
{
char *filename, *keys;
@ -85,4 +60,3 @@ int main(int argc, char* argv[])
return 0;
}
#endif

View File

@ -17,6 +17,8 @@ if [ ! -d "$ECCODES_DEFINITION_PATH" ]; then
fi
temp=temp.$label.grib2
tempFilt=temp.$label.filt
tempText=temp.$label.txt
sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
tables_dir="$ECCODES_DEFINITION_PATH/grib2/tables"
@ -34,7 +36,6 @@ fi
cd $test_dir
# Check table 1.0
# Check it has the latest with description matching "Version implemented on DD MM YYYY"
tempText=temp.$label.txt
${tools_dir}/grib_set -s tablesVersion=$latest $sample2 $temp
${tools_dir}/grib_dump -O -p tablesVersion $temp > $tempText
grep -q "Version implemented on" $tempText
@ -50,4 +51,18 @@ if [ "$tablesVersion" != "$latestOfficial" ]; then
exit 1
fi
rm -f $temp
# Library and definitions versions
cat >$tempFilt<<EOF
transient _iv = 31;
meta _checkit check_internal_version(_iv);
print "checkit=[_checkit]";
EOF
set +e
${tools_dir}/grib_filter $tempFilt $sample2 > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
cat $tempText
grep -q "Definition files version .* is greater than engine version" $tempText
rm -f $tempFilt $temp $tempText

View File

@ -45,6 +45,12 @@ grib_check_key_equals $temp scaleFactorOfLowerWavePeriodLimit,scaledValueOfLower
${tools_dir}/grib_set -s tablesVersion=$latest,productDefinitionTemplateNumber=104 $sample2 $temp
grib_check_key_equals $temp scaleFactorOfLowerWavePeriodLimit,scaledValueOfLowerWavePeriodLimit,perturbationNumber 'MISSING MISSING 0'
${tools_dir}/grib_set -s \
tablesVersion=$latest,productDefinitionTemplateNumber=108,scaleFactorOfFirstWavelength=9,scaledValueOfFirstWavelength=12 \
$sample2 $temp
grib_check_key_equals $temp firstWavelengthInNanometres '12'
grib_check_key_equals $temp firstWavelengthInMetres '1.2e-08'
# Clean up
rm -f $tempSample $temp

View File

@ -16,7 +16,7 @@ temp_dir=tempdir.${label}
NUM_THREADS=3
NUM_ITER=10
OUTPUT=output
PROG="${test_dir}/grib_threads_ecc-604"
PROG="${test_dir}/grib_encode_pthreads2"
validate()
{

View File

@ -237,6 +237,19 @@ grib_check_key_equals $tempGrib scaleFactorOfFirstFixedSurface MISSING
grib_check_key_equals $tempGrib scaledValueOfFirstFixedSurface MISSING
echo "Test for the sum accessor"
# -------------------------------
input="${samp_dir}/reduced_gg_pl_32_grib2.tmpl"
cat >$tempFilt <<EOF
meta sum_of_pl_array sum(pl);
# Default is double
print "sum_of_pl_array =[sum_of_pl_array]";
print "sum_of_pl_array as ints=[sum_of_pl_array:i]";
print "sum_of_pl_array as strs=[sum_of_pl_array:s]";
EOF
${tools_dir}/grib_filter $tempFilt $input > $tempOut
echo "Test from_scale_factor_scaled_value"
# -----------------------------------------
input="${samp_dir}/reduced_gg_pl_32_grib2.tmpl"
@ -454,6 +467,18 @@ set -e
[ $status -ne 0 ]
grep -q "Unable to open file" $tempOut
# Signed bits
# -----------
cat >$tempFilt <<EOF
meta _sb signed_bits(widthOfWidths, numberOfGroups);
print "[_sb]";
EOF
set +e
${tools_dir}/grib_filter $tempFilt $data_dir/boustrophedonic.grib1 > $tempOut 2>&1
status=$?
set -e
[ $status -ne 0 ]
# Setting step
# -------------

View File

@ -11,7 +11,7 @@
# Define a common label for all the tmp files
label="grib_healpix_test"
tempFilter="temp.${label}.filt"
tempFilt="temp.${label}.filt"
tempGrib="temp.${label}.grib"
tempLog="temp.${label}.log"
@ -20,7 +20,7 @@ input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
latest=`${tools_dir}/grib_get -p tablesVersionLatest $input`
# Create a filter
cat > $tempFilter <<EOF
cat > $tempFilt <<EOF
set tablesVersion = $latest;
set gridType = "healpix";
set longitudeOfFirstGridPointInDegrees = 45;
@ -28,9 +28,9 @@ cat > $tempFilter <<EOF
write;
EOF
cat $tempFilter
cat $tempFilt
# Use filter on input to create a new HEALPix GRIB
${tools_dir}/grib_filter -o $tempGrib $tempFilter $input
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input
if [ ! -f "$tempGrib" ]; then
echo 'Failed to create output GRIB from filter' >&2
exit 1
@ -47,7 +47,7 @@ ${tools_dir}/grib_ls -jn geography $tempGrib
# Geoiterator
# -------------
rm -f $tempGrib
cat > $tempFilter <<EOF
cat > $tempFilt <<EOF
set tablesVersion = $latest;
set gridType = "healpix";
set longitudeOfFirstGridPointInDegrees = 45;
@ -55,13 +55,13 @@ cat > $tempFilter <<EOF
set values = {1,2,3,4,5,6,7,8,9,10,11,12}; # count=12*N*N
write;
EOF
${tools_dir}/grib_filter -o $tempGrib $tempFilter $input
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input
${tools_dir}/grib_get_data $tempGrib
val=$(${tools_dir}/grib_get -l 0,0,1 $tempGrib | tr -d ' ')
[ "$val" = 5 ]
# Check other iterator-related keys
cat > $tempFilter <<EOF
cat > $tempFilt <<EOF
print "latLonValues=[latLonValues]";
print "latitudes=[latitudes]";
print "longitudes=[longitudes]";
@ -69,7 +69,7 @@ cat > $tempFilter <<EOF
print "distinctLongitudes=[distinctLongitudes]";
EOF
${tools_dir}/grib_filter $tempFilter $tempGrib
${tools_dir}/grib_filter $tempFilt $tempGrib
# Invalid cases
# --------------
@ -89,4 +89,4 @@ grep -q "Only ring ordering is supported" $tempLog
# Clean up
rm -f $tempFilter $tempGrib $tempLog
rm -f $tempFilt $tempGrib $tempLog

View File

@ -11,14 +11,14 @@
# Define a common label for all the tmp files
label="grib_lambert_conformal_test"
tempFilter="temp.${label}.filt"
tempFilt="temp.${label}.filt"
tempGrib="temp.${label}.grib"
tempOut="temp.${label}.out"
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
# Create a filter
cat > $tempFilter <<EOF
cat > $tempFilt <<EOF
set gridType="lambert";
set numberOfDataPoints=294000;
set shapeOfTheEarth=6;
@ -37,7 +37,7 @@ cat > $tempFilter <<EOF
EOF
# Use filter on input to create a new Lambert conformal GRIB
${tools_dir}/grib_filter -o $tempGrib $tempFilter $input
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input
if [ ! -f "$tempGrib" ]; then
echo 'Failed to create output GRIB from filter' >&2
exit 1
@ -49,7 +49,7 @@ ${tools_dir}/grib_ls -l 50,0 $tempGrib
# Oblate earth
# --------------
cat > $tempFilter <<EOF
cat > $tempFilt <<EOF
set gridType="lambert";
set numberOfDataPoints=294000;
set Nx=588;
@ -68,7 +68,7 @@ cat > $tempFilter <<EOF
EOF
# Use this filter and the input GRIB to create a new GRIB
${tools_dir}/grib_filter -o $tempGrib $tempFilter $input
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input
if [ ! -f "$tempGrib" ]; then
echo 'Failed to create output GRIB from filter' >&2
exit 1
@ -83,4 +83,4 @@ ${tools_dir}/grib_ls -l 40.44,353.56 $tempGrib
# Clean up
rm -f $tempFilter $tempGrib $tempOut
rm -f $tempFilt $tempGrib $tempOut

View File

@ -12,7 +12,7 @@
# Define a common label for all the tmp files
label="grib_mercator_test"
tempOut="temp.${label}.out"
tempFilter="temp.${label}.filt"
tempFilt="temp.${label}.filt"
input=${data_dir}/mercator.grib2
grib_check_key_equals $input "gridType" "mercator"
@ -22,17 +22,17 @@ numlines=`wc -l $tempOut | awk '{print $1}'`
# Check other iterator-related keys
cat > $tempFilter <<EOF
cat > $tempFilt <<EOF
print "[latLonValues]";
print "[distinctLatitudes]";
print "[distinctLongitudes]";
EOF
${tools_dir}/grib_filter $tempFilter $input
${tools_dir}/grib_filter $tempFilt $input
# Nearest function
${tools_dir}/grib_ls -l 19,-97,1 $input > $tempOut
grep -q "Point chosen #1 index=618" $tempOut
# Clean up
rm -f $tempFilter $tempOut
rm -f $tempFilt $tempOut

View File

@ -11,7 +11,7 @@
# Define a common label for all the tmp files
label="grib_polar_stereographic_test"
tempFilter="temp.${label}.filt"
tempFilt="temp.${label}.filt"
tempGrib="temp.${label}.grib"
tempOut="temp.${label}.out"
@ -19,7 +19,7 @@ input=$ECCODES_SAMPLES_PATH/polar_stereographic_pl_grib2.tmpl
# Invoke Geoiterator
${tools_dir}/grib_get_data $input > $tempOut
# Nearest
${tools_dir}/grib_ls -l 60,0 $input
# Scanning mode
@ -27,4 +27,4 @@ ${tools_dir}/grib_get_data -s iScansNegatively=1 $input > $tempOut
# Clean up
rm -f $tempFilter $tempGrib $tempOut
rm -f $tempFilt $tempGrib $tempOut

View File

@ -11,7 +11,7 @@
# Define a common label for all the tmp files
label="grib_space_view_test"
tempFilter="temp.${label}.filt"
tempFilt="temp.${label}.filt"
tempGrib1="temp.${label}.grib1"
tempGrib2="temp.${label}.grib2"
tempOut="temp.${label}.out"
@ -20,7 +20,7 @@ tempOut="temp.${label}.out"
# GRIB2
# -----------
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
cat > $tempFilter <<EOF
cat > $tempFilt <<EOF
set gridType="space_view";
set Nx=1900;
set Ny=900;
@ -35,7 +35,7 @@ cat > $tempFilter <<EOF
EOF
# Use filter on input to create a new GRIB
${tools_dir}/grib_filter -o $tempGrib2 $tempFilter $input
${tools_dir}/grib_filter -o $tempGrib2 $tempFilt $input
if [ ! -f "$tempGrib2" ]; then
echo 'Failed to create output GRIB from filter' >&2
exit 1
@ -66,7 +66,7 @@ rm -f $tempGrib2 $tempOut
# GRIB1
# -----------
input=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
cat > $tempFilter <<EOF
cat > $tempFilt <<EOF
set gridType="space_view";
set Nx=550;
set Ny=550;
@ -77,7 +77,7 @@ cat > $tempFilter <<EOF
set Nr=6610710;
write;
EOF
${tools_dir}/grib_filter -o $tempGrib1 $tempFilter $input
${tools_dir}/grib_filter -o $tempGrib1 $tempFilt $input
${tools_dir}/grib_get_data $tempGrib1 > $tempOut
${tools_dir}/grib_set -s edition=2 $tempGrib1 $tempGrib2
@ -85,4 +85,4 @@ ${tools_dir}/grib_compare -e -b param $tempGrib1 $tempGrib2
# Clean up
rm -f $tempFilter $tempGrib1 $tempGrib2 $tempOut
rm -f $tempFilt $tempGrib1 $tempGrib2 $tempOut

View File

@ -164,6 +164,14 @@ if [ $HAVE_LIBJASPER -eq 0 ]; then
set -e
[ $status -ne 0 ]
grep -q "JasPer JPEG support not enabled" $tempDump
infile=$data_dir/sample.grib2
set +e
ECCODES_GRIB_JPEG=jasper ${tools_dir}/grib_set -rs packingType=grid_jpeg $infile $outfile1 > $tempDump 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "JasPer JPEG support not enabled" $tempDump
fi
# Clean up

View File

@ -31,10 +31,9 @@ int main(int argc, char** argv)
{
int err = 0;
long step = 0;
size_t nfiles = 0;
size_t i = 0, j = 0;
codes_fieldset* set = NULL;
const size_t max_numfiles = 100;
int nfiles = 0, i = 0, j = 0;
codes_fieldset* set = NULL;
const int max_numfiles = 100;
codes_handle* h = NULL;
char param[20] = {0,};
size_t len = 20;

View File

@ -33,4 +33,12 @@ if [ $HAVE_EXTRA_TESTS -eq 1 ]; then
[ "$numlines" = "6599681" ] # 1 + numberOfDataPoints
fi
# Regular Gaussian (no pl array)
input=${data_dir}/regular_gaussian_model_level.grib2
grib_check_key_equals $input isOctahedral 0
result=$( $tools_dir/grib_get -s Ni=missing -p isOctahedral $input )
[ $result -eq 0 ]
# Clean up
rm -f $temp

View File

@ -20,7 +20,7 @@ cd ${data_dir}
encoding=1
simple_no_bitmap=simple.grib
simple_bitmap=simple_bitmap.grib
test_filter=temp.$label.filter
tempFilt=temp.$label.filter
files_no_bitmap="gen_ext.grib \
gen_ext_boust.grib \
@ -41,11 +41,11 @@ simple_bitmap.grib"
no_packing="gen.grib|row.grib|gen_bitmap.grib|constant_width_bitmap.grib|constant_width_boust_bitmap.grib"
test_data() {
${tools_dir}/grib_filter $test_filter $simple > $simple.data
${tools_dir}/grib_filter $tempFilt $simple > $simple.data
for f in $files
do
${tools_dir}/grib_filter $test_filter $f > $f.data
${tools_dir}/grib_filter $tempFilt $f > $f.data
diff $simple.data $f.data > /dev/null
${tools_dir}/grib_compare -cvalues $f $simple
echo $f decoding test passed > $REDIRECT
@ -55,7 +55,7 @@ test_data() {
then
rm -f $f.copied
${tools_dir}/grib_copy -r $f $f.copied
${tools_dir}/grib_filter $test_filter $f.copied > $f.copied.data
${tools_dir}/grib_filter $tempFilt $f.copied > $f.copied.data
diff $simple.data $f.copied.data > /dev/null
${tools_dir}/grib_compare -cvalues $f.copied $simple
echo $f encoding test passed > $REDIRECT
@ -67,7 +67,7 @@ test_data() {
}
cat > $test_filter<<EOF
cat > $tempFilt<<EOF
print "[values!1]!";
EOF
@ -132,21 +132,21 @@ done
# Two coded values: Should stay as grid_simple
temp2=temp2.$label.grib
temp3=temp3.$label.grib
cat > $test_filter<<EOF
cat > $tempFilt<<EOF
set values={ 2.1, 3.4 };
write;
EOF
${tools_dir}/grib_filter -o $temp2 $test_filter $ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_filter -o $temp2 $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl
ECCODES_DEBUG=1 ${tools_dir}/grib_set -r -s packingType=grid_second_order $temp2 $temp3 2>$tempText
grib_check_key_equals $temp3 packingType,accuracy 'grid_simple 24'
grep -q "Packing not changed" $tempText
# Three coded values: Now we can change to 2nd order
cat > $test_filter<<EOF
cat > $tempFilt<<EOF
set values={ 2.1, 3.4, 8.9 };
write;
EOF
${tools_dir}/grib_filter -o $temp2 $test_filter $ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_filter -o $temp2 $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_set -r -s packingType=grid_second_order $temp2 $temp3
grib_check_key_equals $temp3 packingType,accuracy 'grid_second_order 24'
@ -211,4 +211,4 @@ grib_check_key_equals $temp1 packingType grid_second_order
# Clean up
rm -f $temp_stat1 $temp_stat2
rm -f $temp1 $temp2 $temp3 $sec_ord_bmp
rm -f $test_filter $tempText
rm -f $tempFilt $tempText

View File

@ -18,6 +18,7 @@ tempLog=temp.$label.log
tempRef=temp.$label.ref
# Use a GRIB2 input with a bitmap
# ----------------------------------
input=$data_dir/reduced_latlon_surface.grib2
grib_check_key_equals $input bitmapPresent 1
${tools_dir}/grib_set -s packingType=grid_simple_matrix,NC=1,NR=1 $input $tempGribA
@ -26,10 +27,23 @@ ${tools_dir}/grib_dump -O $tempGribB
${tools_dir}/grib_dump -Dat $tempGribB
# Call pack_double and unpack_double
# ----------------------------------
cat >$tempFilt<<EOF
set values = {0, 1, 9999};
print "[bitmap]";
EOF
${tools_dir}/grib_filter $tempFilt $tempGribB
# data_g1secondary_bitmap
# ----------------------------------
cat >$tempFilt<<EOF
transient expandBy = 1;
meta _s data_g1secondary_bitmap(bitmap,secondaryBitmaps,missingValue,expandBy,octetAtWichPackedDataBegins);
print "[_s]";
set _s = {0, 9};
EOF
# The above filter is for testing only. Add -f as we know it will fail
${tools_dir}/grib_filter -f $tempFilt $tempGribB
# Clean up
rm -f $tempGribA $tempGribB $tempFilt $tempLog $tempRef

View File

@ -520,6 +520,20 @@ cat $tempFilt
${tools_dir}/grib_filter $tempFilt $data_dir/constant_field.grib2
unset ECCODES_GRIB_HOURLY_STEPS_WITH_UNITS
# Changing the product definition template
# ----------------------------------------
# See ECC-1768
${tools_dir}/grib_set -s step=62m $sample_g2 $temp
${tools_dir}/grib_set -s productDefinitionTemplateNumber=8 $temp $temp2
${tools_dir}/grib_set -s productDefinitionTemplateNumber=8,stepUnits=s,step=0 $sample_g2 $temp
grib_check_key_equals $temp '-p stepUnits:s,startStep,productDefinitionTemplateNumber' 's 0s 8'
${tools_dir}/grib_set -s productDefinitionTemplateNumber=8,stepUnits=m,step=60 $sample_g2 $temp
grib_check_key_equals $temp '-p stepUnits:s,productDefinitionTemplateNumber' 'h 8'
# Bad stepUnits
set +e
${tools_dir}/grib_set -s stepUnits=190 $sample_g2 $temp > $tempText 2>&1

View File

@ -17,19 +17,6 @@ tempFilt=temp.${label}.filt
tempRef=temp.${label}.ref
sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
cat > $tempFilt <<EOF
meta a_deprecated_key suppressed(typeOfOriginalFieldValues);
print "[a_deprecated_key]";
EOF
set +e
${tools_dir}/grib_filter $tempFilt $sample2 2>$tempErr
status=$?
set -e
[ $status -ne 0 ]
cat $tempErr
cat > $tempRef <<EOF
ECCODES ERROR : key 'a_deprecated_key' is unavailable in this version.
ECCODES ERROR : Please use the following key(s):
@ -37,7 +24,22 @@ ECCODES ERROR : - typeOfOriginalFieldValues
ERROR: Key/value not found (message 1)
EOF
diff $tempRef $tempErr
do_tests()
{
qualifier=$1
echo "meta a_deprecated_key suppressed(typeOfOriginalFieldValues); print \"[a_deprecated_key$qualifier]\";" > $tempFilt
set +e
${tools_dir}/grib_filter $tempFilt $sample2 2>$tempErr
status=$?
set -e
[ $status -ne 0 ]
cat $tempErr
diff $tempRef $tempErr
}
do_tests ""
do_tests ":i"
do_tests ":d"
# Clean up

View File

@ -0,0 +1,221 @@
/*
* (C) Copyright 2005- 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 "grib_api_internal.h"
#include "eccodes.h"
static void dump_it(grib_handle* h)
{
int dump_flags = GRIB_DUMP_FLAG_CODED | GRIB_DUMP_FLAG_OCTET | GRIB_DUMP_FLAG_VALUES | GRIB_DUMP_FLAG_READ_ONLY;
grib_dump_content(h, stdout, "wmo", dump_flags, NULL);
}
// Lambert conformal
static grib_handle* test0()
{
int err = 0;
grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,};
double values[4] = {1.1, 2.2, 3.3, 0.4};
int set_spec_flags = 0;
size_t outlen = 4;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB1");
spec.grid_type = GRIB_UTIL_GRID_SPEC_LAMBERT_CONFORMAL;
spec.Ni = 2;
spec.Nj = 2;
// packing_spec.packing_type = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE;
// packing_spec.bitsPerValue = 16;
// packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES;
// packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED;
grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err);
Assert(err == 0);
return finalh;
}
// Lambert azimuthal
static grib_handle* test1()
{
int err = 0;
grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,};
double values[4] = {1.1, 2.2, 3.3, 0.4};
int set_spec_flags = 0;
size_t outlen = 4;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2");
grib_set_long(handle, "tablesVersion", 32);
spec.grid_type = GRIB_UTIL_GRID_SPEC_LAMBERT_AZIMUTHAL_EQUAL_AREA;
grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err);
Assert(err == 0);
return finalh;
}
// HEALPix
static grib_handle* test2()
{
int err = 0;
grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,};
double values[4] = {1.1, 2.2, 3.3, 0.4};
int set_spec_flags = 0;
size_t outlen = 4;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2");
spec.grid_type = GRIB_UTIL_GRID_SPEC_HEALPIX;
spec.N = 2;
packing_spec.extra_settings_count = 1;
packing_spec.extra_settings[0].type = GRIB_TYPE_LONG;
packing_spec.extra_settings[0].name = "tablesVersion";
packing_spec.extra_settings[0].long_value = 32;
grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err);
Assert(err == 0);
return finalh;
}
// Spherical harmonics
static grib_handle* test3()
{
int err = 0;
grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,};
double values[4] = {1.1, 2.2};
int set_spec_flags = 0;
size_t outlen = 0;
grib_handle* handle = grib_handle_new_from_samples(0, "sh_pl_grib2");
spec.grid_type = GRIB_UTIL_GRID_SPEC_SH;
spec.truncation = 20;
outlen = 2;
packing_spec.packing_type = GRIB_UTIL_PACKING_TYPE_SPECTRAL_SIMPLE;
packing_spec.bitsPerValue = 16;
packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES;
packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED;
grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err);
Assert(err == 0);
return finalh;
}
// Polar stereo
static grib_handle* test4()
{
int err = 0;
grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,};
double values[4] = {1.1, 2.2, 3.3, 0.4};
int set_spec_flags = 0;
size_t outlen = 0;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2");
grib_set_long(handle, "tablesVersion", 32);
spec.grid_type = GRIB_UTIL_GRID_SPEC_POLAR_STEREOGRAPHIC;
outlen = 4;
grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err);
Assert(err == 0);
return finalh;
}
// Regular Gaussian
static grib_handle* test5()
{
int err = 0;
grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,};
double values[4] = {1.1, 2.2, 3.3, 0.4};
int set_spec_flags = 0;
size_t outlen = 0;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2");
spec.grid_type = GRIB_UTIL_GRID_SPEC_REGULAR_GG;
spec.Ni = spec.Nj = 2;
outlen = 4;
grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err);
Assert(err == 0);
return finalh;
}
// Reduced LL
static grib_handle* test6()
{
int err = 0;
grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,};
double values[4] = {1.1, 2.2, 3.3, 0.4};
int set_spec_flags = 0;
size_t outlen = 0;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2");
spec.grid_type = GRIB_UTIL_GRID_SPEC_REDUCED_LL;
spec.Nj = 2;
outlen = 4;
grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err);
Assert(err == 0);
return finalh;
}
// Unstructured
static grib_handle* test7()
{
int err = 0;
grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,};
double values[4] = {1.1, 2.2, 3.3, 0.4};
int set_spec_flags = 0;
size_t outlen = 4;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2");
spec.grid_type = GRIB_UTIL_GRID_SPEC_UNSTRUCTURED;
grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err);
Assert(err == 0);
return finalh;
}
int main()
{
typedef grib_handle* (*test_func)(void);
test_func funcs[] = {test0, test1, test2, test3, test4, test5, test6, test7};
//grib_handle* (*p[8]) (void) = {test0, test1, test2, test3, test4, test5, test6, test7};
const size_t num_tests = sizeof(funcs)/sizeof(funcs[0]);
for (size_t i = 0; i < num_tests; i++) {
grib_handle* result = funcs[i]();
Assert(result);
dump_it(result);
}
return 0;
}

13
tests/grib_util_set_spec2.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# (C) Copyright 2005- 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.ctest.sh
$EXEC ${test_dir}/grib_util_set_spec2

View File

@ -58,10 +58,11 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi
*/
int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
{
size_t i, j, err = 0;
size_t i, j;
size_t last_size = 0;
long missingValuesPresent;
double delta;
int err = 0;
double* values = NULL;
size_t size;

View File

@ -256,7 +256,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g
#ifndef ECCODES_ON_WINDOWS
/* Check at compile time to ensure our file offset is at least 64 bits */
COMPILE_TIME_ASSERT(sizeof(options->infile_offset) >= 8);
static_assert(sizeof(options->infile_offset) >= 8);
#endif
has_output = grib_options_on("U");

View File

@ -340,7 +340,7 @@ static int grib_tool_without_orderby(grib_runtime_options* options)
if (options->infile_offset) {
#ifndef ECCODES_ON_WINDOWS
/* Check at compile time to ensure our file offset is at least 64 bits */
COMPILE_TIME_ASSERT(sizeof(options->infile_offset) >= 8);
static_assert(sizeof(options->infile_offset) >= 8);
#endif
err = fseeko(infile->file, options->infile_offset, SEEK_SET);
if (err) {