2024-01-07 15:26:58 +00:00
|
|
|
#!/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.
|
2024-01-07 17:28:36 +00:00
|
|
|
#
|
2024-01-07 15:26:58 +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.ctest.sh
|
|
|
|
|
|
|
|
label="grib_repair_test"
|
|
|
|
tempText=temp.$label.txt
|
2024-01-07 17:28:36 +00:00
|
|
|
tempGoodGribs=temp.$label.good.grib
|
|
|
|
tempBadGribs=temp.$label.bad.grib
|
2024-01-07 15:26:58 +00:00
|
|
|
|
2024-01-20 14:09:25 +00:00
|
|
|
if [ ! -e "${tools_dir}/grib_repair" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2024-01-07 17:28:36 +00:00
|
|
|
|
2024-01-20 14:09:25 +00:00
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_repair
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
2024-01-07 17:28:36 +00:00
|
|
|
|
|
|
|
|
2024-01-20 14:09:25 +00:00
|
|
|
export ECCODES_GRIB_REPAIR_MAX_NUM_MESSAGES=3
|
|
|
|
${tools_dir}/grib_repair $data_dir/bad.grib $tempGoodGribs $tempBadGribs > $tempText 2>&1
|
|
|
|
grep -q "Wrong message length" $tempText
|
|
|
|
|
|
|
|
count=$( ${tools_dir}/grib_count $tempGoodGribs )
|
|
|
|
[ $count -eq 1 ]
|
|
|
|
|
|
|
|
count=$( ${tools_dir}/grib_count $tempBadGribs )
|
|
|
|
[ $count -eq 3 ]
|
|
|
|
|
|
|
|
${tools_dir}/grib_ls $tempGoodGribs
|
|
|
|
${tools_dir}/grib_ls $tempBadGribs
|
|
|
|
|
2024-01-07 15:26:58 +00:00
|
|
|
|
|
|
|
# Clean up
|
2024-01-07 17:28:36 +00:00
|
|
|
rm -f $tempText $tempGoodGribs $tempBadGribs
|