diff --git a/definitions/grib1/scanning_mode.def b/definitions/grib1/scanning_mode.def index 31a56e27d..19a7f8167 100644 --- a/definitions/grib1/scanning_mode.def +++ b/definitions/grib1/scanning_mode.def @@ -9,8 +9,8 @@ flagbit jScansPositively(scanningMode,6) : dump; flagbit jPointsAreConsecutive(scanningMode,5) : dump; constant alternativeRowScanning=0 : dump; -transient iScansPositively = !iScansNegatively : constraint; -transient jScansNegatively = !jScansPositively : constraint; +transient iScansPositively = !iScansNegatively : constraint, read_only; +transient jScansNegatively = !jScansPositively : constraint, read_only; alias geography.iScansNegatively=iScansNegatively; alias geography.jScansPositively=jScansPositively; diff --git a/definitions/grib2/template.3.healpix.def b/definitions/grib2/template.3.healpix.def index bf0429a5b..136904194 100644 --- a/definitions/grib2/template.3.healpix.def +++ b/definitions/grib2/template.3.healpix.def @@ -32,8 +32,8 @@ alias geography.orderingConvention = orderingConvention; flags[1] scanningMode 'grib2/tables/[tablesVersion]/3.13.table'; flagbit iScansNegatively(scanningMode,7) : dump; # WMO bit 1 flagbit jScansPositively(scanningMode,6) : dump; # WMO bit 2 -transient iScansPositively = !iScansNegatively : constraint; -transient jScansNegatively = !jScansPositively : constraint; +transient iScansPositively = !iScansNegatively : constraint, read_only; +transient jScansNegatively = !jScansPositively : constraint, read_only; iterator healpix(numberOfPoints,missingValue,values,Nside,orderingConvention); nearest healpix(values,radius,Nx,Ny); diff --git a/definitions/grib2/template.3.scanning_mode.def b/definitions/grib2/template.3.scanning_mode.def index 2eb2ca71e..1be608f41 100644 --- a/definitions/grib2/template.3.scanning_mode.def +++ b/definitions/grib2/template.3.scanning_mode.def @@ -20,8 +20,8 @@ alias geography.iScansNegatively=iScansNegatively; alias geography.jScansPositively=jScansPositively; alias geography.jPointsAreConsecutive=jPointsAreConsecutive; -transient iScansPositively = !iScansNegatively : constraint; -transient jScansNegatively = !jScansPositively : constraint; +transient iScansPositively = !iScansNegatively : constraint, read_only; +transient jScansNegatively = !jScansPositively : constraint, read_only; flagbit scanningMode5(scanningMode,3) = 0: read_only; flagbit scanningMode6(scanningMode,2) = 0: read_only; diff --git a/definitions/grib3/template.4.scanning_mode.def b/definitions/grib3/template.4.scanning_mode.def index 4fcd2fabb..31414321f 100644 --- a/definitions/grib3/template.4.scanning_mode.def +++ b/definitions/grib3/template.4.scanning_mode.def @@ -20,7 +20,7 @@ alias geography.iScansNegatively=iScansNegatively; alias geography.jScansPositively=jScansPositively; alias geography.jPointsAreConsecutive=jPointsAreConsecutive; -transient iScansPositively = !iScansNegatively : constraint; +transient iScansPositively = !iScansNegatively : constraint, read_only; flagbit scanningMode5(scanningMode,3) = 0: read_only; flagbit scanningMode6(scanningMode,2) = 0: read_only; diff --git a/examples/C/new_sample.c b/examples/C/new_sample.c index 9560e3924..82524b022 100644 --- a/examples/C/new_sample.c +++ b/examples/C/new_sample.c @@ -25,8 +25,7 @@ int main(int argc, char** argv) exit(1); } - /* h = codes_grib_handle_new_from_samples(NULL, "GRIB2"); */ - h = codes_handle_new_from_samples(NULL, "just a test"); + h = codes_handle_new_from_samples(NULL, "nonexistentsample"); if (h) return 1; h = codes_handle_new_from_samples(NULL, "GRIB2"); @@ -148,12 +147,6 @@ int main(int argc, char** argv) CODES_CHECK(codes_set_long(h, "jScansPositively", 0), 0); CODES_CHECK(codes_set_long(h, "jPointsAreConsecutive", 0), 0); CODES_CHECK(codes_set_long(h, "alternativeRowScanning", 0), 0); - CODES_CHECK(codes_set_long(h, "iScansPositively", 1), 0); - - /* ITERATOR */ - - - /* NEAREST */ CODES_CHECK(codes_set_long(h, "timeRangeIndicator", 0), 0); CODES_CHECK(codes_set_long(h, "NV", 0), 0); @@ -165,15 +158,12 @@ int main(int argc, char** argv) /* Parameter information */ - /* 0 = Temperature (grib2/tables/4/4.1.0.table) */ CODES_CHECK(codes_set_long(h, "parameterCategory", 0), 0); - /* 0 = Temperature (K) (grib2/tables/4/4.2.0.0.table) */ CODES_CHECK(codes_set_long(h, "parameterNumber", 0), 0); - /* 0 = Analysis (grib2/tables/4/4.3.table) */ CODES_CHECK(codes_set_long(h, "typeOfGeneratingProcess", 0), 0); @@ -185,7 +175,6 @@ int main(int argc, char** argv) /* 1 = Hour (grib2/tables/4/4.4.table) */ CODES_CHECK(codes_set_long(h, "indicatorOfUnitOfTimeRange", 1), 0); - /* 1 = Hour (stepUnits.table) */ CODES_CHECK(codes_set_long(h, "stepUnits", 1), 0); @@ -226,7 +215,6 @@ int main(int argc, char** argv) /* grib 2 Section 6 BIT-MAP SECTION */ - /* 255 = A bit map does not apply to this product (grib2/tables/4/6.0.table) */ CODES_CHECK(codes_set_long(h, "bitMapIndicator", 255), 0); diff --git a/src/accessor/grib_accessor_class_g2end_step.cc b/src/accessor/grib_accessor_class_g2end_step.cc index 20bf71e59..70fb9451c 100644 --- a/src/accessor/grib_accessor_class_g2end_step.cc +++ b/src/accessor/grib_accessor_class_g2end_step.cc @@ -127,9 +127,13 @@ int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len){ } if (add_time_range) { *val = start_step_value + time_range_value; + if ((err = grib_set_long_internal(h, "endStepUnit", step_units)) != GRIB_SUCCESS) + return err; } else { *val = start_step_value; + if ((err = grib_set_long_internal(h, "endStepUnit", step_units)) != GRIB_SUCCESS) + return err; } return GRIB_SUCCESS; @@ -174,9 +178,13 @@ int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* len){ } if (add_time_range) { *val = (start_step + time_range).value(eccodes::Unit(step_units)); + if ((err = grib_set_long_internal(h, "endStepUnit", step_units)) != GRIB_SUCCESS) + return err; } else { *val = start_step.value(eccodes::Unit(start_step_unit)); + if ((err = grib_set_long_internal(h, "endStepUnit", start_step_unit)) != GRIB_SUCCESS) + return err; } return GRIB_SUCCESS; @@ -302,14 +310,19 @@ int grib_accessor_class_g2end_step_t::unpack_long(grib_accessor* a, long* val, s grib_handle* h = grib_handle_of_accessor(a); int ret = 0; long start_step_value; + long start_step_unit; long numberOfTimeRange; if ((ret = grib_get_long_internal(h, self->start_step_value, &start_step_value))) return ret; + if ((ret = grib_get_long_internal(h, "startStepUnit", &start_step_unit))) + return ret; /* point in time */ if (self->year == NULL) { *val = start_step_value; + if ((ret = grib_set_long_internal(h, "endStepUnit", start_step_unit))) + return ret; return 0; } @@ -339,14 +352,19 @@ int grib_accessor_class_g2end_step_t::unpack_double(grib_accessor* a, double* va grib_handle* h = grib_handle_of_accessor(a); int ret = 0; long start_step_value; + long start_step_unit; long numberOfTimeRange; if ((ret = grib_get_long_internal(h, self->start_step_value, &start_step_value))) return ret; + if ((ret = grib_get_long_internal(h, "startStepUnit", &start_step_unit))) + return ret; /* point in time */ if (self->year == NULL) { *val = start_step_value; + if ((ret = grib_set_long_internal(h, "endStepUnit", start_step_unit))) + return ret; return 0; } @@ -401,7 +419,8 @@ int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_ /*point in time */ if (self->year == NULL) { - err = grib_set_long_internal(h, "startStepUnit", end_step.unit().value()); + if ((err = grib_set_long_internal(h, "startStepUnit", end_step.unit().value())) != GRIB_SUCCESS) + return err; err = grib_set_long_internal(h, self->start_step_value, end_step.value()); return err; } diff --git a/src/accessor/grib_accessor_class_optimal_step_units.cc b/src/accessor/grib_accessor_class_optimal_step_units.cc index ccd6b07d4..adc89e743 100644 --- a/src/accessor/grib_accessor_class_optimal_step_units.cc +++ b/src/accessor/grib_accessor_class_optimal_step_units.cc @@ -71,6 +71,12 @@ int grib_accessor_class_optimal_step_units_t::pack_long(grib_accessor* a, const grib_handle* h = grib_handle_of_accessor(a); grib_accessor_optimal_step_units_t* self = (grib_accessor_optimal_step_units_t*)a; + long start_step = 0; + long start_step_unit = 0; + long end_step = 0; + long end_step_unit = 0; + int ret; + auto supported_units = eccodes::Unit::list_supported_units(); try { eccodes::Unit unit{*val}; // throws if not supported @@ -91,10 +97,42 @@ int grib_accessor_class_optimal_step_units_t::pack_long(grib_accessor* a, const return GRIB_INVALID_ARGUMENT; } - int ret; + // ECC-1813: When the stepUnits key is used without specifying a value, as in the command + // "grib-set -s stepUnits=m in.grib out.grib", the following code initiates an indirect update + // of the low-level keys: forecastTime,indicatorOfUnitOfTimeRange,indicatorOfUnitForTimeRange,lengthOfTimeRange + self->overwriteStepUnits = *val; - if ((ret = grib_set_long_internal(h, "forceStepUnits", *val)) != GRIB_SUCCESS) { + if ((ret = grib_set_long_internal(h, "forceStepUnits", *val)) != GRIB_SUCCESS) return ret; + + if ((ret = grib_get_long_internal(h, "startStep", &start_step)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, "startStepUnit", &start_step_unit)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, "endStep", &end_step)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, "endStepUnit", &end_step_unit)) != GRIB_SUCCESS) + return ret; + + try { + eccodes::Step start{start_step, start_step_unit}; + start.set_unit(*val); + eccodes::Step end{end_step, end_step_unit}; + end.set_unit(*val); + + if ((ret = grib_set_long_internal(h, "startStepUnit", start.unit().value())) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(h, "startStep", start.value())) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(h, "endStepUnit", end.unit().value())) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(h, "endStep", end.value())) != GRIB_SUCCESS) + return ret; + } + catch (std::exception& e) { + std::string msg = std::string{"Failed to convert steps to: "} + std::to_string(*val) + " (" + e.what() + ")"; + grib_context_log(a->context, GRIB_LOG_ERROR, "%s", msg.c_str()); + return GRIB_INTERNAL_ERROR; } return GRIB_SUCCESS; diff --git a/src/grib_accessor.cc b/src/grib_accessor.cc new file mode 100644 index 000000000..a684b9e1d --- /dev/null +++ b/src/grib_accessor.cc @@ -0,0 +1,877 @@ +/* + * (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. + */ + +/*************************************************************************** + * Jean Baptiste Filippi - 01.11.2005 + ***************************************************************************/ + +#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 +GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) +{ + if (*a != *b) + return 1; + while ((*a != 0 && *b != 0) && *(a) == *(b)) { + a++; + b++; + } + return (*a == 0 && *b == 0) ? 0 : 1; +} + +void grib_accessor_dump(grib_accessor* a, grib_dumper* f) +{ + grib_accessor_class* c = a->cclass; + while (c) { + if (c->dump) { + c->dump(a, f); + return; + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); +} + +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); + while (c) { + if (c->pack_missing) { + return c->pack_missing(a); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +// int grib_pack_zero(grib_accessor* a) +// { +// grib_accessor_class* c = a->cclass; +// while (c) { +// if (c->clear) { +// return c->clear(a); +// } +// c = c->super ? *(c->super) : NULL; +// } +// DEBUG_ASSERT(0); +// return 0; +// } + +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); + while (c) { + if (c->is_missing) { + return c->is_missing(a); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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); + while (c) { + if (c->pack_double) { + return c->pack_double(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +int grib_pack_float(grib_accessor* a, const float* v, size_t* len) +{ + grib_accessor_class* c = a->cclass; + while (c) { + if (c->pack_float) { + return c->pack_float(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +int grib_pack_expression(grib_accessor* a, grib_expression* e) +{ + grib_accessor_class* c = a->cclass; + // grib_context_log(a->context, GRIB_LOG_INFO, "....(%s)%s is packing", + // (a->parent->owner)?(a->parent->owner->name):"root", + // a->name); + while (c) { + if (c->pack_expression) { + return c->pack_expression(a, e); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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)"); + while (c) { + if (c->pack_string) { + return c->pack_string(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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)"); + while (c) { + if (c->pack_string_array) { + return c->pack_string_array(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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); + while (c) { + if (c->pack_long) { + return c->pack_long(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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); + while (c) { + if (c->pack_bytes) { + return c->pack_bytes(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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); + while (c) { + if (c->unpack_bytes) { + return c->unpack_bytes(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_t len) +{ + grib_accessor_class* c = a->cclass; + while (c) { + if (c->unpack_double_subarray) { + return c->unpack_double_subarray(a, v, start, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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); + while (c) { + if (c->unpack_double) { + return c->unpack_double(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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); + if (c->unpack_float) { + return c->unpack_float(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +template <> +int grib_unpack(grib_accessor* a, double* v, size_t* len) +{ + return grib_unpack_double(a, v, len); +} + +template <> +int grib_unpack(grib_accessor* a, float* v, size_t* len) +{ + return grib_unpack_float(a, v, len); +} + +int grib_unpack_double_element(grib_accessor* a, size_t i, double* v) +{ + grib_accessor_class* c = a->cclass; + while (c) { + if (c->unpack_double_element) { + return c->unpack_double_element(a, i, v); + } + c = c->super ? *(c->super) : NULL; + } + return GRIB_NOT_IMPLEMENTED; +} +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; + //} + + 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 +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; + DEBUG_ASSERT(len > 0); + while (c) { + if (c->unpack_double_element_set) { + return c->unpack_double_element_set(a, index_array, len, val_array); + } + c = c->super ? *(c->super) : NULL; + } + return GRIB_NOT_IMPLEMENTED; +} +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; + // } + + 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 ); + while (c) { + if (c->unpack_string) { + return c->unpack_string(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +int grib_unpack_string_array(grib_accessor* a, char** v, size_t* len) +{ + grib_accessor_class* c = a->cclass; + while (c) { + if (c->unpack_string_array) { + return c->unpack_string_array(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +int grib_accessors_list_unpack_long(grib_accessors_list* al, long* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = grib_unpack_long(al->accessor, val + unpacked_len, &len); + unpacked_len += len; + al = al->next; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list_unpack_double(grib_accessors_list* al, double* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = grib_unpack_double(al->accessor, val + unpacked_len, &len); + unpacked_len += len; + al = al->next; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list_unpack_float(grib_accessors_list* al, float* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = grib_unpack_float(al->accessor, val + unpacked_len, &len); + unpacked_len += len; + al = al->next; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list_unpack_string(grib_accessors_list* al, char** val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = grib_unpack_string_array(al->accessor, val + unpacked_len, &len); + unpacked_len += len; + al = al->next; + } + + *buffer_len = unpacked_len; + return err; +} + +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 ); + while (c) { + if (c->unpack_long) { + return c->unpack_long(a, v, len); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +long grib_accessor_get_native_type(grib_accessor* a) +{ + grib_accessor_class* c = NULL; + if (a) + c = a->cclass; + + while (c) { + if (c->get_native_type) + return c->get_native_type(a); + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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 ); + if (a) + c = a->cclass; + + while (c) { + if (c->next_offset) + return c->next_offset(a); + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +long grib_string_length(grib_accessor* a) +{ + grib_accessor_class* c = NULL; + if (a) + c = a->cclass; + + while (c) { + if (c->string_length) + return c->string_length(a); + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +long grib_byte_offset(grib_accessor* a) +{ + grib_accessor_class* c = NULL; + if (a) + c = a->cclass; + + while (c) { + if (c->byte_offset) + return c->byte_offset(a); + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +long grib_byte_count(grib_accessor* a) +{ + grib_accessor_class* c = NULL; + if (a) + c = a->cclass; + + while (c) { + if (c->byte_count) + return c->byte_count(a); + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +int grib_value_count(grib_accessor* a, long* count) +{ + grib_accessor_class* c = NULL; + int err = 0; + if (a) + c = a->cclass; + + while (c) { + if (c->value_count) { + err = c->value_count(a, count); + return err; + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +int grib_accessors_list_value_count(grib_accessors_list* al, size_t* count) +{ + long lcount = 0; + *count = 0; + while (al) { + grib_value_count(al->accessor, &lcount); + *count += lcount; + al = al->next; + } + return 0; +} + +int grib_accessor_notify_change(grib_accessor* a, grib_accessor* changed) +{ + grib_accessor_class* c = NULL; + if (a) + c = a->cclass; + + while (c) { + if (c->notify_change) + return c->notify_change(a, changed); + c = c->super ? *(c->super) : NULL; + } + if (a && a->cclass) + fprintf(stderr, "Error: notify_change not implemented for %s %s\n", a->cclass->name, a->name); + DEBUG_ASSERT(0); + return 0; +} + +// 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) { + grib_accessor_class* s = c->super ? *(c->super) : NULL; + init_accessor(s, a, len, args); + if (c->init) + c->init(a, len, args); + } +} + +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 +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); + if (c->destroy) { + c->destroy(ct, a); + } + c = s; + } + // 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; + 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); + if (c->make_clone) { + return c->make_clone(a, s, err); + } + c = super; + } + return 0; +} + +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); + while (c) { + if (c->update_size) { + c->update_size(a, len); + return; + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); +} + +int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest) +{ + grib_accessor_class* c = a->cclass; + while (c) { + if (c->nearest_smaller_value) { + return c->nearest_smaller_value(a, val, nearest); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + + +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); + while (c) { + if (c->preferred_size) { + return c->preferred_size(a, from_handle); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +grib_accessor* grib_next_accessor(grib_accessor* a) +{ + grib_accessor_class* c = a->cclass; + while (c) { + if (c->next) { + return c->next(a, 1); + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return 0; +} + +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); + while (c) { + if (c->resize) { + c->resize(a, new_size); + return; + } + c = c->super ? *(c->super) : NULL; + } + DEBUG_ASSERT(0); + return; +} + +int grib_compare_accessors(grib_accessor* a1, grib_accessor* a2, int compare_flags) +{ + int ret = 0; + long type1 = 0; + long type2 = 0; + int type_mismatch = 0; + grib_accessor_class* c1 = NULL; + + if ((compare_flags & GRIB_COMPARE_NAMES) && grib_inline_strcmp(a1->name, a2->name)) + return GRIB_NAME_MISMATCH; + + if (compare_flags & GRIB_COMPARE_TYPES) { + type1 = grib_accessor_get_native_type(a1); + type2 = grib_accessor_get_native_type(a2); + + type_mismatch = type1 != type2 ? 1 : 0; + } + + ret = GRIB_UNABLE_TO_COMPARE_ACCESSORS; + c1 = a1->cclass; + while (c1) { + if (c1->compare) { + ret = c1->compare(a1, a2); + break; + } + c1 = c1->super ? *(c1->super) : NULL; + } + + if (ret == GRIB_VALUE_MISMATCH && type_mismatch) + ret = GRIB_TYPE_AND_VALUE_MISMATCH; + + return ret; +} + +// int grib_accessor_clear_attributes(grib_accessor* a) +// { +// int id; +// for (id=0;idattributes[id]=NULL; +// } +// return 0; +// } + +int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_if_clash) +{ + int id = 0; + int idx = 0; + grib_accessor* same = NULL; + grib_accessor* aloc = a; + + if (grib_accessor_has_attributes(a)) { + same = grib_accessor_get_attribute_index(a, attr->name, &id); + } + + if (same) { + if (nest_if_clash == 0) + return GRIB_ATTRIBUTE_CLASH; + aloc = same; + } + + for (id = 0; id < MAX_ACCESSOR_ATTRIBUTES; id++) { + if (aloc->attributes[id] == NULL) { + // attr->parent=a->parent; + aloc->attributes[id] = attr; + attr->parent_as_attribute = aloc; + if (aloc->same) + attr->same = grib_accessor_get_attribute_index(aloc->same, attr->name, &idx); + + grib_context_log(a->context, GRIB_LOG_DEBUG, "added attribute %s->%s", a->name, attr->name); + return GRIB_SUCCESS; + } + } + return GRIB_TOO_MANY_ATTRIBUTES; +} + +// int grib_accessor_replace_attribute(grib_accessor* a, grib_accessor* attr) +// { +// int id = 0; +// int idx = 0; +// if (grib_accessor_get_attribute_index(a, attr->name, &id) != NULL) { +// grib_accessor_delete(a->context, a->attributes[id]); +// a->attributes[id] = attr; +// attr->parent_as_attribute = a; +// if (a->same) +// attr->same = grib_accessor_get_attribute_index(a->same, attr->name, &idx); +// } +// else { +// grib_accessor_add_attribute(a, attr, 0); +// } +// return GRIB_SUCCESS; +// } + +// int grib_accessor_delete_attribute(grib_accessor* a, const char* name) +// { +// int id = 0; +// if (grib_accessor_get_attribute_index(a, name, &id) != NULL) { +// grib_accessor_delete(a->context, a->attributes[id]); +// a->attributes[id] = NULL; +// return GRIB_SUCCESS; +// } +// else { +// return GRIB_NOT_FOUND; +// } +// } + +// grib_accessor* grib_accessor_get_attribute_by_index(grib_accessor* a, int index) +// { +// if (index < MAX_ACCESSOR_ATTRIBUTES) +// return a->attributes[index]; +// return NULL; +// } + +// const char* grib_accessor_get_name(grib_accessor* a) +// { +// return a->name; +// } + +grib_accessor* grib_accessor_get_attribute_index(grib_accessor* a, const char* name, int* index) +{ + int i = 0; + while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { + if (!grib_inline_strcmp(a->attributes[i]->name, name)) { + *index = i; + return a->attributes[i]; + } + i++; + } + return NULL; +} + +int grib_accessor_has_attributes(grib_accessor* a) +{ + return a->attributes[0] ? 1 : 0; +} + +grib_accessor* grib_accessor_get_attribute(grib_accessor* a, const char* name) +{ + int index = 0; + const char* p = 0; + char* basename = NULL; + const char* attribute_name = NULL; + grib_accessor* acc = NULL; + p = name; + while (*(p + 1) != '\0' && (*p != '-' || *(p + 1) != '>')) + p++; + if (*(p + 1) == '\0') { + return grib_accessor_get_attribute_index(a, name, &index); + } + else { + size_t size = p - name; + attribute_name = p + 2; + basename = (char*)grib_context_malloc_clear(a->context, size + 1); + basename = (char*)memcpy(basename, name, size); + acc = grib_accessor_get_attribute_index(a, basename, &index); + grib_context_free(a->context, basename); + if (acc) + return grib_accessor_get_attribute(acc, attribute_name); + else + return NULL; + } +} + +grib_accessors_list* grib_accessors_list_create(grib_context* c) +{ + return (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); +} + +void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank) +{ + grib_accessors_list* last; + const grib_context* c = a->context; + + last = grib_accessors_list_last(al); + if (last && last->accessor) { + last->next = (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); + last->next->accessor = a; + last->next->prev = last; + last->next->rank = rank; + al->last = last->next; + } + else { + al->accessor = a; + al->rank = rank; + al->last = al; + } +} + +grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al) +{ + // grib_accessors_list* last=al; + // grib_accessors_list* next=al->next; + // while(next) { + // last=next; + // next=last->next; + // } + return al->last; +} + +// grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a) +// { +// grib_accessors_list* last = al; +// grib_accessors_list* next = al->next; +// while (next) { +// if (last->accessor == a) +// return last; +// last = next; +// next = last->next; +// } +// return NULL; +// } + +void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al) +{ + grib_accessors_list* tmp; + + while (al) { + tmp = al->next; + //grib_accessor_delete(c, al->accessor); + grib_context_free(c, al); + al = tmp; + } +} diff --git a/src/grib_expression_class_unop.cc b/src/grib_expression_class_unop.cc index 6188b4586..ae7678043 100644 --- a/src/grib_expression_class_unop.cc +++ b/src/grib_expression_class_unop.cc @@ -17,6 +17,7 @@ CLASS = expression IMPLEMENTS = destroy IMPLEMENTS = native_type + IMPLEMENTS = get_name IMPLEMENTS = evaluate_long IMPLEMENTS = evaluate_double IMPLEMENTS = print @@ -42,6 +43,7 @@ typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); static void print(grib_context*,grib_expression*,grib_handle*); static void add_dependency(grib_expression* e, grib_accessor* observer); +static string get_name(grib_expression* e); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); static int evaluate_double(grib_expression*,grib_handle*,double*); @@ -65,7 +67,7 @@ static grib_expression_class _grib_expression_class_unop = { &print, &add_dependency, &native_type, - 0, + &get_name, &evaluate_long, &evaluate_double, 0, @@ -97,6 +99,12 @@ static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) return GRIB_SUCCESS; } +static const char* get_name(grib_expression* g) +{ + grib_expression_unop* e = (grib_expression_unop*)g; + return grib_expression_get_name(e->exp); +} + static void print(grib_context* c, grib_expression* g, grib_handle* f) { grib_expression_unop* e = (grib_expression_unop*)g; @@ -111,7 +119,6 @@ static void destroy(grib_context* c, grib_expression* g) grib_expression_free(c, e->exp); } - static void add_dependency(grib_expression* g, grib_accessor* observer) { grib_expression_unop* e = (grib_expression_unop*)g; diff --git a/src/grib_handle.cc b/src/grib_handle.cc index faaefbebe..1bbcef4ae 100644 --- a/src/grib_handle.cc +++ b/src/grib_handle.cc @@ -231,7 +231,7 @@ grib_handle* codes_handle_new_from_samples(grib_context* c, const char* name) if (!g) { grib_context_log(c, GRIB_LOG_ERROR, "Unable to load sample file '%s.tmpl'\n" - " from %s\n" + " samples path='%s'\n" " (ecCodes Version=%s)", name, c->grib_samples_path, ECCODES_VERSION_STR); } diff --git a/src/grib_iterator_class_healpix.cc b/src/grib_iterator_class_healpix.cc index 7befaf894..6a545b6c5 100644 --- a/src/grib_iterator_class_healpix.cc +++ b/src/grib_iterator_class_healpix.cc @@ -83,9 +83,9 @@ grib_iterator_class* grib_iterator_class_healpix = &_grib_iterator_class_healpix static void init_class(grib_iterator_class* c) { - c->previous = (*(c->super))->previous; - c->reset = (*(c->super))->reset; - c->has_next = (*(c->super))->has_next; + c->previous = (*(c->super))->previous; + c->reset = (*(c->super))->reset; + c->has_next = (*(c->super))->has_next; } /* END_CLASS_IMP */ diff --git a/tests/big2gribex.sh b/tests/big2gribex.sh index c8c0b6098..acc78cdf2 100755 --- a/tests/big2gribex.sh +++ b/tests/big2gribex.sh @@ -17,6 +17,12 @@ if [ ! -x ${tools_dir}/big2gribex ]; then exit 0 fi +set +e +${tools_dir}/big2gribex +status=$? +set -e +[ $status -ne 0 ] + ${tools_dir}/big2gribex $data_dir/test.grib1 $tempGrib # Clean up diff --git a/tests/grib_change_scanning.sh b/tests/grib_change_scanning.sh index 25c5e005b..5f1d46596 100755 --- a/tests/grib_change_scanning.sh +++ b/tests/grib_change_scanning.sh @@ -11,6 +11,12 @@ . ./include.ctest.sh label="grib_change_scanning_test" +tempFilt=temp.$label.filt +tempGribA=temp.$label.A.grib +tempGribB=temp.$label.B.grib +tempText=temp.$label.txt +tempRef=temp.$label.ref + editions="1 2" gridTypes="regular_ll rotated_ll" @@ -77,12 +83,6 @@ done # alternativeRowScanning # ----------------------- -tempFilt=temp.$label.filt -tempGribA=temp.$label.A.grib -tempGribB=temp.$label.B.grib -tempText=temp.$label.txt -tempRef=temp.$label.ref - cat > $tempFilt </dev/null cmp $tempGribA $tempGribB + +# Check constraint keys follow (observe) their expressions +# -------------------------------------------------------- +cat > $tempFilt <$tempText + status=$? + set -e + [ $status -ne 0 ] + grep -q "Value is read only" $tempText + rm $tempText + done +done + # Clean up rm -f $tempFilt $tempGribA $tempGribB $tempRef $tempText rm -f ${data_dir}/scan1.grib ${data_dir}/scan.grib diff --git a/tests/grib_grid_lamb_az_eq_area.sh b/tests/grib_grid_lamb_az_eq_area.sh index f3ed52588..a580d0498 100755 --- a/tests/grib_grid_lamb_az_eq_area.sh +++ b/tests/grib_grid_lamb_az_eq_area.sh @@ -11,21 +11,21 @@ label="grib_grid_lamb_az_eq_area_test" -GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2 -REF_FILE=grib_lamb_az_eq_area.ref +input=${data_dir}/regular_gaussian_pressure_level_constant.grib2 +tempRef=grib_lamb_az_eq_area.ref # Temporary files created for this test -FILTER_FILE=temp.$label.filter -GRIB_OUTFILE=temp.$label.grib2 -DATA_OUTFILE=temp.$label.txt -rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE +tempFilt=temp.$label.filter +tempGrib=temp.$label.grib2 +tempOut=temp.$label.txt +rm -f $tempFilt $tempGrib $tempOut # -------------------- # Spherical Earth # -------------------- # Create a filter -cat > $FILTER_FILE< $tempFilt< $DATA_OUTFILE +${tools_dir}/grib_get_data $tempGrib > $tempOut # Compare output with reference. If the diff fails, script will immediately exit with status 1 -diff $REF_FILE $DATA_OUTFILE +diff $tempRef $tempOut -grib_check_key_equals $GRIB_OUTFILE standardParallelInDegrees,centralLongitudeInDegrees '48 9' -grib_check_key_equals $GRIB_OUTFILE xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000' +grib_check_key_equals $tempGrib standardParallelInDegrees,centralLongitudeInDegrees '48 9' +grib_check_key_equals $tempGrib xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000' # Nearest -${tools_dir}/grib_ls -l 67,-33,1 $GRIB_OUTFILE +${tools_dir}/grib_ls -l 67,-33,1 $tempGrib # jPointsAreConsecutive tempOutA=temp.$label.A.txt tempOutB=temp.$label.B.txt -${tools_dir}/grib_get_data -s jPointsAreConsecutive=0 $GRIB_OUTFILE > $tempOutA -${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $GRIB_OUTFILE > $tempOutB +${tools_dir}/grib_get_data -s jPointsAreConsecutive=0 $tempGrib > $tempOutA +${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $tempGrib > $tempOutB # Results should be different. set +e diff $tempOutA $tempOutB > /dev/null @@ -80,7 +80,7 @@ rm -f $tempOutA $tempOutB # Oblate spheroid # -------------------- -cat > $FILTER_FILE< $tempFilt< $DATA_OUTFILE +${tools_dir}/grib_get_data $tempGrib > $tempOut + +# ECC-1818 +# --------- +cat > $tempFilt< $tempOut # Clean up -rm -f $FILTER_FILE $DATA_OUTFILE -rm -f $GRIB_OUTFILE +rm -f $tempFilt $tempOut $tempGrib diff --git a/tests/grib_histogram.sh b/tests/grib_histogram.sh index c5b56ab22..9653a9500 100755 --- a/tests/grib_histogram.sh +++ b/tests/grib_histogram.sh @@ -17,5 +17,17 @@ tempOut=temp.$label.txt ${tools_dir}/grib_histogram $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut ${tools_dir}/grib_histogram $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut +${tools_dir}/grib_histogram -p step,shortName $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut + +# Something with a bitmap +input=$data_dir/reduced_latlon_surface.grib2 +grib_check_key_equals $input numberOfMissing 98701 +${tools_dir}/grib_histogram $input > $tempOut + +# Skip +input=$data_dir/tigge_cf_ecmwf.grib2 +${tools_dir}/grib_histogram -w level=925,shortName=gh $input > $tempOut + + # Clean up rm -f $tempOut diff --git a/tests/grib_sub_hourly.sh b/tests/grib_sub_hourly.sh index 2f399da0f..bb7bac891 100755 --- a/tests/grib_sub_hourly.sh +++ b/tests/grib_sub_hourly.sh @@ -62,86 +62,109 @@ fi instantaneous_field=$data_dir/reduced_gaussian_surface.grib2 accumulated_field=$data_dir/reduced_gaussian_sub_area.grib2 + +# ECC-1813: Test that we can set the stepUnits without setting the step +in="$instantaneous_field" +low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" +${tools_dir}/grib_set -s stepUnits=m,step=60 $in $temp +grib_check_key_equals $temp "-p $low_level_keys" "60 m" +${tools_dir}/grib_set -s stepUnits=s $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "3600 s" +${tools_dir}/grib_set -s stepUnits=m $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "60 m" +${tools_dir}/grib_set -s stepUnits=h $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "1 h" + +in="$accumulated_field" +low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" +${tools_dir}/grib_set -s stepUnits=m,stepRange=60-180 $in $temp +grib_check_key_equals $temp "-p $low_level_keys" "60 m 120 m" +${tools_dir}/grib_set -s stepUnits=s $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "3600 s 7200 s" +${tools_dir}/grib_set -s stepUnits=m $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "60 m 120 m" +${tools_dir}/grib_set -s stepUnits=h $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "1 h 2 h" + # Check the lowercase alias 'stepunits' for a variety of step types (instant, accum etc) ${tools_dir}/grib_get -p stepunits $data_dir/tigge_cf_ecmwf.grib2 #### Make sure that step, stepRange, startStep, endStep produce the same result for instantaneous fields -fn="$instantaneous_field" +in="$instantaneous_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" keys_step="step,step:s,step:i,step:d,stepUnits:s" keys_step_range="stepRange,stepRange:s,stepRange:i,stepRange:d,stepUnits:s" keys_start_step="startStep,startStep:s,startStep:i,startStep:d,stepUnits:s" keys_end_step="endStep,endStep:s,endStep:i,endStep:d,stepUnits:s" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 h" -${tools_dir}/grib_set -s stepUnits=m,step=59 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,step=59 $in $temp grib_check_key_equals $temp "-p $keys_step" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_step_range" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_start_step" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_end_step" "59m 59m 59 59 m" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 h" -${tools_dir}/grib_set -s step=59m $fn $temp +${tools_dir}/grib_set -s step=59m $in $temp grib_check_key_equals $temp "-p $keys_step" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_step_range" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_start_step" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_end_step" "59m 59m 59 59 m" - #### stepUnits overrides the units in the low level keys # if stepUnits=UNIT is set, then set the low level keys to UNIT # else optimise low level keys # instant fields: low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -fn="$instantaneous_field" +in="$instantaneous_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" keys__="step,stepUnits:s" keys_s="step:s" keys_i="step:i,stepUnits:s" keys_d="step:d,stepUnits:s" -${tools_dir}/grib_set -s stepUnits=m,step=60 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,step=60 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m" grib_check_key_equals $temp "-p $keys_s" "1$HOUR" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "60m" -${tools_dir}/grib_set -s stepUnits=m,step=60 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,step=60 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m" grib_check_key_equals $temp "-p $keys_s" "1$HOUR" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "60m" -${tools_dir}/grib_set -s step=60m $fn $temp +${tools_dir}/grib_set -s step=60m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1 h" grib_check_key_equals $temp "-p $keys_s" "1$HOUR" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "60m" # accumulated fields: -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" keys__="step,startStep,endStep,stepRange,stepUnits:s" keys_s="step:s,startStep:s,endStep:s,stepRange:s,stepUnits:s" keys_i="step:i,startStep:i,endStep:i,stepRange:i,stepUnits:s" keys_d="step:d,startStep:d,endStep:d,stepRange:d,stepUnits:s" -${tools_dir}/grib_set -s stepUnits=m,stepRange=60-120 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,stepRange=60-120 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m 60 m" grib_check_key_equals $temp "-p $keys_s" "2$HOUR 1$HOUR 2$HOUR 1$HOUR-2$HOUR h" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "120m 60m 120m 60m-120m m" -${tools_dir}/grib_set -s stepUnits=m,stepRange=60-120 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,stepRange=60-120 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m 60 m" grib_check_key_equals $temp "-p $keys_s" "2$HOUR 1$HOUR 2$HOUR 1$HOUR-2$HOUR h" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "120m 60m 120m 60m-120m m" -${tools_dir}/grib_set -s stepRange=60m-120m $fn $temp +${tools_dir}/grib_set -s stepRange=60m-120m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1 h 1 h" grib_check_key_equals $temp "-p $keys_s" "2$HOUR 1$HOUR 2$HOUR 1$HOUR-2$HOUR h" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "120m 60m 120m 60m-120m m" #### CHECK units -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=96,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=96,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 h 96 h" grib_check_key_equals $temp " -w count=1 -s stepUnits=s -p step:i,stepUnits:s" "345600 s" @@ -162,38 +185,38 @@ grib_check_key_equals $temp " -w count=1 -s stepUnits=6h -p step,stepUnits:s" "1 grib_check_key_equals $temp " -w count=1 -s stepUnits=12h -p step,stepUnits:s" "8x12h 12h" grib_check_key_equals $temp " -w count=1 -s stepUnits=D -p step,stepUnits:s" "4D D" -${tools_dir}/grib_set -s stepUnits=s,startStep=0,endStep=345600 $fn $temp +${tools_dir}/grib_set -s stepUnits=s,startStep=0,endStep=345600 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 s 345600 s" -${tools_dir}/grib_set -s stepUnits=m,startStep=0,endStep=5760 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,startStep=0,endStep=5760 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 m 5760 m" -${tools_dir}/grib_set -s stepUnits=h,startStep=0,endStep=96 $fn $temp +${tools_dir}/grib_set -s stepUnits=h,startStep=0,endStep=96 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 h 96 h" -${tools_dir}/grib_set -s stepUnits=6h,startStep=0,endStep=16 $fn $temp +${tools_dir}/grib_set -s stepUnits=6h,startStep=0,endStep=16 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 6h 16 6h" -${tools_dir}/grib_set -s stepUnits=12h,startStep=0,endStep=8 $fn $temp +${tools_dir}/grib_set -s stepUnits=12h,startStep=0,endStep=8 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 12h 8 12h" -${tools_dir}/grib_set -s stepUnits=D,startStep=0,endStep=4 $fn $temp +${tools_dir}/grib_set -s stepUnits=D,startStep=0,endStep=4 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 D 4 D" #### CHECK negative forecastTime -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s forecastTime=-6,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=-6,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "-6 h 6 h" grib_check_key_equals $temp "-s stepUnits:s=h -p startStep:s,endStep:s" "-6$HOUR 0$HOUR" grib_check_key_equals $temp "-s stepUnits:s=m -p startStep:s,endStep:s" "-360m 0m" grib_check_key_equals $temp "-s stepUnits:s=s -p startStep:s,endStep:s" "-21600s 0s" -${tools_dir}/grib_set -s forecastTime=-48,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=0,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=-48,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=0,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p stepRange" "-48$HOUR" #### CHECK: check optimal units are set correctly in GRIB files -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D" ### TODO(maee): @Shahram: how to make parameters position independent @@ -220,18 +243,18 @@ grib_check_key_equals $temp2 "-p $low_level_keys" "60 h 120 h" ${tools_dir}/grib_set -s stepUnits:s=h,startStep:i=60,endStep:i=180 $temp $temp2 grib_check_key_equals $temp2 "-p $low_level_keys" "60 h 120 h" -#fn="$accumulated_field" +#in="$accumulated_field" #low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" ##high_level_keys="startStep:s,endStep:s" #high_level_keys="startStep:i,endStep:i" -#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp #grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D" #grib_check_key_equals $temp "-p $high_level_keys" "24 48" #${tools_dir}/grib_set -s startStep:i=24 $temp $temp2 #grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 0 h" #grib_check_key_equals $temp2 "-p $high_level_keys" "24 24" -#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=24,indicatorOfUnitForTimeRange=h $fn $temp +#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=24,indicatorOfUnitForTimeRange=h $in $temp #grib_check_key_equals $temp "-p $low_level_keys" "24 h 24 h" #grib_check_key_equals $temp "-p $high_level_keys" "24 48" #${tools_dir}/grib_set -s startStep:i=24 $temp $temp2 @@ -240,9 +263,9 @@ grib_check_key_equals $temp2 "-p $low_level_keys" "60 h 120 h" #exit #### CHECK: grib_set - endStep + stepUnits -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D" # Use range unit: hour @@ -302,14 +325,14 @@ ${tools_dir}/grib_set -s stepRange:s=62D-122D $temp $temp2 grib_check_key_equals $temp2 "-p $low_level_keys" "1488 h 1440 h" grib_check_key_equals $temp2 "-p stepRange:s" "1488$HOUR-2928$HOUR" -fn="$instantaneous_field" +in="$instantaneous_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" keys__="step,stepUnits:s" keys_s="step:s" keys_i="step:i,stepUnits:s" keys_d="step:d,stepUnits:s" -${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $keys__ -s stepUnits=s" "3540s s" grib_check_key_equals $temp "-p $keys__ -s stepUnits=m" "59m m" #grib_check_key_equals $temp "-p $keys__ -s stepUnits=h" "0" # not supported @@ -324,7 +347,7 @@ grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "59 m" #grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0.983333" # not supported -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $keys_i -s stepUnits=s" "0 s" grib_check_key_equals $temp "-p $keys_i -s stepUnits=m" "0 m" grib_check_key_equals $temp "-p $keys_i -s stepUnits=h" "0 h" @@ -333,14 +356,14 @@ grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "0 m" grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0 h" -fn="$instantaneous_field" +in="$instantaneous_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" keys__="step,stepUnits:s" keys_s="step:s,stepUnits:s" keys_i="step:i,stepUnits:s" keys_d="step:d,stepUnits:s" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 m" grib_check_key_equals $temp "-p $keys__" "0m m" grib_check_key_equals $temp "-p $keys_s" "0m m" @@ -361,7 +384,7 @@ grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "0 m" grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0 h" -${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "59 m" grib_check_key_equals $temp "-p $keys__" "59m m" #grib_check_key_equals $temp "-p $keys_s" "59" @@ -369,14 +392,14 @@ grib_check_key_equals $temp "-p $keys_s" "59m m" grib_check_key_equals $temp "-p $keys_i" "59 m" grib_check_key_equals $temp "-p $keys_d" "59 m" -${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m" grib_check_key_equals $temp "-p $keys__" "1$HOUR h" grib_check_key_equals $temp "-p $keys_s" "1$HOUR h" grib_check_key_equals $temp "-p $keys_i" "1 h" grib_check_key_equals $temp "-p $keys_d" "1 h" -${tools_dir}/grib_set -s forecastTime=61,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=61,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "61 m" grib_check_key_equals $temp "-p $keys__" "61m m" #grib_check_key_equals $temp "-p $keys_s" "61" @@ -384,14 +407,14 @@ grib_check_key_equals $temp "-p $keys_s" "61m m" grib_check_key_equals $temp "-p $keys_i" "61 m" grib_check_key_equals $temp "-p $keys_d" "61 m" -${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "24 h" grib_check_key_equals $temp "-p $keys__" "24$HOUR h" grib_check_key_equals $temp "-p $keys_s" "24$HOUR h" grib_check_key_equals $temp "-p $keys_i" "24 h" grib_check_key_equals $temp "-p $keys_d" "24 h" -${tools_dir}/grib_set -s forecastTime=1440,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=1440,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1440 m" grib_check_key_equals $temp "-p $keys__" "24$HOUR h" grib_check_key_equals $temp "-p $keys_s" "24$HOUR h" @@ -399,40 +422,40 @@ grib_check_key_equals $temp "-p $keys_i" "24 h" grib_check_key_equals $temp "-p $keys_d" "24 h" -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s stepRange=60m-2h $fn $temp +${tools_dir}/grib_set -s stepRange=60m-2h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1 h 1 h" -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" keys__="stepRange,startStep,endStep" keys_s="stepRange:s,startStep:s,endStep:s" keys_i="stepRange:i,startStep:i,endStep:i" keys_d="stepRange:d,startStep:d,endStep:d" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 m 2 h" grib_check_key_equals $temp "-p $keys__" "0$HOUR-2$HOUR 0$HOUR 2$HOUR" grib_check_key_equals $temp "-p $keys_s" "0$HOUR-2$HOUR 0$HOUR 2$HOUR" grib_check_key_equals $temp "-p $keys_i" "2 0 2" grib_check_key_equals $temp "-p $keys_d" "2 0 2" -${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D" grib_check_key_equals $temp "-p $keys__" "24$HOUR-48$HOUR 24$HOUR 48$HOUR" grib_check_key_equals $temp "-p $keys_s" "24$HOUR-48$HOUR 24$HOUR 48$HOUR" grib_check_key_equals $temp "-p $keys_i" "48 24 48" grib_check_key_equals $temp "-p $keys_d" "48 24 48" -${tools_dir}/grib_set -s forecastTime=25,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +${tools_dir}/grib_set -s forecastTime=25,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp grib_check_key_equals $temp "-p $low_level_keys" "25 h 1 D" grib_check_key_equals $temp "-p $keys__" "25$HOUR-49$HOUR 25$HOUR 49$HOUR" grib_check_key_equals $temp "-p $keys_s" "25$HOUR-49$HOUR 25$HOUR 49$HOUR" grib_check_key_equals $temp "-p $keys_i" "49 25 49" grib_check_key_equals $temp "-p $keys_d" "49 25 49" -${tools_dir}/grib_set -s forecastTime=45,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=15,indicatorOfUnitForTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=45,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=15,indicatorOfUnitForTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "45 m 15 m" grib_check_key_equals $temp "-p $keys__" "45m-60m 45m 60m" #grib_check_key_equals $temp "-p $keys_s" "45-60 45 60" @@ -440,28 +463,28 @@ grib_check_key_equals $temp "-p $keys_s" "45m-60m 45m 60m" grib_check_key_equals $temp "-p $keys_i" "60 45 60" grib_check_key_equals $temp "-p $keys_d" "60 45 60" -${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m 2 h" grib_check_key_equals $temp "-p $keys__" "1$HOUR-3$HOUR 1$HOUR 3$HOUR" grib_check_key_equals $temp "-p $keys_s" "1$HOUR-3$HOUR 1$HOUR 3$HOUR" grib_check_key_equals $temp "-p $keys_i" "3 1 3" grib_check_key_equals $temp "-p $keys_d" "3 1 3" -${tools_dir}/grib_set -s forecastTime=18,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=18,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "18 h 6 h" grib_check_key_equals $temp "-p $keys__" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_s" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_i" "24 18 24" grib_check_key_equals $temp "-p $keys_d" "24 18 24" -${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=360,indicatorOfUnitForTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=360,indicatorOfUnitForTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1080 m 360 m" grib_check_key_equals $temp "-p $keys__" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_s" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_i" "24 18 24" grib_check_key_equals $temp "-p $keys_d" "24 18 24" -${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1080 m 6 h" grib_check_key_equals $temp "-p $keys__" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_s" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" diff --git a/tools/bufr_ls.cc b/tools/bufr_ls.cc index c57114617..b3ebaf531 100644 --- a/tools/bufr_ls.cc +++ b/tools/bufr_ls.cc @@ -17,7 +17,7 @@ grib_option grib_options[] = { { "F:", 0, 0, 1, 1, "%g" }, { "P:", 0, 0, 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "j", 0, "JSON output\n", 0, 1, 0 }, + { "j", 0, "JSON output.\n", 0, 1, 0 }, /* {"B:",0,0,0,1,0}, */ { "s:", 0, 0, 0, 1, 0 }, { "n:", 0, 0, 1, 1, "ls" }, diff --git a/tools/bufr_3to4.cc b/tools/deprecated/bufr_3to4.cc similarity index 100% rename from tools/bufr_3to4.cc rename to tools/deprecated/bufr_3to4.cc diff --git a/tools/mars_request.cc b/tools/deprecated/mars_request.cc similarity index 100% rename from tools/mars_request.cc rename to tools/deprecated/mars_request.cc diff --git a/tools/grib_histogram.cc b/tools/grib_histogram.cc index 90a7e8532..6c84da43a 100644 --- a/tools/grib_histogram.cc +++ b/tools/grib_histogram.cc @@ -62,7 +62,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) size_t last_size = 0; long missingValuesPresent; double delta; - int err = 0; double* values = NULL; size_t size; @@ -76,14 +75,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) names[name_count++] = options->requested_print_keys[i].name; } - if (!options->skip) { - if (options->set_values_count != 0) - err = grib_set_values(h, options->set_values, options->set_values_count); - - if (err != GRIB_SUCCESS && options->fail) - exit(err); - } - GRIB_CHECK(grib_get_long(h, "missingValuesPresent", &missingValuesPresent), 0); GRIB_CHECK(grib_get_size(h, "values", &size), 0); diff --git a/tools/grib_ls.cc b/tools/grib_ls.cc index 59f25306b..c5d06df01 100644 --- a/tools/grib_ls.cc +++ b/tools/grib_ls.cc @@ -17,7 +17,7 @@ grib_option grib_options[] = { { "F:", 0, 0, 1, 1, "%g" }, { "P:", 0, 0, 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "j", 0, "JSON output\n", 0, 1, 0 }, + { "j", 0, "JSON output.\n", 0, 1, 0 }, { "B:", 0, 0, 0, 1, 0 }, { "l:", 0, 0, 0, 1, 0 }, { "s:", 0, 0, 0, 1, 0 }, diff --git a/tools/grib_options.cc b/tools/grib_options.cc index c15de1d80..b612db63a 100644 --- a/tools/grib_options.cc +++ b/tools/grib_options.cc @@ -39,7 +39,7 @@ static grib_options_help grib_options_help_list[] = { { "e:", "tolerance", "\n\t\tOnly values whose difference is more than tolerance are considered different.\n" }, { "f", 0, "Force. Force the execution not to fail on error.\n" }, { "F:", "format", "\n\t\tC style format for floating-point values.\n" }, - { "g", 0, "Copy GTS header. \n" }, + { "g", 0, "Copy GTS header.\n" }, { "G", 0, "GRIBEX compatibility mode.\n" }, { "i:", "index", "\n\t\tData value corresponding to the given index is printed.\n" }, @@ -81,7 +81,7 @@ static grib_options_help grib_options_help_list[] = { "\n\t\tIn the value you can also use the forward-slash character '/' to specify an OR condition (i.e. a logical disjunction)" "\n\t\tNote: only one -w clause is allowed.\n" }, { "v", 0, "Verbose.\n" }, - { "7", 0, "Does not fail when the message has wrong length\n" }, + { "7", 0, "Does not fail when the message has wrong length.\n" }, { "A:", "absolute error\n", "\tCompare floating-point values using the absolute error as tolerance.\n\t\tDefault is absolute error=0\n" }, { "C", 0, "C code mode. A C code program generating the message is dumped.\n" }, @@ -98,7 +98,7 @@ static grib_options_help grib_options_help_list[] = { { "S", 0, "Strict. Only messages matching all the constraints are copied to" "\n\t\tthe output file\n" }, - { "T:", "T | B | M | A", "Message type. T->GTS, B->BUFR, M->METAR (Experimental), A->Any (Experimental).\n\t\t\t\tThe input file is interpreted according to the message type.\n" }, + { "T:", "T | B | A", "Message type. T->GTS, B->BUFR, A->Any (Experimental).\n\t\t\tThe input file is interpreted according to the message type.\n" }, { "V", 0, "Version.\n" }, { "W:", "width", "\n\t\tMinimum width of each column in output. Default is 10.\n" }, { "X:", "offset", "\n\t\tInput file offset in bytes. Processing of the input file will start from the given offset.\n" },