Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ecCodesMIA 2.17.0 b6 #28

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ECC-1030: grib_get: Add '-B' option for ordering
  • Loading branch information
shahramn committed Nov 26, 2019
commit 76f3cd31713d3e77b360c99dc31ddc3abe571363
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions tests/grib_ecc-1030.sh
Original file line number Diff line number Diff line change
@@ -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 https://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
6 changes: 1 addition & 5 deletions tools/grib_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
* 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[]={
/* {id, args, help}, on, command_line, value*/
{"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},
Expand Down
6 changes: 3 additions & 3 deletions tools/grib_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down