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: set_fortran
00010 C
00011 C Description: how to set key values.
00012 C
00013 C
00014 C Author: Enrico Fucile
00015 C
00016 C
00017 C
00018 program set
00019 implicit none
00020 include 'grib_api_f77.h'
00021 integer err
00022 integer*4 centre
00023 integer*4 int_value
00024 character*10 string_value
00025 character*20 string_centre
00026 integer len
00027 integer size
00028 integer infile,outfile
00029 integer igrib,iret
00030 character*256 error
00031
00032 infile=5
00033 outfile=6
00034
00035 call grib_check(grib_open_file(infile
00036 X,'../../data/regular_latlon_surface.grib1','r'))
00037
00038 call grib_check(grib_open_file(outfile
00039 X,'../../data/out.grib1','w'))
00040
00041 C a new grib message is loaded from file
00042 C igrib is the grib id to be used in subsequent calls
00043 call grib_check(grib_new_from_file(infile,igrib))
00044
00045 C set centre as a long */
00046 centre=80
00047 call grib_check(grib_set_int(igrib,'centre',centre))
00048
00049 C get centre as a integer*4
00050 call grib_check(grib_get_int(igrib,'centre',int_value))
00051 write(*,*) 'centre=',int_value
00052
00053 C get centre as a string
00054 call grib_check(grib_get_string(igrib,'centre',string_value))
00055 string_centre='centre='
00056 write(*,*) string_centre
00057
00058 C write modified message to a file
00059 call grib_check(grib_write(igrib,outfile))
00060
00061 call grib_check(grib_release(igrib))
00062
00063 call grib_check(grib_close_file(infile))
00064
00065 call grib_check(grib_close_file(outfile))
00066
00067 end