Merge branch 'develop' into feature/ECC-1467-FloatDataValues

This commit is contained in:
Shahram Najm 2023-01-06 23:00:05 +00:00
commit 7f076a3754
70 changed files with 130 additions and 79 deletions

View File

@ -0,0 +1,5 @@
# Code table 4.238 - Source or sink for ECMWF
192 192 Vegetation
193 193 Biomass burning
194 194 Settlements

View File

@ -110,7 +110,7 @@ static int execute(grib_action* a, grib_handle* h)
if (self->nofail) if (self->nofail)
return 0; return 0;
if (ret != GRIB_SUCCESS) { if (ret != GRIB_SUCCESS) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error while setting key %s (%s)", grib_context_log(h->context, GRIB_LOG_ERROR, "Error while setting key '%s' (%s)",
self->name, grib_get_error_message(ret)); self->name, grib_get_error_message(ret));
} }
return ret; return ret;

View File

@ -44,7 +44,7 @@ static int init (grib_iterator* i,grib_handle*,grib_arguments*);
typedef struct grib_iterator_gaussian{ typedef struct grib_iterator_gaussian{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in regular */ /* Members defined in regular */
double *las; double *las;

View File

@ -52,7 +52,7 @@ static int destroy (grib_iterator* i);
typedef struct grib_iterator_gaussian_reduced{ typedef struct grib_iterator_gaussian_reduced{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in gaussian_reduced */ /* Members defined in gaussian_reduced */
double *las; double *las;

View File

@ -19,8 +19,8 @@
IMPLEMENTS = has_next IMPLEMENTS = has_next
IMPLEMENTS = init IMPLEMENTS = init
IMPLEMENTS = reset IMPLEMENTS = reset
MEMBERS = long carg MEMBERS = int carg
MEMBERS = const char* missingValue; MEMBERS = const char* missingValue;
END_CLASS_DEF END_CLASS_DEF
*/ */
@ -47,7 +47,7 @@ static long has_next (grib_iterator* i);
typedef struct grib_iterator_gen{ typedef struct grib_iterator_gen{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
} grib_iterator_gen; } grib_iterator_gen;

View File

@ -46,7 +46,7 @@ static int destroy (grib_iterator* i);
typedef struct grib_iterator_lambert_azimuthal_equal_area{ typedef struct grib_iterator_lambert_azimuthal_equal_area{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in lambert_azimuthal_equal_area */ /* Members defined in lambert_azimuthal_equal_area */
double *lats; double *lats;

View File

@ -46,7 +46,7 @@ static int destroy (grib_iterator* i);
typedef struct grib_iterator_lambert_conformal{ typedef struct grib_iterator_lambert_conformal{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in lambert_conformal */ /* Members defined in lambert_conformal */
double *lats; double *lats;

View File

@ -41,7 +41,7 @@ static int next (grib_iterator* i, double *lat, double *lon, doubl
typedef struct grib_iterator_latlon{ typedef struct grib_iterator_latlon{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in regular */ /* Members defined in regular */
double *las; double *las;

View File

@ -51,7 +51,7 @@ static int destroy (grib_iterator* i);
typedef struct grib_iterator_latlon_reduced{ typedef struct grib_iterator_latlon_reduced{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in latlon_reduced */ /* Members defined in latlon_reduced */
double *las; double *las;

View File

@ -46,7 +46,7 @@ static int destroy (grib_iterator* i);
typedef struct grib_iterator_mercator{ typedef struct grib_iterator_mercator{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in mercator */ /* Members defined in mercator */
double *lats; double *lats;

View File

@ -46,7 +46,7 @@ static int destroy (grib_iterator* i);
typedef struct grib_iterator_polar_stereographic{ typedef struct grib_iterator_polar_stereographic{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in polar_stereographic */ /* Members defined in polar_stereographic */
double *lats; double *lats;

View File

@ -56,7 +56,7 @@ static int destroy (grib_iterator* i);
typedef struct grib_iterator_regular{ typedef struct grib_iterator_regular{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in regular */ /* Members defined in regular */
double *las; double *las;

View File

@ -46,7 +46,7 @@ static int destroy (grib_iterator* i);
typedef struct grib_iterator_space_view{ typedef struct grib_iterator_space_view{
grib_iterator it; grib_iterator it;
/* Members defined in gen */ /* Members defined in gen */
long carg; int carg;
const char* missingValue; const char* missingValue;
/* Members defined in space_view */ /* Members defined in space_view */
double *lats; double *lats;

View File

@ -168,7 +168,7 @@ int grib_nearest_find_multiple(
int ret = 0; int ret = 0;
long i = 0; long i = 0;
size_t len = 4; size_t len = 4;
int flags = GRIB_NEAREST_SAME_GRID | GRIB_NEAREST_SAME_DATA; const unsigned long flags = GRIB_NEAREST_SAME_GRID | GRIB_NEAREST_SAME_DATA;
if (values) if (values)
rvalues = qvalues; rvalues = qvalues;
@ -306,8 +306,8 @@ int grib_nearest_find_generic(
double* outlats, double* outlons, double* outlats, double* outlons,
double* values, double* distances, int* indexes, size_t* len) double* values, double* distances, int* indexes, size_t* len)
{ {
int ret = 0, i = 0; int ret = 0;
size_t nvalues = 0, nneighbours = 0; size_t i = 0, nvalues = 0, nneighbours = 0;
double radiusInKm; double radiusInKm;
grib_iterator* iter = NULL; grib_iterator* iter = NULL;
double lat = 0, lon = 0; double lat = 0, lon = 0;
@ -399,7 +399,7 @@ int grib_nearest_find_generic(
/*printf("Candidate: lat=%.5f lon=%.5f dist=%f Idx=%ld Val=%f\n",lat,lon,dist,the_index,the_value);*/ /*printf("Candidate: lat=%.5f lon=%.5f dist=%f Idx=%ld Val=%f\n",lat,lon,dist,the_index,the_value);*/
/* store this candidate point */ /* store this candidate point */
neighbours[i].m_dist = dist; neighbours[i].m_dist = dist;
neighbours[i].m_index = the_index; neighbours[i].m_index = (int)the_index;
neighbours[i].m_lat = lat; neighbours[i].m_lat = lat;
neighbours[i].m_lon = lon; neighbours[i].m_lon = lon;
neighbours[i].m_value = the_value; neighbours[i].m_value = the_value;

View File

@ -33,7 +33,7 @@ static const struct table_entry table[] = {
grib_nearest* grib_nearest_factory(grib_handle* h, grib_arguments* args) grib_nearest* grib_nearest_factory(grib_handle* h, grib_arguments* args)
{ {
int i; size_t i = 0;
int ret = GRIB_SUCCESS; int ret = GRIB_SUCCESS;
char* type = (char*)grib_arguments_get_name(h, args, 0); char* type = (char*)grib_arguments_get_name(h, args, 0);

View File

@ -186,7 +186,8 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
double* distances, int* indexes, size_t* len) double* distances, int* indexes, size_t* len)
{ {
grib_nearest_reduced* self = (grib_nearest_reduced*)nearest; grib_nearest_reduced* self = (grib_nearest_reduced*)nearest;
int ret = 0, kk = 0, ii = 0, jj = 0; int ret = 0, kk = 0, ii = 0;
size_t jj = 0;
long* pla = NULL; long* pla = NULL;
long* pl = NULL; long* pl = NULL;
size_t nvalues = 0; size_t nvalues = 0;

View File

@ -100,7 +100,8 @@ static int find(grib_nearest* nearest, grib_handle* h,
grib_nearest_sh* self = (grib_nearest_sh*)nearest; grib_nearest_sh* self = (grib_nearest_sh*)nearest;
long J, K, M; long J, K, M;
double* values; double* values;
int size, i, ret; int i, ret;
size_t size = 0;
size_t vsize = 0; size_t vsize = 0;
double val; double val;
@ -116,8 +117,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
values = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size); values = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size);
if (!values) { if (!values) {
grib_context_log(h->context, GRIB_LOG_ERROR, grib_context_log(h->context, GRIB_LOG_ERROR,
"nearest_sh: Error allocating %ld bytes", "nearest_sh: Error allocating %zu bytes", sizeof(double) * size);
sizeof(double) * size);
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }

View File

@ -50,6 +50,14 @@ list(APPEND test_c_bins
grib_lam_bf grib_lam_bf
grib_lam_gp) grib_lam_gp)
if( HAVE_EXPERIMENTAL_BUILD_WITH_CXX )
foreach( _bin ${test_c_bins} )
SET( _src ${_bin}.c )
set_source_files_properties( ${_src} PROPERTIES LANGUAGE CXX )
endforeach()
endif()
foreach( tool ${test_c_bins} ) foreach( tool ${test_c_bins} )
# here we use the fact that each tool has only one C file that matches its name # here we use the fact that each tool has only one C file that matches its name
ecbuild_add_executable( TARGET ${tool} ecbuild_add_executable( TARGET ${tool}

View File

@ -34,7 +34,7 @@ EOF
${tools_dir}/bufr_filter -f $tempFilt $sample_bufr4 2>$tempOut ${tools_dir}/bufr_filter -f $tempFilt $sample_bufr4 2>$tempOut
# Check the right error message came out # Check the right error message came out
grep -q "ECCODES ERROR.*Error while setting key pack (Encoding invalid)" $tempOut grep -q "ECCODES ERROR.*Error while setting key 'pack' (Encoding invalid)" $tempOut
# Now fix the order of keys and rerun # Now fix the order of keys and rerun

View File

@ -31,7 +31,7 @@ if [ "$latest" != "$highest_num" ]; then
exit 1 exit 1
fi fi
cd $test_dir
# Check table 1.0 # Check table 1.0
# Check it has the latest with description matching "Version implemented on DD MM YYYY" # Check it has the latest with description matching "Version implemented on DD MM YYYY"
tempText=temp.$label.txt tempText=temp.$label.txt

View File

@ -41,7 +41,6 @@ ${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample2
${tools_dir}/grib_ls -l 37.5,16.0,1 $tempGrib > $tempOut ${tools_dir}/grib_ls -l 37.5,16.0,1 $tempGrib > $tempOut
grep -q "Grid Point chosen #1 index=5016590" $tempOut grep -q "Grid Point chosen #1 index=5016590" $tempOut
grep -q "grid_simple 42" $tempOut
${tools_dir}/grib_ls -j -l 37.5,16.0,1 $tempGrib > $tempOut ${tools_dir}/grib_ls -j -l 37.5,16.0,1 $tempGrib > $tempOut
grep -q 'latitude" : 37.5, "longitude" : 16, "distance" : 0,.*"value" : 42 ,' $tempOut grep -q 'latitude" : 37.5, "longitude" : 16, "distance" : 0,.*"value" : 42 ,' $tempOut

View File

@ -12,7 +12,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "grib_api.h" #include "grib_api_internal.h"
/* /*
* Test encoding of LAM spectral fields * Test encoding of LAM spectral fields

View File

@ -12,7 +12,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "grib_api.h" #include "grib_api_internal.h"
/* /*
* Test encoding of grid-point LAM fields * Test encoding of grid-point LAM fields

View File

@ -21,10 +21,13 @@ infile=regular_gaussian_model_level.grib1
# Basic test of man page # Basic test of man page
set +e set +e
${tools_dir}/grib_ls > /dev/null ${tools_dir}/grib_ls > $tempLog
status=$? status=$?
set -e set -e
[ $status -eq 1 ] [ $status -eq 1 ]
grep -q "Full documentation and examples at" $tempLog
grep -q "https://confluence.ecmwf.int/display/ECC/grib_ls" $tempLog
${tools_dir}/grib_ls -P count $infile > $tempLog ${tools_dir}/grib_ls -P count $infile > $tempLog
${tools_dir}/grib_ls -p count,step $infile >> $tempLog ${tools_dir}/grib_ls -p count,step $infile >> $tempLog

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/ */
#include "grib_api.h" #include "grib_api_internal.h"
/* /*
* Test the use of optimizeScaleFactor; on the following field, the packing error * Test the use of optimizeScaleFactor; on the following field, the packing error

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/ */
#include "grib_api.h" #include "grib_api_internal.h"
/* /*
* Check that optimizeScaleFactor=1 reduces the error on spherical harmonics encoding. Check that sub-truncation is preserved in IEEE-32 precision. * Check that optimizeScaleFactor=1 reduces the error on spherical harmonics encoding. Check that sub-truncation is preserved in IEEE-32 precision.

View File

@ -10,8 +10,6 @@
. ./include.ctest.sh . ./include.ctest.sh
REDIRECT=/dev/null
label="grib_set_force_test" label="grib_set_force_test"
tempInput=temp.$label.input.grib2 tempInput=temp.$label.input.grib2

View File

@ -11,7 +11,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "grib_api.h" #include "grib_api_internal.h"
/* /*
* Check that encoding of sub-truncation using IEEE64 works. * Check that encoding of sub-truncation using IEEE64 works.

View File

@ -1607,9 +1607,9 @@ static void test_parse_keyval_string()
int err = 0; int err = 0;
int values_required = 1; int values_required = 1;
int count = 0; int count = 0;
grib_values values1[128] = {0,}; grib_values values1[128] = {{0},};
grib_values values2[128] = {0,}; grib_values values2[128] = {{0},};
grib_values values3[128] = {0,}; grib_values values3[128] = {{0},};
const int max_count = 128; const int max_count = 128;
char input1[] = "key1=value1,key2!=value2"; char input1[] = "key1=value1,key2!=value2";
char input2[] = "x=14"; char input2[] = "x=14";

View File

@ -16,14 +16,11 @@ tempOut=temp.${label}.out
tempTxt=temp.${label}.txt tempTxt=temp.${label}.txt
tempRef=temp.${label}.ref tempRef=temp.${label}.ref
REDIRECT=/dev/null
input=$ECCODES_SAMPLES_PATH/wrap.tmpl input=$ECCODES_SAMPLES_PATH/wrap.tmpl
${tools_dir}/grib_dump -TA -O $input ${tools_dir}/grib_dump -TA -O $input
id=`${tools_dir}/grib_get -TA -p identifier $input` id=`${tools_dir}/grib_get -TA -p identifier $input`
[ "$id" = "WRAP" ] [ "$id" = "WRAP" ]
# Clean up # Clean up
rm -f $tempOut $tempRef $tempTxt rm -f $tempOut $tempRef $tempTxt

View File

@ -77,6 +77,12 @@ foreach( tool ${ecc_tools_binaries_extra} )
LIBS ecc_tools ) LIBS ecc_tools )
endforeach() endforeach()
if( HAVE_EXPERIMENTAL_BUILD_WITH_CXX )
set_source_files_properties(bufr_filter.c PROPERTIES LANGUAGE CXX)
set_source_files_properties(codes_count.c PROPERTIES LANGUAGE CXX)
set_source_files_properties(grib_to_netcdf.c PROPERTIES LANGUAGE CXX)
endif()
# grib_count/bufr_count etc. Same source code, different executable names # grib_count/bufr_count etc. Same source code, different executable names
ecbuild_add_executable( TARGET grib_count ecbuild_add_executable( TARGET grib_count
SOURCES codes_count.c SOURCES codes_count.c
@ -100,9 +106,6 @@ ecbuild_add_executable( TARGET grib_list_keys
CONDITION ECCODES_INSTALL_EXTRA_TOOLS CONDITION ECCODES_INSTALL_EXTRA_TOOLS
LIBS ecc_tools ) LIBS ecc_tools )
if( HAVE_EXPERIMENTAL_BUILD_WITH_CXX )
set_source_files_properties(bufr_filter.c PROPERTIES LANGUAGE CXX)
endif()
ecbuild_add_executable( TARGET codes_bufr_filter ecbuild_add_executable( TARGET codes_bufr_filter
SOURCES bufr_filter.c SOURCES bufr_filter.c
LIBS ecc_tools ) LIBS ecc_tools )

View File

@ -45,8 +45,9 @@ const char* tool_description =
"\n\tFloating-point values are compared exactly by default, different tolerances can be defined (see -A -R)." "\n\tFloating-point values are compared exactly by default, different tolerances can be defined (see -A -R)."
"\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files.";
const char* tool_name = "bufr_compare"; const char* tool_name = "bufr_compare";
const char* tool_usage = "[options] bufr_file1 bufr_file2"; const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_compare";
const char* tool_usage = "[options] bufr_file1 bufr_file2";
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
{ {

View File

@ -19,8 +19,9 @@ const char* tool_description =
"Copies the content of BUFR files printing" "Copies the content of BUFR files printing"
" values of some keys." " values of some keys."
"\n\tIf the name of the output_bufr_file contains a key enclosed in square brackets, its value will be used."; "\n\tIf the name of the output_bufr_file contains a key enclosed in square brackets, its value will be used.";
const char* tool_name = "bufr_copy"; const char* tool_name = "bufr_copy";
const char* tool_usage = "[options] bufr_file bufr_file ... output_bufr_file"; const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_copy";
const char* tool_usage = "[options] bufr_file bufr_file ... output_bufr_file";
grib_option grib_options[] = { grib_option grib_options[] = {
/* {id, args, help}, on, command_line, value */ /* {id, args, help}, on, command_line, value */

View File

@ -64,6 +64,7 @@ grib_option grib_options[] = {
const char* tool_description = "Dump the content of a BUFR file in different formats."; const char* tool_description = "Dump the content of a BUFR file in different formats.";
const char* tool_name = "bufr_dump"; const char* tool_name = "bufr_dump";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_dump";
const char* tool_usage = "[options] bufr_file bufr_file ..."; const char* tool_usage = "[options] bufr_file bufr_file ...";
static int json = 0; static int json = 0;
static int dump_descriptors = 0; static int dump_descriptors = 0;

View File

@ -34,10 +34,10 @@ const char* tool_description =
"Apply the rules defined in rules_file to each BUFR " "Apply the rules defined in rules_file to each BUFR "
"message\n\tin the BUFR files provided as arguments.\n\t" "message\n\tin the BUFR files provided as arguments.\n\t"
"If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input.";
const char* tool_name = "bufr_filter"; const char* tool_name = "bufr_filter";
const char* tool_usage = const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_filter";
"[options] rules_file " const char* tool_usage = "[options] rules_file "
"bufr_file bufr_file ..."; "bufr_file bufr_file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -39,8 +39,9 @@ const char* tool_description =
"Get values of some header keys from a BUFR file." "Get values of some header keys from a BUFR file."
"\n\tIt is similar to bufr_ls, but fails returning an error code " "\n\tIt is similar to bufr_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* tool_name = "bufr_get"; const char* tool_name = "bufr_get";
const char* tool_usage = "[options] file file ..."; const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_get";
const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -18,11 +18,12 @@
const char* tool_description = const char* tool_description =
"Build an index file for a set of input BUFR files.\n" "Build an index file for a set of input BUFR files.\n"
"\tWarning: THIS TOOL IS STILL EXPERIMENTAL"; "\tWarning: THIS TOOL IS STILL EXPERIMENTAL";
const char* tool_name = "bufr_index_build"; const char* tool_name = "bufr_index_build";
const char* tool_usage = "[options] file file ... "; const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ... ";
grib_index* idx = NULL; grib_index* idx = NULL;
char* keys; const char* keys;
char* default_keys = "mars"; const char* default_keys = "mars";
grib_option grib_options[] = { grib_option grib_options[] = {
/* {id, args, help}, on, command_line, value */ /* {id, args, help}, on, command_line, value */

View File

@ -42,6 +42,7 @@ const char* tool_description =
"some header keys.\n\tOnly scalar keys can be printed." "some header keys.\n\tOnly scalar keys can be printed."
"\n\tIt does not fail when a key is not found."; "\n\tIt does not fail when a key is not found.";
const char* tool_name = "bufr_ls"; const char* tool_name = "bufr_ls";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_ls";
const char* tool_usage = "[options] bufr_file bufr_file ..."; const char* tool_usage = "[options] bufr_file bufr_file ...";
static int first_handle = 1; static int first_handle = 1;

View File

@ -45,8 +45,9 @@ const char* tool_description =
"Sets key/value pairs in the input BUFR file and writes" "Sets key/value pairs in the input BUFR file and writes"
"\n\teach message to the output_file." "\n\teach message to the output_file."
"\n\tIt fails when an error occurs (e.g. key not found)."; "\n\tIt fails when an error occurs (e.g. key not found).";
const char* tool_name = "bufr_set"; const char* tool_name = "bufr_set";
const char* tool_usage = "[options] file file ... output_file"; const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_set";
const char* tool_usage = "[options] file file ... output_file";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -8,8 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/ */
#include "grib_api.h" #include "grib_api_internal.h"
#include <assert.h>
#define CMAP_MAX 20480 #define CMAP_MAX 20480
@ -186,7 +185,7 @@ int main(int argc, char* argv[])
for (jj = 0; jj < height; jj++) { for (jj = 0; jj < height; jj++) {
for (i = 0; i < width; i++) { for (i = 0; i < width; i++) {
int m = (i + width / 2) % width + jj * width; int m = (i + width / 2) % width + jj * width;
assert(k < count); Assert(k < count);
indices[k++] = m; indices[k++] = m;
} }
} }

View File

@ -44,6 +44,7 @@ const char* tool_description =
"\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files.";
const char* tool_name = "grib_compare"; const char* tool_name = "grib_compare";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_compare";
const char* tool_usage = "[options] grib_file1 grib_file2"; const char* tool_usage = "[options] grib_file1 grib_file2";
typedef double (*compare_double_proc)(const double*, const double*, double); typedef double (*compare_double_proc)(const double*, const double*, double);

View File

@ -20,6 +20,7 @@ const char* tool_description =
" values of some keys." " values of some keys."
"\n\tIf the name of the output_grib_file contains a key enclosed in square brackets, its value will be used."; "\n\tIf the name of the output_grib_file contains a key enclosed in square brackets, its value will be used.";
const char* tool_name = "grib_copy"; const char* tool_name = "grib_copy";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_copy";
const char* tool_usage = "[options] grib_file grib_file ... output_grib_file"; const char* tool_usage = "[options] grib_file grib_file ... output_grib_file";
grib_option grib_options[] = { grib_option grib_options[] = {

View File

@ -41,6 +41,7 @@ grib_option grib_options[] = {
const char* tool_description = "Dump the content of a GRIB file in different formats."; const char* tool_description = "Dump the content of a GRIB file in different formats.";
const char* tool_name = "grib_dump"; const char* tool_name = "grib_dump";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_dump";
const char* tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
static int json = 0; static int json = 0;
static int first_handle = 1; static int first_handle = 1;

View File

@ -31,9 +31,9 @@ const char* tool_description =
"message\n\tin the GRIB files provided as arguments.\n\t" "message\n\tin the GRIB files provided as arguments.\n\t"
"If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input.";
const char* tool_name = "grib_filter"; const char* tool_name = "grib_filter";
const char* tool_usage = const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_filter";
"[options] rules_file " const char* tool_usage = "[options] rules_file "
"grib_file grib_file ..."; "grib_file grib_file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -40,6 +40,7 @@ const char* tool_description =
"\n\tIt is similar to grib_ls, but fails returning an error code " "\n\tIt is similar to grib_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* tool_name = "grib_get"; const char* tool_name = "grib_get";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_get";
const char* tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -39,6 +39,7 @@ const char* tool_description =
"Print a latitude, longitude, data values list.\n" "Print a latitude, longitude, data values list.\n"
"\tNote: Rotated grids are first unrotated"; "\tNote: Rotated grids are first unrotated";
const char* tool_name = "grib_get_data"; const char* tool_name = "grib_get_data";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_get_data";
const char* tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
extern FILE* dump_file; extern FILE* dump_file;
@ -158,8 +159,8 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
num_bytes = (numberOfPoints + 1) * sizeof(double); num_bytes = (numberOfPoints + 1) * sizeof(double);
data_values = (double*)calloc(numberOfPoints + 1, sizeof(double)); data_values = (double*)calloc(numberOfPoints + 1, sizeof(double));
if (!data_values) { if (!data_values) {
fprintf(stderr, "ERROR: Failed to allocate %ld bytes for data values (number of points=%ld)\n", fprintf(stderr, "ERROR: Failed to allocate %zu bytes for data values (number of points=%ld)\n",
(long)num_bytes, numberOfPoints); num_bytes, numberOfPoints);
exit(GRIB_OUT_OF_MEMORY); exit(GRIB_OUT_OF_MEMORY);
} }
@ -182,7 +183,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
} }
if (size != (size_t)numberOfPoints) { if (size != (size_t)numberOfPoints) {
if (!grib_options_on("q")) if (!grib_options_on("q"))
fprintf(stderr, "ERROR: Wrong number of points %d\n", (int)numberOfPoints); fprintf(stderr, "ERROR: Wrong number of points %ld\n", numberOfPoints);
if (grib_options_on("f")) if (grib_options_on("f"))
exit(1); exit(1);
} }

View File

@ -21,6 +21,7 @@ int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
const char* tool_description = "Histogram of GRIB files"; const char* tool_description = "Histogram of GRIB files";
const char* tool_name = "grib_histogram"; const char* tool_name = "grib_histogram";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
int main(int argc, char* argv[]) int main(int argc, char* argv[])

View File

@ -17,6 +17,7 @@
const char* tool_description = "Build an index file for a set of input GRIB files."; const char* tool_description = "Build an index file for a set of input GRIB files.";
const char* tool_name = "grib_index_build"; const char* tool_name = "grib_index_build";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_index_build";
const char* tool_usage = "[options] grib_file grib_file ... "; const char* tool_usage = "[options] grib_file grib_file ... ";
static grib_index* idx = NULL; static grib_index* idx = NULL;
static const char* keys; static const char* keys;

View File

@ -45,8 +45,9 @@ grib_option grib_options[] = {
const char* tool_description = const char* tool_description =
"List content of GRIB files printing values of " "List content of GRIB files printing values of "
"some keys.\n\tIt does not fail when a key is not found."; "some keys.\n\tIt does not fail when a key is not found.";
const char* tool_name = "grib_ls"; const char* tool_name = "grib_ls";
const char* tool_usage = "[options] grib_file grib_file ..."; const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_ls";
const char* tool_usage = "[options] grib_file grib_file ...";
static const char* new_handle = ""; static const char* new_handle = "";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -36,6 +36,7 @@ static const char* md5Key = "md5Product";
const char* tool_description = "Merge two fields with identical parameters and different geographical area"; const char* tool_description = "Merge two fields with identical parameters and different geographical area";
const char* tool_name = "grib_merge"; const char* tool_name = "grib_merge";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ... output_file"; const char* tool_usage = "[options] file file ... output_file";
grib_option grib_options[] = { grib_option grib_options[] = {

View File

@ -131,7 +131,10 @@ void usage(void)
grib_options_get_help(grib_options[i].id)); grib_options_get_help(grib_options[i].id));
} }
} }
printf("\n\n"); printf("\n");
if (tool_online_doc)
printf("SEE ALSO\n\tFull documentation and examples at:\n\t<%s>\n\n", tool_online_doc);
printf("\n");
exit(1); exit(1);
} }

View File

@ -50,8 +50,9 @@ const char* tool_description =
"Sets key/value pairs in the input GRIB file and writes" "Sets key/value pairs in the input GRIB file and writes"
"\n\teach message to the output_grib_file." "\n\teach message to the output_grib_file."
"\n\tIt fails when an error occurs (e.g. key not found)."; "\n\tIt fails when an error occurs (e.g. key not found).";
const char* tool_name = "grib_set"; const char* tool_name = "grib_set";
const char* tool_usage = "[options] grib_file grib_file ... output_grib_file"; const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_set";
const char* tool_usage = "[options] grib_file grib_file ... output_grib_file";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -33,6 +33,7 @@ const char* tool_description =
"\n\tNote: The GRIB geometry should be a regular lat/lon grid or a regular Gaussian grid" "\n\tNote: The GRIB geometry should be a regular lat/lon grid or a regular Gaussian grid"
"\n\t(the key \"typeOfGrid\" should be \"regular_ll\" or \"regular_gg\")"; "\n\t(the key \"typeOfGrid\" should be \"regular_ll\" or \"regular_gg\")";
const char* tool_name = "grib_to_netcdf"; const char* tool_name = "grib_to_netcdf";
const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/grib_to_netcdf";
const char* tool_usage = "[options] -o output_file grib_file grib_file ... "; const char* tool_usage = "[options] -o output_file grib_file grib_file ... ";
static char argvString[2048] = {0,}; static char argvString[2048] = {0,};
@ -1841,7 +1842,7 @@ typedef struct ncatt
nc_type nctype; nc_type nctype;
} ncatt_t; } ncatt_t;
typedef struct filter typedef struct filter_type
{ {
fieldset* fset; fieldset* fset;
hypercube* filter; hypercube* filter;
@ -2944,10 +2945,10 @@ static int define_netcdf_dimensions(hypercube* h, fieldset* fs, int ncid, datase
for (i = 0; i < naxis; ++i) { for (i = 0; i < naxis; ++i) {
int nctype = NC_INT; int nctype = NC_INT;
const char* axis = get_axis(h, i); const char* axis = get_axis(h, i);
char* units = NULL; const char* units = NULL;
char u[10240]; char u[10240];
const char* lowaxis = (axis); const char* lowaxis = (axis);
char* longname = (char*)lowaxis; const char* longname = (char*)lowaxis;
n = count_values(cube, axis); n = count_values(cube, axis);
if (count_values(data_r, "levtype") > 1) { if (count_values(data_r, "levtype") > 1) {
@ -3048,7 +3049,7 @@ static int define_netcdf_dimensions(hypercube* h, fieldset* fs, int ncid, datase
const char* cal = "gregorian"; const char* cal = "gregorian";
if (setup.mmeans) { if (setup.mmeans) {
char* period = "0000-01-00 00:00:00"; const char* period = "0000-01-00 00:00:00";
stat = nc_put_att_text(ncid, var_id, "avg_period", strlen(period), period); stat = nc_put_att_text(ncid, var_id, "avg_period", strlen(period), period);
check_err("nc_put_att_text", stat, __LINE__); check_err("nc_put_att_text", stat, __LINE__);
} }
@ -3178,7 +3179,7 @@ static int define_netcdf_dimensions(hypercube* h, fieldset* fs, int ncid, datase
char timestamp[80]; char timestamp[80];
time_t now; time_t now;
/* char *convention = "MARS;CF"; */ /* char *convention = "MARS;CF"; */
char* convention = "CF-1.6"; const char* convention = "CF-1.6";
char history[10240]; char history[10240];
/* char *institution = "ECMWF Meteorological Archival and Retrieval System"; */ /* char *institution = "ECMWF Meteorological Archival and Retrieval System"; */
@ -3935,7 +3936,7 @@ static int deflate_option = 0;
/* Table of formats for legal -k values. Inspired by nccopy */ /* Table of formats for legal -k values. Inspired by nccopy */
struct KindValue struct KindValue
{ {
char* name; const char* name;
int kind; int kind;
} legalkinds[] = { } legalkinds[] = {
{ "1", NC_FORMAT_CLASSIC }, { "1", NC_FORMAT_CLASSIC },

View File

@ -181,6 +181,7 @@ extern int grib_options_count;
extern const char* tool_name; extern const char* tool_name;
extern const char* tool_description; extern const char* tool_description;
extern const char* tool_usage; extern const char* tool_usage;
extern const char* tool_online_doc; /* Can be NULL */
extern FILE* dump_file; extern FILE* dump_file;

View File

@ -41,6 +41,7 @@ const char* tool_description =
"\n\tDefault behaviour: bit-by-bit compare, same order in files."; "\n\tDefault behaviour: bit-by-bit compare, same order in files.";
const char* tool_name = "gts_compare"; const char* tool_name = "gts_compare";
const char* tool_online_doc = NULL;
const char* tool_usage = const char* tool_usage =
"[options] " "[options] "
"file file"; "file file";

View File

@ -14,6 +14,7 @@ const char* tool_description =
"Copies the content of GTS files printing" "Copies the content of GTS files printing"
" values of some keys."; " values of some keys.";
const char* tool_name = "gts_copy"; const char* tool_name = "gts_copy";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ... output_file"; const char* tool_usage = "[options] file file ... output_file";
grib_option grib_options[] = { grib_option grib_options[] = {

View File

@ -35,6 +35,7 @@ grib_option grib_options[] = {
const char* tool_description = "Dump the content of a GTS file in different formats."; const char* tool_description = "Dump the content of a GTS file in different formats.";
const char* tool_name = "gts_dump"; const char* tool_name = "gts_dump";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -31,6 +31,7 @@ const char* tool_description =
"message\n\tin the GTS files provided as arguments.\n\t" "message\n\tin the GTS files provided as arguments.\n\t"
"If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input.";
const char* tool_name = "gts_filter"; const char* tool_name = "gts_filter";
const char* tool_online_doc = NULL;
const char* tool_usage = const char* tool_usage =
"[options] rules_file " "[options] rules_file "
"file file ..."; "file file ...";

View File

@ -33,6 +33,7 @@ const char* tool_description =
"\n\tIt is similar to gts_ls, but fails returning an error code " "\n\tIt is similar to gts_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* tool_name = "gts_get"; const char* tool_name = "gts_get";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -36,6 +36,7 @@ const char* tool_description =
"List content of GTS files printing values of " "List content of GTS files printing values of "
"some keys.\n\tIt does not fail when a key is not found."; "some keys.\n\tIt does not fail when a key is not found.";
const char* tool_name = "gts_ls"; const char* tool_name = "gts_ls";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -44,6 +44,7 @@ const char* tool_description =
"\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files.";
const char* tool_name = "metar_compare"; const char* tool_name = "metar_compare";
const char* tool_online_doc = NULL;
const char* tool_usage = const char* tool_usage =
"[options] " "[options] "
"file file"; "file file";

View File

@ -14,6 +14,7 @@ const char* tool_description =
"Copies the content of METAR files printing" "Copies the content of METAR files printing"
" values of some keys."; " values of some keys.";
const char* tool_name = "metar_copy"; const char* tool_name = "metar_copy";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ... output_file"; const char* tool_usage = "[options] file file ... output_file";
grib_option grib_options[] = { grib_option grib_options[] = {

View File

@ -38,6 +38,7 @@ grib_option grib_options[] = {
const char* tool_description = "Dump the content of a METAR file in different formats."; const char* tool_description = "Dump the content of a METAR file in different formats.";
const char* tool_name = "metar_dump"; const char* tool_name = "metar_dump";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -28,6 +28,7 @@ const char* tool_description =
"Apply the rules defined in rules_file to each METAR " "Apply the rules defined in rules_file to each METAR "
"message\n\tin the files provided as arguments."; "message\n\tin the files provided as arguments.";
const char* tool_name = "metar_filter"; const char* tool_name = "metar_filter";
const char* tool_online_doc = NULL;
const char* tool_usage = const char* tool_usage =
"[options] rules_file " "[options] rules_file "
"file file ..."; "file file ...";

View File

@ -34,6 +34,7 @@ const char* tool_description =
"\n\tIt is similar to metar_ls, but fails returning an error code " "\n\tIt is similar to metar_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* tool_name = "metar_get"; const char* tool_name = "metar_get";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -48,6 +48,7 @@ const char* tool_description =
"List content of METAR files printing values of " "List content of METAR files printing values of "
"some keys.\n\tIt does not fail when a key is not found."; "some keys.\n\tIt does not fail when a key is not found.";
const char* tool_name = "metar_ls"; const char* tool_name = "metar_ls";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -31,6 +31,7 @@ grib_option grib_options[] = {
const char* tool_description = "Dump the content of a TAF file in different formats."; const char* tool_description = "Dump the content of a TAF file in different formats.";
const char* tool_name = "taf_dump"; const char* tool_name = "taf_dump";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -30,6 +30,7 @@ const char* tool_description =
"Apply the rules defined in rules_file to each TAF " "Apply the rules defined in rules_file to each TAF "
"message\n\tin the files provided as arguments."; "message\n\tin the files provided as arguments.";
const char* tool_name = "taf_filter"; const char* tool_name = "taf_filter";
const char* tool_online_doc = NULL;
const char* tool_usage = const char* tool_usage =
"[options] rules_file " "[options] rules_file "
"file file ..."; "file file ...";

View File

@ -38,6 +38,7 @@ const char* tool_description =
"\n\tIt is similar to taf_ls, but fails returning an error code " "\n\tIt is similar to taf_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* tool_name = "taf_get"; const char* tool_name = "taf_get";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -41,6 +41,7 @@ const char* tool_description =
"List content of TAF files printing values of " "List content of TAF files printing values of "
"some keys.\n\tIt does not fail when a key is not found."; "some keys.\n\tIt does not fail when a key is not found.";
const char* tool_name = "taf_ls"; const char* tool_name = "taf_ls";
const char* tool_online_doc = NULL;
const char* tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);