2015-01-22 09:25:57 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2015-01-22 09:25:57 +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-01-22 09:25:57 +00:00
|
|
|
|
2020-07-04 14:30:10 +00:00
|
|
|
# Enter data dir
|
2015-01-22 09:25:57 +00:00
|
|
|
cd ${data_dir}/bufr
|
|
|
|
|
2020-07-04 14:30:10 +00:00
|
|
|
# Define a common label for all the tmp files
|
2015-02-02 17:17:29 +00:00
|
|
|
label="bufr_ls_test"
|
|
|
|
|
|
|
|
fLog=${label}".log"
|
2015-01-22 11:55:55 +00:00
|
|
|
rm -f $fLog
|
2015-02-02 17:17:29 +00:00
|
|
|
touch $fLog
|
|
|
|
fTmp=${label}".tmp.txt"
|
2015-01-22 11:55:55 +00:00
|
|
|
rm -f $fTmp
|
2015-01-22 09:25:57 +00:00
|
|
|
|
|
|
|
#----------------------------------------------
|
|
|
|
# Test default "ls" on all the bufr data files
|
|
|
|
#----------------------------------------------
|
2015-03-13 17:51:03 +00:00
|
|
|
bufr_files=`cat bufr_data_files.txt`
|
|
|
|
for f in ${bufr_files} ; do
|
2015-01-22 11:55:55 +00:00
|
|
|
echo $f >> $fLog
|
2015-01-22 09:25:57 +00:00
|
|
|
${tools_dir}/bufr_ls $f >> $fLog
|
|
|
|
done
|
|
|
|
|
2020-07-25 16:27:02 +00:00
|
|
|
#-----------------
|
2015-01-22 09:25:57 +00:00
|
|
|
# Test "-p" switch
|
2020-07-25 16:27:02 +00:00
|
|
|
#-----------------
|
2015-01-22 09:25:57 +00:00
|
|
|
f="aaen_55.bufr"
|
|
|
|
ref_ls=$f".ls.ref"
|
|
|
|
res_ls=$f".ls.test"
|
|
|
|
REDIRECT=/dev/null
|
|
|
|
|
2016-07-05 12:10:01 +00:00
|
|
|
${tools_dir}/bufr_ls -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,localNumberOfObservations $f 2> $REDIRECT > $fTmp
|
2015-01-22 09:25:57 +00:00
|
|
|
|
2020-07-04 14:30:10 +00:00
|
|
|
# Write the values into a file and compare with ref
|
2015-01-22 09:25:57 +00:00
|
|
|
awk NR==3 $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_ls
|
2015-08-27 15:06:43 +00:00
|
|
|
diff $ref_ls $res_ls
|
2015-01-22 09:25:57 +00:00
|
|
|
|
2020-07-25 16:27:02 +00:00
|
|
|
# ------------------------
|
|
|
|
# Test printing array key
|
|
|
|
# ------------------------
|
|
|
|
set +e
|
|
|
|
${tools_dir}/bufr_ls -p numericValues $f >$fTmp 2>&1
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
cat $fTmp
|
|
|
|
grep -q "Passed array is too small" $fTmp
|
|
|
|
|
2019-08-28 14:42:36 +00:00
|
|
|
|
2022-06-27 10:22:02 +00:00
|
|
|
# ------------------------
|
|
|
|
# Test setting header key
|
|
|
|
# ------------------------
|
|
|
|
${tools_dir}/bufr_ls -s satelliteID=313 -p satelliteID aaen_55.bufr > $fTmp
|
|
|
|
grep -q "313" $fTmp
|
|
|
|
|
|
|
|
|
2023-12-31 16:49:12 +00:00
|
|
|
# ------------------------
|
|
|
|
# Test -w
|
|
|
|
# ------------------------
|
|
|
|
${tools_dir}/bufr_ls -w count=2 syno_multi.bufr
|
|
|
|
|
2023-08-24 16:32:37 +00:00
|
|
|
# ------------------------
|
|
|
|
# Test corner cases
|
|
|
|
# ------------------------
|
|
|
|
echo BUFR > $fTmp
|
|
|
|
set +e
|
|
|
|
${tools_dir}/bufr_ls $fTmp > $fLog 2>&1
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
grep -w "unreadable message" $fLog
|
|
|
|
|
2024-01-10 12:42:45 +00:00
|
|
|
set +e
|
|
|
|
${tools_dir}/bufr_ls -j $fTmp > $fLog 2>&1
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
grep -w "unreadable message" $fLog
|
|
|
|
|
2023-08-24 16:32:37 +00:00
|
|
|
|
2022-06-27 10:22:02 +00:00
|
|
|
# Clean up
|
2015-02-02 17:17:29 +00:00
|
|
|
rm -f $fLog $res_ls
|
2015-03-13 17:51:03 +00:00
|
|
|
rm -f $fTmp
|