diff --git a/tests/grib_get_fail.sh b/tests/grib_get_fail.sh index 7f1c967e4..7dc795226 100755 --- a/tests/grib_get_fail.sh +++ b/tests/grib_get_fail.sh @@ -87,6 +87,16 @@ set -e grep -q "unreadable message" $tempText rm -f $outfile +# ---------------------- +# Printing array keys +# ---------------------- +set +e +${tools_dir}/grib_get -p bitmap $data_dir/reduced_latlon_surface.grib2 > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Hint: Tool grib_get cannot print keys of array type" $tempText + # ---------------------- # Wrong message type diff --git a/tests/grib_ls.sh b/tests/grib_ls.sh index be4f7a38b..244ad76ba 100755 --- a/tests/grib_ls.sh +++ b/tests/grib_ls.sh @@ -283,6 +283,16 @@ set -e [ $status -ne 0 ] grep -q "unable to open mask file" $tempText +# ---------------------- +# Printing array keys +# ---------------------- +set +e +${tools_dir}/grib_ls -p bitmap $data_dir/reduced_latlon_surface.grib2 > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Hint: Tool grib_ls cannot print keys of array type" $tempText + # Clean up rm -f $temp1 $temp2 $tempText $tempLog diff --git a/tools/grib_tools.cc b/tools/grib_tools.cc index 976f712be..cde99abac 100644 --- a/tools/grib_tools.cc +++ b/tools/grib_tools.cc @@ -1239,14 +1239,18 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h) //GRIB_CHECK_NOLINE(ret, options->print_keys[i].name); grib_context_log(h->context, GRIB_LOG_ERROR, "%s (%s)", options->print_keys[i].name, grib_get_error_message(ret)); + if (ret == GRIB_ARRAY_TOO_SMALL || ret == GRIB_BUFFER_TOO_SMALL) { + fprintf(dump_file, "\tHint: Tool %s cannot print keys of array type. Use grib_filter.\n", tool_name); + } exit(ret); } if (ret == GRIB_NOT_FOUND) { strcpy(value, notfound); } else { fprintf(dump_file, "%s (%s)\n", options->print_keys[i].name, grib_get_error_message(ret)); - if (ret == GRIB_ARRAY_TOO_SMALL) + if (ret == GRIB_ARRAY_TOO_SMALL || ret == GRIB_BUFFER_TOO_SMALL) { fprintf(dump_file, "\tHint: Tool %s cannot print keys of array type. Use grib_filter.\n", tool_name); + } exit(ret); } }