mirror of https://github.com/ecmwf/eccodes.git
Moved bufr_read_header to examples/C
This commit is contained in:
parent
e5585348ed
commit
63cbf82101
|
@ -1,68 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2005-2015 ECMWF.
|
|
||||||
*
|
|
||||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
||||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
||||||
*
|
|
||||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
|
||||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
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;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Copyright 2005-2015 ECMWF.
|
|
||||||
#
|
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
|
||||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
||||||
#
|
|
||||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
|
||||||
#
|
|
||||||
|
|
||||||
. ./include.sh
|
|
||||||
|
|
||||||
# set -x
|
|
||||||
|
|
||||||
#Enter data dir
|
|
||||||
cd ${data_dir}/bufr
|
|
||||||
|
|
||||||
#-----------------------------------------------------
|
|
||||||
# Test reading the header only from a BUFR
|
|
||||||
# file with multiple messages
|
|
||||||
#----------------------------------------------------
|
|
||||||
f="syno_multi.bufr"
|
|
||||||
fRef=$f".header.ref"
|
|
||||||
fRes=$f".header.test"
|
|
||||||
REDIRECT=/dev/null
|
|
||||||
|
|
||||||
${test_dir}/bufr_read_header ${data_dir}/bufr/$f 2> $REDIRECT > $fRes
|
|
||||||
|
|
||||||
#Write the values into a file and compare with reference
|
|
||||||
diff $fRef $fRes >$REDIRECT 2> $REDIRECT
|
|
||||||
|
|
||||||
rm -f $fRes
|
|
Loading…
Reference in New Issue