2015-02-03 10:06:03 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2015-02-03 10:06:03 +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
|
2015-02-03 10:06:03 +00:00
|
|
|
|
2020-07-04 14:30:10 +00:00
|
|
|
# Enter data dir
|
2015-02-03 10:06:03 +00:00
|
|
|
cd ${data_dir}/bufr
|
|
|
|
|
|
|
|
label="bufr_copy_test"
|
|
|
|
fLog=${label}".log"
|
|
|
|
rm -f $fLog
|
|
|
|
touch $fLog
|
|
|
|
|
|
|
|
fBufrInput=${label}".bufr.input"
|
|
|
|
fBufrTmp=${label}".bufr.tmp"
|
|
|
|
|
2020-07-04 14:30:10 +00:00
|
|
|
# Create a bufr file with various message types
|
2015-02-03 10:06:03 +00:00
|
|
|
cat syno_multi.bufr temp_101.bufr > $fBufrInput
|
|
|
|
|
|
|
|
#----------------------------------------------------
|
2020-12-10 15:52:00 +00:00
|
|
|
echo "Test: copy synop messages ..."
|
2015-02-03 10:06:03 +00:00
|
|
|
#----------------------------------------------------
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f $fBufrTmp
|
2015-02-03 10:06:03 +00:00
|
|
|
|
|
|
|
echo "Test: copy synop messages " >> $fLog
|
2024-01-10 12:42:17 +00:00
|
|
|
${tools_dir}/bufr_copy -p typicalDate -w dataCategory=0 $fBufrInput $fBufrTmp >> $fLog
|
2015-02-03 10:06:03 +00:00
|
|
|
|
|
|
|
for i in 1 2 3 ;do
|
|
|
|
category=`${tools_dir}/bufr_get -w count=$i -p dataCategory:l $fBufrTmp`
|
|
|
|
[ $category = "0" ]
|
|
|
|
done
|
|
|
|
|
|
|
|
#----------------------------------------------------
|
2020-12-10 15:52:00 +00:00
|
|
|
echo "Test: copy non-synop messages ..."
|
2015-02-03 10:06:03 +00:00
|
|
|
#----------------------------------------------------
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f $fBufrTmp
|
2015-02-03 10:06:03 +00:00
|
|
|
|
|
|
|
echo "Test: copy non-synop messages " >> $fLog
|
|
|
|
${tools_dir}/bufr_copy -w dataCategory!=0 $fBufrInput $fBufrTmp >> $fLog
|
|
|
|
|
|
|
|
[ `${tools_dir}/bufr_get -p dataCategory:l $fBufrTmp` = "2" ]
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
2020-12-10 15:52:00 +00:00
|
|
|
echo "Test: use the square brackets to insert the value of a key ..."
|
2015-02-03 10:06:03 +00:00
|
|
|
#-------------------------------------------------------------------
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f ${fBufrTmp}
|
|
|
|
rm -f ${fBufrTmp}_*.bufr
|
2015-02-03 10:06:03 +00:00
|
|
|
|
|
|
|
echo "Test: use the square brackets to insert the value of a key " >> $fLog
|
2015-02-03 11:16:00 +00:00
|
|
|
${tools_dir}/bufr_copy $fBufrInput ${fBufrTmp}_[dataCategory].bufr >> $fLog
|
2015-02-03 10:06:03 +00:00
|
|
|
|
2015-02-03 11:16:00 +00:00
|
|
|
[ -s ${fBufrTmp}_0.bufr ]
|
|
|
|
[ -s ${fBufrTmp}_2.bufr ]
|
2015-02-03 10:06:03 +00:00
|
|
|
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f ${fBufrTmp}_*.bufr
|
2018-08-22 11:39:40 +00:00
|
|
|
rm -f $fBufrInput
|
2015-02-03 10:06:03 +00:00
|
|
|
|
2018-08-22 11:39:40 +00:00
|
|
|
#-------------------------------------------------------------------
|
2020-12-10 15:52:00 +00:00
|
|
|
echo "Test: The -X option ..."
|
2018-08-22 11:39:40 +00:00
|
|
|
#-------------------------------------------------------------------
|
|
|
|
echo "Test: use of -X option" >> $fLog
|
|
|
|
fBufrInput=aeolus_wmo_26.bufr
|
|
|
|
${tools_dir}/bufr_copy -w count=1 -X 0 $fBufrInput $fBufrTmp #First msg
|
|
|
|
r1=`${tools_dir}/bufr_get -w count=1 -n ls $fBufrInput`
|
|
|
|
r2=`${tools_dir}/bufr_get -n ls $fBufrTmp`
|
|
|
|
[ "$r1" = "$r2" ]
|
|
|
|
|
2018-08-22 13:53:01 +00:00
|
|
|
#${tools_dir}/bufr_copy -w count=1 -X 19449 $fBufrInput $fBufrTmp #Last msg
|
|
|
|
#r1=`${tools_dir}/bufr_get -w count=11 -n ls $fBufrInput`
|
|
|
|
#r2=`${tools_dir}/bufr_get -n ls $fBufrTmp`
|
|
|
|
#[ "$r1" = "$r2" ]
|
|
|
|
|
|
|
|
#${tools_dir}/bufr_copy -w count=1 -X 10972 $fBufrInput $fBufrTmp
|
|
|
|
#r=`${tools_dir}/bufr_get -p typicalTime,numberOfSubsets $fBufrTmp`
|
|
|
|
#[ "$r" = "000013 41" ]
|
2018-08-22 11:39:40 +00:00
|
|
|
|
2020-12-10 15:52:00 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
echo "Test: The -w option with unpack ..."
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
fBufrInput=tropical_cyclone.bufr
|
|
|
|
rm -f $fBufrTmp
|
|
|
|
${tools_dir}/bufr_copy -s unpack=1 -w stormIdentifier=70E $fBufrInput $fBufrTmp
|
|
|
|
num_msgs=`${tools_dir}/bufr_count $fBufrTmp`
|
|
|
|
[ $num_msgs -eq 1 ]
|
|
|
|
storm=`${tools_dir}/bufr_get -s unpack=1 -p stormIdentifier $fBufrTmp`
|
|
|
|
[ "$storm" = "70E" ]
|
|
|
|
|
|
|
|
rm -f $fBufrTmp
|
|
|
|
${tools_dir}/bufr_copy -s unpack=1 -w stormIdentifier=none $fBufrInput $fBufrTmp
|
|
|
|
[ ! -f "$fBufrTmp" ]
|
|
|
|
|
|
|
|
|
2023-08-24 16:32:37 +00:00
|
|
|
#-------------------------------------------------------------------
|
|
|
|
echo "Test: corner cases ..."
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
echo BUFR > $fBufrTmp
|
|
|
|
set +e
|
|
|
|
${tools_dir}/bufr_copy $fBufrTmp /dev/null > $fLog 2>&1
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
grep -w "unreadable message" $fLog
|
|
|
|
|
|
|
|
|
2018-08-22 11:39:40 +00:00
|
|
|
# Clean up
|
|
|
|
#-----------
|
2020-12-10 15:52:00 +00:00
|
|
|
rm -f $fLog $fBufrTmp
|