multi.f90

How to decode a grib message containing many fields.

00001 ! Copyright 2005-2007 ECMWF
00002 ! 
00003 ! Licensed under the GNU Lesser General Public License which
00004 ! incorporates the terms and conditions of version 3 of the GNU
00005 ! General Public License.
00006 ! See LICENSE and gpl-3.0.txt for details.
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