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