2015-02-03 09:14:05 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2015-02-03 09:14:05 +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 09:14:05 +00:00
|
|
|
|
2023-03-18 16:00:11 +00:00
|
|
|
label="bufr_count_test"
|
|
|
|
temp=temp.$label.truncated.bufr
|
|
|
|
|
2018-01-02 11:01:36 +00:00
|
|
|
# Enter data dir
|
2015-02-03 09:14:05 +00:00
|
|
|
cd ${data_dir}/bufr
|
2018-01-02 11:01:36 +00:00
|
|
|
input=syno_multi.bufr
|
2015-02-03 09:14:05 +00:00
|
|
|
|
2018-01-02 11:01:36 +00:00
|
|
|
# Counting valid messages
|
|
|
|
# ------------------------
|
|
|
|
count=`${tools_dir}/bufr_count $input`
|
|
|
|
[ "$count" = "3" ]
|
|
|
|
count=`${tools_dir}/codes_count $input`
|
2015-02-03 09:14:05 +00:00
|
|
|
[ "$count" = "3" ]
|
2018-01-02 11:01:36 +00:00
|
|
|
|
|
|
|
# Files with invalid (unreadable) messages
|
|
|
|
# -----------------------------------------
|
2018-01-02 11:21:27 +00:00
|
|
|
# BUFR file size = 660 bytes. Write out only the first 640 bytes
|
|
|
|
# thereby creating an unreadable final message
|
|
|
|
head -c 640 $input > $temp
|
2018-01-02 11:01:36 +00:00
|
|
|
|
|
|
|
set +e
|
|
|
|
# Without -f, bufr_count should fail
|
|
|
|
${tools_dir}/bufr_count $temp
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
|
|
|
|
# With -f should count the valid messages
|
2018-02-01 11:00:58 +00:00
|
|
|
vcount=`${tools_dir}/bufr_count -f $temp`
|
|
|
|
[ "$vcount" = "2" ]
|
|
|
|
|
2023-03-18 16:00:11 +00:00
|
|
|
# Clean up
|
2018-01-02 11:01:36 +00:00
|
|
|
rm -f $temp
|