From 1ee583a7c9d4c66e3e4fb3b2a71709eee5b8b0c6 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 16 Feb 2023 18:29:32 +0000 Subject: [PATCH] grib_util_set_spec: input grid_ccsds gets converted to grid_simple --- tests/grib_util_set_spec.cc | 14 ++++++++++---- tests/grib_util_set_spec.sh | 10 +++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/grib_util_set_spec.cc b/tests/grib_util_set_spec.cc index a2a4b4756..a233c6ea0 100644 --- a/tests/grib_util_set_spec.cc +++ b/tests/grib_util_set_spec.cc @@ -17,11 +17,11 @@ static int get_packing_type_code(const char* packingType) { int result = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE; if (packingType == NULL) - return result; + return GRIB_UTIL_PACKING_TYPE_SAME_AS_INPUT; if (STR_EQUAL(packingType, "grid_jpeg")) result = GRIB_UTIL_PACKING_TYPE_JPEG; - if (STR_EQUAL(packingType, "grid_ccsds")) + else if (STR_EQUAL(packingType, "grid_ccsds")) result = GRIB_UTIL_PACKING_TYPE_CCSDS; else if (STR_EQUAL(packingType, "grid_simple")) result = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE; @@ -90,7 +90,10 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi packing_spec.packing_type = get_packing_type_code(packingType); packing_spec.bitsPerValue = 24; packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; - packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED; + if (packingType) + packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED; + else + packing_spec.packing = GRIB_UTIL_PACKING_SAME_AS_INPUT; /*Extra settings packing_spec.extra_settings_count++; @@ -201,7 +204,10 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi packing_spec.packing_type = get_packing_type_code(packingType); packing_spec.bitsPerValue = 24; packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; - packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED; + if (packingType) + packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED; + else + packing_spec.packing = GRIB_UTIL_PACKING_SAME_AS_INPUT; packing_spec.extra_settings_count++; packing_spec.extra_settings[0].type = GRIB_TYPE_LONG; diff --git a/tests/grib_util_set_spec.sh b/tests/grib_util_set_spec.sh index b132091ad..1e677b707 100755 --- a/tests/grib_util_set_spec.sh +++ b/tests/grib_util_set_spec.sh @@ -14,13 +14,21 @@ # -------------------------------------------------- # Regular Lat/Lon Grid # -------------------------------------------------- -infile=../data/latlon.grib +infile=${data_dir}/latlon.grib outfile=out.grib_util_set_spec.grib tempOut=temp.grib_util_set_spec.grib grib_util_set_spec=${test_dir}/grib_util_set_spec rm -f $outfile +# CCSDS input +$EXEC $grib_util_set_spec ${data_dir}/ccsds.grib2 $outfile > /dev/null +grib_check_key_equals $outfile packingType grid_ccsds + +$EXEC $grib_util_set_spec -p grid_simple ${data_dir}/ccsds.grib2 $outfile > /dev/null +grib_check_key_equals $outfile packingType grid_simple + + # GRIB1 with local definition for MARS. Convert to edition2 and remove local def $EXEC $grib_util_set_spec -e 2 -r $infile $outfile > /dev/null