From a9e361fb9655205ad548aabf62e265e3d9da091e Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 30 Apr 2024 17:13:31 +0100 Subject: [PATCH 01/14] ECC-1817: Tools documentation: grib_compare/bufr_compare '-f' option --- tools/bufr_compare.cc | 2 +- tools/grib_compare.cc | 2 +- tools/gts_compare.cc | 2 +- tools/metar_compare.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc index e0447e20b..325c67cd3 100644 --- a/tools/bufr_compare.cc +++ b/tools/bufr_compare.cc @@ -26,7 +26,7 @@ grib_option grib_options[] = { { "A:", 0, 0, 0, 1, 0 }, { "t:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -R -A.\n", 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "f", 0, 0, 0, 1, 0 }, + { "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, { "q", 0, 0, 1, 0, 0 }, { "M", 0, 0, 1, 0, 0 }, diff --git a/tools/grib_compare.cc b/tools/grib_compare.cc index 558ff0386..ba86c1a1f 100644 --- a/tools/grib_compare.cc +++ b/tools/grib_compare.cc @@ -27,7 +27,7 @@ grib_option grib_options[] = { { "P", 0, "Compare data values using the packing error as tolerance.\n", 0, 1, 0 }, { "T:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -P -R -A.\n", 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "f", 0, 0, 0, 1, 0 }, + { "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, { "q", 0, 0, 1, 0, 0 }, { "M", 0, 0, 1, 0, 0 }, diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc index 1dc362059..d5cd47126 100644 --- a/tools/gts_compare.cc +++ b/tools/gts_compare.cc @@ -23,7 +23,7 @@ grib_option grib_options[] = { /*{"R:",0,0,0,1,0},*/ /*{"A:",0,0,0,1,0},*/ { "w:", 0, 0, 0, 1, 0 }, - { "f", 0, 0, 0, 1, 0 }, + { "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, { "q", 0, 0, 1, 0, 0 }, { "I", 0, 0, 1, 0, 0 }, diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc index a86cafd0d..d5aa9315b 100644 --- a/tools/metar_compare.cc +++ b/tools/metar_compare.cc @@ -20,7 +20,7 @@ grib_option grib_options[] = { { "R:", 0, 0, 0, 1, 0 }, { "A:", 0, 0, 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "f", 0, 0, 0, 1, 0 }, + { "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, { "q", 0, 0, 1, 0, 0 }, { "I", 0, 0, 1, 0, 0 }, From 7d49e7b87acc8a14bcd48ba89f8ad5025c423d76 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 1 May 2024 14:20:26 +0100 Subject: [PATCH 02/14] Compiler warning: parameter 'err' set but not used --- tests/CMakeLists.txt | 3 +++ tests/grib_histogram.sh | 21 ++++++++++++++++++++ tests/grib_to_json.sh | 43 +++++++++++++++++++++++++++++++++++++++++ tests/grib_to_ppm.sh | 24 +++++++++++++++++++++++ tools/metar_compare.cc | 4 ++-- 5 files changed, 93 insertions(+), 2 deletions(-) create mode 100755 tests/grib_histogram.sh create mode 100755 tests/grib_to_json.sh create mode 100755 tests/grib_to_ppm.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 56bfa91ed..31d1b744f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -226,6 +226,9 @@ if( HAVE_BUILD_TOOLS ) grib_keys_iter grib_keys_iter_skip grib_geo_iter + grib_to_json + grib_to_ppm + grib_histogram bufr_get_element bufr_wmo_tables bufr_extract_headers diff --git a/tests/grib_histogram.sh b/tests/grib_histogram.sh new file mode 100755 index 000000000..c5b56ab22 --- /dev/null +++ b/tests/grib_histogram.sh @@ -0,0 +1,21 @@ +#!/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 + +label="grib_histogram_test" +REDIRECT=/dev/null +tempOut=temp.$label.txt + +${tools_dir}/grib_histogram $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut +${tools_dir}/grib_histogram $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut + +# Clean up +rm -f $tempOut diff --git a/tests/grib_to_json.sh b/tests/grib_to_json.sh new file mode 100755 index 000000000..be05aa00c --- /dev/null +++ b/tests/grib_to_json.sh @@ -0,0 +1,43 @@ +#!/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 + +label="grib_to_json_test" +REDIRECT=/dev/null +tempOut=temp.$label.txt + +if [ ! -x "${tools_dir}/grib_to_json" ]; then + exit 0 +fi + +# Currently only works for GRIB edition 1 !!! +${tools_dir}/grib_to_json $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut + +# Decide if we have the JSON verifier commandline utility +JSON_VERIF="json_xs" +JSON_CHECK="" +if command -v $JSON_VERIF >/dev/null 2>&1; then + JSON_CHECK=$JSON_VERIF +fi + +# Check the json_xs command actually works! +set +e +echo '[]' | json_xs > $REDIRECT 2>&1 +if [ $? -ne 0 ]; then JSON_CHECK=""; fi +set -e +echo "Using $JSON_CHECK ..." + +if test "x$JSON_CHECK" != "x"; then + json_xs < $tempOut >$REDIRECT 2> $REDIRECT +fi + +# Clean up +rm -f $tempOut diff --git a/tests/grib_to_ppm.sh b/tests/grib_to_ppm.sh new file mode 100755 index 000000000..470f169ff --- /dev/null +++ b/tests/grib_to_ppm.sh @@ -0,0 +1,24 @@ +#!/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 + +label="grib_to_ppm_test" +tempOut=temp.$label.txt + +if [ ! -x "${tools_dir}/grib2ppm" ]; then + exit 0 +fi + +${tools_dir}/grib2ppm $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut +${tools_dir}/grib2ppm $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut + +# Clean up +rm -f $tempOut diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc index d5aa9315b..6ffc5db5a 100644 --- a/tools/metar_compare.cc +++ b/tools/metar_compare.cc @@ -713,7 +713,7 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, return GRIB_SUCCESS; } -static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* err) +static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* pErr) { int ret = 0; const char* name = NULL; @@ -733,7 +733,7 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_ if (xa == NULL || (xa->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) continue; if (compare_values(options, h1, h2, name, GRIB_TYPE_UNDEFINED)) { - err++; + (*pErr)++; write_messages(h1, h2); ret = 1; } From 147bdc429083a2fa28bfdb9267349f4acc1e477f Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 1 May 2024 14:29:46 +0100 Subject: [PATCH 03/14] Compiler warning: parameter 'err' set but not used --- tools/gts_compare.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc index d5cd47126..3a084893d 100644 --- a/tools/gts_compare.cc +++ b/tools/gts_compare.cc @@ -559,7 +559,7 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, return GRIB_SUCCESS; } -static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* err) +static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* pErr) { int ret = 0; const char* name = NULL; @@ -580,7 +580,7 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_ if (xa == NULL || (xa->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) continue; if (compare_values(options, h1, h2, name, GRIB_TYPE_UNDEFINED)) { - err++; + (*pErr)++; write_messages(h1, h2); ret = 1; } From 7688705e4d03fa9cb96eeb2da267b36372956132 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 1 May 2024 15:49:54 +0100 Subject: [PATCH 04/14] Test generator --- tests/create_test.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/create_test.sh b/tests/create_test.sh index 3be842e8e..a63abcb5f 100755 --- a/tests/create_test.sh +++ b/tests/create_test.sh @@ -43,6 +43,7 @@ tempGrib=temp.\$label.grib tempBufr=temp.\$label.bufr tempFilt=temp.\$label.filt tempLog=temp.\$label.log +tempOut=temp.\$label.txt tempRef=temp.\$label.ref sample_grib2=\$ECCODES_SAMPLES_PATH/GRIB2.tmpl @@ -61,7 +62,8 @@ sample_bufr4=\$ECCODES_SAMPLES_PATH/BUFR4.tmpl #\${tools_dir}/bufr_set #... -rm -f \$tempGrib \$tempBufr \$tempFilt \$tempLog \$tempRef +# Clean up +rm -f \$tempGrib \$tempBufr \$tempFilt \$tempLog \$tempOut \$tempRef EOF echo >&2 From a76e0f57d395426f84b75158c06be432bd95853e Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 1 May 2024 15:50:18 +0100 Subject: [PATCH 05/14] Testing: Extra tools --- tests/CMakeLists.txt | 1 + tests/grib_list_keys.sh | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 tests/grib_list_keys.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 31d1b744f..b26747382 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -228,6 +228,7 @@ if( HAVE_BUILD_TOOLS ) grib_geo_iter grib_to_json grib_to_ppm + grib_list_keys grib_histogram bufr_get_element bufr_wmo_tables diff --git a/tests/grib_list_keys.sh b/tests/grib_list_keys.sh new file mode 100755 index 000000000..c93a8fc63 --- /dev/null +++ b/tests/grib_list_keys.sh @@ -0,0 +1,21 @@ +#!/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 + +label="grib_list_keys_test" +tempOut=temp.$label.txt + +if [ -d "$ECCODES_DEFINITION_PATH" ]; then + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/boot.def +fi + +# Clean up +rm -f $tempOut From 906a395cc58bed789c4687f7149e24c1da594acc Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 1 May 2024 16:02:43 +0100 Subject: [PATCH 06/14] Testing: Fix broken test --- tests/grib_list_keys.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/grib_list_keys.sh b/tests/grib_list_keys.sh index c93a8fc63..c5b71cb07 100755 --- a/tests/grib_list_keys.sh +++ b/tests/grib_list_keys.sh @@ -14,7 +14,9 @@ label="grib_list_keys_test" tempOut=temp.$label.txt if [ -d "$ECCODES_DEFINITION_PATH" ]; then - ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/boot.def + if [ -x "${tools_dir}/grib_list_keys" ]; then + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/boot.def + fi fi # Clean up From 49d742eabe894806e06d70b4b08e96e7e95a9bbb Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 1 May 2024 18:08:34 +0100 Subject: [PATCH 07/14] Testing: grib_sub_area_check --- tests/CMakeLists.txt | 1 + tests/grib_sub_area_check.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 tests/grib_sub_area_check.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b26747382..43dd441cd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -228,6 +228,7 @@ if( HAVE_BUILD_TOOLS ) grib_geo_iter grib_to_json grib_to_ppm + grib_sub_area_check grib_list_keys grib_histogram bufr_get_element diff --git a/tests/grib_sub_area_check.sh b/tests/grib_sub_area_check.sh new file mode 100755 index 000000000..a80ea6be7 --- /dev/null +++ b/tests/grib_sub_area_check.sh @@ -0,0 +1,29 @@ +#!/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 + +label="grib_sub_area_check_test" +tempOut=temp.$label.txt + +if [ ! -x "${tools_dir}/gg_sub_area_check" ]; then + exit 0 +fi + +f1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +f2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +${tools_dir}/gg_sub_area_check $f1 $f2 > $tempOut + +f1=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib1.tmpl +f2=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl +${tools_dir}/gg_sub_area_check $f1 $f2 > $tempOut + +# Clean up +rm -f $tempOut From 6874520bfc48a589b614f6d53e4ccc70d0219431 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 1 May 2024 21:41:59 +0100 Subject: [PATCH 08/14] Testing: grib_to_ppm and grib_sub_area_check --- tests/grib_sub_area_check.sh | 6 ++++++ tests/grib_to_ppm.sh | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/tests/grib_sub_area_check.sh b/tests/grib_sub_area_check.sh index a80ea6be7..9b602e4cb 100755 --- a/tests/grib_sub_area_check.sh +++ b/tests/grib_sub_area_check.sh @@ -17,6 +17,12 @@ if [ ! -x "${tools_dir}/gg_sub_area_check" ]; then exit 0 fi +set +e +${tools_dir}/gg_sub_area_check +status=$? +set -e +[ $status -ne 0 ] + f1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl f2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl ${tools_dir}/gg_sub_area_check $f1 $f2 > $tempOut diff --git a/tests/grib_to_ppm.sh b/tests/grib_to_ppm.sh index 470f169ff..0b2f63308 100755 --- a/tests/grib_to_ppm.sh +++ b/tests/grib_to_ppm.sh @@ -17,6 +17,11 @@ if [ ! -x "${tools_dir}/grib2ppm" ]; then exit 0 fi +# No options +${tools_dir}/grib2ppm + +${tools_dir}/grib2ppm -l 6 -u 7 -c $data_dir/sample.grib2 > $tempOut + ${tools_dir}/grib2ppm $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut ${tools_dir}/grib2ppm $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut From 1f335a011e88e85c4a6909cdbad071581fd25b48 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 1 May 2024 21:53:06 +0100 Subject: [PATCH 09/14] Testing: big2gribex --- tests/CMakeLists.txt | 1 + tests/big2gribex.sh | 23 +++++++++++++++++++++++ tools/big2gribex.cc | 21 ++++++--------------- 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100755 tests/big2gribex.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 43dd441cd..1508b820a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -228,6 +228,7 @@ if( HAVE_BUILD_TOOLS ) grib_geo_iter grib_to_json grib_to_ppm + big2gribex grib_sub_area_check grib_list_keys grib_histogram diff --git a/tests/big2gribex.sh b/tests/big2gribex.sh new file mode 100755 index 000000000..c8c0b6098 --- /dev/null +++ b/tests/big2gribex.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 + +label="big2gribex_test" +tempGrib=temp.$label.grib + +if [ ! -x ${tools_dir}/big2gribex ]; then + exit 0 +fi + +${tools_dir}/big2gribex $data_dir/test.grib1 $tempGrib + +# Clean up +rm -f $tempGrib diff --git a/tools/big2gribex.cc b/tools/big2gribex.cc index a36b01126..c2797a821 100644 --- a/tools/big2gribex.cc +++ b/tools/big2gribex.cc @@ -8,18 +8,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/* - * Implementation: big2gribex - * - * Description: - * - */ - #include #include #include "grib_api.h" -void usage(char*); + +static void usage(const char* progname) +{ + printf("\nUsage: %s grib_in grib_out\n", progname); + exit(1); +} int main(int argc, char* argv[]) { @@ -70,12 +68,5 @@ int main(int argc, char* argv[]) exit(1); } - return 0; } - -void usage(char* progname) -{ - printf("\nUsage: %s grib_in grib_out\n", progname); - exit(1); -} From 3ffb5a6bd0cceb25c201d8d370984fe6788dc6b1 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 2 May 2024 08:23:00 +0100 Subject: [PATCH 10/14] Testing: grib_merge --- tests/CMakeLists.txt | 1 + tests/grib_list_keys.sh | 5 ++++- tests/grib_merge.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 tests/grib_merge.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1508b820a..ac0f133de 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -228,6 +228,7 @@ if( HAVE_BUILD_TOOLS ) grib_geo_iter grib_to_json grib_to_ppm + grib_merge big2gribex grib_sub_area_check grib_list_keys diff --git a/tests/grib_list_keys.sh b/tests/grib_list_keys.sh index c5b71cb07..c58bddc96 100755 --- a/tests/grib_list_keys.sh +++ b/tests/grib_list_keys.sh @@ -15,7 +15,10 @@ tempOut=temp.$label.txt if [ -d "$ECCODES_DEFINITION_PATH" ]; then if [ -x "${tools_dir}/grib_list_keys" ]; then - ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/boot.def + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/boot.def > $tempOut + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.4.2000.def > $tempOut + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.3.0.def > $tempOut + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.3.120.def > $tempOut fi fi diff --git a/tests/grib_merge.sh b/tests/grib_merge.sh new file mode 100755 index 000000000..33c7960ce --- /dev/null +++ b/tests/grib_merge.sh @@ -0,0 +1,26 @@ +#!/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 + +label="grib_merge_test" + +tempGrib=temp.$label.grib +tempFilt=temp.$label.filt +tempLog=temp.$label.log +tempOut=temp.$label.txt +tempRef=temp.$label.ref + +f1=$ECCODES_SAMPLES_PATH/regular_ll_pl_grib1.tmpl +f2=$ECCODES_SAMPLES_PATH/regular_ll_sfc_grib1.tmpl +${tools_dir}/grib_merge $f1 $f2 $tempGrib + +# Clean up +rm -f $tempGrib $tempFilt $tempLog $tempOut $tempRef From 8168444b122fc731afb9537baef41c5d14611a42 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 2 May 2024 08:29:38 +0100 Subject: [PATCH 11/14] Testing: grib_merge --- tests/grib_merge.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/grib_merge.sh b/tests/grib_merge.sh index 33c7960ce..acf59e7a6 100755 --- a/tests/grib_merge.sh +++ b/tests/grib_merge.sh @@ -13,14 +13,10 @@ label="grib_merge_test" tempGrib=temp.$label.grib -tempFilt=temp.$label.filt -tempLog=temp.$label.log -tempOut=temp.$label.txt -tempRef=temp.$label.ref f1=$ECCODES_SAMPLES_PATH/regular_ll_pl_grib1.tmpl f2=$ECCODES_SAMPLES_PATH/regular_ll_sfc_grib1.tmpl ${tools_dir}/grib_merge $f1 $f2 $tempGrib # Clean up -rm -f $tempGrib $tempFilt $tempLog $tempOut $tempRef +rm -f $tempGrib From e06656c67309faf2d68517ce5d193e8008a4be97 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 2 May 2024 08:50:21 +0000 Subject: [PATCH 12/14] Testing: Fix grib2ppm test --- tests/grib_to_ppm.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/grib_to_ppm.sh b/tests/grib_to_ppm.sh index 0b2f63308..6deea0f8a 100755 --- a/tests/grib_to_ppm.sh +++ b/tests/grib_to_ppm.sh @@ -21,9 +21,7 @@ fi ${tools_dir}/grib2ppm ${tools_dir}/grib2ppm -l 6 -u 7 -c $data_dir/sample.grib2 > $tempOut - -${tools_dir}/grib2ppm $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut -${tools_dir}/grib2ppm $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut +${tools_dir}/grib2ppm $data_dir/sample.grib2 > $tempOut # Clean up rm -f $tempOut From 607f15bbdcba70fb9ae696e97626baf9ef784726 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 2 May 2024 10:54:23 +0100 Subject: [PATCH 13/14] Tools: Fix for Windows and constant fields --- tools/grib2ppm.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/grib2ppm.cc b/tools/grib2ppm.cc index cac306481..820178789 100644 --- a/tools/grib2ppm.cc +++ b/tools/grib2ppm.cc @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) continue; } - f = fopen(argv[i], "r"); + f = fopen(argv[i], "rb"); if (!f) { perror(argv[i]); exit(1); @@ -226,7 +226,9 @@ int main(int argc, char* argv[]) if (v > ucap) { v = ucap; } - c = (v - min) * 65535 / (max - min); + double denom = 1; + if (max != min) denom = max - min; + c = (v - min) * 65535 / denom; hh = c >> 8; l = c & 0xff; printf("%c", hh); From c04bc4fa03e3b19d9f83d5ab9cd01ebad54ae8d2 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 2 May 2024 10:25:11 +0000 Subject: [PATCH 14/14] ECC-1818: GRIB Geoiterator issues for Lambert azimuthal equal area --- ...b_iterator_class_lambert_azimuthal_equal_area.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/grib_iterator_class_lambert_azimuthal_equal_area.cc b/src/grib_iterator_class_lambert_azimuthal_equal_area.cc index a945ee1d2..24dba1877 100644 --- a/src/grib_iterator_class_lambert_azimuthal_equal_area.cc +++ b/src/grib_iterator_class_lambert_azimuthal_equal_area.cc @@ -209,7 +209,11 @@ static int init_oblate(grib_handle* h, sinphi_ = sin(standardParallelInRadians); /* (P->phi0); */ Q__sinb1 = pj_qsfn(sinphi_, e, one_es) / Q__qp; Q__cosb1 = sqrt(1.0 - Q__sinb1 * Q__sinb1); - Q__dd = cos(standardParallelInRadians) / (sqrt(1. - es * sinphi_ * sinphi_) * Q__rq * Q__cosb1); + if (Q__cosb1 == 0) { + Q__dd = 1.0; + } else { + Q__dd = cos(standardParallelInRadians) / (sqrt(1. - es * sinphi_ * sinphi_) * Q__rq * Q__cosb1); + } Q__ymf = (Q__xmf = Q__rq) / Q__dd; Q__xmf *= Q__dd; @@ -253,7 +257,12 @@ static int init_oblate(grib_handle* h, xy_y *= Q__dd; rho = hypot(xy_x, xy_y); Assert(rho >= EPS10); /* TODO(masn): check */ - sCe = 2. * asin(.5 * rho / Q__rq); + const double asin_arg = (0.5 * rho / Q__rq); + if (asin_arg < -1.0 || asin_arg > 1.0) { + grib_context_log(h->context, GRIB_LOG_ERROR, "Invalid value: arcsin argument=%g", asin_arg); + return GRIB_GEOCALCULUS_PROBLEM; + } + sCe = 2. * asin(asin_arg); cCe = cos(sCe); sCe = sin(sCe); xy_x *= sCe;