1#!/bin/sh 2# Copyright 2005-2018 ECMWF. 3# 4# This software is licensed under the terms of the Apache Licence Version 2.0 5# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 6# 7# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by 8# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. 9# 10 11. ./include.sh 12 13REDIRECT=/dev/null 14 15# First check if Adaptive Entropy Coding (AEC) feature is enabled 16skip_test=0 17src_config=${src_dir}/config.h 18if [ -f ${src_config} ]; then 19 set +e 20 grep '#undef HAVE_LIBAEC' ${src_config} >/dev/null 21 status=$? 22 set -e 23 if [ $status -eq 0 ]; then 24 # Found the string so feature is disabled 25 skip_test=1 26 fi 27fi 28if [ $skip_test -eq 1 ]; then 29 #echo "AEC feature was not enabled. Skipping this test." 30 exit 0 31fi 32echo "AEC feature was enabled." 33 34BLACKLIST="totalLength,section5Length,section7Length,dataRepresentationTemplateNumber" 35 36infile=${data_dir}/ccsds.grib2 37outfile1=$infile.tmp_ccsds.1 38outfile2=$infile.tmp_ccsds.2 39 40rm -f $outfile1 $outfile2 || true 41${tools_dir}grib_set -f -r -s packingType=grid_simple $infile $outfile1 2> $REDIRECT 42${tools_dir}grib_compare -P -b $BLACKLIST $outfile1 $infile > $REDIRECT 43 44${tools_dir}grib_set -r -s packingType=grid_ccsds $outfile1 $outfile2 45${tools_dir}grib_compare -P -b $BLACKLIST $outfile1 $outfile2 > $REDIRECT 46 47templateNumber=`${tools_dir}grib_get -p dataRepresentationTemplateNumber $outfile2` 48 49if [ $templateNumber -ne 42 ] 50then 51 echo dataRepresentationTemplateNumber=$templateNumber 52 exit 1 53fi 54 55rm -f $outfile1 $outfile2 || true 56 57infile=${data_dir}/reduced_latlon_surface.grib2 58outfile1=$infile.tmp_ccsds.1 59outfile2=$infile.tmp_ccsds.2 60 61${tools_dir}grib_set -r -s packingType=grid_ccsds $infile $outfile1 62${tools_dir}grib_compare -P -b $BLACKLIST $infile $outfile1 > $REDIRECT 63${tools_dir}grib_set -f -r -s packingType=grid_simple $outfile1 $outfile2 2> $REDIRECT 64${tools_dir}grib_compare -P -b $BLACKLIST $outfile2 $outfile1 > $REDIRECT 65 66res1=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile` 67res2=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $outfile1` 68res3=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $outfile2` 69[ "$res1" = "$res2" ] 70[ "$res1" = "$res3" ] 71 72rm -f $outfile1 $outfile2 || true 73 74infile=${data_dir}/tigge_ecmwf.grib2 75outfile1=$infile.tmp_ccsds.1 76outfile2=$infile.tmp_ccsds.2 77 78${tools_dir}grib_set -r -s bitsPerValue=17 $infile $outfile1 79${tools_dir}grib_set -r -s packingType=grid_ccsds $outfile1 $outfile2 80${tools_dir}grib_compare -P -c data:n $outfile1 $outfile2 81 82rm -f $outfile1 $outfile2 83