eccodes/tests/grib_dump_debug.sh

117 lines
3.4 KiB
Bash
Raw Normal View History

2013-03-25 12:04:10 +00:00
#!/bin/sh
2020-01-28 14:32:34 +00:00
# (C) Copyright 2005- ECMWF.
2013-03-25 12:04:10 +00:00
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
2013-03-25 14:23:07 +00:00
#
2013-03-25 12:04:10 +00:00
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
2022-07-22 16:57:02 +00:00
label="grib_dump_debug_test"
temp=temp.$label.txt
2022-06-06 14:41:18 +00:00
if [ $HAVE_GEOGRAPHY -eq 0 ]; then
exit 0
fi
if [ $HAVE_MEMFS -eq 1 ]; then
unset ECCODES_DEFINITION_PATH
unset ECCODES_SAMPLES_PATH
fi
files="
constant_field.grib1
lfpw.grib1
missing_field.grib1
reduced_gaussian_lsm.grib1
reduced_gaussian_model_level.grib1
reduced_gaussian_pressure_level.grib1
reduced_gaussian_pressure_level_constant.grib1
reduced_gaussian_sub_area.grib1
reduced_gaussian_surface.grib1
reduced_latlon_surface.grib1
reduced_latlon_surface_constant.grib1
reference_ensemble_mean.grib1
reference_stdev.grib1
regular_gaussian_model_level.grib1
regular_gaussian_pressure_level.grib1
regular_gaussian_pressure_level_constant.grib1
regular_gaussian_surface.grib1
regular_latlon_surface.grib1
regular_latlon_surface_constant.grib1
second_ord_rbr.grib1
small_ensemble.grib1
spectral_complex.grib1
spherical_model_level.grib1
spherical_pressure_level.grib1
constant_field.grib2
gfs.c255.grib2
missing.grib2
multi_created.grib2
reduced_gaussian_model_level.grib2
reduced_gaussian_pressure_level.grib2
reduced_gaussian_pressure_level_constant.grib2
reduced_gaussian_sub_area.grib2
reduced_gaussian_surface.grib2
reduced_latlon_surface.grib2
reduced_latlon_surface_constant.grib2
regular_gaussian_model_level.grib2
regular_gaussian_pressure_level.grib2
regular_gaussian_pressure_level_constant.grib2
regular_gaussian_surface.grib2
regular_latlon_surface.grib2
regular_latlon_surface_constant.grib2
sample.grib2
spherical_model_level.grib2
spherical_pressure_level.grib2
test_uuid.grib2
tigge_af_ecmwf.grib2
tigge_cf_ecmwf.grib2
"
# Check if JPEG is enabled
if [ $HAVE_JPEG -eq 1 ]; then
# Include files which have messages with grid_jpeg packing
2018-07-19 14:16:42 +00:00
echo "Add extra files (HAVE_JPEG=1)"
files="jpeg.grib2 reduced_gaussian_surface_jpeg.grib2 "$files
if [ $HAVE_EXTRA_TESTS -eq 1 ]; then
echo "Add extra files (HAVE_EXTRA_TESTS=1)"
files=" v.grib2 multi.grib2 "$files # much slower
fi
fi
for file in $files; do
if [ -f ${data_dir}/$file ]; then
2021-01-26 16:02:23 +00:00
${tools_dir}/grib_dump -w count=1 -Da ${data_dir}/$file > $temp 2>&1
set +e
# Look for the word ERROR in output. We should not find any
grep -q 'ERROR ' $temp
if [ $? -eq 0 ]; then
echo "File $file: found string ERROR in grib_dump output!"
exit 1
fi
set -e
fi
2013-03-25 12:04:10 +00:00
done
2021-05-27 16:24:53 +00:00
# ECC-1247: indicate which keys can have values which are 'missing'
2023-05-09 12:54:39 +00:00
# ECC-1584: indicate which keys are 'read-only'
2021-05-27 16:24:53 +00:00
# ------------------------------------------------------------------
infile=${data_dir}/sample.grib2
${tools_dir}/grib_dump -D $infile > $temp
grep -q "unsigned hoursAfterDataCutoff = 0 (can be missing)" $temp
grep -q "unsigned iDirectionIncrement = 2000000 (can be missing)" $temp
2023-05-09 12:54:39 +00:00
grep -q "constant zero = 0 (read-only)" $temp
grep -q "unsigned reserved = MISSING (can be missing) (read-only)" $temp
2021-05-27 16:24:53 +00:00
2024-09-17 10:37:39 +00:00
# Debug dump a BUFR using -TB switch
infile=${data_dir}/bufr/pgps_110.bufr
2024-09-17 11:11:04 +00:00
${tools_dir}/grib_dump -Da -TB $infile > $temp
# ${tools_dir}/grib_dump -Da -TB -s unpack=1 $infile > $temp
2024-09-17 10:37:39 +00:00
2023-05-09 12:54:39 +00:00
# Clean up
rm -f $temp