2014-10-28 11:31:32 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2014-10-28 11:31:32 +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
|
2014-10-28 11:31:32 +00:00
|
|
|
|
2022-07-22 16:57:02 +00:00
|
|
|
label="grib_check_gaussian_grids_test"
|
2023-03-25 14:25:01 +00:00
|
|
|
tempGrib=temp.$label.grib
|
|
|
|
tempText=temp.$label.txt
|
2018-11-22 18:11:58 +00:00
|
|
|
|
2023-08-22 16:52:29 +00:00
|
|
|
${tools_dir}/grib_check_gaussian_grid -V
|
|
|
|
|
2014-10-28 11:31:32 +00:00
|
|
|
# Check all sample GRIBs with a Gaussian grid
|
2015-09-25 16:09:27 +00:00
|
|
|
samples_dir=$ECCODES_SAMPLES_PATH
|
2014-10-28 11:31:32 +00:00
|
|
|
for gg in ${samples_dir}/reduced_gg_* ${samples_dir}/regular_gg_*; do
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_check_gaussian_grid $gg >/dev/null
|
2016-01-21 16:52:24 +00:00
|
|
|
grib_check_key_equals $gg "global" 1
|
2014-10-28 11:31:32 +00:00
|
|
|
done
|
2018-11-22 18:11:58 +00:00
|
|
|
|
2023-03-25 14:25:01 +00:00
|
|
|
for gg in ${samples_dir}/reduced_gg_*tmpl; do
|
|
|
|
${tools_dir}/grib_set -s global=1 $gg $tempGrib
|
|
|
|
${tools_dir}/grib_check_gaussian_grid $tempGrib
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2024-03-06 14:07:46 +00:00
|
|
|
# Set wrong Nj. Should fail
|
|
|
|
input=$samples_dir/reduced_gg_pl_32_grib2.tmpl
|
|
|
|
${tools_dir}/grib_set -s Nj=1 $input $tempGrib
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_check_gaussian_grid -v $tempGrib 2> $tempText
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
grep -q "Nj is 1 but should be 2\*N" $tempText
|
|
|
|
|
|
|
|
|
2023-08-22 17:03:44 +00:00
|
|
|
# Set wrong N. Should fail
|
|
|
|
input=$samples_dir/reduced_gg_pl_32_grib2.tmpl
|
|
|
|
${tools_dir}/grib_set -s N=0 $input $tempGrib
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_check_gaussian_grid -v $tempGrib 2> $tempText
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -eq 1 ]
|
|
|
|
grep -q "Error: N should be > 0" $tempText
|
|
|
|
|
2024-03-06 14:07:46 +00:00
|
|
|
|
2023-08-22 17:03:44 +00:00
|
|
|
# Set wrong angle. Should fail
|
2018-11-22 18:11:58 +00:00
|
|
|
input=$samples_dir/reduced_gg_pl_1280_grib2.tmpl
|
2023-03-25 14:25:01 +00:00
|
|
|
${tools_dir}/grib_set -s longitudeOfLastGridPoint=359929680 $input $tempGrib
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_check_gaussian_grid -v $tempGrib 2> $tempText
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -eq 1 ]
|
|
|
|
grep -q "Error: longitudeOfLastGridPointInDegrees.*but should be" $tempText
|
|
|
|
|
|
|
|
|
2024-03-06 14:07:46 +00:00
|
|
|
# Set wrong lat2. Should fail
|
|
|
|
input=$samples_dir/reduced_gg_pl_1280_grib2.tmpl
|
|
|
|
${tools_dir}/grib_set -s latitudeOfLastGridPointInDegrees=9 $input $tempGrib
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_check_gaussian_grid -v $tempGrib 2> $tempText
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
grep -q "First latitude must be = last latitude but opposite in sign" $tempText
|
|
|
|
|
|
|
|
|
2023-08-22 17:03:44 +00:00
|
|
|
# Set wrong numberOfDataPoints. Should fail
|
2023-03-25 14:25:01 +00:00
|
|
|
input=$samples_dir/reduced_gg_pl_96_grib2.tmpl
|
|
|
|
${tools_dir}/grib_set -s numberOfDataPoints=44 $input $tempGrib
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_check_gaussian_grid -v $tempGrib 2> $tempText
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -eq 1 ]
|
|
|
|
grep -q "Error: Sum of pl array 50662 does not match numberOfDataPoints 44" $tempText
|
|
|
|
|
|
|
|
|
2023-08-22 17:03:44 +00:00
|
|
|
# Set wrong numberOfValues. Should fail
|
2023-03-25 14:25:01 +00:00
|
|
|
input=$samples_dir/reduced_gg_pl_96_grib2.tmpl
|
|
|
|
${tools_dir}/grib_set -s numberOfValues=44 $input $tempGrib
|
2018-11-22 18:11:58 +00:00
|
|
|
set +e
|
2023-08-22 16:52:29 +00:00
|
|
|
${tools_dir}/grib_check_gaussian_grid -f -v $tempGrib 2> $tempText
|
2018-11-22 18:11:58 +00:00
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -eq 1 ]
|
2024-06-14 15:36:03 +00:00
|
|
|
grep -q "Error: Sum of pl array 50662 does not match size of values array 44" $tempText
|
2018-11-22 18:11:58 +00:00
|
|
|
|
2024-03-06 14:07:46 +00:00
|
|
|
# Octahedral
|
2024-03-06 16:27:33 +00:00
|
|
|
# set +e
|
|
|
|
# ${tools_dir}/grib_check_gaussian_grid -v $data_dir/msl.octa.glob.grib1 > $tempText 2>&1
|
|
|
|
# status=$?
|
|
|
|
# set -e
|
|
|
|
# [ $status -ne 0 ]
|
|
|
|
# grep -q "This is an Octahedral Gaussian grid" $tempText
|
|
|
|
# grep -q "Error: longitudeOfLastGridPointInDegrees.*should be" $tempText
|
2024-03-06 14:07:46 +00:00
|
|
|
|
2023-08-22 17:03:44 +00:00
|
|
|
|
|
|
|
# Other errors/warnings
|
|
|
|
# ----------------------
|
2023-08-22 16:52:29 +00:00
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_check_gaussian_grid
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -eq 1 ]
|
|
|
|
|
2023-08-22 16:55:04 +00:00
|
|
|
${tools_dir}/grib_check_gaussian_grid -v $data_dir > $tempText
|
2024-06-15 12:21:06 +00:00
|
|
|
grep -q "is a directory" $tempText
|
2023-08-22 16:55:04 +00:00
|
|
|
|
2023-08-22 17:03:44 +00:00
|
|
|
${tools_dir}/grib_check_gaussian_grid -v $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempText
|
|
|
|
grep -q "ignoring" $tempText
|
|
|
|
|
2018-11-22 18:11:58 +00:00
|
|
|
|
2023-08-22 16:52:29 +00:00
|
|
|
# Clean up
|
2023-03-25 14:25:01 +00:00
|
|
|
rm -f $tempGrib $tempText
|