mirror of https://github.com/ecmwf/eccodes.git
Testing: Element encoding for integers/doubles
This commit is contained in:
parent
87f5931bb8
commit
af10b60752
|
@ -90,6 +90,12 @@ int grib_accessor_element_t::pack_long(const long* val, size_t* len)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int atype = GRIB_TYPE_UNDEFINED;
|
||||||
|
if (grib_get_native_type(hand, array_, &atype) == GRIB_SUCCESS && atype == GRIB_TYPE_DOUBLE) {
|
||||||
|
const double dVal = *val;
|
||||||
|
return pack_double(&dVal, len);
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = grib_get_size(hand, array_, &size)) != GRIB_SUCCESS)
|
if ((ret = grib_get_size(hand, array_, &size)) != GRIB_SUCCESS)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -76,16 +76,21 @@ set -e
|
||||||
# Encode a single double element in an array
|
# Encode a single double element in an array
|
||||||
input=$data_dir/sample.grib2
|
input=$data_dir/sample.grib2
|
||||||
cat > $tempFilt <<EOF
|
cat > $tempFilt <<EOF
|
||||||
|
print "Before: [min=] [max=]";
|
||||||
|
transient avg1 = avg;
|
||||||
|
transient max1 = max;
|
||||||
meta elemN element(values, -1);
|
meta elemN element(values, -1);
|
||||||
assert( elemN < 301 );
|
assert( elemN < 301 );
|
||||||
print "before: [elemN:d]";
|
print "Last elem was: [elemN:d]";
|
||||||
set elemN = 311.0; # value has to be a double
|
set elemN = 312; # Pass in an integer. Should call pack_double
|
||||||
print "after: [elemN:d]";
|
print "Last elem now: [elemN:d]";
|
||||||
|
print "After: [min=] [max=]";
|
||||||
assert( elemN > 310 );
|
assert( elemN > 310 );
|
||||||
|
assert ( avg > avg1 );
|
||||||
|
assert ( max > max1 );
|
||||||
write;
|
write;
|
||||||
EOF
|
EOF
|
||||||
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input
|
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input
|
||||||
${tools_dir}/grib_get -p avg $input $tempGrib
|
|
||||||
|
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
|
|
Loading…
Reference in New Issue