2013-03-25 12:04:10 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2013-03-25 12:04:10 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2022-04-03 22:02:48 +00:00
|
|
|
. ./include.ctest.sh
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
label="grib_ls_test"
|
|
|
|
tempLog=temp.$label.log
|
|
|
|
temp1=temp.$label.1.txt
|
|
|
|
temp2=temp.$label.2.txt
|
|
|
|
tempText=temp.$label.txt
|
|
|
|
rm -f $temp1 $temp2 $tempText $tempLog
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2022-12-07 19:25:20 +00:00
|
|
|
sample_g1="$ECCODES_SAMPLES_PATH/GRIB1.tmpl"
|
|
|
|
sample_g2="$ECCODES_SAMPLES_PATH/GRIB2.tmpl"
|
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
cd ${data_dir}
|
|
|
|
infile=regular_gaussian_model_level.grib1
|
|
|
|
|
2022-12-05 15:34:35 +00:00
|
|
|
# Basic test of man page
|
|
|
|
set +e
|
2023-01-06 11:58:43 +00:00
|
|
|
${tools_dir}/grib_ls > $tempLog
|
2022-12-05 15:34:35 +00:00
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -eq 1 ]
|
2023-01-06 11:58:43 +00:00
|
|
|
grep -q "Full documentation and examples at" $tempLog
|
|
|
|
grep -q "https://confluence.ecmwf.int/display/ECC/grib_ls" $tempLog
|
|
|
|
|
2022-12-05 15:34:35 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_ls -P count $infile > $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
|
|
|
|
${tools_dir}/grib_get -p count,step $infile >> $tempLog
|
|
|
|
${tools_dir}/grib_get -P count $infile >> $tempLog
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
files=" reduced_gaussian_lsm.grib1
|
|
|
|
reduced_gaussian_model_level.grib1
|
|
|
|
reduced_gaussian_model_level.grib2
|
|
|
|
reduced_gaussian_pressure_level.grib1
|
|
|
|
reduced_gaussian_pressure_level.grib2
|
|
|
|
reduced_gaussian_pressure_level_constant.grib1
|
|
|
|
reduced_gaussian_pressure_level_constant.grib2
|
|
|
|
reduced_gaussian_sub_area.grib1
|
|
|
|
reduced_gaussian_sub_area.grib2
|
|
|
|
reduced_gaussian_surface.grib1
|
|
|
|
reduced_gaussian_surface.grib2
|
|
|
|
reduced_latlon_surface.grib1
|
|
|
|
reduced_latlon_surface.grib2
|
|
|
|
regular_gaussian_model_level.grib1
|
|
|
|
regular_gaussian_model_level.grib2
|
|
|
|
regular_gaussian_pressure_level.grib1
|
|
|
|
regular_gaussian_pressure_level.grib2
|
|
|
|
regular_gaussian_pressure_level_constant.grib1
|
|
|
|
regular_gaussian_pressure_level_constant.grib2
|
|
|
|
regular_gaussian_surface.grib1
|
|
|
|
regular_gaussian_surface.grib2
|
|
|
|
regular_latlon_surface.grib1
|
|
|
|
regular_latlon_surface.grib2
|
|
|
|
"
|
|
|
|
|
2023-02-12 16:16:29 +00:00
|
|
|
for file in $files; do
|
2013-11-13 12:49:54 +00:00
|
|
|
[ -f "$file" ]
|
2015-01-26 15:50:33 +00:00
|
|
|
echo $file >> $tempLog
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_ls -l 40,28 $file | grep index | awk '{print $4;}' >> $tempLog
|
2013-03-25 12:04:10 +00:00
|
|
|
done
|
|
|
|
|
2015-01-26 15:50:33 +00:00
|
|
|
diff $tempLog ls.log
|
|
|
|
rm -f $tempLog
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2023-02-12 16:16:29 +00:00
|
|
|
echo "Test for bug GRIB-56..."
|
|
|
|
# ------------------------------
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -s typeOfLevel=depthBelowLandLayer,topLevel=missing regular_latlon_surface.grib1 tmp_rlls.grib1
|
|
|
|
${tools_dir}/grib_ls -plevels tmp_rlls.grib1 | grep MISSING>/dev/null
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -s typeOfLevel=depthBelowLandLayer,bottomLevel=missing regular_latlon_surface.grib1 tmp_rlls.grib1
|
|
|
|
${tools_dir}/grib_ls -plevels tmp_rlls.grib1 | grep MISSING>/dev/null
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f tmp_rlls.grib1
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2023-02-12 16:16:29 +00:00
|
|
|
echo "GRIB-305. GRIB edition 1 file with one large message..."
|
|
|
|
# ----------------------------------------------------------
|
2013-03-25 12:04:10 +00:00
|
|
|
if [ -f "sst_globus0083.grib" ]; then
|
2023-02-12 16:16:29 +00:00
|
|
|
${tools_dir}/grib_ls sst_globus0083.grib > /dev/null
|
2013-03-25 12:04:10 +00:00
|
|
|
fi
|
|
|
|
|
2023-02-12 16:16:29 +00:00
|
|
|
echo "GRIB-387 printing key of type byte..."
|
|
|
|
# ----------------------------------------------------------
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_ls -p uuidOfVGrid test_uuid.grib2 > /dev/null
|
2013-06-17 16:53:16 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
type=`${tools_dir}/grib_get -wcount=1 -p typeOfLevel test_uuid.grib2`
|
2014-03-25 11:12:01 +00:00
|
|
|
[ "$type" = "generalVertical" ]
|
|
|
|
|
2023-02-12 16:16:29 +00:00
|
|
|
|
|
|
|
echo "GRIB-213 nearest with land-sea mask..."
|
|
|
|
# ----------------------------------------------------------
|
2023-03-18 15:52:13 +00:00
|
|
|
${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
|
2015-12-30 18:54:50 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${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
|
2015-12-30 18:54:50 +00:00
|
|
|
|
|
|
|
|
2023-02-12 16:16:29 +00:00
|
|
|
echo "ECC-278: grib_ls -n namespace..."
|
|
|
|
# ----------------------------------------------------------
|
2018-11-07 17:42:25 +00:00
|
|
|
${tools_dir}/grib_ls -n geography $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib2.tmpl
|
2022-12-07 19:25:20 +00:00
|
|
|
${tools_dir}/grib_ls -n data $sample_g1
|
2018-11-07 17:42:25 +00:00
|
|
|
|
2019-01-03 12:06:44 +00:00
|
|
|
# Angle subdivisions
|
2022-12-07 19:25:20 +00:00
|
|
|
grib_check_key_equals $sample_g1 angleSubdivisions 1000
|
|
|
|
grib_check_key_equals $sample_g2 angleSubdivisions 1000000
|
2019-01-03 12:06:44 +00:00
|
|
|
|
2021-12-09 22:22:20 +00:00
|
|
|
# Print 'offset' key as string and integer
|
|
|
|
${tools_dir}/grib_ls -p offset:s tigge_cf_ecmwf.grib2 > $temp1
|
|
|
|
${tools_dir}/grib_ls -p offset:i tigge_cf_ecmwf.grib2 > $temp2
|
|
|
|
diff $temp1 $temp2
|
2021-12-09 18:53:24 +00:00
|
|
|
|
2022-12-07 19:25:20 +00:00
|
|
|
# Section pointers
|
|
|
|
grib_check_key_equals $sample_g2 'section0Pointer,section1Pointer,section3Pointer,section4Pointer' '0_16 16_21 37_72 109_34'
|
|
|
|
|
2023-02-12 16:16:29 +00:00
|
|
|
|
|
|
|
echo "Test constraints: -w option..."
|
|
|
|
# ----------------------------------------------------------
|
2023-02-01 18:27:02 +00:00
|
|
|
file=tigge_pf_ecmwf.grib2 # Has 38 messages
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w count!=1 $file > $tempText
|
|
|
|
grep -q "37 of 38 messages" $tempText
|
2022-12-07 19:25:20 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w count=1/2/38 $file > $tempText
|
|
|
|
grep -q "3 of 38 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w shortName=u $file > $tempText
|
|
|
|
grep -q "3 of 38 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w shortName=u/v $file > $tempText
|
|
|
|
grep -q "5 of 38 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w shortName!=u/v $file > $tempText
|
|
|
|
grep -q "33 of 38 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w shortName=u/v,level=925 $file > $tempText
|
|
|
|
grep -q "2 of 38 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w shortName=u/v/10u/10v,level=925/10 $file > $tempText
|
|
|
|
grep -q "4 of 38 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w packingType!=grid_simple $file > $tempText
|
|
|
|
grep -q "0 of 38 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w units!=K $file > $tempText
|
|
|
|
grep -q "30 of 38 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-02-11 13:30:42 +00:00
|
|
|
file=mixed.grib # Has 14 messages
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w packingType=grid_simple,gridType=regular_ll/regular_gg $file > $tempText
|
|
|
|
grep -q "12 of 14 messages" $tempText
|
2023-02-11 13:30:42 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w packingType=grid_simple/grid_simple_matrix,gridType=regular_ll/regular_gg $file > $tempText
|
|
|
|
grep -q "12 of 14 messages" $tempText
|
2023-02-11 13:30:42 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w typeOfLevel=surface,centre=7 $file > $tempText
|
|
|
|
grep -q "3 of 14 messages" $tempText
|
2023-02-11 13:30:42 +00:00
|
|
|
|
2023-03-18 15:52:13 +00:00
|
|
|
${tools_dir}/grib_ls -w shortName=t/10u,gridType=regular_gg $file > $tempText
|
|
|
|
grep -q "5 of 14 messages" $tempText
|
2023-02-01 18:27:02 +00:00
|
|
|
|
2023-02-12 16:16:29 +00:00
|
|
|
|
|
|
|
# ECC-1528: Try some invalid values for the count constraint
|
|
|
|
for cval in -1 0 xx; do
|
|
|
|
set +e
|
2023-03-18 15:52:13 +00:00
|
|
|
rm -f $tempText
|
|
|
|
${tools_dir}/grib_ls -w count=$cval $file > $tempText 2>&1
|
2023-02-12 16:16:29 +00:00
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
2023-03-18 15:52:13 +00:00
|
|
|
grep -q "Invalid value for key 'count'" $tempText
|
2023-02-12 16:16:29 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
|
2023-02-01 18:27:02 +00:00
|
|
|
# Clean up
|
2023-03-18 15:52:13 +00:00
|
|
|
rm -f $temp1 $temp2 $tempText $tempLog
|