Testing: Fortran codes_any_scan_file and codes_any_new_from_scanned_file

This commit is contained in:
Shahram Najm 2024-01-02 15:12:57 +00:00
parent efcef18676
commit e22bc13bf6
3 changed files with 56 additions and 0 deletions

View File

@ -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

View File

@ -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

20
examples/F90/codes_scan_file.sh Executable file
View File

@ -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