multi_fortran.F

multi_fortran.F How to decode a grib message containing many fields.

C Copyright 2005-2007 ECMWF
C 
C Licensed under the GNU Lesser General Public License which
C incorporates the terms and conditions of version 3 of the GNU
C General Public License.
C See LICENSE and gpl-3.0.txt for details.
C
C
C  Fortran 77 Implementation: multi_fortran
C
C  Description: How to decode grib messages containing multiple
C               fields. Try to turn on and off multi support to
C               see the difference. Default is OFF.
C         For all the tools defalut is multi support ON.
C
C
C  Author: Enrico Fucile <enrico.fucile@ecmwf.int>
C
C
C
      program multi
      implicit none
      include 'grib_api_f77.h'
      integer iret
      character*256 error
      integer*4 parameterCategory,parameterNumber,discipline
      integer ifile,igrib

      call grib_check( grib_open_file(ifile
     X,'../../data/multi.grib2','r'))

C     turn on support for multi fields messages */
      call grib_check(grib_multi_support_on())

C     turn off support for multi fields messages */
C     call grib_check(grib_multi_support_off())

C     Loop on all the messages in a file.
  10  iret=grib_new_from_file(ifile,igrib)
      if (igrib .eq. -1 )  then
        if (iret .ne.0) then
       call grib_check(iret)
        endif
        stop
      endif

C     get as a integer*4
      call grib_check(grib_get_int(igrib,'discipline',discipline))
      write(*,*) 'discipline=',discipline

C     get as a integer*4
      call grib_check(grib_get_int(igrib,'parameterCategory'
     X,parameterCategory))
      write(*,*) 'parameterCategory=',parameterCategory

C     get as a integer*4
      call grib_check(grib_get_int(igrib,'parameterNumber'
     X,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

      goto 10

      call grib_check(grib_release(igrib))

      call grib_check(grib_close_file(ifile))

      end


Generated on Tue Jul 8 10:17:28 2008 for grib_api by  doxygen 1.5.4