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;
|
||||
}
|
||||
|
||||
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)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -76,16 +76,21 @@ set -e
|
|||
# Encode a single double element in an array
|
||||
input=$data_dir/sample.grib2
|
||||
cat > $tempFilt <<EOF
|
||||
print "Before: [min=] [max=]";
|
||||
transient avg1 = avg;
|
||||
transient max1 = max;
|
||||
meta elemN element(values, -1);
|
||||
assert( elemN < 301 );
|
||||
print "before: [elemN:d]";
|
||||
set elemN = 311.0; # value has to be a double
|
||||
print "after: [elemN:d]";
|
||||
print "Last elem was: [elemN:d]";
|
||||
set elemN = 312; # Pass in an integer. Should call pack_double
|
||||
print "Last elem now: [elemN:d]";
|
||||
print "After: [min=] [max=]";
|
||||
assert( elemN > 310 );
|
||||
assert ( avg > avg1 );
|
||||
assert ( max > max1 );
|
||||
write;
|
||||
EOF
|
||||
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input
|
||||
${tools_dir}/grib_get -p avg $input $tempGrib
|
||||
|
||||
|
||||
# Clean up
|
||||
|
|
Loading…
Reference in New Issue