eccodes/tests/bufr_ls.sh

62 lines
1.6 KiB
Bash
Raw Normal View History

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.
#
. ./include.sh
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"
rm -f $fLog
2015-02-02 17:17:29 +00:00
touch $fLog
fTmp=${label}".tmp.txt"
rm -f $fTmp
2015-01-22 09:25:57 +00:00
#----------------------------------------------
# Test default "ls" on all the bufr data files
#----------------------------------------------
bufr_files=`cat bufr_data_files.txt`
for f in ${bufr_files} ; do
echo $f >> $fLog
2015-01-22 09:25:57 +00:00
${tools_dir}/bufr_ls $f >> $fLog
done
#-----------------
2015-01-22 09:25:57 +00:00
# Test "-p" switch
#-----------------
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
diff $ref_ls $res_ls
2015-01-22 09:25:57 +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
2015-02-02 17:17:29 +00:00
rm -f $fLog $res_ls
rm -f $fTmp