grib_api: multi_fortran.F

- Main Page
- Modules
- Files
- Related Pages
- Examples

# multi_fortran.F

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

    00001 C Copyright 2005-2015 ECMWF
    00002 C This software is licensed under the terms of the Apache Licence Version 2.0
    00003 C which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
    00004 C
    00005 C In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
    00006 C virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
    00007 C
    00008 C
    00009 C  Fortran 77 Implementation: multi_fortran
    00010 C
    00011 C  Description: How to decode grib messages containing multiple
    00012 C               fields. Try to turn on and off multi support to
    00013 C               see the difference. Default is OFF.
    00014 C         For all the tools defalut is multi support ON.
    00015 C
    00016 C
    00017 C  Author: Enrico Fucile
    00018 C
    00019 C
    00020 C
    00021       program multi
    00022       implicit none
    00023       include 'grib_api_f77.h'
    00024       integer iret
    00025       character*256 error
    00026       integer*4 parameterCategory,parameterNumber,discipline
    00027       integer ifile,igrib
    00028
    00029       call grib_check( grib_open_file(ifile
    00030      X,'../../data/multi.grib2','r'))
    00031
    00032 C     turn on support for multi fields messages */
    00033       call grib_check(grib_multi_support_on())
    00034
    00035 C     turn off support for multi fields messages */
    00036 C     call grib_check(grib_multi_support_off())
    00037
    00038 C     Loop on all the messages in a file.
    00039   10  iret=grib_new_from_file(ifile,igrib)
    00040       if (igrib .eq. -1 )  then
    00041         if (iret .ne.0) then
    00042        call grib_check(iret)
    00043         endif
    00044         stop
    00045       endif
    00046
    00047 C     get as a integer*4
    00048       call grib_check(grib_get_int(igrib,'discipline',discipline))
    00049       write(*,*) 'discipline=',discipline
    00050
    00051 C     get as a integer*4
    00052       call grib_check(grib_get_int(igrib,'parameterCategory'
    00053      X,parameterCategory))
    00054       write(*,*) 'parameterCategory=',parameterCategory
    00055
    00056 C     get as a integer*4
    00057       call grib_check(grib_get_int(igrib,'parameterNumber'
    00058      X,parameterNumber))
    00059       write(*,*) 'parameterNumber=',parameterNumber
    00060
    00061       if ( discipline .eq. 0 .and. parameterCategory .eq. 2) then
    00062         if (parameterNumber .eq. 2) then
    00063            write(*,*) "-------- u -------"
    00064         endif
    00065         if (parameterNumber .eq. 3) then
    00066            write(*,*) "-------- v -------"
    00067         endif
    00068       endif
    00069
    00070       goto 10
    00071
    00072       call grib_check(grib_release(igrib))
    00073
    00074       call grib_check(grib_close_file(ifile))
    00075
    00076       end
    00077