#!/bin/sh # (C) Copyright 2005- ECMWF. # # 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.ctest.sh # --------------------------------------------------------- # This is the test for the JIRA issue ECC-379 (Also ECC-830) # BUFR encoding failing when value out of range # --------------------------------------------------------- cd ${data_dir}/bufr label="bufr_ecc-379_test" tempRules=temp.${label}.filter tempOut=temp.${label}.bufr tempText=temp.${label}.text tempRef=temp.${label}.ref # -------------------------------------------------------- # Test: Maximum value exceeded # -------------------------------------------------------- BufrFile=airs_57.bufr cat > $tempRules <$tempText status=$? set -e [ $status -ne 0 ] grep -q 'longitude (006001). Maximum value (value\[0\]=500) out of range' $tempText # -------------------------------------------------------- # Test: Minimum value exceeded # -------------------------------------------------------- cat > $tempRules <$tempText status=$? set -e [ $status -ne 0 ] grep -q 'Minimum value .* out of range' $tempText # Now set environment variable to turn out-of-range values into 'missing' export ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE=1 ${tools_dir}/codes_bufr_filter -o $tempOut $tempRules $BufrFile 2>$tempText grep -q 'WARNING.*Setting it to missing value' $tempText unset ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE #echo 'set unpack=1;print "[longitude]";' | ${tools_dir}/bufr_filter - $BufrFile #echo 'set unpack=1;print "[longitude]";' | ${tools_dir}/bufr_filter - $tempOut > $tempText #cat > $tempRef << EOF #-1e+100 -172.14317 -1e+100 -170.17433 -169.407 -168.9308 -168.49104 -167.98389 #-166.95331 -166.52921 -166.06108 -165.66135 -164.99666 -164.67058 -164.23764 #EOF #diff $tempText $tempRef # -------------------------------------------------------- # Test 2 # -------------------------------------------------------- cat > $tempRules </dev/null status=$? set -e [ $status -ne 0 ] # Now set environment variable to turn out-of-range values into 'missing' export ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE=1 ${tools_dir}/codes_bufr_filter -o $tempOut $tempRules $BufrFile unset ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE # -------------------------------------------------------- # Test 3 # -------------------------------------------------------- BufrFile=airc_144.bufr cat > $tempRules </dev/null status=$? set -e [ $status -ne 0 ] export ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE=1 ${tools_dir}/codes_bufr_filter -o $tempOut $tempRules $BufrFile unset ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE # -------------------------------------------------------- # Test 4: use the key setToMissingIfOutOfRange # -------------------------------------------------------- BufrFile=airc_144.bufr cat > $tempRules < $tempRules <