mirror of https://github.com/ecmwf/eccodes.git
Merge branch 'hotfix/ECC-1602-performance-optim-ccsds' of github.com:ecmwf/eccodes into hotfix/ECC-1602-performance-optim-ccsds
This commit is contained in:
commit
b8a9504e7f
|
@ -201,6 +201,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
|
||||
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
const char* cclass_name = a->cclass->name;
|
||||
int err = GRIB_SUCCESS;
|
||||
size_t buflen = 0, i = 0;
|
||||
bool is_constant_field = false;
|
||||
|
@ -278,7 +279,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
#endif
|
||||
if (grib_get_nearest_smaller_value(hand, self->reference_value, val[0], &reference_value) != GRIB_SUCCESS) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR,
|
||||
"data_ccsds_packing %s: unable to find nearest_smaller_value of %g for %s", __func__, min, self->reference_value);
|
||||
"%s %s: unable to find nearest_smaller_value of %g for %s", cclass_name, __func__, min, self->reference_value);
|
||||
return GRIB_INTERNAL_ERROR;
|
||||
}
|
||||
if ((err = grib_set_double_internal(hand, self->reference_value, reference_value)) != GRIB_SUCCESS)
|
||||
|
@ -305,13 +306,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
|
||||
if (grib_get_nearest_smaller_value(hand, self->reference_value, min, &reference_value) != GRIB_SUCCESS) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR,
|
||||
"data_ccsds_packing %s: unable to find nearest_smaller_value of %g for %s", __func__, min, self->reference_value);
|
||||
"%s %s: unable to find nearest_smaller_value of %g for %s", cclass_name, __func__, min, self->reference_value);
|
||||
return GRIB_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (reference_value > min) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR,
|
||||
"data_ccsds_packing %s: reference_value=%g min_value=%g diff=%g", __func__, reference_value, min, reference_value - min);
|
||||
"%s %s: reference_value=%g min_value=%g diff=%g", cclass_name, __func__, reference_value, min, reference_value - min);
|
||||
DebugAssert(reference_value <= min);
|
||||
return GRIB_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -350,7 +351,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
|
||||
if (grib_get_nearest_smaller_value(hand, self->reference_value, min, &reference_value) != GRIB_SUCCESS) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR,
|
||||
"data_ccsds_packing %s: unable to find nearest_smaller_value of %g for %s", __func__, min, self->reference_value);
|
||||
"%s %s: unable to find nearest_smaller_value of %g for %s", cclass_name, __func__, min, self->reference_value);
|
||||
return GRIB_INTERNAL_ERROR;
|
||||
}
|
||||
d = grib_power(decimal_scale_factor, 10);
|
||||
|
@ -406,12 +407,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
grib_context_log(a->context, GRIB_LOG_DEBUG,"data_ccsds_packing pack_double: packing %s, bits_per_value %d (max 32)", a->name, bits_per_value);
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR,"%s pack_double: packing %s, bits_per_value=%ld (max 32)",
|
||||
cclass_name, a->name, bits_per_value);
|
||||
err = GRIB_INVALID_BPV;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
grib_context_log(a->context, GRIB_LOG_DEBUG,"data_ccsds_packing pack_double: packing %s, %d values", a->name, n_vals);
|
||||
grib_context_log(a->context, GRIB_LOG_DEBUG,"%s pack_double: packing %s, %zu values", cclass_name, a->name, n_vals);
|
||||
|
||||
// ECC-1431: GRIB2: CCSDS encoding failure AEC_STREAM_ERROR
|
||||
buflen = (nbytes * n_vals) * 67 / 64 + 256;
|
||||
|
@ -429,8 +431,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
double ref = 1e-100;
|
||||
grib_get_double_internal(hand, self->reference_value, &ref);
|
||||
if (ref != reference_value) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "data_ccsds_packing %s: %s (ref=%.10e != reference_value=%.10e)",
|
||||
__func__, self->reference_value, ref, reference_value);
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: %s (ref=%.10e != reference_value=%.10e)",
|
||||
cclass_name, __func__, self->reference_value, ref, reference_value);
|
||||
return GRIB_INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -458,8 +460,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
if (hand->context->debug) print_aec_stream_info(&strm, "pack_double");
|
||||
|
||||
if ((err = aec_buffer_encode(&strm)) != AEC_OK) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "data_ccsds_packing %s: aec_buffer_encode error %d (%s)",
|
||||
__func__, err, aec_get_error_message(err));
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_encode error %d (%s)",
|
||||
cclass_name, __func__, err, aec_get_error_message(err));
|
||||
err = GRIB_ENCODING_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -502,7 +504,8 @@ static int unpack(grib_accessor* a, T* val, size_t* len)
|
|||
{
|
||||
static_assert(std::is_floating_point<T>::value, "Requires floating point numbers");
|
||||
grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
const char* cclass_name = a->cclass->name;
|
||||
|
||||
int err = GRIB_SUCCESS, i = 0;
|
||||
size_t buflen = 0;
|
||||
|
@ -595,8 +598,8 @@ static int unpack(grib_accessor* a, T* val, size_t* len)
|
|||
if (hand->context->debug) print_aec_stream_info(&strm, "unpack_*");
|
||||
|
||||
if ((err = aec_buffer_decode(&strm)) != AEC_OK) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "CCSDS %s: aec_buffer_decode error %d (%s)",
|
||||
__func__, err, aec_get_error_message(err));
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_decode error %d (%s)",
|
||||
cclass_name, __func__, err, aec_get_error_message(err));
|
||||
err = GRIB_DECODING_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -622,7 +625,8 @@ static int unpack(grib_accessor* a, T* val, size_t* len)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
grib_context_log(a->context, GRIB_LOG_DEBUG,"data_ccsds_packing %s: packing %s, bits_per_value %d (max 32)", __func__, a->name, bits_per_value);
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%d (max 32)",
|
||||
cclass_name, __func__, a->name, bits_per_value);
|
||||
err = GRIB_INVALID_BPV;
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ BLACKLIST="totalLength,section5Length,section7Length,dataRepresentationTemplateN
|
|||
infile=${data_dir}/ccsds.grib2
|
||||
outfile1=temp.$label.1
|
||||
outfile2=temp.$label.2
|
||||
logfile=temp.$label.log
|
||||
|
||||
rm -f $outfile1 $outfile2
|
||||
|
||||
|
@ -166,6 +167,15 @@ for sample in $ifs_samples; do
|
|||
done
|
||||
done
|
||||
|
||||
# Invalid bitsPerValue (>32)
|
||||
# --------------------------
|
||||
input=${data_dir}/ccsds.grib2
|
||||
set +e
|
||||
${tools_dir}/grib_set -s setBitsPerValue=33 $input $outfile2 2> $logfile
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Invalid number of bits per value" $logfile
|
||||
|
||||
# ECC-1362
|
||||
# ---------
|
||||
|
@ -183,4 +193,4 @@ if [ $HAVE_JPEG -eq 1 ]; then
|
|||
fi
|
||||
|
||||
# Clean up
|
||||
rm -f $outfile1 $outfile2
|
||||
rm -f $outfile1 $outfile2 $logfile
|
||||
|
|
Loading…
Reference in New Issue