Merge remote-tracking branch 'origin/develop' into feature/ECC-1766-EERIE

This commit is contained in:
Matthew Griffith 2024-03-11 17:37:15 +00:00
commit e5cff6ac48
26 changed files with 176 additions and 102 deletions

View File

@ -68,7 +68,7 @@ int main(int argc, char* argv[])
CODES_CHECK(codes_get_message(clone_handle, &buffer, &size), 0);
/* write the buffer to a file */
if (fwrite(buffer, 1, size, out) != size) {
perror(argv[1]);
perror(argv[2]);
return 1;
}
codes_handle_delete(clone_handle);

View File

@ -116,7 +116,7 @@ int main(int argc, char** argv)
/* write the buffer in a file*/
if (fwrite(buffer, 1, size, out) != size) {
perror(argv[1]);
perror(outfile);
exit(1);
}

View File

@ -78,7 +78,7 @@ int main(int argc, char** argv)
/* write the buffer in a file*/
if (fwrite(buffer, 1, size, out) != size) {
perror(argv[1]);
perror(outfile);
exit(1);
}

View File

@ -77,7 +77,7 @@ int main(int argc, char** argv)
/* write the buffer in a file*/
if (fwrite(buffer, 1, size, out) != size) {
perror(argv[1]);
perror(outfile);
exit(1);
}

View File

@ -78,7 +78,7 @@ int main(int argc, char** argv)
/* write the buffer in a file*/
if (fwrite(buffer, 1, size, out) != size) {
perror(argv[1]);
perror(outfile);
exit(1);
}

View File

@ -918,7 +918,6 @@ grib_handle* grib_fieldset_retrieve(grib_fieldset* set, int i, int* err);
/* grib_filepool.cc*/
void grib_file_pool_clean(void);
grib_file* grib_file_pool_get_files(void);
grib_file* grib_file_open(const char* filename, const char* mode, int* err);
void grib_file_pool_delete_file(grib_file* file);
void grib_file_close(const char* filename, int force, int* err);

View File

