From d23e35c6ce50fbcc94b23c5757a9a525185ae95e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 4 Aug 2023 13:23:39 +0000 Subject: [PATCH] Testing: GRIB1 with GDS not present --- definitions/grib1/grid_255.def | 1 + ...b_accessor_class_gds_not_present_bitmap.cc | 11 +++++++-- tests/CMakeLists.txt | 1 + tests/grib1_gds_not_present.sh | 23 +++++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 definitions/grib1/grid_255.def create mode 100755 tests/grib1_gds_not_present.sh diff --git a/definitions/grib1/grid_255.def b/definitions/grib1/grid_255.def new file mode 100644 index 000000000..c0f6d1337 --- /dev/null +++ b/definitions/grib1/grid_255.def @@ -0,0 +1 @@ +label "_empty"; diff --git a/src/grib_accessor_class_gds_not_present_bitmap.cc b/src/grib_accessor_class_gds_not_present_bitmap.cc index 93431c9db..d8ec8ecd1 100644 --- a/src/grib_accessor_class_gds_not_present_bitmap.cc +++ b/src/grib_accessor_class_gds_not_present_bitmap.cc @@ -24,6 +24,7 @@ IMPLEMENTS = unpack_double IMPLEMENTS = pack_double IMPLEMENTS = value_count + IMPLEMENTS = get_native_type MEMBERS=const char* missing_value MEMBERS=const char* number_of_values MEMBERS=const char* number_of_points @@ -43,6 +44,7 @@ or edit "accessor.class" and rerun ./make_class.pl */ +static int get_native_type(grib_accessor*); static int pack_double(grib_accessor*, const double* val, size_t* len); static int unpack_double(grib_accessor*, double* val, size_t* len); static int value_count(grib_accessor*, long*); @@ -77,7 +79,7 @@ static grib_accessor_class _grib_accessor_class_gds_not_present_bitmap = { &value_count, /* get number of values */ 0, /* get number of bytes */ 0, /* get offset to bytes */ - 0, /* get native type */ + &get_native_type, /* get native type */ 0, /* get sub_section */ 0, /* pack_missing */ 0, /* is_missing */ @@ -132,7 +134,7 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) static int value_count(grib_accessor* a, long* number_of_points) { grib_accessor_gds_not_present_bitmap* self = (grib_accessor_gds_not_present_bitmap*)a; - *number_of_points = 0; + *number_of_points = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_points, number_of_points); } @@ -207,3 +209,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) // a possible implementation return GRIB_NOT_IMPLEMENTED; } + +static int get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_DOUBLE; +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f97524872..d5ce08fdf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -236,6 +236,7 @@ if( HAVE_BUILD_TOOLS ) metar_compare bufr_set grib_ieee + grib1_gds_not_present grib_sh_ieee64 grib_optimize_scaling grib_optimize_scaling_sh diff --git a/tests/grib1_gds_not_present.sh b/tests/grib1_gds_not_present.sh new file mode 100755 index 000000000..36fffae56 --- /dev/null +++ b/tests/grib1_gds_not_present.sh @@ -0,0 +1,23 @@ +#!/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 + +REDIRECT=/dev/null + +label="grib1_gds_not_present_test" +tempGrib=temp.$label.grib + +input=$data_dir/reduced_latlon_surface.grib1 +${tools_dir}/grib_set -s gridDescriptionSectionPresent=0 $input $tempGrib +${tools_dir}/grib_dump $tempGrib > $REDIRECT 2>&1 + +# Clean up +rm -f $tempGrib