multi.f90

How to decode a grib message containing many fields.

00001 ! Copyright 2005-2016 ECMWF
00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
00004 ! 
00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
00007 !
00008 !
00009 !  Description: How to decode grib messages containing multiple
00010 !               fields. Try to turn on and off multi support to
00011 !               see the difference. Default is OFF.
00012 !               For all the tools defalut is multi support ON.
00013 !
00014 !
00015 !  Author: Enrico Fucile 
00016 !
00017 !
00018 program multi
00019   use grib_api
00020   implicit none
00021   
00022   integer              :: iret
00023   character(len = 256) :: error
00024   integer(kind = 4)    :: step
00025   integer              :: ifile,igrib
00026 
00027   call grib_open_file(ifile, '../../data/multi_created.grib2','r')
00028 
00029   !     turn on support for multi fields messages */
00030   call grib_multi_support_on()
00031 
00032   !     turn off support for multi fields messages */
00033   !call grib_multi_support_off()
00034 
00035   call grib_new_from_file(ifile,igrib, iret)
00036   !     Loop on all the messages in a file.
00037 
00038   write(*,*) 'step'
00039   do while (iret /= GRIB_END_OF_FILE)
00040 
00041      call grib_get(igrib,'step', step)
00042      write(*,'(i3)') step
00043      
00044      call grib_new_from_file(ifile,igrib, iret)
00045   
00046   end do
00047   call grib_close_file(ifile)
00048 
00049 end program multi
00050 

Generated on Tue Sep 22 15:18:21 2009 for grib_api by  doxygen 1.5.3