2014-08-28 09:03:16 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2014-08-28 09:03:16 +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.
|
|
|
|
#
|
|
|
|
|
|
|
|
. ./include.sh
|
|
|
|
|
|
|
|
REDIRECT=/dev/null
|
2015-02-01 16:35:46 +00:00
|
|
|
|
2018-05-16 10:05:46 +00:00
|
|
|
# Disable if autotools being used
|
2015-02-01 16:35:46 +00:00
|
|
|
src_config=${src_dir}/config.h
|
|
|
|
if [ -f ${src_config} ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-07-13 17:16:04 +00:00
|
|
|
BLACKLIST="totalLength,section5Length,section7Length,dataRepresentationTemplateNumber"
|
2014-08-28 09:03:16 +00:00
|
|
|
|
|
|
|
infile=${data_dir}/ccsds.grib2
|
2015-02-18 10:37:58 +00:00
|
|
|
outfile1=$infile.tmp_ccsds.1
|
|
|
|
outfile2=$infile.tmp_ccsds.2
|
2014-08-28 09:03:16 +00:00
|
|
|
|
2017-10-09 14:01:46 +00:00
|
|
|
rm -f $outfile1 $outfile2
|
2021-07-14 18:24:46 +00:00
|
|
|
|
|
|
|
# ECC-1263
|
|
|
|
# ---------
|
|
|
|
grib2_sample=$ECCODES_SAMPLES_PATH/gg_sfc_grib2.tmpl
|
|
|
|
${tools_dir}/grib_set -s packingType=grid_ccsds $grib2_sample $outfile1
|
|
|
|
${tools_dir}/grib_set -d1 $outfile1 $outfile2
|
|
|
|
grib_check_key_equals $grib2_sample packingType,const "grid_simple 0"
|
|
|
|
grib_check_key_equals $outfile2 packingType,const "grid_ccsds 1"
|
|
|
|
rm -f $outfile1 $outfile2
|
|
|
|
|
|
|
|
# Change packingType
|
|
|
|
# ------------------
|
2018-12-17 13:33:32 +00:00
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_simple $infile $outfile1
|
|
|
|
${tools_dir}/grib_compare -b $BLACKLIST $outfile1 $infile > $REDIRECT
|
2016-07-13 17:16:04 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ccsds $outfile1 $outfile2
|
2018-12-17 13:33:32 +00:00
|
|
|
${tools_dir}/grib_compare -b $BLACKLIST $outfile1 $outfile2 > $REDIRECT
|
2014-08-28 09:03:16 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
templateNumber=`${tools_dir}/grib_get -p dataRepresentationTemplateNumber $outfile2`
|
2021-02-16 16:48:50 +00:00
|
|
|
if [ $templateNumber -ne 42 ]; then
|
|
|
|
echo "dataRepresentationTemplateNumber=$templateNumber. Should be 42!"
|
2014-08-28 09:03:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-09 14:01:46 +00:00
|
|
|
rm -f $outfile1 $outfile2
|
2014-08-28 09:03:16 +00:00
|
|
|
|
|
|
|
infile=${data_dir}/reduced_latlon_surface.grib2
|
2015-02-18 10:37:58 +00:00
|
|
|
outfile1=$infile.tmp_ccsds.1
|
|
|
|
outfile2=$infile.tmp_ccsds.2
|
2014-08-28 09:03:16 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ccsds $infile $outfile1
|
2018-12-17 13:33:32 +00:00
|
|
|
${tools_dir}/grib_compare -b $BLACKLIST $infile $outfile1 > $REDIRECT
|
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_simple $outfile1 $outfile2
|
|
|
|
${tools_dir}/grib_compare -b $BLACKLIST $outfile2 $outfile1 > $REDIRECT
|
2014-08-28 09:03:16 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
res1=`${tools_dir}/grib_get '-F%1.2f' -p min,max,avg $infile`
|
|
|
|
res2=`${tools_dir}/grib_get '-F%1.2f' -p min,max,avg $outfile1`
|
|
|
|
res3=`${tools_dir}/grib_get '-F%1.2f' -p min,max,avg $outfile2`
|
2014-08-28 09:03:16 +00:00
|
|
|
[ "$res1" = "$res2" ]
|
|
|
|
[ "$res1" = "$res3" ]
|
|
|
|
|
2017-10-09 14:01:46 +00:00
|
|
|
rm -f $outfile1 $outfile2
|
2016-05-24 15:18:57 +00:00
|
|
|
|
2021-02-16 16:48:50 +00:00
|
|
|
# ECC-297: Basic support
|
|
|
|
# --------------------------------------
|
2016-05-24 15:18:57 +00:00
|
|
|
infile=${data_dir}/tigge_ecmwf.grib2
|
|
|
|
outfile1=$infile.tmp_ccsds.1
|
|
|
|
outfile2=$infile.tmp_ccsds.2
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -r -s bitsPerValue=17 $infile $outfile1
|
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ccsds $outfile1 $outfile2
|
2018-12-17 13:33:32 +00:00
|
|
|
${tools_dir}/grib_compare -c data:n $outfile1 $outfile2
|
2016-05-24 15:18:57 +00:00
|
|
|
|
2017-10-09 14:01:46 +00:00
|
|
|
# ECC-477: redundant error message during conversion
|
2021-02-16 16:48:50 +00:00
|
|
|
# ---------------------------------------------------
|
2017-10-09 14:01:46 +00:00
|
|
|
infile=${data_dir}/ccsds.grib2
|
|
|
|
rm -f $outfile2
|
2018-12-17 13:33:32 +00:00
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_simple $infile $outfile1 >$outfile2 2>&1
|
2017-10-09 14:01:46 +00:00
|
|
|
# there should be no error messages printed (to stdout or stderr)
|
|
|
|
[ ! -s $outfile2 ]
|
|
|
|
|
2021-02-16 16:48:50 +00:00
|
|
|
# ECC-1202: Check input packingType=grid_ieee
|
|
|
|
# --------------------------------------------
|
|
|
|
infile=${data_dir}/grid_ieee.grib
|
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ccsds $infile $outfile1
|
|
|
|
grib_check_key_equals $outfile1 packingType grid_ccsds
|
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_simple $infile $outfile2
|
|
|
|
${tools_dir}/grib_compare -c data:n $outfile1 $outfile2
|
|
|
|
|
|
|
|
|
|
|
|
# Clean up
|
2016-05-24 15:18:57 +00:00
|
|
|
rm -f $outfile1 $outfile2
|