diff --git a/src/grib_dumper_class_debug.c b/src/grib_dumper_class_debug.c index e3754f61f..07d272877 100644 --- a/src/grib_dumper_class_debug.c +++ b/src/grib_dumper_class_debug.c @@ -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;icols) {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"); } diff --git a/tests/grib_dump_debug.sh b/tests/grib_dump_debug.sh index 24da96e12..a208e6fc3 100755 --- a/tests/grib_dump_debug.sh +++ b/tests/grib_dump_debug.sh @@ -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