ECC-1642: Geoiterator: No error for badly encoded regular grids

This commit is contained in:
Shahram Najm 2023-07-19 15:58:28 +00:00
parent 862764654a
commit e1576f3aa7
2 changed files with 35 additions and 7 deletions

View File

@ -177,6 +177,11 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
return GRIB_WRONG_GRID; return GRIB_WRONG_GRID;
} }
if (Ni*Nj != iter->nv) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator: Ni*Nj!=numberOfDataPoints (%ld*%ld!=%zu)", Ni,Nj,iter->nv);
return GRIB_WRONG_GRID;
}
if ((ret = grib_get_long_internal(h, s_iScansNeg, &self->iScansNegatively))) if ((ret = grib_get_long_internal(h, s_iScansNeg, &self->iScansNegatively)))
return ret; return ret;

View File

@ -11,7 +11,8 @@
. ./include.ctest.sh . ./include.ctest.sh
label="grib_iterator_test" label="grib_iterator_test"
temp=temp.$label.txt tempText=temp.$label.txt
tempGrib=temp.$label.grib
files="reduced_latlon_surface.grib1 \ files="reduced_latlon_surface.grib1 \
reduced_gaussian_pressure_level.grib1 \ reduced_gaussian_pressure_level.grib1 \
@ -32,15 +33,37 @@ for f in $files; do
[ $numberOfPoints = ${iterator_count} ] [ $numberOfPoints = ${iterator_count} ]
done done
# ECC-822: Increase lat/lon decimals using default grib_get_data
${tools_dir}/grib_get_data -L%12.6f%11.5f ${data_dir}/regular_latlon_surface.grib2
${tools_dir}/grib_get_data -p shortName,level ${data_dir}/regular_latlon_surface.grib2 > $temp # ECC-822: Increase lat/lon decimals using default grib_get_data
grep -q "Latitude Longitude Value shortName level" $temp ${tools_dir}/grib_get_data -L%12.6f%11.5f ${data_dir}/regular_latlon_surface.grib2 > $tempText
${tools_dir}/grib_get_data -p shortName,level ${data_dir}/regular_latlon_surface.grib2 > $tempText
grep -q "Latitude Longitude Value shortName level" $tempText
# Run on a spectral field - should just print out its values # Run on a spectral field - should just print out its values
${tools_dir}/grib_get_data "$samp_dir/sh_ml_grib2.tmpl" ${tools_dir}/grib_get_data "$samp_dir/sh_ml_grib2.tmpl" > $tempText
# ECC-1642: badly encoded regular grids
# -------------------------------------
${tools_dir}/grib_set -s Ni=33 $samp_dir/GRIB2.tmpl $tempGrib
set +e
${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
status=$?
set +e
[ $status -ne 0 ]
grep -q "Grid description is wrong or inconsistent" $tempText
${tools_dir}/grib_set -s Ni=MISSING $samp_dir/GRIB2.tmpl $tempGrib
set +e
${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
status=$?
set +e
[ $status -ne 0 ]
grep -q "Grid description is wrong or inconsistent" $tempText
# Clean up # Clean up
rm -f $temp rm -f $tempText $tempGrib