eccodes/examples/F90/multi_fortran.f90

67 lines
1.9 KiB
Fortran
Raw Normal View History

2017-01-03 11:03:48 +00:00
! Copyright 2005-2017 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
2013-03-25 12:04:10 +00:00
! 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
integer(kind = 4) :: parameterCategory,parameterNumber,discipline
integer :: ifile,igrib
call codes_open_file(ifile, '../../data/multi.grib2','r')
2013-03-25 12:04:10 +00:00
! turn on support for multi fields messages */
call codes_grib_multi_support_on()
2013-03-25 12:04:10 +00:00
! turn off support for multi fields messages */
!call codes_grib_multi_support_off()
2013-03-25 12:04:10 +00:00
2015-03-04 17:11:18 +00:00
call codes_grib_new_from_file(ifile,igrib)
! Loop on all the messages in a file.
2013-03-25 12:04:10 +00:00
do while (igrib .ne. -1)
! get as a integer*4
call codes_get(igrib,'discipline',discipline)
2013-03-25 12:04:10 +00:00
write(*,*) 'discipline=',discipline
! get as a integer*4
call codes_get(igrib,'parameterCategory', &
2013-03-25 12:04:10 +00:00
parameterCategory)
write(*,*) 'parameterCategory=',parameterCategory
! get as a integer*4
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
2013-03-25 12:04:10 +00:00
endif
call codes_release(igrib)
2015-03-04 17:11:18 +00:00
call codes_grib_new_from_file(ifile,igrib, iret)
2013-03-25 12:04:10 +00:00
end do
call codes_close_file(ifile)
2013-03-25 12:04:10 +00:00
end program multi