From 9808b03d7681b80ed316773155c377de4c433a34 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 12 Jul 2024 09:51:12 +0100 Subject: [PATCH] ECC-1868: CMake: Add option for enabling the Geoiterator and nearest neighbour functionality --- CMakeLists.txt | 8 +- eccodes_config.h.in | 1 + examples/C/grib_get_data.sh | 5 + examples/C/grib_iterator.sh | 5 + examples/C/grib_nearest.sh | 4 + examples/C/grib_nearest_multiple.sh | 4 + examples/C/include.ctest.sh.in | 1 + examples/F90/grib_get_data.sh | 4 + examples/F90/grib_get_data_real4.sh | 4 + examples/F90/grib_nearest.sh | 4 + examples/F90/grib_nearest_four_single.sh | 4 + examples/F90/grib_nearest_single.sh | 4 + examples/F90/include.ctest.sh.in | 1 + src/accessor/grib_accessor_class_iterator.cc | 11 +++ tests/grib_bitmap.sh | 11 ++- tests/grib_change_scanning.sh | 3 + tests/grib_dump_debug.sh | 4 + tests/grib_ecc-1000.sh | 4 + tests/grib_ecc-1001.sh | 4 + tests/grib_ecc-1258.sh | 4 + tests/grib_ecc-1364.sh | 3 + tests/grib_ecc-1397.sh | 4 + tests/grib_ecc-1406.sh | 4 + tests/grib_ecc-1671.sh | 4 + tests/grib_ecc-1708.sh | 4 + tests/grib_ecc-1792.sh | 4 + tests/grib_ecc-600.sh | 4 + tests/grib_ecc-984.sh | 6 +- tests/grib_geo_iter.sh | 4 + tests/grib_grid_healpix.sh | 4 + tests/grib_grid_lamb_az_eq_area.sh | 4 + tests/grib_grid_lambert_conformal.sh | 4 + tests/grib_grid_mercator.sh | 4 + tests/grib_grid_polar_stereographic.sh | 4 + tests/grib_grid_space_view.sh | 4 + tests/grib_iterator.sh | 4 + tests/grib_jpeg.sh | 11 ++- tests/grib_ls.sh | 99 +++++++++++--------- tests/grib_nearest_test.sh | 4 + tests/grib_octahedral.sh | 3 +- tests/grib_png.sh | 14 +-- tests/grib_run_length_packing.sh | 6 +- tests/grib_second_order.sh | 33 ++++--- tests/grib_to_netcdf.sh | 4 + tests/grib_util_set_spec.sh | 21 +++-- tests/include.ctest.sh.in | 1 + 46 files changed, 260 insertions(+), 91 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2da7bf145..0a4c05cd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,10 @@ ecbuild_add_option( FEATURE BUILD_TOOLS DESCRIPTION "Build the command line tools" DEFAULT ON ) +ecbuild_add_option( FEATURE GEOGRAPHY + DESCRIPTION "Support for Geoiterator and nearest neighbour" + DEFAULT ON ) + ecbuild_add_option( FEATURE JPG DESCRIPTION "Support for JPG decoding/encoding" DEFAULT ON ) @@ -457,7 +461,7 @@ ecbuild_pkgconfig( DESCRIPTION "The ecCodes library" LIBRARIES eccodes IGNORE_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS} ${NETCDF_INCLUDE_DIRS} - VARIABLES HAVE_MEMFS HAVE_JPEG HAVE_LIBJASPER HAVE_LIBOPENJPEG + VARIABLES HAVE_MEMFS HAVE_GEOGRAPHY HAVE_JPEG HAVE_LIBJASPER HAVE_LIBOPENJPEG HAVE_ECCODES_THREADS HAVE_ECCODES_OMP_THREADS HAVE_NETCDF HAVE_FORTRAN HAVE_PNG HAVE_AEC ) @@ -469,7 +473,7 @@ if( HAVE_FORTRAN ) DESCRIPTION "The ecCodes library for Fortran 90" IGNORE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/fortran ${PROJECT_BINARY_DIR}/fortran ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS} ${NETCDF_INCLUDE_DIRS} - VARIABLES HAVE_MEMFS HAVE_JPEG HAVE_LIBJASPER HAVE_LIBOPENJPEG + VARIABLES HAVE_MEMFS HAVE_GEOGRAPHY HAVE_JPEG HAVE_LIBJASPER HAVE_LIBOPENJPEG HAVE_ECCODES_THREADS HAVE_ECCODES_OMP_THREADS HAVE_NETCDF HAVE_PNG HAVE_AEC ) diff --git a/eccodes_config.h.in b/eccodes_config.h.in index d80a4554d..2278151b0 100644 --- a/eccodes_config.h.in +++ b/eccodes_config.h.in @@ -111,6 +111,7 @@ #cmakedefine HAVE_NETCDF +#cmakedefine HAVE_GEOGRAPHY #cmakedefine HAVE_MEMFS #ifdef HAVE_MEMFS diff --git a/examples/C/grib_get_data.sh b/examples/C/grib_get_data.sh index aaf25e909..ef0d701b2 100755 --- a/examples/C/grib_get_data.sh +++ b/examples/C/grib_get_data.sh @@ -8,5 +8,10 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. . ./include.ctest.sh +set -u + +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi ${examples_dir}/c_grib_get_data > /dev/null diff --git a/examples/C/grib_iterator.sh b/examples/C/grib_iterator.sh index e54d9104d..6268cc567 100755 --- a/examples/C/grib_iterator.sh +++ b/examples/C/grib_iterator.sh @@ -8,8 +8,13 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. . ./include.ctest.sh + temp=temp.c_grib_iterator.txt +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + # These two do not have any missing data ${examples_dir}/c_grib_iterator ${data_dir}/reduced_gaussian_model_level.grib1 > /dev/null ${examples_dir}/c_grib_iterator ${data_dir}/regular_gaussian_model_level.grib1 > /dev/null diff --git a/examples/C/grib_nearest.sh b/examples/C/grib_nearest.sh index cd0bc8324..114a01876 100755 --- a/examples/C/grib_nearest.sh +++ b/examples/C/grib_nearest.sh @@ -11,6 +11,10 @@ . ./include.ctest.sh set -u +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + label="grib_nearest_c" tempTxt=temp.$label.txt tempRef=temp.$label.ref diff --git a/examples/C/grib_nearest_multiple.sh b/examples/C/grib_nearest_multiple.sh index 3d8c1ecf3..0d06f0a5b 100755 --- a/examples/C/grib_nearest_multiple.sh +++ b/examples/C/grib_nearest_multiple.sh @@ -10,6 +10,10 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + label="grib_nearest_multiple_c" temp1=$label.temp1.$$ temp2=$label.temp2.$$ diff --git a/examples/C/include.ctest.sh.in b/examples/C/include.ctest.sh.in index e861370cc..1b774a6e1 100644 --- a/examples/C/include.ctest.sh.in +++ b/examples/C/include.ctest.sh.in @@ -27,6 +27,7 @@ data_dir=@PROJECT_BINARY_DIR@/data HAVE_PRODUCT_BUFR=@HAVE_PRODUCT_BUFR@ HAVE_PRODUCT_GRIB=@HAVE_PRODUCT_GRIB@ HAVE_MEMFS=@HAVE_MEMFS@ +HAVE_GEOGRAPHY=@HAVE_GEOGRAPHY@ # use definitions from binary dir to test if installation will be correct def_dir="@CMAKE_BINARY_DIR@/@ECCODES_DEFINITION_SUFF@" diff --git a/examples/F90/grib_get_data.sh b/examples/F90/grib_get_data.sh index a77a43ed3..04125b28e 100755 --- a/examples/F90/grib_get_data.sh +++ b/examples/F90/grib_get_data.sh @@ -9,4 +9,8 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + ${examples_dir}/eccodes_f_grib_get_data > /dev/null diff --git a/examples/F90/grib_get_data_real4.sh b/examples/F90/grib_get_data_real4.sh index b251fd645..4f21b3276 100755 --- a/examples/F90/grib_get_data_real4.sh +++ b/examples/F90/grib_get_data_real4.sh @@ -9,4 +9,8 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + ${examples_dir}/eccodes_f_grib_get_data_real4 > /dev/null diff --git a/examples/F90/grib_nearest.sh b/examples/F90/grib_nearest.sh index 604f202d2..8b4665111 100755 --- a/examples/F90/grib_nearest.sh +++ b/examples/F90/grib_nearest.sh @@ -9,4 +9,8 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + ${examples_dir}/eccodes_f_grib_nearest > /dev/null diff --git a/examples/F90/grib_nearest_four_single.sh b/examples/F90/grib_nearest_four_single.sh index 22b07624f..b4b47995f 100755 --- a/examples/F90/grib_nearest_four_single.sh +++ b/examples/F90/grib_nearest_four_single.sh @@ -9,4 +9,8 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + ${examples_dir}/eccodes_f_grib_nearest_four_single diff --git a/examples/F90/grib_nearest_single.sh b/examples/F90/grib_nearest_single.sh index 0443595dd..4aa7a2c30 100755 --- a/examples/F90/grib_nearest_single.sh +++ b/examples/F90/grib_nearest_single.sh @@ -9,4 +9,8 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + ${examples_dir}/eccodes_f_grib_nearest_single diff --git a/examples/F90/include.ctest.sh.in b/examples/F90/include.ctest.sh.in index 054747238..18b310526 100644 --- a/examples/F90/include.ctest.sh.in +++ b/examples/F90/include.ctest.sh.in @@ -26,6 +26,7 @@ data_dir=@PROJECT_BINARY_DIR@/data HAVE_PRODUCT_BUFR=@HAVE_PRODUCT_BUFR@ HAVE_PRODUCT_GRIB=@HAVE_PRODUCT_GRIB@ HAVE_MEMFS=@HAVE_MEMFS@ +HAVE_GEOGRAPHY=@HAVE_GEOGRAPHY@ # use definitions from binary dir to test if installation will be correct def_dir="@CMAKE_BINARY_DIR@/@ECCODES_DEFINITION_SUFF@" diff --git a/src/accessor/grib_accessor_class_iterator.cc b/src/accessor/grib_accessor_class_iterator.cc index 4cdfd6670..a92f3375b 100644 --- a/src/accessor/grib_accessor_class_iterator.cc +++ b/src/accessor/grib_accessor_class_iterator.cc @@ -26,6 +26,7 @@ void grib_accessor_class_iterator_t::dump(grib_accessor* a, grib_dumper* dumper) grib_dump_label(dumper, a, NULL); } +#if defined(HAVE_GEOGRAPHY) grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error) { grib_handle* h = (grib_handle*)ch; @@ -46,3 +47,13 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int return iter; } +#else +grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error) +{ + *error = GRIB_FUNCTIONALITY_NOT_ENABLED; + grib_context_log(ch->context, GRIB_LOG_ERROR, + "Geoiterator support not enabled. Please rebuild with -DENABLE_GEOGRAPHY=ON"); + + return NULL; +} +#endif diff --git a/tests/grib_bitmap.sh b/tests/grib_bitmap.sh index fb5994db4..456f3255e 100755 --- a/tests/grib_bitmap.sh +++ b/tests/grib_bitmap.sh @@ -87,12 +87,13 @@ EOF ${tools_dir}/grib_filter -o $temp1 $tempRules $grib1 ${tools_dir}/grib_filter -o $temp2 $tempRules $grib2 -${tools_dir}/grib_get_data -m missing $temp1 > $tempData1 -${tools_dir}/grib_get_data -m missing $temp2 > $tempData2 - -diff $tempData1 $tempData2 -rm -f $tempData1 $tempData2 +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + ${tools_dir}/grib_get_data -m missing $temp1 > $tempData1 + ${tools_dir}/grib_get_data -m missing $temp2 > $tempData2 + diff $tempData1 $tempData2 + rm -f $tempData1 $tempData2 +fi # ECC-1233: Allow printing of 'byte' keys e.g., bitmap, section paddings # ----------------------------------------------------------------------- diff --git a/tests/grib_change_scanning.sh b/tests/grib_change_scanning.sh index 5f1d46596..588189034 100755 --- a/tests/grib_change_scanning.sh +++ b/tests/grib_change_scanning.sh @@ -17,6 +17,9 @@ tempGribB=temp.$label.B.grib tempText=temp.$label.txt tempRef=temp.$label.ref +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi editions="1 2" gridTypes="regular_ll rotated_ll" diff --git a/tests/grib_dump_debug.sh b/tests/grib_dump_debug.sh index b5397cb47..56ceb40d0 100755 --- a/tests/grib_dump_debug.sh +++ b/tests/grib_dump_debug.sh @@ -12,6 +12,10 @@ label="grib_dump_debug_test" temp=temp.$label.txt +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + if [ $HAVE_MEMFS -eq 1 ]; then unset ECCODES_DEFINITION_PATH unset ECCODES_SAMPLES_PATH diff --git a/tests/grib_ecc-1000.sh b/tests/grib_ecc-1000.sh index 87f1123f4..794dd2f43 100755 --- a/tests/grib_ecc-1000.sh +++ b/tests/grib_ecc-1000.sh @@ -10,6 +10,10 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + # --------------------------------------------------------- # This is the test for the JIRA issue ECC-1000 # Nearest neighbour using grib_get/grib_ls on severa files diff --git a/tests/grib_ecc-1001.sh b/tests/grib_ecc-1001.sh index 4e3142f9f..0120a9e2d 100755 --- a/tests/grib_ecc-1001.sh +++ b/tests/grib_ecc-1001.sh @@ -10,6 +10,10 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + # --------------------------------------------------------- # This is the test for the JIRA issue ECC-1001 # grib_ls -j -l command (JSON for nearest) diff --git a/tests/grib_ecc-1258.sh b/tests/grib_ecc-1258.sh index da86e0b6a..1c08b6889 100755 --- a/tests/grib_ecc-1258.sh +++ b/tests/grib_ecc-1258.sh @@ -16,6 +16,10 @@ tempGrib=temp.$label.grib tempOut=temp.$label.txt sample_grib1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + cat > $tempFilt < $tempLog ${tools_dir}/grib_ls -p count,step $infile >> $tempLog ${tools_dir}/grib_ls $infile >> $tempLog -${tools_dir}/grib_ls -l 0,0,1 $infile >> $tempLog -${tools_dir}/grib_get -l 0,0,1 $infile >> $tempLog +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + ${tools_dir}/grib_ls -l 0,0,1 $infile >> $tempLog + ${tools_dir}/grib_get -l 0,0,1 $infile >> $tempLog +fi ${tools_dir}/grib_get -p count,step $infile >> $tempLog ${tools_dir}/grib_get -P count $infile >> $tempLog @@ -90,15 +92,16 @@ regular_gaussian_surface.grib2 regular_latlon_surface.grib1 regular_latlon_surface.grib2 " +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + for file in $files; do + [ -f "$file" ] + echo $file >> $tempLog + ${tools_dir}/grib_ls -l 40,28 $file | grep index | awk '{print $4;}' >> $tempLog + done -for file in $files; do - [ -f "$file" ] - echo $file >> $tempLog - ${tools_dir}/grib_ls -l 40,28 $file | grep index | awk '{print $4;}' >> $tempLog -done - -diff $tempLog ls.log -rm -f $tempLog + diff $tempLog ls.log + rm -f $tempLog +fi echo "Test for bug GRIB-56..." # ------------------------------ @@ -123,16 +126,18 @@ type=`${tools_dir}/grib_get -wcount=1 -p typeOfLevel test_uuid.grib2` [ "$type" = "generalVertical" ] -echo "GRIB-213 nearest with land-sea mask..." -# ---------------------------------------------------------- -${tools_dir}/grib_ls -l 85,13,1,reduced_gaussian_lsm.grib1 reduced_gaussian_surface.grib1 >$tempText -grep -q 'Point chosen #3 index=21 .* distance=11\.' $tempText +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + echo "GRIB-213 nearest with land-sea mask..." + # ---------------------------------------------------------- + ${tools_dir}/grib_ls -l 85,13,1,reduced_gaussian_lsm.grib1 reduced_gaussian_surface.grib1 >$tempText + grep -q 'Point chosen #3 index=21 .* distance=11\.' $tempText -${tools_dir}/grib_ls -l 53,2,1,reduced_gaussian_lsm.grib1 reduced_gaussian_surface.grib1 >$tempText -grep -q 'Point chosen #2 index=749 .* distance=204\.' $tempText + ${tools_dir}/grib_ls -l 53,2,1,reduced_gaussian_lsm.grib1 reduced_gaussian_surface.grib1 >$tempText + grep -q 'Point chosen #2 index=749 .* distance=204\.' $tempText -${tools_dir}/grib_get -F%.2f -l 85,13,1,reduced_gaussian_lsm.grib1 reduced_gaussian_surface.grib1 >$tempText -grep -q '252.88' $tempText + ${tools_dir}/grib_get -F%.2f -l 85,13,1,reduced_gaussian_lsm.grib1 reduced_gaussian_surface.grib1 >$tempText + grep -q '252.88' $tempText +fi echo "ECC-278: grib_ls -n namespace..." # ---------------------------------------------------------- @@ -247,42 +252,44 @@ file=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl grib_check_key_equals $file 'expver:d' 1 grib_check_key_equals $file 'expver:s' '0001' -# JSON and lat/lon -${tools_dir}/grib_ls -j -l0,0 -p referenceValue:d $data_dir/sample.grib2 -${tools_dir}/grib_ls -j -l0,0 -p referenceValue:i $data_dir/sample.grib2 -${tools_dir}/grib_ls -j -l0,0 -p bitmap $data_dir/simple_bitmap.grib > $tempText 2>&1 -grep -q "invalid_type" $tempText -${tools_dir}/grib_ls -j -l0,0 -p nosuchkey $data_dir/sample.grib2 > $tempText 2>&1 -grep -q "nosuchkey.* null" $tempText +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + # JSON and lat/lon + ${tools_dir}/grib_ls -j -l0,0 -p referenceValue:d $data_dir/sample.grib2 + ${tools_dir}/grib_ls -j -l0,0 -p referenceValue:i $data_dir/sample.grib2 + ${tools_dir}/grib_ls -j -l0,0 -p bitmap $data_dir/simple_bitmap.grib > $tempText 2>&1 + grep -q "invalid_type" $tempText + ${tools_dir}/grib_ls -j -l0,0 -p nosuchkey $data_dir/sample.grib2 > $tempText 2>&1 + grep -q "nosuchkey.* null" $tempText +fi # -M and -g options ${tools_dir}/grib_ls -M -g $data_dir/gts.grib -${tools_dir}/grib_get -l0,0,4 $data_dir/sample.grib2 +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + ${tools_dir}/grib_get -l0,0,4 $data_dir/sample.grib2 -set +e -${tools_dir}/grib_ls -l0,0,666 $data_dir/sample.grib2 > $tempText 2>&1 -status=$? -set -e -[ $status -ne 0 ] -grep -q "Wrong mode given" $tempText + set +e + ${tools_dir}/grib_ls -l0,0,666 $data_dir/sample.grib2 > $tempText 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "Wrong mode given" $tempText -set +e -${tools_dir}/grib_ls -l poo $data_dir/sample.grib2 > $tempText 2>&1 -status=$? -set -e -[ $status -ne 0 ] -grep -q "Wrong latitude value" $tempText - - -set +e -${tools_dir}/grib_ls -l0,0,1,nonexistingmask $data_dir/sample.grib2 > $tempText 2>&1 -status=$? -set -e -[ $status -ne 0 ] -grep -q "unable to open mask file" $tempText + set +e + ${tools_dir}/grib_ls -l poo $data_dir/sample.grib2 > $tempText 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "Wrong latitude value" $tempText + set +e + ${tools_dir}/grib_ls -l0,0,1,nonexistingmask $data_dir/sample.grib2 > $tempText 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "unable to open mask file" $tempText +fi # Clean up rm -f $temp1 $temp2 $tempText $tempLog diff --git a/tests/grib_nearest_test.sh b/tests/grib_nearest_test.sh index 998af27c9..7160bef74 100755 --- a/tests/grib_nearest_test.sh +++ b/tests/grib_nearest_test.sh @@ -10,6 +10,10 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + label="grib_nearest_test" temp=temp.$label.txt tempGrib=temp.$label.grib diff --git a/tests/grib_octahedral.sh b/tests/grib_octahedral.sh index 6ed838d99..5c6cbdeb4 100755 --- a/tests/grib_octahedral.sh +++ b/tests/grib_octahedral.sh @@ -25,9 +25,8 @@ grib_check_key_equals $input "global,isOctahedral" "1 1" # Check numberOfDataPoints grib_check_key_equals $input "numberOfDataPoints,numberOfCodedValues" "6599680 6599680" - # Only do lengthy iterator test if extra tests are enabled -if [ $HAVE_EXTRA_TESTS -eq 1 ]; then +if [ $HAVE_EXTRA_TESTS -eq 1 -a $HAVE_GEOGRAPHY -eq 1 ]; then ${tools_dir}/grib_get_data $input > $temp numlines=`wc -l $temp | awk '{print $1}'` [ "$numlines" = "6599681" ] # 1 + numberOfDataPoints diff --git a/tests/grib_png.sh b/tests/grib_png.sh index 64c6ba4de..f92772526 100755 --- a/tests/grib_png.sh +++ b/tests/grib_png.sh @@ -57,13 +57,15 @@ grep -q "Unable to set double array 'codedValues'" $tempErr # Nearest neighbour # ---------------------- -infile=${data_dir}/reduced_gaussian_model_level.grib2 -${tools_dir}/grib_set -r -s packingType=grid_png $infile $temp -${tools_dir}/grib_get -F%.6g -l 48.835,327.600,1 $temp > $temp1 -grep -q "224.455" $temp1 +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + infile=${data_dir}/reduced_gaussian_model_level.grib2 + ${tools_dir}/grib_set -r -s packingType=grid_png $infile $temp + ${tools_dir}/grib_get -F%.6g -l 48.835,327.600,1 $temp > $temp1 + grep -q "224.455" $temp1 -${tools_dir}/grib_ls -F%.6g -l 48.835,327.600 $temp > $temp1 -grep -q "Grid Point chosen #4 index=936 " $temp1 + ${tools_dir}/grib_ls -F%.6g -l 48.835,327.600 $temp > $temp1 + grep -q "Grid Point chosen #4 index=936 " $temp1 +fi # jPointsAreConsecutive infile=${data_dir}/reduced_gaussian_model_level.grib2 diff --git a/tests/grib_run_length_packing.sh b/tests/grib_run_length_packing.sh index 3b39bf0e8..a41fd5d7f 100755 --- a/tests/grib_run_length_packing.sh +++ b/tests/grib_run_length_packing.sh @@ -39,7 +39,11 @@ $EXEC ${test_dir}/grib_run_length_packing $tempGrib unset ECCODES_DEBUG ${tools_dir}/grib_dump -O $tempGrib -${tools_dir}/grib_get_data -mXXX $tempGrib + +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + ${tools_dir}/grib_get_data -mXXX $tempGrib +fi + grib_check_key_equals $tempGrib packingType grid_run_length stats=`${tools_dir}/grib_get -M -F%.1f -p min,max,avg $tempGrib` diff --git a/tests/grib_second_order.sh b/tests/grib_second_order.sh index 1dc6092df..0d44a87cb 100755 --- a/tests/grib_second_order.sh +++ b/tests/grib_second_order.sh @@ -94,21 +94,23 @@ grib_check_key_equals $sec_ord_bmp accuracy 4 nums=`${tools_dir}/grib_get -p numberOfDataPoints,numberOfCodedValues,numberOfMissing $sec_ord_bmp` [ "$nums" = "5969 4 5965" ] -res=`${tools_dir}/grib_get -l 33,88.5 $sec_ord_bmp` -[ "$res" = "9999 5.51552 9999 9999 " ] +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + res=`${tools_dir}/grib_get -l 33,88.5 $sec_ord_bmp` + [ "$res" = "9999 5.51552 9999 9999 " ] -res=`${tools_dir}/grib_get -l 30,90.0 $sec_ord_bmp` -[ "$res" = "5.26552 9999 9999 9999 " ] + res=`${tools_dir}/grib_get -l 30,90.0 $sec_ord_bmp` + [ "$res" = "5.26552 9999 9999 9999 " ] -res=`${tools_dir}/grib_get -l 28.5,87 $sec_ord_bmp` -[ "$res" = "9999 2.51552 9999 9999 " ] + res=`${tools_dir}/grib_get -l 28.5,87 $sec_ord_bmp` + [ "$res" = "9999 2.51552 9999 9999 " ] -res=`${tools_dir}/grib_get -l 28.5,90 $sec_ord_bmp` -[ "$res" = "3.51552 9999 5.26552 9999 " ] + res=`${tools_dir}/grib_get -l 28.5,90 $sec_ord_bmp` + [ "$res" = "3.51552 9999 5.26552 9999 " ] -# GRIB-203 nearest on M-F second order boustrophedonic -res=`${tools_dir}/grib_get -w count=1 -l 0,0,1 lfpw.grib1` -[ "$res" = "20563.4 " ] + # GRIB-203 nearest on M-F second order boustrophedonic + res=`${tools_dir}/grib_get -w count=1 -l 0,0,1 lfpw.grib1` + [ "$res" = "20563.4 " ] +fi # Unpack/pack test for second order grib1 data # -------------------------------------------- @@ -196,10 +198,11 @@ set -e [ $status -ne 0 ] grep -q "Not implemented" $tempText -${tools_dir}/grib_get_data $temp1 > $REDIRECT -${tools_dir}/grib_ls -l46,1 $temp1 > $REDIRECT -${tools_dir}/grib_ls -j -l46,1,1 $temp1 > $REDIRECT - +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + ${tools_dir}/grib_get_data $temp1 > $REDIRECT + ${tools_dir}/grib_ls -l46,1 $temp1 > $REDIRECT + ${tools_dir}/grib_ls -j -l46,1,1 $temp1 > $REDIRECT +fi # Encoding input=second_ord_rbr.grib1 diff --git a/tests/grib_to_netcdf.sh b/tests/grib_to_netcdf.sh index ba3589329..5e1aaf015 100755 --- a/tests/grib_to_netcdf.sh +++ b/tests/grib_to_netcdf.sh @@ -9,6 +9,10 @@ . ./include.ctest.sh +if [ $HAVE_GEOGRAPHY -eq 0 ]; then + exit 0 +fi + if [ $ECCODES_ON_WINDOWS -eq 1 ]; then # m2-bash messes with the system path. # %CONDA_PREFIX%\Library\usr\bin is converted to /usr/bin. diff --git a/tests/grib_util_set_spec.sh b/tests/grib_util_set_spec.sh index e18047bae..2b923edc9 100755 --- a/tests/grib_util_set_spec.sh +++ b/tests/grib_util_set_spec.sh @@ -27,8 +27,10 @@ $EXEC $grib_util_set_spec -e 2 -r $infile $outfile > /dev/null res=`${tools_dir}/grib_get -p edition,section2Used,Ni,Nj,numberOfValues,bitsPerValue $outfile` [ "$res" = "2 0 17 14 238 24" ] -# Check output file geometry -${tools_dir}/grib_get_data $outfile > /dev/null +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + # Check output file geometry + ${tools_dir}/grib_get_data $outfile > /dev/null +fi # Remove the local definition from input ${tools_dir}/grib_set -s deleteLocalDefinition=1 $infile $tempOut @@ -110,10 +112,12 @@ grib_check_key_equals $outfile packingType grid_second_order stats_new=`${tools_dir}/grib_get -F%.2f -p min,max $outfile` [ "$stats_new" = "4.84 246.90" ] -${tools_dir}/grib_get_data $outfile > /dev/null -CHECK_TOOL="${tools_dir}/grib_check_gaussian_grid" -if [ -x $CHECK_TOOL ]; then - $CHECK_TOOL $outfile +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + ${tools_dir}/grib_get_data $outfile > /dev/null + CHECK_TOOL="${tools_dir}/grib_check_gaussian_grid" + if [ -x $CHECK_TOOL ]; then + $CHECK_TOOL $outfile + fi fi ### Constant field N=32 @@ -123,8 +127,9 @@ rm -f $outfile $EXEC $grib_util_set_spec $infile $outfile grib_check_key_equals $outfile "packingType,const" "grid_simple 0" -${tools_dir}/grib_get_data $outfile > /dev/null - +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + ${tools_dir}/grib_get_data $outfile > /dev/null +fi # CCSDS input # --------------------------- diff --git a/tests/include.ctest.sh.in b/tests/include.ctest.sh.in index 8832e2d0b..90473b7ad 100644 --- a/tests/include.ctest.sh.in +++ b/tests/include.ctest.sh.in @@ -65,6 +65,7 @@ HAVE_LIBJASPER=@HAVE_LIBJASPER@ HAVE_LIBOPENJPEG=@HAVE_LIBOPENJPEG@ HAVE_PNG=@HAVE_PNG@ HAVE_AEC=@HAVE_AEC@ +HAVE_GEOGRAPHY=@HAVE_GEOGRAPHY@ HAVE_EXTRA_TESTS=@HAVE_EXTRA_TESTS@ HAVE_MEMFS=@HAVE_MEMFS@ ECCODES_ON_WINDOWS=@ECCODES_ON_WINDOWS@