diff --git a/confluence/examples.par b/confluence/examples.par index 4ee11b0c4..029347fa3 100644 --- a/confluence/examples.par +++ b/confluence/examples.par @@ -1,6 +1,6 @@ #examples -GRIB ( +!GRIB ( grib_clone grib_ensemble_index grib_get_keys @@ -18,7 +18,7 @@ GRIB ( set_pv grib_set_keys ) -!BUFR ( +BUFR ( bufr_attributes bufr_clone bufr_expanded @@ -27,6 +27,7 @@ GRIB ( bufr_missing bufr_print_header bufr_print_data + bufr_read_temp bufr_set_keys bufr_subset ) diff --git a/examples/C/bufr_read_synop.c b/examples/C/bufr_read_synop.c index 8cebc954e..1cba1758a 100644 --- a/examples/C/bufr_read_synop.c +++ b/examples/C/bufr_read_synop.c @@ -15,6 +15,13 @@ * */ +/* + * Please note that SYNOP reports can be encoded in various ways in BUFR. Therefore the code + * below might not work directly for other types of SYNOP messages than the one used in the + * example. + */ + + #include "eccodes.h" void usage(char* prog) { @@ -55,20 +62,35 @@ int main(int argc,char* argv[]) /* we need to instruct ecCodes to unpack the data values */ CODES_CHECK(codes_set_long(h,"unpack",1),0); - /* read and print some data values. This example was written for a SYNOP - BUFR file!! */ - + /* station id*/ CODES_CHECK(codes_get_long(h,"blockNumber",&longVal),0); printf(" blockNumber: %ld\n",longVal); CODES_CHECK(codes_get_long(h,"stationNumber",&longVal),0); printf(" stationNumber: %ld\n",longVal); - /* in the current BUFR message this key represents the 2m temperature. - it might not be available in other type of SYNOP messages */ + /* location*/ + CODES_CHECK(codes_get_double(h,"latitude",&doubleVal),0); + printf(" latitude: %f\n",doubleVal); + + CODES_CHECK(codes_get_double(h,"longitude",&doubleVal),0); + printf(" longitude: %f\n",doubleVal); + + /* 2m temperature */ CODES_CHECK(codes_get_double(h,"airTemperatureAt2M",&doubleVal),0); printf(" airTemperatureAt2M %f\n",doubleVal); + /* 2m dewpoint temperature */ + CODES_CHECK(codes_get_double(h,"dewpointTemperatureAt2M",&doubleVal),0); + printf(" dewpointTemperatureAt2M %f\n",doubleVal); + + /* 10 wind */ + CODES_CHECK(codes_get_double(h,"windSpeedAt10M",&doubleVal),0); + printf(" windSpeedAt10M %f\n",doubleVal); + + CODES_CHECK(codes_get_double(h,"windDirectionAt10M",&doubleVal),0); + printf(" windDirectionAt10M %f\n",doubleVal); + /* delete handle */ codes_handle_delete(h); diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index 10ec0b3c2..b9d3e8456 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -34,8 +34,8 @@ list( APPEND tests bufr_expanded bufr_get_keys bufr_keys_iterator - bufr_print_header - bufr_print_data + bufr_read_header + bufr_read_synop bufr_read_temp bufr_set_keys bufr_subset diff --git a/examples/F90/Makefile.am b/examples/F90/Makefile.am index c820f40de..f1564ce13 100644 --- a/examples/F90/Makefile.am +++ b/examples/F90/Makefile.am @@ -5,15 +5,15 @@ TESTS = copy_message.sh grib_get_keys.sh get_data.sh get_pl.sh get_pv.sh grib_ke grib_nearest.sh precision.sh multi_write.sh multi.sh grib_print_data.sh grib_set_keys.sh \ grib_set_bitmap.sh set_missing.sh set_pv.sh samples.sh count_messages.sh read_message.sh \ read_from_file.sh index.sh get_set_uuid.sh bufr_attributes.sh bufr_clone.sh \ - bufr_expanded.sh bufr_get_keys.sh bufr_print_header.sh bufr_print_data.sh \ + bufr_expanded.sh bufr_get_keys.sh bufr_read_header.sh bufr_read_synop.sh \ bufr_set_keys.sh bufr_keys_iterator.sh bufr_subset.sh get_product_kind.sh bufr_read_temp.sh noinst_PROGRAMS = f_index f_copy_message f_grib_get_keys f_get_data f_get_pl f_get_pv f_grib_keys_iterator \ f_multi_write f_multi f_grib_nearest f_precision f_grib_print_data f_grib_set_keys \ f_grib_set_bitmap f_set_missing f_set_pv f_samples f_count_messages f_read_message \ f_read_from_file f_new_from_file f_copy_namespace f_get_set_uuid f_set_gvc \ - f_grib_clone f_bufr_clone f_bufr_expanded f_bufr_get_keys f_bufr_print_header \ - f_bufr_print_data f_bufr_set_keys f_bufr_keys_iterator f_bufr_subset f_bufr_attributes \ + f_grib_clone f_bufr_clone f_bufr_expanded f_bufr_get_keys f_bufr_read_header \ + f_bufr_read_synop f_bufr_set_keys f_bufr_keys_iterator f_bufr_subset f_bufr_attributes \ f_get_product_kind f_bufr_read_temp f_index_SOURCES=index.f90 @@ -46,8 +46,8 @@ f_bufr_clone_SOURCES=bufr_clone.f90 f_bufr_expanded_SOURCES=bufr_expanded.f90 f_bufr_get_keys_SOURCES=bufr_get_keys.f90 f_bufr_keys_iterator_SOURCES=bufr_keys_iterator.f90 -f_bufr_print_header_SOURCES=bufr_print_header.f90 -f_bufr_print_data_SOURCES=bufr_print_data.f90 +f_bufr_read_header_SOURCES=bufr_read_header.f90 +f_bufr_read_synop_SOURCES=bufr_read_synop.f90 f_bufr_read_temp_SOURCES=bufr_read_temp.f90 f_bufr_set_keys_SOURCES=bufr_set_keys.f90 f_bufr_subset_SOURCES=bufr_subset.f90 diff --git a/examples/F90/bufr_print_header.f90 b/examples/F90/bufr_read_header.f90 similarity index 97% rename from examples/F90/bufr_print_header.f90 rename to examples/F90/bufr_read_header.f90 index 325c73917..f3fcbf5e2 100644 --- a/examples/F90/bufr_print_header.f90 +++ b/examples/F90/bufr_read_header.f90 @@ -13,7 +13,7 @@ ! Description: how to read the header of BUFR messages. ! ! -program bufr_print_header +program bufr_read_header use eccodes implicit none integer :: ifile @@ -74,4 +74,4 @@ integer(kind=4) :: numberofsubsets call codes_close_file(ifile) -end program bufr_print_header +end program bufr_read_header diff --git a/examples/F90/bufr_print_header.sh b/examples/F90/bufr_read_header.sh similarity index 91% rename from examples/F90/bufr_print_header.sh rename to examples/F90/bufr_read_header.sh index 47db78e82..b539011a3 100755 --- a/examples/F90/bufr_print_header.sh +++ b/examples/F90/bufr_read_header.sh @@ -10,7 +10,7 @@ . ./include.sh #Define a common label for all the tmp files -label="bufr_print_header_test_f" +label="bufr_read_header_test_f" #Prepare tmp file fTmp=${label}.tmp.txt @@ -27,7 +27,7 @@ fRef=${f}.header.ref REDIRECT=/dev/null #Write the values into a file and compare with reference -${examples_dir}/f_bufr_print_header $f 2> $REDIRECT > $fTmp +${examples_dir}/f_bufr_read_header $f 2> $REDIRECT > $fTmp #We compare output to the reference by ignoring the whitespaces diff -w $fRef $fTmp >$REDIRECT 2> $REDIRECT diff --git a/examples/F90/bufr_print_data.f90 b/examples/F90/bufr_read_synop.f90 similarity index 57% rename from examples/F90/bufr_print_data.f90 rename to examples/F90/bufr_read_synop.f90 index 00c2e788f..330dbacc4 100644 --- a/examples/F90/bufr_print_data.f90 +++ b/examples/F90/bufr_read_synop.f90 @@ -8,12 +8,18 @@ ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. ! ! -! FOTRAN 90 Implementation: bufr_print_data +! FOTRAN 90 Implementation: bufr_read_synop ! -! Description: how to read data values from BUFR messages. +! Description: how to read SYNOP BUFR messages. + +! Please note that SYNOP reports can be encoded in various ways in BUFR. Therefore the code +! below might not work directly for other types of SYNOP messages than the one used in the +! example. + + ! ! -program bufr_print_data +program bufr_read_synop use eccodes implicit none integer :: ifile @@ -21,7 +27,7 @@ integer :: iret integer :: ibufr integer :: count=0 integer(kind=4) :: blockNumber,stationNumber -real(kind=8) :: t2m +real(kind=8) :: lat,lon,t2m,td2m,ws,wdir call codes_open_file(ifile,'../../data/bufr/syno_multi.bufr','r') @@ -35,24 +41,42 @@ real(kind=8) :: t2m ! we need to instruct ecCodes to expand all the descriptors ! i.e. unpack the data values - call codes_set(ibufr,"unpack",1); + call codes_set(ibufr,"unpack",1) !read and print some data values. This example was written ! for a SYNOP BUFR file! - ! get wmo block number - call codes_get(ibufr,'blockNumber',blockNumber); + ! wmo block number + call codes_get(ibufr,'blockNumber',blockNumber) write(*,*) ' blockNumber:',blockNumber - ! get station number - call codes_get(ibufr,'stationNumber',stationNumber); + ! station number + call codes_get(ibufr,'stationNumber',stationNumber) write(*,*) ' stationNumber:',stationNumber - ! in the current BUFR message this key represents the 2m temperature. - ! it might not be available in other type of SYNOP messages + ! location + call codes_get(ibufr,'latitude',lat) + write(*,*) ' latitude:',lat + + call codes_get(ibufr,'longitude',lat) + write(*,*) ' longitude:',lat + + ! 2m temperature call codes_get(ibufr,'airTemperatureAt2M',t2m); write(*,*) ' airTemperatureAt2M:',t2m + ! 2m dewpoint temperature + call codes_get(ibufr,'dewpointTemperatureAt2M',td2m); + write(*,*) ' dewpointTemperatureAt2M:',td2m + + ! 10m wind + call codes_get(ibufr,'windSpeedAt10M',ws); + write(*,*) ' windSpeedAt10M:',ws + + call codes_get(ibufr,'windDirectionAt10M',wdir); + write(*,*) ' windDirectionAt10M',wdir + + ! release the bufr message call codes_release(ibufr) @@ -67,4 +91,5 @@ real(kind=8) :: t2m call codes_close_file(ifile) -end program bufr_print_data +end program bufr_read_synop + diff --git a/examples/F90/bufr_print_data.sh b/examples/F90/bufr_read_synop.sh similarity index 89% rename from examples/F90/bufr_print_data.sh rename to examples/F90/bufr_read_synop.sh index 387244faa..68cbcc322 100755 --- a/examples/F90/bufr_print_data.sh +++ b/examples/F90/bufr_read_synop.sh @@ -12,7 +12,7 @@ #Define a common label for all the tmp files -label="bufr_print_data_test_f" +label="bufr_read_synop_test_f" #Define tmp file fTmp=${label}".tmp.txt" @@ -24,7 +24,7 @@ rm -f $fTmp | true REDIRECT=/dev/null #Write the values into a file and compare with reference -${examples_dir}/f_bufr_print_data 2> $REDIRECT > $fTmp +${examples_dir}/f_bufr_read_synop #2> $REDIRECT > $fTmp #TODO: check the output diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index d10ad3d35..9075830b6 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -44,8 +44,8 @@ list( APPEND tests bufr_expanded bufr_get_keys bufr_keys_iterator - bufr_print_header - bufr_print_data + bufr_read_header + bufr_read_synop bufr_read_temp bufr_set_keys bufr_subset diff --git a/examples/python/Makefile.am b/examples/python/Makefile.am index 2d6cd781b..340da7c80 100644 --- a/examples/python/Makefile.am +++ b/examples/python/Makefile.am @@ -4,7 +4,7 @@ AM_CFLAGS = @WARN_PEDANTIC@ @WERROR@ TESTS = grib_clone.sh count_messages.sh grib_get_keys.sh index.sh grib_iterator.sh \ grib_keys_iterator.sh multi_write.sh grib_nearest.sh grib_print_data.sh \ samples.sh grib_set_keys.sh set_missing.sh binary_message.sh grib_set_bitmap.sh \ - bufr_print_header.sh bufr_print_data.sh bufr_clone.sh bufr_get_keys.sh \ + bufr_read_header.sh bufr_read_synop.sh bufr_clone.sh bufr_get_keys.sh \ bufr_set_keys.sh bufr_expanded.sh bufr_keys_iterator.sh bufr_subset.sh \ bufr_attributes.sh get_product_kind.sh bufr_read_temp.sh TESTS_ENVIRONMENT = TOPBUILDDIR=$(top_builddir) PYTHON=$(PYTHON) @@ -18,11 +18,12 @@ INCLUDES = -I$(top_builddir)/src LDADD = $(top_builddir)/src/libeccodes.la DEPENDENCIES = $(LDADD) +<<<<<<< HEAD EXTRA_DIST = $(TESTS) include.sh grib_clone.py count_messages.py grib_get_keys.py index.py \ grib_iterator.py grib_keys_iterator.py multi_write.py \ grib_nearest.py grib_print_data.py samples.py grib_set_keys.py \ set_missing.py binary_message.py set_pv.py grib_set_bitmap.py \ - bufr_print_header.py bufr_print_data.py \ + bufr_read_header.py bufr_read_synop.py \ bufr_clone.py bufr_get_keys.py bufr_set_keys.py \ bufr_expanded.py bufr_keys_iterator.py bufr_subset.py bufr_attributes.py \ get_product_kind.py bufr_read_temp.py \ diff --git a/examples/python/bufr_print_header.py b/examples/python/bufr_read_header.py similarity index 97% rename from examples/python/bufr_print_header.py rename to examples/python/bufr_read_header.py index 44b4177fc..459560cb4 100644 --- a/examples/python/bufr_print_header.py +++ b/examples/python/bufr_read_header.py @@ -8,7 +8,7 @@ # -# Python implementation: bufr_print_header +# Python implementation: bufr_read_header # # Description: how to read the header from BUFR messages. # diff --git a/examples/python/bufr_print_header.sh b/examples/python/bufr_read_header.sh similarity index 90% rename from examples/python/bufr_print_header.sh rename to examples/python/bufr_read_header.sh index 1b0ceec0b..5f711993d 100755 --- a/examples/python/bufr_print_header.sh +++ b/examples/python/bufr_read_header.sh @@ -14,12 +14,12 @@ fRes=$f".header.test.p" REDIRECT=/dev/null #Write the values into a file and compare with reference -$PYTHON bufr_print_header.py 2> $REDIRECT > $fRes +$PYTHON bufr_read_header.py 2> $REDIRECT > $fRes #We compare output to the reference by ignoring the whitespaces diff -w $fRef $fRes >$REDIRECT 2> $REDIRECT -#cat $fRes +cat $fRes #Clean up rm -f $fRes diff --git a/examples/python/bufr_print_data.py b/examples/python/bufr_read_synop.py similarity index 82% rename from examples/python/bufr_print_data.py rename to examples/python/bufr_read_synop.py index 6ea5a3695..99f7300e4 100644 --- a/examples/python/bufr_print_data.py +++ b/examples/python/bufr_read_synop.py @@ -7,10 +7,15 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # -# Python implementation: bufr_print_data +# Python implementation: bufr_read_synop # # Description: how to read data values from BUFR messages. # + +# +# Please note that SYNOP reports can be encoded in various ways in BUFR. Therefore the code +# below might not work directly for other types of SYNOP messages than the one used in the +# example. # import traceback @@ -30,7 +35,12 @@ def example(): keys = [ 'blockNumber', 'stationNumber', + 'latitude', + 'longitude', 'airTemperatureAt2M', + 'dewpointTemperatureAt2M', + 'windSpeedAt10M', + 'windDirectionAt10M' ] cnt=0 diff --git a/examples/python/bufr_print_data.sh b/examples/python/bufr_read_synop.sh similarity index 90% rename from examples/python/bufr_print_data.sh rename to examples/python/bufr_read_synop.sh index e6de281c4..92744750f 100755 --- a/examples/python/bufr_print_data.sh +++ b/examples/python/bufr_read_synop.sh @@ -12,7 +12,7 @@ #Define a common label for all the tmp files -label="bufr_print_data_test_p" +label="bufr_read_synop_test_p" #Define tmp file fTmp=${label}".tmp.txt" @@ -24,7 +24,7 @@ rm -f $fTmp | true REDIRECT=/dev/null #Write the values into a file and compare with reference -$PYTHON bufr_print_data.py 2> $REDIRECT > $fTmp +$PYTHON bufr_read_synop.py #2> $REDIRECT > $fTmp #TODO: check the output diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 92f6cc583..347be8224 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -42,6 +42,7 @@ list( APPEND tests2 bufr_filter bufr_json bufr_ls + gts_ls bufr_set ieee grib1to2 diff --git a/tests/Makefile.am b/tests/Makefile.am index 6b29a169b..e3c6b3dba 100755 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,7 @@ TESTS = definitions.sh calendar.sh \ bufrdc_desc_ref.sh bufrdc_ref.sh bufr_dump.sh bufr_filter.sh \ bufr_json.sh bufr_compare.sh bufr_copy.sh bufr_count.sh bufr_get.sh bufr_ls.sh bufr_set.sh \ + gts_ls.sh \ ieee.sh grib1to2.sh \ unit_tests.sh \ grib2to1.sh badgrib.sh ls.sh filter.sh \ diff --git a/tests/gts_ls.sh b/tests/gts_ls.sh new file mode 100755 index 000000000..b4a8ad0a5 --- /dev/null +++ b/tests/gts_ls.sh @@ -0,0 +1,48 @@ +#!/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 + +#Enter data dir +cd ${data_dir}/gts + +#Define a common label for all the tmp files +label="gts_ls_test" + +#Create log file +fLog=${label}".log" +rm -f $fLog +touch $fLog + +#Define tmp file +fTmp=${label}".tmp.txt" +rm -f $fTmp + +#---------------------------------------------- +# Test default "ls" on all the gts data files +#---------------------------------------------- +gts_file=EGRR20150317121020_00493212.DAT +f=$gts_file + +echo $f >> $fLog +${tools_dir}/gts_ls $f >> $fLog + +#------------------------------------------- +# Test "-p" switch +#------------------------------------------- +ref_ls=$f".ls.ref" +res_ls=$f".ls.test" +REDIRECT=/dev/null + +${tools_dir}/gts_ls -p TT,AA,II,CCCC,YY,GG,gg,BBB $f 2> $REDIRECT > $res_ls + +diff $ref_ls $res_ls >$REDIRECT 2> $REDIRECT + +rm -f $fLog $res_ls