eccodes/examples/C/bufr_clone.sh

45 lines
1.2 KiB
Bash
Raw Normal View History

2015-02-04 15:58:52 +00:00
#!/bin/sh
2020-01-28 14:32:34 +00:00
# (C) Copyright 2005- ECMWF.
2015-02-04 15:58:52 +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.ctest.sh
2015-02-04 15:58:52 +00:00
2019-07-31 11:45:15 +00:00
# Define a common label for all the tmp files
2015-02-06 09:32:42 +00:00
label="bufr_clone_test_c"
2015-02-04 15:58:52 +00:00
2019-07-31 11:45:15 +00:00
fBufrTmp1=${label}.cloned1.bufr
fBufrTmp2=${label}.cloned2.bufr
rm -f $fBufrTmp1 $fBufrTmp2
2015-02-06 09:32:42 +00:00
2019-07-31 11:45:15 +00:00
# We clone this bufr file
2015-02-09 15:41:15 +00:00
f=${data_dir}/bufr/syno_1.bufr
2015-02-04 15:58:52 +00:00
REDIRECT=/dev/null
2019-07-31 11:45:15 +00:00
# Clone the bufr message and change something
${examples_dir}/c_bufr_clone $f $fBufrTmp1
2015-02-04 15:58:52 +00:00
2019-07-31 11:45:15 +00:00
# There should be 3 messages in the new file
count=`${tools_dir}/bufr_count $fBufrTmp1`
[ $count -eq 3 ]
# Compare the first message to the original. It should be different
${tools_dir}/bufr_copy -w count=1 $fBufrTmp1 $fBufrTmp2
2015-02-04 15:58:52 +00:00
set +e
2019-07-31 11:45:15 +00:00
${tools_dir}/bufr_compare $f $fBufrTmp2
2015-02-04 15:58:52 +00:00
2019-07-31 11:45:15 +00:00
# bufr_compare should have returned 1
2015-02-04 15:58:52 +00:00
if [ $? -eq 0 ]; then
2019-07-31 11:45:15 +00:00
echo "Error: Clones messages should be different!" >&2
2015-02-04 15:58:52 +00:00
exit 1
fi
set -e
2019-07-31 11:45:15 +00:00
# Clean up
rm -f $fBufrTmp1 $fBufrTmp2