@ -106,22 +106,20 @@ grib_accessor_class* grib_accessor_class_bit = &_grib_accessor_class_bit;
static void init(grib_accessor* a, const long len, grib_arguments* arg)
{
grib_accessor_bit* self = (grib_accessor_bit*)a;
a->length = 0;
self->owner = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0);
self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1);
a->length = 0;
self->owner = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0);
self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_bit* self = (grib_accessor_bit*)a;
int ret = 0;
int ret = 0;
long data = 0;
if (*len < 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : unpack_long : Wrong size for %s it contains %d values ", a->name, 1);
*len = 0;
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit: unpack_long: Wrong size for %s, it contains %d values ", a->name, 1);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
@ -142,23 +140,22 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
grib_accessor_bit* self = (grib_accessor_bit*)a;
grib_accessor* owner = NULL;
unsigned char* mdata = 0;
if (*len < 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : pack_long : At least one value to pack for %s", a->name);
*len = 0;
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit: pack_long: At least one value to pack for %s", a->name);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
owner = grib_find_accessor(grib_handle_of_accessor(a), self->owner);
grib_accessor* owner = grib_find_accessor(grib_handle_of_accessor(a), self->owner);
if (!owner) {
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : Cannot get the owner %s for computing the bit value of %s ", self->owner, a->name);
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit: Cannot get the owner %s for computing the bit value of %s",
self->owner, a->name);
*len = 0;
return GRIB_NOT_FOUND;
}
mdata = grib_handle_of_accessor(a)->buffer->data;
unsigned char* mdata = grib_handle_of_accessor(a)->buffer->data;
mdata += grib_byte_offset(owner);
/* Note: In the definitions, flagbit numbers go from 7 to 0 (the bit_index), while WMO convention is from 1 to 8 */

View File

@ -161,8 +161,8 @@ static void compute_size(grib_accessor* a)
static void init(grib_accessor* a, const long len, grib_arguments* arg)
{
grib_accessor_bitmap* self = (grib_accessor_bitmap*)a;
grib_handle* hand = grib_handle_of_accessor(a);
int n = 0;
grib_handle* hand = grib_handle_of_accessor(a);
int n = 0;
self->tableReference = grib_arguments_get_name(hand, arg, n++);
self->missing_value = grib_arguments_get_name(hand, arg, n++);
@ -190,23 +190,21 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
long pos = a->offset * 8;
long tlen = 0;
long i = 0;
int err = 0;
long pos = a->offset * 8;
long tlen = 0;
const grib_handle* hand = grib_handle_of_accessor(a);
err = grib_value_count(a, &tlen);
int err = grib_value_count(a, &tlen);
if (err)
return err;
if (*len < tlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen);
*len = 0;
*len = tlen;
return GRIB_ARRAY_TOO_SMALL;
}
for (i = 0; i < tlen; i++) {
for (long i = 0; i < tlen; i++) {
val[i] = (long)grib_decode_unsigned_long(hand->buffer->data, &pos, 1);
}
*len = tlen;
@ -219,21 +217,19 @@ static int unpack(grib_accessor* a, T* val, size_t* len)
static_assert(std::is_floating_point<T>::value, "Requires floating points numbers");
long pos = a->offset * 8;
long tlen;
long i;
int err = 0;
grib_handle* hand = grib_handle_of_accessor(a);
err = grib_value_count(a, &tlen);
int err = grib_value_count(a, &tlen);
if (err)
return err;
if (*len < tlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen);
*len = 0;
*len = tlen;
return GRIB_ARRAY_TOO_SMALL;
}
for (i = 0; i < tlen; i++) {
for (long i = 0; i < tlen; i++) {
val[i] = (T)grib_decode_unsigned_long(hand->buffer->data, &pos, 1);
}
*len = tlen;
@ -261,8 +257,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
}
static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array)
{
size_t i = 0;
for (i=0; i<len; ++i) {
for (size_t i=0; i<len; ++i) {
unpack_double_element(a, index_array[i], val_array + i);
}
return GRIB_SUCCESS;
@ -280,7 +275,6 @@ static size_t string_length(grib_accessor* a)
static int unpack_string(grib_accessor* a, char* val, size_t* len)
{
long i = 0;
grib_handle* hand = grib_handle_of_accessor(a);
const size_t l = a->length;
@ -293,7 +287,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
return GRIB_BUFFER_TOO_SMALL;
}
for (i = 0; i < a->length; i++) {
for (long i = 0; i < a->length; i++) {
val[i] = hand->buffer->data[a->offset + i];
}

View File

@ -908,9 +908,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
}
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %ld values",
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values",
*len, a->name, rlen);
*len = 0;
*len = rlen;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -167,8 +167,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen);
*len = 0;
"Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen);
*len = rlen;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -16,7 +16,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
IMPLEMENTS = next_offset
IMPLEMENTS = value_count
IMPLEMENTS = byte_offset
@ -43,7 +43,6 @@ static int unpack_long(grib_accessor*, long* val, size_t* len);
static long byte_offset(grib_accessor*);
static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
static void update_size(grib_accessor*, size_t);
@ -68,7 +67,7 @@ static grib_accessor_class _grib_accessor_class_unexpanded_descriptors = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
&next_offset, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -122,11 +121,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = 0;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a;

View File

