diff --git a/data/bufr/bufr_data_files.txt b/data/bufr/bufr_data_files.txt index b79128bc3..04a56d9d4 100644 --- a/data/bufr/bufr_data_files.txt +++ b/data/bufr/bufr_data_files.txt @@ -145,3 +145,4 @@ eum_iasi_twt.bufr delayed_repl_01.bufr israel_observations_2017041010.bufr goes16_nm.bufr +aeolus_wmo_26.bufr diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1cfa66f44..a67ca59a8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -125,6 +125,7 @@ list( APPEND tests_data_reqd grib_set grib_iterator grib_compare + grib_copy grib_level index grib_bitmap diff --git a/tests/bufr_copy.sh b/tests/bufr_copy.sh index ab73c0ba1..f45314222 100755 --- a/tests/bufr_copy.sh +++ b/tests/bufr_copy.sh @@ -31,9 +31,8 @@ fBufrTmp=${label}".bufr.tmp" cat syno_multi.bufr temp_101.bufr > $fBufrInput #---------------------------------------------------- -# Test: copy synop messages +# Test: copy synop messages #---------------------------------------------------- - rm -f $fBufrTmp echo "Test: copy synop messages " >> $fLog @@ -45,9 +44,8 @@ for i in 1 2 3 ;do done #---------------------------------------------------- -# Test: copy non-synop messages +# Test: copy non-synop messages #---------------------------------------------------- - rm -f $fBufrTmp echo "Test: copy non-synop messages " >> $fLog @@ -55,11 +53,9 @@ ${tools_dir}/bufr_copy -w dataCategory!=0 $fBufrInput $fBufrTmp >> $fLog [ `${tools_dir}/bufr_get -p dataCategory:l $fBufrTmp` = "2" ] - #------------------------------------------------------------------- # Test: use the square brackets to insert the value of a key #------------------------------------------------------------------- - rm -f ${fBufrTmp} rm -f ${fBufrTmp}_*.bufr @@ -70,8 +66,28 @@ ${tools_dir}/bufr_copy $fBufrInput ${fBufrTmp}_[dataCategory].bufr >> $fLog [ -s ${fBufrTmp}_2.bufr ] rm -f ${fBufrTmp}_*.bufr +rm -f $fBufrInput -#Clean up +#------------------------------------------------------------------- +# Test: The -X option +#------------------------------------------------------------------- +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" ] + +${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" ] + +# Clean up +#----------- rm -f $fLog rm -f $fBufrTmp -rm -f $fBufrInput diff --git a/tests/bufr_dump_decode_filter.sh b/tests/bufr_dump_decode_filter.sh index 9b8559b7b..a111cefba 100755 --- a/tests/bufr_dump_decode_filter.sh +++ b/tests/bufr_dump_decode_filter.sh @@ -34,7 +34,7 @@ fRules=${label}.filter #----------------------------------------------------------- files=`cat ${data_dir}/bufr/bufr_data_files.txt` -exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr" +exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr aeolus_wmo_26.bufr" for f in $files do diff --git a/tests/bufr_dump_encode_filter.sh b/tests/bufr_dump_encode_filter.sh index 36218d52f..82089afe8 100755 --- a/tests/bufr_dump_encode_filter.sh +++ b/tests/bufr_dump_encode_filter.sh @@ -41,10 +41,11 @@ files=`cat ${data_dir}/bufr/bufr_data_files.txt` # ias1_240.bufr: Too large. The filter rules file generated is too big for the parser! # tropical_cyclone.bufr: multi-message # syno_multi.bufr: multi-message +# aeolus_wmo_26: multi-message # israel_observations_2017041010.bufr: Suffers from a bug. In filter cannot do: # set #1#3HourPressureChange=-1.6; # The hash cannot be followed by a number! -exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr israel_observations_2017041010.bufr" +exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr aeolus_wmo_26.bufr israel_observations_2017041010.bufr " for f in $files do diff --git a/tests/grib_copy.sh b/tests/grib_copy.sh new file mode 100755 index 000000000..465e35043 --- /dev/null +++ b/tests/grib_copy.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright 2005-2018 ECMWF. +# +# 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 + +#set -x + +#Enter data dir +cd ${data_dir} + +#Define a common label for all the tmp files +label="grib_copy_test" +temp=${label}".grib.tmp" + +#------------------------------------------------------------------- +# Test: The -X option +#------------------------------------------------------------------- +echo "Test: use of -X option" +input=tigge_pf_ecmwf.grib2 +${tools_dir}/grib_copy -w count=1 -X 0 $input $temp #First msg +r1=`${tools_dir}/grib_get -w count=1 -n ls $input` +r2=`${tools_dir}/grib_get -n ls $temp` +[ "$r1" = "$r2" ] + +${tools_dir}/grib_copy -w count=1 -X 57143 $input $temp #Last msg +r1=`${tools_dir}/grib_get -w count=37 -n ls $input` +r2=`${tools_dir}/grib_get -n ls $temp` +[ "$r1" = "$r2" ] + +# Get two messages +${tools_dir}/grib_copy -w count=1/2 -X 25071 $input $temp +count=`${tools_dir}/grib_count $temp` +[ $count -eq 2 ] + +r=`${tools_dir}/grib_get -w count=1 -p typeOfLevel,level,shortName $temp` +[ "$r" = "heightAboveGround 2 mx2t6" ] +r=`${tools_dir}/grib_get -w count=2 -p typeOfLevel,level,shortName $temp` +[ "$r" = "heightAboveGround 2 mn2t6" ] + +# Clean up +#----------- +rm -f $temp diff --git a/tools/bufr_copy.c b/tools/bufr_copy.c index da106ce95..da7c36e99 100644 --- a/tools/bufr_copy.c +++ b/tools/bufr_copy.c @@ -44,6 +44,7 @@ grib_option grib_options[]={ {"S",0,0,1,0,0}, {"g",0,0,0,1,0}, {"7",0,0,0,1,0}, + {"X:",0,0,0,1,0}, {"v",0,0,0,1,0} }; diff --git a/tools/grib_copy.c b/tools/grib_copy.c index d2d3d4a4d..954488a8c 100644 --- a/tools/grib_copy.c +++ b/tools/grib_copy.c @@ -48,6 +48,7 @@ grib_option grib_options[]={ {"g",0,0,0,1,0}, {"G",0,0,0,1,0}, {"7",0,0,0,1,0}, + {"X:",0,0,0,1,0}, {"v",0,0,0,1,0} };