2015-01-05 15:45:46 +00:00
|
|
|
! Copyright 2005-2015 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.
|
|
|
|
!
|
|
|
|
! 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.
|
|
|
|
!
|
|
|
|
!
|
|
|
|
! Description: How to decode grib messages containing multiple
|
|
|
|
! fields. Try to turn on and off multi support to
|
|
|
|
! see the difference. Default is OFF.
|
|
|
|
! For all the tools default is multi support ON.
|
|
|
|
!
|
|
|
|
!
|
|
|
|
program multi
|
2015-01-28 22:54:42 +00:00
|
|
|
use eccodes
|
2013-03-25 12:04:10 +00:00
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer :: iret
|
|
|
|
character(len = 256) :: error
|
|
|
|
integer(kind = 4) :: parameterCategory,parameterNumber,discipline
|
|
|
|
integer :: ifile,igrib
|
|
|
|
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_open_file(ifile, &
|
2013-03-25 12:04:10 +00:00
|
|
|
'../../data/multi.grib2','r')
|
|
|
|
|
|
|
|
! turn on support for multi fields messages */
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_multi_support_on()
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
! turn off support for multi fields messages */
|
2015-01-07 16:11:28 +00:00
|
|
|
! call codes_multi_support_off()
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_new_from_file(ifile,igrib)
|
2013-03-25 12:04:10 +00:00
|
|
|
! Loop on all the messages in a file.
|
|
|
|
|
|
|
|
do while (igrib .ne. -1)
|
|
|
|
|
|
|
|
! get as a integer*4
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_get(igrib,'discipline',discipline)
|
2013-03-25 12:04:10 +00:00
|
|
|
write(*,*) 'discipline=',discipline
|
|
|
|
|
|
|
|
! get as a integer*4
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_get(igrib,'parameterCategory', &
|
2013-03-25 12:04:10 +00:00
|
|
|
parameterCategory)
|
|
|
|
write(*,*) 'parameterCategory=',parameterCategory
|
|
|
|
|
|
|
|
! get as a integer*4
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_get(igrib,'parameterNumber', &
|
2013-03-25 12:04:10 +00:00
|
|
|
parameterNumber)
|
|
|
|
write(*,*) 'parameterNumber=',parameterNumber
|
|
|
|
|
|
|
|
if ( discipline .eq. 0 .and. parameterCategory .eq. 2) then
|
|
|
|
if (parameterNumber .eq. 2) then
|
|
|
|
write(*,*) "-------- u -------"
|
|
|
|
endif
|
|
|
|
if (parameterNumber .eq. 3) then
|
|
|
|
write(*,*) "-------- v -------"
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_release(igrib)
|
|
|
|
call codes_new_from_file(ifile,igrib, iret)
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
end do
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_close_file(ifile)
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
end program multi
|
|
|
|
|