Testing: cleanup

This commit is contained in:
Shahram Najm 2022-06-25 13:01:00 +01:00
parent 43bce2bc38
commit 9ddef2ea04
2 changed files with 15 additions and 12 deletions

View File

@ -2718,6 +2718,7 @@ static void encode_decode(double* zval, const char* packingType, const int bitsP
size_t len, slen;
grib_handle* h;
/*printf("encode_decode: packingType=%s bitsPerValue=%d opt=%d\n", packingType, bitsPerValue, ioptimizeScaleFactor);*/
GRIB_CHECK(((h = grib_handle_new_from_samples(NULL, "regular_ll_pl_grib2")) == NULL), 0);
GRIB_CHECK(grib_set_long(h, "Ni", NLON), 0);
GRIB_CHECK(grib_set_long(h, "Nj", NLAT), 0);
@ -2749,8 +2750,7 @@ int main(int argc, char* argv[])
int bitsPerValue[11] = { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
int ipackingType, ibitsPerValue, ioptimizeScaleFactor;
for (ibitsPerValue = 0; ibitsPerValue < 11; ibitsPerValue++)
for (ibitsPerValue = 0; ibitsPerValue < 11; ibitsPerValue++) {
for (ipackingType = 0; ipackingType < 2; ipackingType++) {
double zval_simple[NLAT * NLON];
double zval_second[NLAT * NLON];
@ -2766,7 +2766,7 @@ int main(int argc, char* argv[])
return 1;
}
}
}
printf(" %30s %30s %30s %s\n", "bitsPerValue", "error(optimizeScaleFactor=0)", "error(optimizeScaleFactor=1)", "ratio");
for (ibitsPerValue = 0; ibitsPerValue < 11; ibitsPerValue++) {
double zerr[2];

View File

@ -12,13 +12,15 @@
workdir=`pwd`
REDIRECT=/dev/null
label="grib_second_order_test"
tempText=temp.$label.txt
cd ${data_dir}
encoding=1
simple_no_bitmap=simple.grib
simple_bitmap=simple_bitmap.grib
test_filter=temp.grib_second_order.filter
test_filter=temp.$label.filter
files_no_bitmap="gen_ext.grib \
gen_ext_boust.grib \
@ -113,9 +115,9 @@ res=`${tools_dir}/grib_get -w count=1 -l 0,0,1 lfpw.grib1`
g1files="lfpw.grib1
gen_ext_spd_2.grib
gen_ext_spd_3.grib"
temp1=temp1.grib_second_order.grib
temp_stat1=temp.grib_second_order.stat1
temp_stat2=temp.grib_second_order.stat2
temp1=temp1.$label.grib
temp_stat1=temp.$label.stat1
temp_stat2=temp.$label.stat2
for f1 in $g1files; do
# This does unpack and repack
@ -128,15 +130,16 @@ done
# GRIB-883
# ------------
# Two coded values: Should stay as grid_simple
temp2=temp2.grib_second_order.grib
temp3=temp3.grib_second_order.grib
temp2=temp2.$label.grib
temp3=temp3.$label.grib
cat > $test_filter<<EOF
set values={ 2.1, 3.4 };
write;
EOF
${tools_dir}/grib_filter -o $temp2 $test_filter $ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_set -r -s packingType=grid_second_order $temp2 $temp3
ECCODES_DEBUG=1 ${tools_dir}/grib_set -r -s packingType=grid_second_order $temp2 $temp3 2>$tempText
grib_check_key_equals $temp3 packingType,accuracy 'grid_simple 24'
grep -q "Packing not changed" $tempText
# Three coded values: Now we can change to 2nd order
cat > $test_filter<<EOF
@ -174,4 +177,4 @@ grib_check_key_equals $temp1 packingType grid_simple
# Clean up
rm -f $temp_stat1 $temp_stat2
rm -f $temp1 $temp2 $temp3 $sec_ord_bmp
rm -f $test_filter
rm -f $test_filter $tempText