mirror of https://github.com/ecmwf/eccodes.git
Merge branch 'develop' into feature/modernisation_merge_accessor_classes
This commit is contained in:
commit
1a7a94e1d3
|
@ -18,6 +18,7 @@
|
|||
START_CLASS_DEF
|
||||
CLASS = action
|
||||
IMPLEMENTS = destroy;execute
|
||||
IMPLEMENTS = create_accessor
|
||||
MEMBERS = char *name
|
||||
MEMBERS = char *outname
|
||||
END_CLASS_DEF
|
||||
|
@ -36,6 +37,7 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
|
||||
static void init_class (grib_action_class*);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
static int execute(grib_action* a,grib_handle* h);
|
||||
|
||||
|
||||
|
@ -57,7 +59,7 @@ static grib_action_class _grib_action_class_print = {
|
|||
&destroy, /* destroy */
|
||||
0, /* dump */
|
||||
0, /* xref */
|
||||
0, /* create_accessor */
|
||||
&create_accessor, /* create_accessor */
|
||||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
|
@ -141,3 +143,21 @@ static void destroy(grib_context* context, grib_action* act)
|
|||
grib_context_free_persistent(context, act->name);
|
||||
grib_context_free_persistent(context, act->op);
|
||||
}
|
||||
|
||||
static int create_accessor(grib_section* p, grib_action* act, grib_loader* h)
|
||||
{
|
||||
// ECC-1929: A print statement within the definitions does not
|
||||
// actually create an accessor. So we just run it
|
||||
grib_action_print* self = (grib_action_print*)act;
|
||||
|
||||
const int err = execute(act, p->h);
|
||||
if (err)
|
||||
grib_context_log(act->context, GRIB_LOG_ERROR, "Print: '%s' (%s)", self->name, grib_get_error_message(err));
|
||||
return err;
|
||||
|
||||
// We may want to be forgiving and ignore the error
|
||||
// if (act->context->debug) {
|
||||
// return err;
|
||||
// }
|
||||
// return GRIB_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
START_CLASS_DEF
|
||||
CLASS = action
|
||||
IMPLEMENTS = dump
|
||||
IMPLEMENTS = destroy;execute
|
||||
MEMBERS = char *name
|
||||
END_CLASS_DEF
|
||||
|
@ -32,7 +31,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
*/
|
||||
|
||||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int execute(grib_action* a,grib_handle* h);
|
||||
|
||||
|
@ -52,7 +50,7 @@ static grib_action_class _grib_action_class_set_missing = {
|
|||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
&destroy, /* destroy */
|
||||
&dump, /* dump */
|
||||
0, /* dump */
|
||||
0, /* xref */
|
||||
0, /* create_accessor */
|
||||
0, /* notify_change */
|
||||
|
@ -95,17 +93,6 @@ static int execute(grib_action* a, grib_handle* h)
|
|||
return grib_set_missing(h, self->name);
|
||||
}
|
||||
|
||||
static void dump(grib_action* act, FILE* f, int lvl)
|
||||
{
|
||||
grib_context_log(act->context, GRIB_LOG_ERROR, "%s %s(): Not implemented", __FILE__, __func__);
|
||||
// int i = 0;
|
||||
// const grib_action_set_missing* self = (grib_action_set_missing*)act;
|
||||
// for (i = 0; i < lvl; i++)
|
||||
// grib_context_print(act->context, f, " ");
|
||||
// grib_context_print(act->context, f, self->name);
|
||||
// printf("\n");
|
||||
}
|
||||
|
||||
static void destroy(grib_context* context, grib_action* act)
|
||||
{
|
||||
grib_action_set_missing* a = (grib_action_set_missing*)act;
|
||||
|
|
|
@ -282,7 +282,9 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_set_bytes
|
||||
grib_set_force
|
||||
bufr_ecc-556
|
||||
codes_assert
|
||||
codes_ecc-1698
|
||||
codes_ecc-1929
|
||||
codes_get_string
|
||||
codes_codetable
|
||||
gts_get
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
# (C) Copyright 2005- 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.ctest.sh
|
||||
|
||||
label="codes_assert_test"
|
||||
|
||||
tempOut=temp.$label.txt
|
||||
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
tempDir=${label}.temp.dir
|
||||
rm -rf $tempDir
|
||||
mkdir -p $tempDir/definitions/grib2
|
||||
bootfile=$tempDir/definitions/grib2/boot.def
|
||||
cat $def_dir/grib2/boot.def > $bootfile
|
||||
echo 'assert( year == 1990 );' >> $bootfile
|
||||
echo >> $bootfile
|
||||
|
||||
export ECCODES_DEFINITION_PATH=$PWD/$tempDir/definitions
|
||||
# This will activate the print statement above
|
||||
${tools_dir}/grib_set -s year=1990 $sample_grib2 /dev/null
|
||||
|
||||
set +e
|
||||
${tools_dir}/grib_set -s year=1991 $sample_grib2 /dev/null > $tempOut 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "year.*Assertion failure" $tempOut
|
||||
|
||||
# Clean up
|
||||
rm -rf $tempDir
|
||||
rm -f $tempOut
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
# (C) Copyright 2005- 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.ctest.sh
|
||||
|
||||
label="codes_ecc-1929_test"
|
||||
|
||||
tempOut=temp.$label.txt
|
||||
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
tempDir=${label}.temp.dir
|
||||
rm -rf $tempDir
|
||||
mkdir -p $tempDir/definitions/grib2
|
||||
bootfile=$tempDir/definitions/grib2/boot.def
|
||||
cat $def_dir/grib2/boot.def > $bootfile
|
||||
echo 'print "DEBUG: [gridType=] [typeOfLevel=]";' >> $bootfile
|
||||
echo >> $bootfile
|
||||
|
||||
export ECCODES_DEFINITION_PATH=$PWD/$tempDir/definitions
|
||||
# This will activate the print statement above
|
||||
${tools_dir}/grib_get -p edition $sample_grib2 > $tempOut
|
||||
grep -q "DEBUG: gridType=regular_ll typeOfLevel=surface" $tempOut
|
||||
|
||||
# Clean up
|
||||
rm -rf $tempDir
|
||||
rm -f $tempOut
|
|
@ -85,6 +85,17 @@ set -e
|
|||
[ $status -ne 0 ]
|
||||
grep -q "Unable to open file" $tempOut
|
||||
|
||||
|
||||
# Bad print
|
||||
# ----------
|
||||
set +e
|
||||
echo 'print ("/") "should fail";' | ${tools_dir}/grib_filter - $input > $tempOut 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "IO ERROR" $tempOut
|
||||
|
||||
|
||||
# Signed bits
|
||||
# -----------
|
||||
cat >$tempFilt <<EOF
|
||||
|
|
|
@ -18,9 +18,10 @@ grib_option grib_options[] = {
|
|||
{ "w:", "key[:{s|d|i}]=value,key[:{s|d|i}]=value,...",
|
||||
"\n\t\tWhere clause.\n\t\tSet is only executed for BUFR messages matching all the "
|
||||
"key/value constraints.\n\t\tIf a BUFR message does not match the constraints it is"
|
||||
" copied unchanged\n\t\tto the output_file. This behaviour can be changed "
|
||||
" copied unchanged\n\t\tto the output_bufr_file. This behaviour can be changed "
|
||||
"setting the option -S.\n\t\tFor each key a string (key:s), a double (key:d) or"
|
||||
" an integer (key:i)\n\t\ttype can be defined. Default type is string."
|
||||
"\n\t\tIn the value you can also use the forward-slash character '/' to specify an OR condition (i.e. a logical disjunction)"
|
||||
"\n\t\tNote: only one -w clause is allowed.\n",
|
||||
0, 1, 0 },
|
||||
{ "q", 0, 0, 1, 0, 0 },
|
||||
|
@ -36,12 +37,12 @@ grib_option grib_options[] = {
|
|||
};
|
||||
|
||||
const char* tool_description =
|
||||
"Sets key/value pairs in the input BUFR file and writes"
|
||||
"\n\teach message to the output_file."
|
||||
"Sets key/value pairs in the input BUFR file(s) and writes"
|
||||
"\n\teach message to the output_bufr_file."
|
||||
"\n\tIt fails when an error occurs (e.g. key not found).";
|
||||
const char* tool_name = "bufr_set";
|
||||
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_set";
|
||||
const char* tool_usage = "[options] file file ... output_file";
|
||||
const char* tool_usage = "[options] bufr_file bufr_file ... output_bufr_file";
|
||||
|
||||
int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ ECCODES_PATCH_VERSION=@eccodes_VERSION_PATCH@
|
|||
# ECCODES_VERSION="$ECCODES_MAJOR_VERSION.$ECCODES_MINOR_VERSION.$ECCODES_PATCH_VERSION"
|
||||
|
||||
ECCODES_GIT_SHA1="@eccodes_GIT_SHA1@"
|
||||
if [ "x$ECCODES_GIT_SHA1" = "x" ]; then
|
||||
ECCODES_GIT_SHA1="unknown"
|
||||
fi
|
||||
|
||||
#################################################################
|
||||
# Commands
|
||||
|
|
|
@ -44,7 +44,7 @@ grib_option grib_options[] = {
|
|||
};
|
||||
|
||||
const char* tool_description =
|
||||
"Sets key/value pairs in the input GRIB file and writes"
|
||||
"Sets key/value pairs in the input GRIB file(s) and writes"
|
||||
"\n\teach message to the output_grib_file."
|
||||
"\n\tIt fails when an error occurs (e.g. key not found).";
|
||||
const char* tool_name = "grib_set";
|
||||
|
|
Loading…
Reference in New Issue