mirror of https://github.com/ecmwf/eccodes.git
ECC-1018: charValues changed back to integers. Modified dump to cater for them
This commit is contained in:
parent
dfa667741f
commit
8cdb2cd94a
|
@ -29,9 +29,13 @@ if (numberOfIntegers) {
|
|||
signed[4] integerValues[numberOfIntegers] : dump;
|
||||
}
|
||||
|
||||
charList list(numberOfCharacters) {
|
||||
ascii[1] charValues : dump;
|
||||
# Have to use integers to represent single char strings
|
||||
if (numberOfCharacters) {
|
||||
unsigned[1] charValues[numberOfCharacters] : dump, string_type;
|
||||
}
|
||||
#charList list(numberOfCharacters) {
|
||||
# ascii[1] charValues : dump;
|
||||
#}
|
||||
|
||||
# Final padding
|
||||
section_padding padding;
|
||||
|
|
|
@ -404,6 +404,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
|
|||
double* buf = NULL;
|
||||
size_t size=0;
|
||||
long count=0;
|
||||
int is_char = 0;
|
||||
|
||||
if( a->length == 0 &&
|
||||
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0)
|
||||
|
@ -420,6 +421,11 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
|
|||
|
||||
set_begin_end(d,a);
|
||||
|
||||
/* For the DIAG pseudo GRIBs. Key charValues uses 1-byte integers to represent a character */
|
||||
if ( a->flags & GRIB_ACCESSOR_FLAG_STRING_TYPE ) {
|
||||
is_char = 1;
|
||||
}
|
||||
|
||||
/*for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");*/
|
||||
print_offset(self->dumper.out,self->begin,self->theEnd);
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0)
|
||||
|
@ -453,7 +459,6 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
|
|||
size = 100;
|
||||
}
|
||||
|
||||
|
||||
k = 0;
|
||||
while(k < size)
|
||||
{
|
||||
|
@ -462,14 +467,16 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
|
|||
/*for(i = 0; i < d->depth + 3 ; i++) fprintf(self->dumper.out," ");*/
|
||||
for(j = 0; j < 8 && k < size; j++, k++)
|
||||
{
|
||||
fprintf(self->dumper.out,"%.10e",buf[k]);
|
||||
if (is_char) fprintf(self->dumper.out,"'%c'",(char)buf[k]);
|
||||
else fprintf(self->dumper.out,"%.10e",buf[k]);
|
||||
if(k != size-1)
|
||||
fprintf(self->dumper.out,", ");
|
||||
}
|
||||
fprintf(self->dumper.out,"\n");
|
||||
#else
|
||||
|
||||
fprintf(self->dumper.out,"%d %g\n",k,buf[k]);
|
||||
if(is_char) fprintf(self->dumper.out,"%d '%c'\n",k,(char)buf[k]);
|
||||
else fprintf(self->dumper.out,"%d %g\n",k,buf[k]);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -70,10 +70,11 @@ cat > $tempRef <<EOF
|
|||
EOF
|
||||
diff $tempRef $tempTxt
|
||||
|
||||
# TODO encoding of characters not fully working. We are using one-byte integers instead
|
||||
#echo 'set numberOfCharacters=4; set charValues={"J","u","m","p"}; write;'| ${tools_dir}/grib_filter -o $tempOut - $sample
|
||||
#res=`${tools_dir}/grib_dump $tempOut | grep charValues | tr -d '\n' | tr -d ' '`
|
||||
#[ "$res" = "charValues=J;charValues=u;charValues=m;charValues=p;" ]
|
||||
|
||||
echo 'set numberOfCharacters=4; set charValues={"J","u","m","p"}; write;'| ${tools_dir}/grib_filter -o $tempOut - $sample
|
||||
res=`${tools_dir}/grib_dump $tempOut | grep charValues | tr -d '\n' | tr -d ' '`
|
||||
[ "$res" = "charValues=J;charValues=u;charValues=m;charValues=p;" ]
|
||||
|
||||
# Clean up
|
||||
rm -f $tempOut $tempRef
|
||||
|
|
Loading…
Reference in New Issue