ECC-1030: grib_get: Add '-B' option for ordering

This commit is contained in:
Shahram Najm 2019-11-26 10:54:41 +00:00
parent eaf13376e8
commit 5dc40557cc
4 changed files with 56 additions and 8 deletions

View File

@ -118,6 +118,7 @@ list( APPEND tests_data_reqd
grib_ecc-984
grib_ecc-1000
grib_ecc-1001
grib_ecc-1030
bufr_ecc-556
gts_get
gts_ls

51
tests/grib_ecc-1030.sh Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
# Copyright 2005-2019 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 -u
# ---------------------------------------------------------
# This is the test for the JIRA issue ECC-1030
# grib_get with the ordering option '-B'
# ---------------------------------------------------------
label="grib_ecc-1030-test"
tempRef=temp.${label}.ref
tempOut=temp.${label}.out
# Test 1
# ------
input=${data_dir}/pad.grib
${tools_dir}/grib_get -p count,level -B'level:i' $input > $tempOut
cat > $tempRef <<EOF
1 0
2 0
3 0
4 1
5 1000
6 1000
EOF
diff -w $tempRef $tempOut
# Test 2
# ------
input=${data_dir}/pad.grib
${tools_dir}/grib_get -p count,level -B'level:i desc' $input > $tempOut
cat > $tempRef <<EOF
1 1000
2 1000
3 1
4 0
5 0
6 0
EOF
diff -w $tempRef $tempOut
# Clean up
rm -f $tempRef $tempOut

View File

@ -8,11 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/*
* C Implementation: grib_get
*
*/
#include "grib_tools.h"
grib_option grib_options[]={
@ -20,6 +15,7 @@ grib_option grib_options[]={
{"f",0,0,0,1,0},
{"p:",0,0,0,1,0},
{"F:",0,0,1,1,"%g"},
{"B:",0,0,0,1,0},
{"l:",0,0,0,1,0},
{"P:",0,0,0,1,0},
{"w:",0,0,0,1,0},

View File

@ -29,9 +29,9 @@ static grib_options_help grib_options_help_list[] ={
{"a",0,"Dump aliases.\n"},
{"b:","key,key,...",
"\n\t\tAll the keys in this list are skipped in the comparison. Bit-by-bit compare on.\n"},
{"B:","order by directive",
"\n\t\tOrder by. The output will be ordered according to the order by directive."
"\n\t\tOrder by example: \"step:i asc, centre desc\" (step numeric ascending and centre descending)\n"},
{"B:","'order by' directive",
"\n\t\tOrder by. The output will be ordered according to the 'order by' directive."
"\n\t\tExample: \"step:i asc, centre desc\" (step numeric ascending and centre descending)\n"},
{"c:","key[:i|d|s|n],key[:i|d|s|n],...",
"\n\t\tOnly the listed keys or namespaces (:n) are compared. The optional letter after the colon is used "
"\n\t\tto force the type in the comparison: i->integer, d->float, s->string, n->namespace."