00001 ! Copyright 2005-2013 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 get PV values.
00010 !
00011 !
00012 ! Author: Anne Fouilloux
00013 !
00014 !
00015 program get_pv
00016 use grib_api
00017 implicit none
00018 integer :: infile
00019 integer :: igrib
00020 integer :: PVPresent, nb_pv
00021 real, dimension(:), allocatable :: pv
00022
00023
00024 call grib_open_file(infile, &
00025 '../../data/reduced_gaussian_model_level.grib1','r')
00026
00027 ! a new grib message is loaded from file
00028 ! igrib is the grib id to be used in subsequent calls
00029 call grib_new_from_file(infile,igrib)
00030
00031 ! set PVPresent as an integer
00032 call grib_get(igrib,'PVPresent',PVPresent)
00033 print*, "PVPresent = ", PVPresent
00034 if (PVPresent == 1) then
00035 call grib_get_size(igrib,'pv',nb_pv)
00036 print*, "There are ", nb_pv, " PV values"
00037 allocate(pv(nb_pv))
00038 call grib_get(igrib,'pv',pv)
00039 print*, "pv = ", pv
00040 deallocate(pv)
00041 else
00042 print*, "There is no PV values in your GRIB message!"
00043 end if
00044 call grib_release(igrib)
00045
00046 call grib_close_file(infile)
00047
00048 end program get_pv