ECC-597: grib_dump -D returns 'wrong size' errors on grid_second_order

This commit is contained in:
Shahram Najm 2017-12-12 14:46:32 +00:00
parent c84004b698
commit b1d73f721c
2 changed files with 44 additions and 9 deletions

View File

@ -129,8 +129,11 @@ static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_debug *self = (grib_dumper_debug*)d;
long value=0; size_t size = 1;
int err = grib_unpack_long(a,&value,&size);
int i;
long *values=NULL; /* array of long */
long count = 0;
int err = 0, i = 0;
grib_value_count(a,&count);size=count;
if( a->length == 0 &&
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0)
@ -140,21 +143,42 @@ static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
(d->option_flags & GRIB_DUMP_FLAG_READ_ONLY) == 0)
return;
if (size>1) {
values=(long*)grib_context_malloc_clear(a->context,sizeof(long)*size);
err=grib_unpack_long(a,values,&size);
} else {
err=grib_unpack_long(a,&value,&size);
}
set_begin_end(d,a);
for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");
if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a))
fprintf(self->dumper.out,"%ld-%ld %s %s = MISSING",self->begin,self->theEnd,a->creator->op, a->name);
else
fprintf(self->dumper.out,"%ld-%ld %s %s = %ld",self->begin,self->theEnd,a->creator->op, a->name,value);
if(comment) fprintf(self->dumper.out," [%s]",comment);
if (size>1) {
int cols=19;
int icount=0;
fprintf(self->dumper.out,"%ld-%ld %s %s = { \t",self->begin,self->theEnd,a->creator->op,a->name);
if (values) {
for (i=0;i<size;i++) {
if (icount>cols) {fprintf(self->dumper.out,"\n\t\t\t\t");icount=0;}
fprintf(self->dumper.out,"%ld ",values[i]);
icount++;
}
fprintf(self->dumper.out,"}\n");
grib_context_free(a->context,values);
}
} else {
if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a))
fprintf(self->dumper.out,"%ld-%ld %s %s = MISSING",self->begin,self->theEnd,a->creator->op, a->name);
else
fprintf(self->dumper.out,"%ld-%ld %s %s = %ld",self->begin,self->theEnd,a->creator->op, a->name,value);
if(comment) fprintf(self->dumper.out," [%s]",comment);
}
if(err)
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_debug::dump_long]",err,grib_get_error_message(err));
aliases(d,a);
fprintf(self->dumper.out,"\n");
}

View File

@ -9,6 +9,8 @@
#
. ./include.sh
label="grib_dump_debug"
temp=temp.$label.txt
REDIRECT=/dev/null
@ -68,6 +70,15 @@ v.grib2
for file in $files; do
if [ -f ${data_dir}/$file ]; then
${tools_dir}/grib_dump -Da ${data_dir}/$file 2> $REDIRECT > $REDIRECT
${tools_dir}/grib_dump -Da ${data_dir}/$file > $temp 2>&1
set +e
# Look for the word ERROR in output. We should not find any
grep -q 'ERROR ' $temp
if [ $? -eq 0 ]; then
echo "File $file: found string ERROR in grib_dump output!"
exit 1
fi
set -e
fi
done
rm -f $temp