2020-01-28 14:32:34 +00:00
|
|
|
! (C) Copyright 2005- ECMWF.
|
2013-03-25 12:04:10 +00:00
|
|
|
!
|
|
|
|
! 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.
|
2017-02-06 16:45:30 +00:00
|
|
|
!
|
2013-03-25 12:04:10 +00:00
|
|
|
! 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.
|
|
|
|
!
|
|
|
|
!
|
2020-12-17 15:07:13 +00:00
|
|
|
! Description: How to decode GRIB2 multi-field messages.
|
|
|
|
! Try to turn multi support on and off to
|
2013-03-25 12:04:10 +00:00
|
|
|
! see the difference. Default is OFF.
|
2023-08-17 12:50:33 +00:00
|
|
|
! For all the tools (e.g., grib_ls etc) multi support is ON.
|
2013-03-25 12:04:10 +00:00
|
|
|
!
|
|
|
|
program multi
|
2021-02-14 18:14:39 +00:00
|
|
|
use eccodes
|
|
|
|
implicit none
|
2017-02-06 16:45:30 +00:00
|
|
|
|
2023-12-19 19:04:04 +00:00
|
|
|
integer :: iret, counter=0
|
2023-08-17 12:50:33 +00:00
|
|
|
integer(kind=4) :: step
|
|
|
|
integer :: ifile, igrib
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2021-02-14 18:14:39 +00:00
|
|
|
call codes_open_file(ifile, '../../data/multi_created.grib2', 'r')
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2023-08-25 17:44:07 +00:00
|
|
|
! Turn off support for multi-field messages
|
|
|
|
call codes_grib_multi_support_off()
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2023-08-25 17:44:07 +00:00
|
|
|
! Turn on support for multi-field messages
|
|
|
|
call codes_grib_multi_support_on()
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2023-08-17 12:50:33 +00:00
|
|
|
! Loop on all the messages in a file
|
2021-02-14 18:14:39 +00:00
|
|
|
write (*, *) 'step'
|
2023-08-17 12:50:33 +00:00
|
|
|
do while (.true.)
|
|
|
|
call codes_grib_new_from_file(ifile, igrib, iret)
|
|
|
|
if (iret == CODES_END_OF_FILE) exit
|
2023-08-25 17:44:07 +00:00
|
|
|
counter = counter + 1
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2021-02-14 18:14:39 +00:00
|
|
|
call codes_get(igrib, 'step', step)
|
|
|
|
write (*, '(i3)') step
|
|
|
|
end do
|
|
|
|
call codes_close_file(ifile)
|
2023-08-25 17:44:07 +00:00
|
|
|
!write(*,*) 'Message count =', counter
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
end program multi
|