@ -16,7 +16,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
IMPLEMENTS = next_offset
IMPLEMENTS = byte_count
IMPLEMENTS = value_count
@ -45,7 +45,6 @@ static long byte_count(grib_accessor*);
static long byte_offset(grib_accessor*);
static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
static void update_size(grib_accessor*, size_t);
@ -70,7 +69,7 @@ static grib_accessor_class _grib_accessor_class_unsigned_bits = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
&next_offset, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -149,11 +148,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = compute_byte_count(a);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a;
@ -169,7 +163,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Wrong size (%ld) for %s, it contains %ld values", *len, a->name, rlen);
*len = 0;
*len = rlen;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -208,7 +208,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
const double dval = *val;
if (*len != 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains 1 value", a->name);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
@ -233,7 +233,7 @@ static int pack_float(grib_accessor* a, const float* val, size_t* len)
const double fval = *val;
if (*len != 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains 1 value", a->name);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
@ -252,7 +252,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
grib_accessor_variable* self = (grib_accessor_variable*)a;
if (*len != 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains 1 value", a->name);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -132,10 +132,10 @@ void grib_file_pool_clean()
// return grib_write_file(fh, file->next);
// }
grib_file* grib_file_pool_get_files()
{
return file_pool.first;
}
// grib_file* grib_file_pool_get_files()
// {
// return file_pool.first;
// }
// int grib_file_pool_read(grib_context* c, FILE* fh)
// {

View File

@ -1723,6 +1723,7 @@ static void set_value(grib_values* value, char* str, int equal)
}
break;
case GRIB_TYPE_LONG:
errno = 0; // must clear errno before calling strtol
value->long_value = strtol(buf, &p, 10);
if (*p != 0)
value->has_value = 1;
@ -1746,11 +1747,11 @@ static void set_value(grib_values* value, char* str, int equal)
}
break;
case GRIB_TYPE_UNDEFINED:
errno = 0; // must clear errno before calling strtol
value->long_value = strtol(buf, &p, 10);
if (*p == 0) {
// check the conversion from string to long
if ((errno == ERANGE && (value->long_value == LONG_MAX || value->long_value == LONG_MIN)) ||
(errno != 0 && value->long_value == 0)) {
if (errno == ERANGE && (value->long_value == LONG_MAX || value->long_value == LONG_MIN)) {
fprintf(stderr, "ECCODES WARNING : Setting %s=%s causes overflow/underflow\n", value->name, buf);
fprintf(stderr, "ECCODES WARNING : Value adjusted to %ld\n", value->long_value);
//perror("strtol");

View File

@ -20,10 +20,9 @@ int main(int argc, char** argv)
codes_handle* h = NULL;
long* ivalues = NULL;
const char* sampleName = "BUFR3_local";
char* outfilename = NULL;
assert(argc == 2);
outfilename = argv[1];
char* outfilename = argv[1];
// Test non-existent sample file. Should fail
h = codes_bufr_handle_new_from_samples(NULL, "some rubbish");
@ -33,10 +32,8 @@ int main(int argc, char** argv)
assert(h);
ivalues = (long*)malloc(1 * sizeof(long));
if (!ivalues) {
fprintf(stderr, "Failed to allocate memory (ivalues).\n");
return 1;
}
assert(ivalues);
size = 1;
ivalues[0] = 1;
CODES_CHECK(codes_set_long_array(h, "inputDelayedDescriptorReplicationFactor", ivalues, size), 0);
@ -89,10 +86,8 @@ int main(int argc, char** argv)
free(ivalues);
ivalues = (long*)malloc(9 * sizeof(long));
if (!ivalues) {
fprintf(stderr, "Failed to allocate memory (ivalues).\n");
return 1;
}
assert(ivalues);
size = 4;
ivalues[0] = 309052;
ivalues[1] = 5001;
@ -104,11 +99,8 @@ int main(int argc, char** argv)
CODES_CHECK(codes_set_long(h, "pack", 1), 0);
fout = fopen(outfilename, "wb");
if (!fout) {
fprintf(stderr, "Failed to open (create) output file.\n");
free(ivalues);
return 1;
}
assert(fout);
CODES_CHECK(codes_get_message(h, &buffer, &size), 0);
CODES_CHECK(codes_check_message_header(buffer, size, PRODUCT_BUFR), 0);
CODES_CHECK(codes_check_message_footer(buffer, size, PRODUCT_BUFR), 0);

View File

@ -199,4 +199,38 @@ status=$?
set -e
[ $status -ne 0 ]
echo "Test with nonexistent file..."
# ---------------------------------
set +e
$EXEC ${test_dir}/bufr_extract_headers centre nosuchfile > $temp1 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Unable to read file" $temp1
echo "Test with bad BUFR file..."
# ---------------------------------
echo BUFR > $temp1
set +e
$EXEC ${test_dir}/bufr_extract_headers centre $temp1 > $temp2 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Unable to count BUFR messages" $temp2
echo "Test with GRIB file..."
# ---------------------------------
input=${data_dir}/sample.grib2
set +e
$EXEC ${test_dir}/bufr_extract_headers centre $input > $temp2 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "No BUFR messages in file" $temp2
# Clean up
rm -f $temp1 $temp2

View File

@ -54,6 +54,8 @@ int main(int argc, char* argv[])
codes_compare_key(h1, h2, "computeStatistics", 0); // statistics
codes_compare_key(h1, h2, "paramId", 0); // concept
codes_compare_key(h1, h2, "identifier", 0); // ascii
err = codes_compare_key(h1, h2, "abcdefghij", 0); // no such key
Assert(err == GRIB_NOT_FOUND);
if (list_provided_keys) {
for (i = 0; list_provided_keys[i] != NULL; ++i) {

View File

@ -37,6 +37,7 @@ key: hoursAfterDataCutoff (Long values are different)
key: minutesAfterDataCutoff (Long values are different)
key: numberOfValues (Long values are different)
key: referenceValue (Double values are different)
ECCODES ERROR : Key abcdefghij not found in first message
Comparison failed: 13 differences
EOF
@ -57,6 +58,7 @@ cat $tempLog
cat > $tempRef <<EOF
key: referenceValue (Double values are different)
key: codedValues (Double values are different)
ECCODES ERROR : Key abcdefghij not found in first message
Comparison failed: 2 differences
EOF

View File

@ -195,6 +195,46 @@ grib_check_key_equals $temp isTemplateDeprecated,isTemplateExperimental '0 1'
$tools_dir/grib_set -s gridType=time_section $sample2 $temp
grib_check_key_equals $temp isTemplateDeprecated,isTemplateExperimental '0 1'
# Use of eps key (for local section)
# -----------------------------------
input=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
$tools_dir/grib_set -s stepType=accum,eps=1 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '11'
#17 Ensemble mean
#18 Ensemble standard deviation
$tools_dir/grib_set -s type=17,stepType=accum,eps=1 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber,derivedForecast '12 0'
$tools_dir/grib_set -s type=18,stepType=accum,eps=1 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber,derivedForecast '12 4'
# Chemicals
$tools_dir/grib_set -s paramId=217019,stepType=instant,eps=0 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '40'
$tools_dir/grib_set -s paramId=217019,stepType=instant,eps=1 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '41'
$tools_dir/grib_set -s paramId=217019,stepType=accum,eps=0 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '42'
$tools_dir/grib_set -s paramId=217019,stepType=accum,eps=1 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '43'
# Aerosol 210072
$tools_dir/grib_set -s paramId=210072,stepType=instant,eps=0 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '48'
$tools_dir/grib_set -s paramId=210072,stepType=instant,eps=1 $input $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '45'
#$tools_dir/grib_set -s paramId=210072,stepType=accum,eps=0 $input $temp
#grib_check_key_equals $temp productDefinitionTemplateNumber '42'
#$tools_dir/grib_set -s paramId=210072,stepType=accum,eps=1 $input $temp
#grib_check_key_equals $temp productDefinitionTemplateNumber '43'
# Clean up
rm -f $temp $temp1 $temp2 $tempFilt $tempText

View File

@ -34,28 +34,24 @@ static int check_error_code(int err)
int main(int argc, char** argv)
{
int err = 0, i;
int err = 0, i;
size_t values_len = 0;
double* values = NULL;
char error_msg[100];
const double tolerance = 1e-5;
size_t slong = sizeof(long) * 8;
grib_handle* h;
char* filename;
size_t slong = sizeof(long) * 8;
Assert(argc == 2);
filename = argv[1];
char* filename = argv[1];
for (i = 0; i < 255; i++) {
FILE* in = fopen(filename, "rb");
Assert(in);
h = grib_handle_new_from_file(0, in, &err);
grib_handle* h = grib_handle_new_from_file(0, in, &err);
Assert(h);
/* get the size of the values array*/
GRIB_CHECK(grib_get_size(h, "values", &values_len), 0);
values = (double*)malloc(values_len * sizeof(double));
double* values = (double*)malloc(values_len * sizeof(double));
err = grib_get_double_array(h, "values", values, &values_len);
if (compare_double_absolute(values[0], 2.7900000000e+02, tolerance) != 0)
@ -82,9 +78,8 @@ int main(int argc, char** argv)
/* do nothing */
}
else {
snprintf(error_msg, sizeof(error_msg), "Error decoding when bpv=%d. Error message:%s", i, grib_get_error_message(err));
perror(error_msg);
exit(1);
fprintf(stderr, "Error decoding when bpv=%d. Error message:%s\n", i, grib_get_error_message(err));
return 1;
}
values = (double*)malloc(values_len * sizeof(double));
@ -102,9 +97,8 @@ int main(int argc, char** argv)
/* do nothing */
}
else {
snprintf(error_msg, sizeof(error_msg), "Error decoding when bpv=%d. Error message:%s", i, grib_get_error_message(err));
perror(error_msg);
exit(1);
fprintf(stderr, "Error decoding when bpv=%d. Error message:%s\n", i, grib_get_error_message(err));
return 1;
}
free(values);

View File

@ -22,6 +22,11 @@ logfile=temp.$label.log
rm -f $outfile1 $outfile2
# Debug info
ECCODES_DEBUG=-1 ${tools_dir}/grib_copy -r $infile $outfile1 > $logfile 2>&1
grep -q "ECCODES DEBUG CCSDS .* aec_stream.flags" $logfile
# Convert a non-constant grib2 file (Note: not using -r)
grib2_sample=$ECCODES_SAMPLES_PATH/gg_sfc_grib2.tmpl
${tools_dir}/grib_set -s packingType=grid_ccsds $grib2_sample $outfile1

View File

@ -112,6 +112,8 @@ ${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample_grib2
grib_check_key_equals $tempGrib selectedFcIndex,step '1 4'
grib_check_key_equals $tempGrib mars.date,mars.time '20220607 300'
${tools_dir}/grib_dump -Dat $tempGrib > $tempOut
for pdtn in 88 92 93 94 95 96 97 98; do
${tools_dir}/grib_set -s \
tablesVersion=30,productDefinitionTemplateNumber=$pdtn,numberOfForecastsUsedInLocalTime=1 \

View File

@ -148,7 +148,9 @@ set -e
[ $status -ne 0 ]
grep -q "Wrong number of fields" $tempText
# Not regular grid
echo "Not a regular grid ..."
# --------------------------
input=${data_dir}/reduced_gaussian_pressure_level.grib2
set +e
${tools_dir}/grib_to_netcdf -o $tempNetcdf $input > $tempText 2>&1
@ -158,6 +160,17 @@ set -e
grep -q "not on a regular lat/lon grid or on a regular Gaussian grid" $tempText
# ECC-1783: No error message when input file has invalid fields
input=$data_dir/bad.grib
set +e
${tools_dir}/grib_to_netcdf -o $tempNetcdf $input > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Wrong message length" $tempText
# Validity time check
export GRIB_TO_NETCDF_CHECKVALIDTIME=0
${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib
[ -f "$tempNetcdf" ]

View File

@ -13,6 +13,9 @@
label="grib_unpack_subarray_test"
temp=${label}".grib.tmp"
infile=$data_dir/constant_field.grib2
$EXEC ${test_dir}/grib_unpack_subarray $infile
infile=$data_dir/sample.grib2
$EXEC ${test_dir}/grib_unpack_subarray $infile

View File

@ -4225,7 +4225,15 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
grib_handle_delete(h);
}
grib_file_close(file->name, 0, &e);
if (e != GRIB_SUCCESS) {
grib_context_log(ctx, GRIB_LOG_ERROR, "%s (message %d)", grib_get_error_message(e), i);
}
int e2 = 0;
grib_file_close(file->name, 0, &e2);
if (e2 != GRIB_SUCCESS) {
grib_context_log(ctx, GRIB_LOG_ERROR, "Failed to close file %s (%s)", file->name, grib_get_error_message(e2));
}
{
/* Now do some checks */