mirror of https://github.com/ecmwf/eccodes.git
Fix failing tests: bufr_ls and bufr_read_header
This commit is contained in:
parent
bd423aa499
commit
8392a110e1
|
@ -401,9 +401,9 @@ set(bufr_refs_to_download
|
|||
tmr7_129.bufr.desc.ref
|
||||
tros_31.bufr.desc.ref
|
||||
wavb_134.bufr.desc.ref
|
||||
|
||||
aaen_55.bufr.ls.ref
|
||||
syno_multi.bufr.header.ref
|
||||
syno_multi.bufr
|
||||
)
|
||||
|
||||
foreach( f ${bufr_files_to_download} ${bufr_refs_to_download} )
|
||||
|
|
|
@ -493,6 +493,7 @@ files="
|
|||
bufr/syno_2.bufr
|
||||
bufr/syno_3.bufr
|
||||
bufr/syno_4.bufr
|
||||
bufr/syno_multi.bufr
|
||||
bufr/temp_101.bufr
|
||||
bufr/temp_102.bufr
|
||||
bufr/temp_106.bufr
|
||||
|
@ -764,6 +765,8 @@ files="
|
|||
bufr/tmr7_129.bufr.desc.ref
|
||||
bufr/tros_31.bufr.desc.ref
|
||||
bufr/wavb_134.bufr.desc.ref
|
||||
bufr/aaen_55.bufr.ls.ref
|
||||
bufr/syno_multi.bufr.header.ref
|
||||
"
|
||||
|
||||
[ -d "${DATA_DIR}/tigge" ] || mkdir "${DATA_DIR}/tigge"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
TESTS = definitions.sh calendar.sh \
|
||||
bufrdc_desc_ref.sh bufrdc_ref.sh bufr_dump.sh bufr_json.sh\
|
||||
bufrdc_desc_ref.sh bufrdc_ref.sh bufr_dump.sh bufr_json.sh bufr_read_header.sh bufr_ls.sh \
|
||||
ieee.sh grib1to2.sh \
|
||||
unit_tests.sh \
|
||||
grib2to1.sh badgrib.sh ls.sh filter.sh \
|
||||
|
@ -16,7 +16,7 @@ TESTS = definitions.sh calendar.sh \
|
|||
noinst_PROGRAMS = packing_check gauss_sub read_any double_cmp packing pack_unpack \
|
||||
multi_from_message julian read_index index gribex_perf\
|
||||
jpeg_perf ccsds_perf so_perf png_perf bpv_limit laplacian \
|
||||
unit_tests
|
||||
unit_tests bufr_read_header
|
||||
|
||||
multi_from_message_SOURCES = multi_from_message.c
|
||||
laplacian_SOURCES = laplacian.c
|
||||
|
@ -35,6 +35,7 @@ png_perf_SOURCES = png_perf.c
|
|||
ccsds_perf_SOURCES = ccsds_perf.c
|
||||
gribex_perf_SOURCES = gribex_perf.c
|
||||
gauss_sub_SOURCES = gauss_sub.c
|
||||
bufr_read_header_SOURCES = bufr_read_header.c
|
||||
|
||||
LDADD = $(top_builddir)/src/libgrib_api.la $(EMOS_LIB)
|
||||
|
||||
|
|
|
@ -10,19 +10,17 @@
|
|||
|
||||
. ./include.sh
|
||||
|
||||
set -x
|
||||
#set -x
|
||||
|
||||
#Remember work dir
|
||||
dWork=`pwd`
|
||||
|
||||
#Enter data dir
|
||||
cd ${data_dir}/bufr
|
||||
|
||||
fLog="log"
|
||||
rm -f $fLog | true
|
||||
fLog="bufr_ls.log"
|
||||
rm -f $fLog
|
||||
|
||||
fTmp="tmp.txt"
|
||||
rm -f $fTmp | true
|
||||
fTmp="tmp.bufr_ls.txt"
|
||||
rm -f $fTmp
|
||||
|
||||
#Create log filemore lev
|
||||
touch $fLog
|
||||
|
@ -30,16 +28,14 @@ touch $fLog
|
|||
#----------------------------------------------
|
||||
# Test default "ls" on all the bufr data files
|
||||
#----------------------------------------------
|
||||
|
||||
for f in `ls *.bufr` ; do
|
||||
echo $f >> log
|
||||
echo $f >> $fLog
|
||||
${tools_dir}/bufr_ls $f >> $fLog
|
||||
done
|
||||
|
||||
#-------------------------------------------
|
||||
# Test "-p" switch
|
||||
#-------------------------------------------
|
||||
|
||||
f="aaen_55.bufr"
|
||||
ref_ls=$f".ls.ref"
|
||||
res_ls=$f".ls.test"
|
||||
|
@ -47,11 +43,8 @@ REDIRECT=/dev/null
|
|||
|
||||
${tools_dir}/bufr_ls -p totalLength,centre,subCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,numberOfObservations $f 2> $REDIRECT > $fTmp
|
||||
|
||||
#Write the values into a file and compare to ref
|
||||
#Write the values into a file and compare with ref
|
||||
awk NR==3 $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_ls
|
||||
diff $ref_ls $res_ls >$REDIRECT 2> $REDIRECT
|
||||
[ $? -eq 0 ]
|
||||
|
||||
|
||||
#Go back to workdir
|
||||
cd $dWork
|
||||
rm -f $fLog $res_ls $fTmp
|
||||
|
|
|
@ -11,63 +11,58 @@
|
|||
#include "eccodes.h"
|
||||
|
||||
void usage(char* prog) {
|
||||
printf("usage: %s infile\n",prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc,char* argv[]) {
|
||||
|
||||
char* filename;
|
||||
FILE* f;
|
||||
codes_handle* h=NULL;
|
||||
long longVal;
|
||||
double doubleVal;
|
||||
int count;
|
||||
int err=0;
|
||||
int header_only=1;
|
||||
|
||||
if (argc!=2) usage(argv[0]);
|
||||
filename=argv[1];
|
||||
|
||||
f=fopen(filename,"r");
|
||||
if (!f) {
|
||||
perror(filename);
|
||||
printf("usage: %s infile\n",prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
count=1;
|
||||
|
||||
while((h=bufr_new_from_file(NULL,f,header_only,&err)) != NULL)
|
||||
{
|
||||
/* Check of errors after reading a message. */
|
||||
if (err != CODES_SUCCESS) CODES_CHECK(err,0);
|
||||
|
||||
printf("=======================================\n");
|
||||
printf("message no: %d\n",count);
|
||||
|
||||
/*From section 0 */
|
||||
CODES_CHECK(codes_get_long(h,"totalLength",&longVal),0);
|
||||
printf("\ttotalLength: %d\n",longVal);
|
||||
|
||||
/*From section 1 */
|
||||
CODES_CHECK(codes_get_long(h,"centre",&longVal),0);
|
||||
printf("\tcentre: %d\n",longVal);
|
||||
|
||||
/*From section 2 */
|
||||
CODES_CHECK(codes_get_long(h,"rdbtimeDay",&longVal),0);
|
||||
printf("\trdbtimeDay: %d\n",longVal);
|
||||
|
||||
/*From section 3 */
|
||||
/*CODES_CHECK(codes_get_long(h,"numberOfSubsets",&longVal),0);
|
||||
printf("\tnumberOfSubsets: %d\n",longVal);*/
|
||||
|
||||
count++;
|
||||
|
||||
codes_handle_delete(h);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
char* filename;
|
||||
FILE* f;
|
||||
codes_handle* h=NULL;
|
||||
long longVal;
|
||||
int count;
|
||||
int err=0;
|
||||
int header_only=1;
|
||||
|
||||
if (argc!=2) usage(argv[0]);
|
||||
filename=argv[1];
|
||||
|
||||
f=fopen(filename,"r");
|
||||
if (!f) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
count=1;
|
||||
while((h=bufr_new_from_file(NULL,f,header_only,&err)) != NULL)
|
||||
{
|
||||
/* Check for errors after reading a message. */
|
||||
if (err != CODES_SUCCESS) CODES_CHECK(err,0);
|
||||
|
||||
printf("=======================================\n");
|
||||
printf("message no: %d\n",count);
|
||||
|
||||
/*From section 0 */
|
||||
CODES_CHECK(codes_get_long(h,"totalLength",&longVal),0);
|
||||
printf("\ttotalLength: %ld\n",longVal);
|
||||
|
||||
/*From section 1 */
|
||||
CODES_CHECK(codes_get_long(h,"centre",&longVal),0);
|
||||
printf("\tcentre: %ld\n",longVal);
|
||||
|
||||
/*From section 2 */
|
||||
CODES_CHECK(codes_get_long(h,"rdbtimeDay",&longVal),0);
|
||||
printf("\trdbtimeDay: %ld\n",longVal);
|
||||
|
||||
/*From section 3 */
|
||||
/*CODES_CHECK(codes_get_long(h,"numberOfSubsets",&longVal),0);
|
||||
printf("\tnumberOfSubsets: %d\n",longVal);*/
|
||||
|
||||
count++;
|
||||
codes_handle_delete(h);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,20 +12,13 @@
|
|||
|
||||
set -x
|
||||
|
||||
#Remember work dir
|
||||
dWork=`pwd`
|
||||
|
||||
#Enter data dir
|
||||
cd ${data_dir}/bufr
|
||||
|
||||
fTmp="tmp.txt"
|
||||
rm -f $fTmp | true
|
||||
|
||||
#-----------------------------------------------------
|
||||
# Test reading the header only from a
|
||||
# Test reading the header only from a BUFR
|
||||
# file with multiple messages
|
||||
#----------------------------------------------------
|
||||
|
||||
f="syno_multi.bufr"
|
||||
fRef=$f".header.ref"
|
||||
fRes=$f".header.test"
|
||||
|
@ -33,9 +26,7 @@ REDIRECT=/dev/null
|
|||
|
||||
${test_dir}/bufr_read_header ${data_dir}/bufr/$f 2> $REDIRECT > $fRes
|
||||
|
||||
#Write the values into a file and compare to ref
|
||||
#Write the values into a file and compare with reference
|
||||
diff $fRef $fRes >$REDIRECT 2> $REDIRECT
|
||||
[ $? -eq 0 ]
|
||||
|
||||
#Go back to workdir
|
||||
cd $dWork
|
||||
rm -f $fRes
|
||||
|
|
Loading…
Reference in New Issue