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.
|
2014-08-28 09:03:16 +00:00
|
|
|
#
|
2013-03-25 12:04:10 +00:00
|
|
|
# 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.sh
|
|
|
|
|
|
|
|
REDIRECT=/dev/null
|
|
|
|
|
|
|
|
infile=${data_dir}/regular_gaussian_surface.grib1
|
|
|
|
outfile=${data_dir}/set.grib1
|
|
|
|
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f $outfile
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -v -p levtype,centre,levtype:l,centre:l -s levtype=pl,centre=80 $infile $outfile >$REDIRECT
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
levtype=`${tools_dir}/grib_get -p levtype $outfile`
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $levtype = "pl" ]
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
centre=`${tools_dir}/grib_get -p centre $outfile`
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $centre = "cnmc" ]
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
levtype=`${tools_dir}/grib_get -p levtype:l $outfile`
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $levtype -eq 100 ]
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
centre=`${tools_dir}/grib_get -p centre:l $outfile`
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $centre -eq 80 ]
|
|
|
|
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f $outfile
|
2015-01-26 15:50:33 +00:00
|
|
|
|
2014-08-28 09:03:16 +00:00
|
|
|
infile=${data_dir}/regular_gaussian_surface.grib2
|
2013-03-25 12:04:10 +00:00
|
|
|
outfile=${data_dir}/set.grib2
|
|
|
|
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f $outfile
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -v -p levtype:l,centre:s -s levtype:l=100,centre:s=cnmc $infile $outfile >$REDIRECT
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
levtype=`${tools_dir}/grib_get -p levtype $outfile`
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $levtype = "pl" ]
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
centre=`${tools_dir}/grib_get -p centre $outfile`
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $centre = "cnmc" ]
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
levtype=`${tools_dir}/grib_get -p levtype:l $outfile`
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $levtype -eq 100 ]
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
centre=`${tools_dir}/grib_get -p centre:l $outfile`
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $centre -eq 80 ]
|
|
|
|
|
|
|
|
set +e
|
2016-03-10 16:05:06 +00:00
|
|
|
# This is expected to fail
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -p levtype $infile $outfile 2> $REDIRECT > $REDIRECT
|
2013-03-25 12:04:10 +00:00
|
|
|
[ $? -ne 0 ]
|
2016-03-07 18:05:27 +00:00
|
|
|
set -e
|
2016-03-10 16:05:06 +00:00
|
|
|
|
2016-03-07 17:52:07 +00:00
|
|
|
# GRIB-941: encoding of grib2 angles
|
|
|
|
angleInDegrees=130.9989
|
|
|
|
angleInMicroDegrees=130998900
|
|
|
|
files="GRIB2.tmpl regular_gg_pl_grib2.tmpl reduced_gg_pl_320_grib2.tmpl polar_stereographic_pl_grib2.tmpl"
|
|
|
|
for f in $files; do
|
|
|
|
f=$ECCODES_SAMPLES_PATH/$f
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -s longitudeOfFirstGridPointInDegrees=$angleInDegrees $f $outfile
|
2016-03-07 17:52:07 +00:00
|
|
|
grib_check_key_equals $outfile longitudeOfFirstGridPoint $angleInMicroDegrees
|
|
|
|
done
|
|
|
|
|
2016-03-10 16:05:06 +00:00
|
|
|
# GRIB-943: centre code table
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -s centre=289 $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile
|
|
|
|
${tools_dir}/grib_dump -O $outfile | grep -q 'centre = 289.*Zambia'
|
2016-03-10 16:05:06 +00:00
|
|
|
|
2021-01-25 15:44:30 +00:00
|
|
|
# ECC-539: avoid output being the same as input
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_set -s centre=0 $outfile $outfile
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
2016-03-10 16:05:06 +00:00
|
|
|
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f $outfile
|