From 356dc20280d23571cea72bed753df5508b0cd464 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 1 Dec 2021 22:03:19 +0000 Subject: [PATCH] ECC-1316: added test --- examples/F90/CMakeLists.txt | 1 + examples/F90/grib_ecc-1316.f90 | 48 ++++++++++++++++++++++++++++++++ examples/F90/grib_ecc-1316.sh | 13 +++++++++ examples/F90/grib_set_packing.sh | 2 +- 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 examples/F90/grib_ecc-1316.f90 create mode 100755 examples/F90/grib_ecc-1316.sh diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index ecd3a3d1a..7119d771a 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -38,6 +38,7 @@ if( HAVE_BUILD_TOOLS ) grib_read_from_file grib_get_set_uuid grib_clone + grib_ecc-1316 bufr_attributes bufr_copy_data bufr_clone diff --git a/examples/F90/grib_ecc-1316.f90 b/examples/F90/grib_ecc-1316.f90 new file mode 100644 index 000000000..7efabf280 --- /dev/null +++ b/examples/F90/grib_ecc-1316.f90 @@ -0,0 +1,48 @@ +! (C) Copyright 2005- 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. +! +! +program grib_ecc_1316 + use eccodes + implicit none + + integer :: iret, ostep, olevel, onumber + character(len=80) :: parameterName + integer :: idx, igrib, count1 = 0 + + ! create an index from a grib file using some keys + call codes_index_create(idx, '../../data/tigge_cf_ecmwf.grib2', & + 'parameterName,number,level,step') + + call codes_index_select(idx, 'step', 96) + call codes_index_select(idx, 'level', 0) + call codes_index_select(idx, 'number', 0) + call codes_index_select(idx, 'parameterName', 'Soil moisture') + + call codes_new_from_index(idx, igrib, iret) + do while (iret /= CODES_END_OF_INDEX) + count1 = count1 + 1 + call codes_get(igrib, 'parameterName', parameterName) + call codes_get(igrib, 'number', onumber) + call codes_get(igrib, 'level', olevel) + call codes_get(igrib, 'step', ostep) + write (*, '(A,A,A,i3,A,i4,A,i3)') 'parameterName=', parameterName, & + ' number=', onumber, & + ' level=', olevel, & + ' step=', ostep + call codes_release(igrib) + call codes_new_from_index(idx, igrib, iret) + end do + call codes_release(igrib) + + write (*, '(i4,a)') count1, ' messages selected' + if (count1 /= 1) stop 1 + + call codes_index_release(idx) + +end program grib_ecc_1316 diff --git a/examples/F90/grib_ecc-1316.sh b/examples/F90/grib_ecc-1316.sh new file mode 100755 index 000000000..a8c3b3fdf --- /dev/null +++ b/examples/F90/grib_ecc-1316.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# (C) Copyright 2005- 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 + +exec ${examples_dir}/eccodes_f_grib_ecc-1316 diff --git a/examples/F90/grib_set_packing.sh b/examples/F90/grib_set_packing.sh index 0c32617ec..9ece9c13c 100755 --- a/examples/F90/grib_set_packing.sh +++ b/examples/F90/grib_set_packing.sh @@ -30,4 +30,4 @@ ${tools_dir}/grib_compare -c data:n $tempSimple $tempCCSDS ${tools_dir}/grib_compare -c data:n $tempSimple $tempSecond -rm -f $tempSimple $tempCCSDS +rm -f $tempSimple $tempCCSDS $tempSecond