mirror of https://github.com/ecmwf/eccodes.git
Testing: listing all codetable and flagtable keys
This commit is contained in:
parent
bd3a25aaae
commit
0b803b314e
|
@ -10,6 +10,7 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_S
|
|||
# Build the executables used by test scripts
|
||||
################################################
|
||||
list(APPEND test_bins
|
||||
list_codetable_flagtable_keys
|
||||
grib_bpv_limit
|
||||
grib_double_cmp
|
||||
read_any
|
||||
|
@ -226,6 +227,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
list(APPEND tests_data_reqd grib_tigge_conversions2)
|
||||
list(APPEND tests_data_reqd bufr_dump_encode_C)
|
||||
list(APPEND tests_data_reqd bufr_dump_decode_C)
|
||||
list(APPEND tests_no_data_reqd list_codetable_flagtable_keys)
|
||||
endif()
|
||||
|
||||
# These tests do not require any data downloads
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* (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 "grib_api_internal.h"
|
||||
|
||||
typedef struct grib_action_if
|
||||
{
|
||||
grib_action act;
|
||||
/* Members defined in section */
|
||||
/* Members defined in if */
|
||||
grib_expression* expression;
|
||||
grib_action* block_true;
|
||||
grib_action* block_false;
|
||||
} grib_action_if;
|
||||
|
||||
typedef struct grib_action_list
|
||||
{
|
||||
grib_action act;
|
||||
/* Members defined in section */
|
||||
/* Members defined in list */
|
||||
grib_expression* expression;
|
||||
grib_action* block_list;
|
||||
} grib_action_list;
|
||||
|
||||
typedef struct grib_action_gen
|
||||
{
|
||||
grib_action act;
|
||||
/* Members defined in gen */
|
||||
long len;
|
||||
grib_arguments* params;
|
||||
} grib_action_gen;
|
||||
|
||||
void print_names(grib_action* a)
|
||||
{
|
||||
while (a) {
|
||||
if (a->op && !strcmp(a->op, "label")) {
|
||||
a = a->next;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(a->cclass->name, "action_class_noop") ||
|
||||
!strcmp(a->cclass->name, "action_class_when")) {
|
||||
a = a->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(a->cclass->name, "action_class_list")) {
|
||||
grib_action_list* al = (grib_action_list*)a;
|
||||
/*printf("%s\n", a->name);*/
|
||||
print_names(al->block_list);
|
||||
}
|
||||
else if (!strcmp(a->cclass->name, "action_class_if")) {
|
||||
grib_action_if* ai = (grib_action_if*)a;
|
||||
print_names(ai->block_false);
|
||||
print_names(ai->block_true);
|
||||
}
|
||||
else if (!strcmp(a->cclass->name, "action_class_gen")) {
|
||||
const char* table = NULL;
|
||||
grib_action_gen* ag = (grib_action_gen*)a;
|
||||
if (strcmp(a->op,"codetable")==0 || strcmp(a->op,"codeflag")==0) {
|
||||
printf("%s", a->name);
|
||||
table = grib_arguments_get_string(NULL, ag->params, 0);
|
||||
if (table) printf("\t%s=%s", a->op, table);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*printf("%s\n", a->name);*/
|
||||
}
|
||||
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int i = 0;
|
||||
int fail = 0;
|
||||
|
||||
grib_context* c = grib_context_get_default();
|
||||
grib_action* a = NULL;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!(a = grib_parse_file(c, argv[i]))) {
|
||||
fail++;
|
||||
printf("FAILED\n");
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
print_names(a);
|
||||
}
|
||||
}
|
||||
|
||||
return fail;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#!/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.sh
|
||||
|
||||
OUTPUT=all_codetable_flagtable_keys.txt
|
||||
TEMP=temp.list_codetable_flagtable_keys.txt
|
||||
|
||||
[ -z "$ECCODES_DEFINITION_PATH" ] | ECCODES_DEFINITION_PATH=`${tools_dir}/codes_info -d`
|
||||
|
||||
touch $TEMP
|
||||
echo "Go through all files in $ECCODES_DEFINITION_PATH ..."
|
||||
for file in `find $ECCODES_DEFINITION_PATH/ -name '*.def' -print`; do
|
||||
${test_dir}/list_codetable_flagtable_keys $file >> $TEMP
|
||||
done
|
||||
|
||||
sort -u < $TEMP > $OUTPUT
|
||||
echo "Created $OUTPUT"
|
||||
rm -f $TEMP
|
|
@ -9,10 +9,15 @@ echo "\\endverbatim"
|
|||
|
||||
echo "-# If you want to define your missing value=1111 and to print the string 'missing' in place of it"
|
||||
echo "\\verbatim"
|
||||
echo ">grib_get_data -m 1111:missing ../data/reduced_gaussian_model_level.grib2"
|
||||
echo ">grib_get_data -m 1111:missing ../data/reduced_latlon_surface.grib2"
|
||||
echo "\\endverbatim"
|
||||
|
||||
echo "-# If you want to print the value of other keys with the data value list"
|
||||
echo "\\verbatim"
|
||||
echo ">grib_get_data -p centre,level,step ../data/reduced_gaussian_model_level.grib2"
|
||||
echo "\\endverbatim"
|
||||
|
||||
echo "-# If you want to control the formatting of the latitudes and longitudes"
|
||||
echo "\\verbatim"
|
||||
echo ">grib_get_data -L %12.6f%12.6f ../data/reduced_latlon_surface.grib2"
|
||||
echo "\\endverbatim"
|
||||
|
|
Loading…
Reference in New Issue