Debugging: Take missingValue into account when printing values

This commit is contained in:
Shahram Najm 2023-08-31 11:08:26 +01:00
parent 2fa3376441
commit 3b9cd2e018
1 changed files with 6 additions and 0 deletions

View File

@ -37,8 +37,13 @@ static void print_debug_info__set_array(grib_handle* h, const char* func, const
size_t N = 7, i = 0;
T minVal = std::numeric_limits<T>::max();
T maxVal = -std::numeric_limits<T>::max();
double missingValue = 0;
Assert( h->context->debug );
if (grib_get_double(h, "missingValue", &missingValue)!=GRIB_SUCCESS) {
missingValue = 9999.0;
}
if (length <= N)
N = length;
fprintf(stderr, "ECCODES DEBUG %s key=%s, %zu entries (", func, name, length);
@ -49,6 +54,7 @@ static void print_debug_info__set_array(grib_handle* h, const char* func, const
if (N >= length) fprintf(stderr, ") ");
else fprintf(stderr, "...) ");
for (i = 0; i < length; ++i) {
if (val[i] == (T)missingValue) continue;
if (val[i] < minVal) minVal = val[i];
if (val[i] > maxVal) maxVal = val[i];
}