diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index ead88a487..880a47f37 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -22,6 +22,7 @@ if( HAVE_BUILD_TOOLS ) list( APPEND tests_extra grib_index codes_dump + codes_scan_file grib_copy_message bufr_copy_message grib_get_keys diff --git a/examples/F90/codes_scan_file.f90 b/examples/F90/codes_scan_file.f90 new file mode 100644 index 000000000..5136f126a --- /dev/null +++ b/examples/F90/codes_scan_file.f90 @@ -0,0 +1,35 @@ +! (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 codes_scan_file + use eccodes + implicit none + integer, parameter :: max_strsize = 200 + integer :: ifile, cnt, level, step + integer :: i, igrib + character(len=max_strsize) :: infile_name + + call getarg(1, infile_name) + + call codes_open_file(ifile, infile_name, 'r') + + call codes_any_scan_file(ifile,cnt) + + i = 45 + call codes_any_new_from_scanned_file(ifile,i,igrib) + call codes_get(igrib, 'level', level) + call codes_get(igrib, 'stepRange', step) + + print *, 'Num messages=', cnt + print *, 'Msg ',i,' level=',level, ' step=', step + + call codes_release(igrib) + call codes_close_file(ifile) + +end program diff --git a/examples/F90/codes_scan_file.sh b/examples/F90/codes_scan_file.sh new file mode 100755 index 000000000..80ca95bc3 --- /dev/null +++ b/examples/F90/codes_scan_file.sh @@ -0,0 +1,20 @@ +#!/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.ctest.sh + +temp='temp.eccodes_f_codes_scan_file.txt' + +input=../../data/index.grib +${examples_dir}/eccodes_f_codes_scan_file $input > $temp + +grep -q "Num messages= *384" $temp +grep -q "level= *700 step= *60" $temp + +rm -f $temp