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.
|
|
|
|
#
|
|
|
|
# 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
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2022-02-04 19:05:34 +00:00
|
|
|
# This file does not have a bitmap
|
2013-03-25 12:04:10 +00:00
|
|
|
infile=${data_dir}/regular_latlon_surface.grib1
|
2022-02-04 19:05:34 +00:00
|
|
|
|
2022-02-10 17:19:13 +00:00
|
|
|
# Clean environment before we begin
|
|
|
|
unset GRIB_IEEE_PACKING
|
|
|
|
unset ECCODES_GRIB_IEEE_PACKING
|
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
shdata=${data_dir}/spherical_model_level.grib1
|
|
|
|
suff=_ieee_test.grib1
|
|
|
|
outsimple=simple$suff
|
|
|
|
out32=32$suff
|
|
|
|
out64=64$suff
|
|
|
|
|
|
|
|
cat > w.filter <<EOF
|
|
|
|
set Nj = 2;
|
|
|
|
set latitudeOfFirstGridPointInDegrees = 60;
|
|
|
|
set latitudeOfLastGridPointInDegrees = 59;
|
|
|
|
set Ni = 3;
|
|
|
|
set longitudeOfFirstGridPointInDegrees = 0;
|
|
|
|
set longitudeOfLastGridPointInDegrees = 2;
|
|
|
|
set DjInDegrees = 1;
|
|
|
|
set DiInDegrees = 1;
|
|
|
|
set values={1.234567e-36,2.34567e-36,1.234567e-36,2.34567e-36,1.234567e-36,2.34567e-36};
|
|
|
|
write;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > r.filter <<EOF
|
2015-10-14 09:22:00 +00:00
|
|
|
print "[values%g]";
|
2013-03-25 12:04:10 +00:00
|
|
|
EOF
|
|
|
|
|
2022-02-04 19:05:34 +00:00
|
|
|
${tools_dir}/grib_filter -o $outsimple w.filter $infile
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_filter r.filter $outsimple > $outsimple.txt
|
2013-03-25 12:04:10 +00:00
|
|
|
diff $outsimple.txt ${data_dir}/ieee_test.good
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ieee $outsimple $out32
|
2022-02-04 19:05:34 +00:00
|
|
|
${tools_dir}/grib_filter r.filter $out32 > $out32.txt
|
2016-02-02 11:29:30 +00:00
|
|
|
diff $out32.txt ${data_dir}/ieee_test.good
|
|
|
|
|
2022-02-10 17:19:13 +00:00
|
|
|
export GRIB_IEEE_PACKING=32
|
2022-02-04 19:05:34 +00:00
|
|
|
${tools_dir}/grib_filter -o $out32 w.filter $infile
|
|
|
|
${tools_dir}/grib_filter r.filter $out32 > $out32.txt
|
2019-08-16 20:00:48 +00:00
|
|
|
diff $out32.txt ${data_dir}/ieee_test.good
|
2022-03-28 14:55:39 +00:00
|
|
|
grib_check_key_equals $out32 'packingType,precision,accuracy' 'grid_ieee 1 32'
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2022-02-10 17:19:13 +00:00
|
|
|
|
|
|
|
export GRIB_IEEE_PACKING=64
|
2022-02-04 19:05:34 +00:00
|
|
|
${tools_dir}/grib_filter -o $out64 w.filter $infile
|
|
|
|
${tools_dir}/grib_filter r.filter $out64 > $out64.txt
|
2019-08-16 20:00:48 +00:00
|
|
|
diff $out64.txt ${data_dir}/ieee_test.good
|
2022-03-28 14:55:39 +00:00
|
|
|
grib_check_key_equals $out64 'packingType,precision,accuracy' 'grid_ieee 2 64'
|
2020-05-12 17:18:27 +00:00
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
rm -f $outsimple $out32 $out64 $out32.txt $out64.txt
|
2022-02-04 19:05:34 +00:00
|
|
|
rm -f ${data_dir}/$outsimple.txt ${data_dir}/$out32.txt ${data_dir}/$out64.txt
|
2014-04-12 20:15:11 +00:00
|
|
|
rm -f w.filter $outsimple.txt
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_filter r.filter $shdata > $shdata.txt
|
2013-03-25 12:04:10 +00:00
|
|
|
diff $shdata.txt $shdata.good
|
|
|
|
|
2017-02-03 14:21:24 +00:00
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ieee $shdata ${shdata}_ieee
|
|
|
|
${tools_dir}/grib_filter r.filter ${shdata}_ieee > $shdata.txt
|
2016-02-02 11:29:30 +00:00
|
|
|
diff $shdata.txt $shdata.good
|
2016-02-05 09:48:25 +00:00
|
|
|
rm -f ${shdata}_ieee
|
2016-02-02 11:29:30 +00:00
|
|
|
|
2022-02-10 17:19:13 +00:00
|
|
|
unset GRIB_IEEE_PACKING
|
|
|
|
unset ECCODES_GRIB_IEEE_PACKING
|
|
|
|
|
2020-02-14 13:16:19 +00:00
|
|
|
|
|
|
|
echo "Test ECC-1075: grib_dump error on GRIB1 with raw packing"
|
|
|
|
# -------------------------------------------------------------
|
|
|
|
temp=temp.grib_ieee.grib
|
|
|
|
infile=${data_dir}/reduced_gaussian_surface.grib1
|
2020-02-14 13:36:38 +00:00
|
|
|
grib_check_key_equals $infile numberOfMissing 0
|
2020-02-14 13:16:19 +00:00
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ieee $infile $temp
|
|
|
|
grib_check_key_equals $temp 'numberOfEffectiveValues,numberOfValues' '6114 6114'
|
|
|
|
${tools_dir}/grib_get -p numberOfEffectiveValues,numberOfValues $temp
|
2020-02-14 13:36:38 +00:00
|
|
|
#${tools_dir}/grib_dump -O $temp
|
2020-02-14 13:16:19 +00:00
|
|
|
|
|
|
|
stats1=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $infile`
|
|
|
|
stats2=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $temp`
|
|
|
|
[ "$stats1" = "$stats2" ]
|
|
|
|
|
2020-02-14 13:36:38 +00:00
|
|
|
echo "Test raw packing on GRIB2 with bitmap..."
|
|
|
|
# ---------------------------------------------
|
|
|
|
infile=${data_dir}/reduced_latlon_surface.grib2
|
|
|
|
grib_check_key_equals $infile numberOfMissing,const '98701 0'
|
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ieee $infile $temp
|
|
|
|
${tools_dir}/grib_get -p numberOfEffectiveValues,numberOfValues,numberOfMissing $temp
|
|
|
|
stats1=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $infile`
|
|
|
|
stats2=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $temp`
|
|
|
|
[ "$stats1" = "$stats2" ]
|
|
|
|
grib_check_key_equals $temp numberOfEffectiveValues,numberOfValues,numberOfMissing '214661 214661 98701'
|
|
|
|
grib_check_key_equals $temp totalLength 899004
|
|
|
|
|
2022-02-04 19:05:34 +00:00
|
|
|
echo "Test ECCODES_GRIB_IEEE_PACKING on GRIB2 with bitmap..."
|
|
|
|
# ------------------------------------------------------------
|
|
|
|
infile=${data_dir}/reduced_latlon_surface.grib2
|
|
|
|
grib_check_key_equals $infile bitmapPresent 1
|
|
|
|
ECCODES_GRIB_IEEE_PACKING=32 ${tools_dir}/grib_copy -r $infile $temp
|
|
|
|
grib_check_key_equals $temp packingType grid_ieee
|
|
|
|
${tools_dir}/grib_compare -c data:n -R all=6e-8 $infile $temp
|
|
|
|
|
|
|
|
echo "Test ECCODES_GRIB_IEEE_PACKING on GRIB2 without bitmap..."
|
|
|
|
# --------------------------------------------------------------
|
|
|
|
infile=${data_dir}/regular_latlon_surface.grib2
|
|
|
|
grib_check_key_equals $infile bitmapPresent 0
|
|
|
|
ECCODES_GRIB_IEEE_PACKING=32 ${tools_dir}/grib_copy -r $infile $temp
|
|
|
|
grib_check_key_equals $temp packingType grid_ieee
|
|
|
|
${tools_dir}/grib_compare -c data:n $infile $temp
|
2020-02-14 13:36:38 +00:00
|
|
|
|
2022-02-09 11:04:24 +00:00
|
|
|
#### All combinations: with/without bitmap, grib1/2, 32/64bits
|
|
|
|
editions="1 2"
|
|
|
|
precisions="32 64"
|
|
|
|
inputs="reduced_latlon_surface.grib regular_latlon_surface.grib"
|
|
|
|
for edition in $editions; do
|
|
|
|
for prec in $precisions; do
|
|
|
|
for input in $inputs; do
|
|
|
|
infile=${data_dir}/$input$edition
|
|
|
|
ECCODES_GRIB_IEEE_PACKING=$prec ${tools_dir}/grib_copy -r $infile $temp
|
|
|
|
grib_check_key_equals $temp packingType grid_ieee
|
|
|
|
${tools_dir}/grib_compare -c data:n -R all=6e-8 $infile $temp
|
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
2020-02-14 13:36:38 +00:00
|
|
|
|
2022-02-09 13:14:31 +00:00
|
|
|
echo "Test ECC-1345: env. var value should be checked..."
|
|
|
|
# -------------------------------------------------------
|
|
|
|
tempErr=temp.grib_ieee.txt
|
|
|
|
set +e
|
|
|
|
# Should fail. Only 32 and 64 are valid
|
|
|
|
infile=${data_dir}/regular_latlon_surface.grib2
|
|
|
|
ECCODES_GRIB_IEEE_PACKING=16 ${tools_dir}/grib_copy -r $infile $temp 2>$tempErr
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
grep -q "Invalid value for ECCODES_GRIB_IEEE_PACKING: should be 32 or 64" $tempErr
|
|
|
|
rm -f $tempErr
|
|
|
|
|
2020-02-14 13:36:38 +00:00
|
|
|
echo "Test raw packing on GRIB1 with bitmap..."
|
|
|
|
# ---------------------------------------------
|
|
|
|
infile=${data_dir}/reduced_latlon_surface.grib1
|
|
|
|
grib_check_key_equals $infile numberOfMissing 98701
|
|
|
|
${tools_dir}/grib_set -r -s packingType=grid_ieee $infile $temp
|
|
|
|
${tools_dir}/grib_get -p numberOfEffectiveValues,numberOfValues,numberOfMissing $temp
|
|
|
|
stats1=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $infile`
|
|
|
|
stats2=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $temp`
|
2022-02-05 19:28:17 +00:00
|
|
|
[ "$stats1" = "$stats2" ]
|
|
|
|
ECCODES_GRIB_IEEE_PACKING=32 ${tools_dir}/grib_copy -r $infile $temp
|
|
|
|
stats2=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $temp`
|
|
|
|
[ "$stats1" = "$stats2" ]
|
2020-02-14 13:36:38 +00:00
|
|
|
|
|
|
|
|
2021-02-17 17:14:27 +00:00
|
|
|
echo "Test changing precision ..."
|
|
|
|
# ----------------------------------
|
|
|
|
infile=${data_dir}/grid_ieee.grib
|
|
|
|
grib_check_key_equals $infile 'precision,section7Length' '1 44005'
|
|
|
|
# Switch from 32bits to 64bits
|
|
|
|
${tools_dir}/grib_set -r -s precision=2 $infile $temp
|
|
|
|
grib_check_key_equals $temp 'precision,section7Length' '2 88005'
|
|
|
|
|
|
|
|
stats1=`${tools_dir}/grib_get -M -F%.3f -p skew,kurt $infile`
|
|
|
|
stats2=`${tools_dir}/grib_get -M -F%.3f -p skew,kurt $temp`
|
|
|
|
[ "$stats1" = "$stats2" ]
|
|
|
|
|
2022-04-26 10:27:46 +00:00
|
|
|
# The same thing but use 'accuracy' instead of 'precision'
|
|
|
|
temp2=temp2.grib_ieee.grib
|
|
|
|
${tools_dir}/grib_set -r -s accuracy=64 $infile $temp2
|
|
|
|
cmp $temp $temp2
|
2020-02-14 13:16:19 +00:00
|
|
|
|
2022-04-26 10:27:46 +00:00
|
|
|
rm -f $temp2
|
2021-02-17 17:14:27 +00:00
|
|
|
rm -f $temp
|
|
|
|
|
2019-08-16 20:00:48 +00:00
|
|
|
##################################
|
|
|
|
# Disabled for now. Infinite loop
|
2016-02-02 11:29:30 +00:00
|
|
|
#GRIB_IEEE_PACKING=32
|
|
|
|
#export GRIB_IEEE_PACKING
|
2017-02-03 14:21:24 +00:00
|
|
|
#${tools_dir}/grib_copy -r $shdata ${shdata}_32
|
|
|
|
#${tools_dir}/grib_filter r.filter ${shdata}_32 > ${shdata}_32.txt
|
2013-03-25 12:04:10 +00:00
|
|
|
#diff ${shdata}_32.txt ${shdata}_32.good
|
|
|
|
|
2016-02-02 11:29:30 +00:00
|
|
|
#GRIB_IEEE_PACKING=64
|
|
|
|
#export GRIB_IEEE_PACKING
|
2017-02-03 14:21:24 +00:00
|
|
|
#${tools_dir}/grib_copy -r $shdata ${shdata}_64
|
|
|
|
#${tools_dir}/grib_filter r.filter ${shdata}_64 > ${shdata}_64.txt
|
2013-03-25 12:04:10 +00:00
|
|
|
#diff ${shdata}_64.txt ${shdata}.good
|
|
|
|
|
2013-11-13 12:49:54 +00:00
|
|
|
rm -f r.filter ${shdata}_64.txt ${shdata}_32.txt $shdata.txt
|