mirror of https://github.com/ecmwf/eccodes.git
Debugging: print grib_values key/value pair array
This commit is contained in:
parent
e5e0952fb4
commit
d35518ec46
|
@ -733,7 +733,7 @@ int grib_get_long_array_internal(grib_handle* h, const char* name, long* val, si
|
||||||
int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_t* length);
|
int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_t* length);
|
||||||
int grib_set_values(grib_handle* h, grib_values* args, size_t count);
|
int grib_set_values(grib_handle* h, grib_values* args, size_t count);
|
||||||
int grib_get_nearest_smaller_value(grib_handle* h, const char* name, double val, double* nearest);
|
int grib_get_nearest_smaller_value(grib_handle* h, const char* name, double val, double* nearest);
|
||||||
void grib_print_values(const char* title, grib_values* values, FILE* out);
|
void grib_print_values(const char* title, const grib_values* values, FILE* out, int count);
|
||||||
int grib_values_check(grib_handle* h, grib_values* values, int count);
|
int grib_values_check(grib_handle* h, grib_values* values, int count);
|
||||||
int codes_copy_key(grib_handle* h1, grib_handle* h2, const char* key, int type);
|
int codes_copy_key(grib_handle* h1, grib_handle* h2, const char* key, int type);
|
||||||
int codes_compare_key(grib_handle* h1, grib_handle* h2, const char* key, int compare_flags);
|
int codes_compare_key(grib_handle* h1, grib_handle* h2, const char* key, int compare_flags);
|
||||||
|
|
|
@ -1801,7 +1801,7 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count)
|
||||||
|
|
||||||
if (h->context->debug) {
|
if (h->context->debug) {
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
grib_print_values("ECCODES DEBUG about to set key/value pair", &args[i], stderr);
|
grib_print_values("ECCODES DEBUG about to set key/value pair", &args[i], stderr, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1875,22 +1875,24 @@ int grib_get_nearest_smaller_value(grib_handle* h, const char* name,
|
||||||
return act->nearest_smaller_value(val, nearest);
|
return act->nearest_smaller_value(val, nearest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void grib_print_values(const char* title, grib_values* values, FILE* out)
|
void grib_print_values(const char* title, const grib_values* values, FILE* out, int count)
|
||||||
{
|
{
|
||||||
if (values) {
|
Assert(values);
|
||||||
fprintf(out, "%s: %s=", title, values->name);
|
for (int i = 0; i < count; ++i) {
|
||||||
switch (values->type) {
|
const grib_values aVal = values[i];
|
||||||
|
fprintf(out, "%s: %s=", title, aVal.name);
|
||||||
|
switch (aVal.type) {
|
||||||
case GRIB_TYPE_LONG:
|
case GRIB_TYPE_LONG:
|
||||||
fprintf(out, "%ld", values->long_value);
|
fprintf(out, "%ld", aVal.long_value);
|
||||||
break;
|
break;
|
||||||
case GRIB_TYPE_DOUBLE:
|
case GRIB_TYPE_DOUBLE:
|
||||||
fprintf(out, "%g", values->double_value);
|
fprintf(out, "%g", aVal.double_value);
|
||||||
break;
|
break;
|
||||||
case GRIB_TYPE_STRING:
|
case GRIB_TYPE_STRING:
|
||||||
fprintf(out, "%s", values->string_value);
|
fprintf(out, "%s", aVal.string_value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(out, " (type=%s)\n", grib_get_type_name(values->type));
|
fprintf(out, " (type=%s)\n", grib_get_type_name(aVal.type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,7 @@ static void test_parse_keyval_string()
|
||||||
values_required, GRIB_TYPE_UNDEFINED, values1, &count);
|
values_required, GRIB_TYPE_UNDEFINED, values1, &count);
|
||||||
Assert( !err );
|
Assert( !err );
|
||||||
Assert( count == 2 );
|
Assert( count == 2 );
|
||||||
grib_print_values("print values test: values1", values1, stdout);
|
grib_print_values("print values test: values1", values1, stdout, count);
|
||||||
|
|
||||||
Assert( strcmp(values1[0].name, "key1")==0 );
|
Assert( strcmp(values1[0].name, "key1")==0 );
|
||||||
Assert( strcmp(values1[0].string_value, "value1")==0 );
|
Assert( strcmp(values1[0].string_value, "value1")==0 );
|
||||||
|
@ -506,7 +506,7 @@ static void test_parse_keyval_string()
|
||||||
values_required, GRIB_TYPE_LONG, values2, &count);
|
values_required, GRIB_TYPE_LONG, values2, &count);
|
||||||
Assert( !err );
|
Assert( !err );
|
||||||
Assert( count == 1 );
|
Assert( count == 1 );
|
||||||
grib_print_values("print values test: values2", values2, stdout);
|
grib_print_values("print values test: values2", values2, stdout, count);
|
||||||
Assert( strcmp(values2[0].name, "x")==0 );
|
Assert( strcmp(values2[0].name, "x")==0 );
|
||||||
Assert( values2[0].long_value == 14 );
|
Assert( values2[0].long_value == 14 );
|
||||||
Assert( values2[0].equal == 1 );
|
Assert( values2[0].equal == 1 );
|
||||||
|
@ -517,7 +517,7 @@ static void test_parse_keyval_string()
|
||||||
values_required, GRIB_TYPE_DOUBLE, values3, &count);
|
values_required, GRIB_TYPE_DOUBLE, values3, &count);
|
||||||
Assert( !err );
|
Assert( !err );
|
||||||
Assert( count == 1 );
|
Assert( count == 1 );
|
||||||
grib_print_values("print values test: values3", values3, stdout);
|
grib_print_values("print values test: values3", values3, stdout, count);
|
||||||
Assert( strcmp(values3[0].name, "mars.level")==0 );
|
Assert( strcmp(values3[0].name, "mars.level")==0 );
|
||||||
free( (void*)values3[0].name );
|
free( (void*)values3[0].name );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue