ECC-200: Remove obsolete html data

This commit is contained in:
Shahram Najm 2016-08-25 19:09:54 +01:00
parent ba9b0291d4
commit 4aa5870a9d
58 changed files with 0 additions and 7476 deletions

View File

@ -1,101 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: clone.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>clone.f90</h1>How to clone a message.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to create a <span class="keyword">new</span> GRIB message by cloning
<a name="l00010"></a>00010 ! an existing message.
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 !
<a name="l00013"></a>00013 ! Author: Anne Fouilloux
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 !
<a name="l00016"></a>00016 program clone
<a name="l00017"></a>00017 use grib_api
<a name="l00018"></a>00018 implicit none
<a name="l00019"></a>00019 integer :: err,i,iret
<a name="l00020"></a>00020 integer :: nx, ny
<a name="l00021"></a>00021 integer :: infile,outfile
<a name="l00022"></a>00022 integer :: igrib_in
<a name="l00023"></a>00023 integer :: igrib_out
<a name="l00024"></a>00024 character(len=2) :: step
<a name="l00025"></a>00025 double precision, dimension(:,:), allocatable :: field2D
<a name="l00026"></a>00026
<a name="l00027"></a>00027
<a name="l00028"></a>00028 call grib_open_file(infile,'../../data/constant_field.grib1','r')
<a name="l00029"></a>00029 call grib_open_file(outfile,'out.grib1','w')
<a name="l00030"></a>00030
<a name="l00031"></a>00031 ! a new grib message is loaded from file
<a name="l00032"></a>00032 ! igrib is the grib id to be used in subsequent calls
<a name="l00033"></a>00033 call grib_new_from_file(infile,igrib_in)
<a name="l00034"></a>00034
<a name="l00035"></a>00035 call grib_get(igrib_in,<span class="stringliteral">"numberOfPointsAlongAParallel"</span>, nx)
<a name="l00036"></a>00036
<a name="l00037"></a>00037 call grib_get(igrib_in,<span class="stringliteral">"numberOfPointsAlongAMeridian"</span>,ny)
<a name="l00038"></a>00038
<a name="l00039"></a>00039 allocate(field2D(nx,ny),stat=err)
<a name="l00040"></a>00040
<a name="l00041"></a>00041 if (err .ne. 0) then
<a name="l00042"></a>00042 print*, 'Failed to allocate ', nx*ny, ' values'
<a name="l00043"></a>00043 STOP
<a name="l00044"></a>00044 end if
<a name="l00045"></a>00045 ! clone the constant field to create 4 new GRIB messages
<a name="l00046"></a>00046 do i=0,18,6
<a name="l00047"></a>00047 call grib_clone(igrib_in, igrib_out)
<a name="l00048"></a>00048 write(step,'(i2)') i
<a name="l00049"></a>00049 ! Careful: stepRange is a string (could be 0-6, 12-24, etc.)
<a name="l00050"></a>00050 ! use adjustl to remove blank from the left.
<a name="l00051"></a>00051 call grib_set(igrib_out,'stepRange',adjustl(step))
<a name="l00052"></a>00052
<a name="l00053"></a>00053 call generate_field(field2D)
<a name="l00054"></a>00054
<a name="l00055"></a>00055 ! use pack to create 1D values
<a name="l00056"></a>00056 call grib_set(igrib_out,'values',pack(field2D, mask=.true.))
<a name="l00057"></a>00057
<a name="l00058"></a>00058 ! write cloned messages to a file
<a name="l00059"></a>00059 call grib_write(igrib_out,outfile)
<a name="l00060"></a>00060 call grib_release(igrib_out)
<a name="l00061"></a>00061 end do
<a name="l00062"></a>00062
<a name="l00063"></a>00063 call grib_release(igrib_in)
<a name="l00064"></a>00064
<a name="l00065"></a>00065 call grib_close_file(infile)
<a name="l00066"></a>00066
<a name="l00067"></a>00067 call grib_close_file(outfile)
<a name="l00068"></a>00068 deallocate(field2D)
<a name="l00069"></a>00069
<a name="l00070"></a>00070 contains
<a name="l00071"></a>00071 !======================================
<a name="l00072"></a>00072 subroutine generate_field(gfield2D)
<a name="l00073"></a>00073 double precision, dimension(:,:) :: gfield2D
<a name="l00074"></a>00074
<a name="l00075"></a>00075 call random_number(gfield2D)
<a name="l00076"></a>00076 end subroutine generate_field
<a name="l00077"></a>00077 !======================================
<a name="l00078"></a>00078
<a name="l00079"></a>00079 end program clone
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,76 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: copy_message.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>copy_message.f90</h1>How to copy a message in memory and create a new message.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to copy a message in memory
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Anne Fouilloux
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 program copy
<a name="l00016"></a>00016 use grib_api
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer :: err, centre
<a name="l00019"></a>00019 integer(kind=kindOfSize) :: byte_size
<a name="l00020"></a>00020 integer :: infile,outfile
<a name="l00021"></a>00021 integer :: igrib_in,iret
<a name="l00022"></a>00022 integer :: igrib_out
<a name="l00023"></a>00023 character(len=1), dimension(:), allocatable :: message
<a name="l00024"></a>00024
<a name="l00025"></a>00025
<a name="l00026"></a>00026 call grib_open_file(infile,'../../data/constant_field.grib1','r')
<a name="l00027"></a>00027 call grib_open_file(outfile,'out.grib1','w')
<a name="l00028"></a>00028
<a name="l00029"></a>00029 ! a new grib message is loaded from file
<a name="l00030"></a>00030 ! igrib is the grib id to be used in subsequent calls
<a name="l00031"></a>00031 call grib_new_from_file(infile,igrib_in)
<a name="l00032"></a>00032
<a name="l00033"></a>00033 call grib_get_message_size(igrib_in, byte_size)
<a name="l00034"></a>00034 allocate(message(byte_size), stat=err)
<a name="l00035"></a>00035
<a name="l00036"></a>00036 call grib_copy_message(igrib_in,message)
<a name="l00037"></a>00037
<a name="l00038"></a>00038 call grib_new_from_message(igrib_out, message)
<a name="l00039"></a>00039
<a name="l00040"></a>00040 centre=80
<a name="l00041"></a>00041 call grib_set(igrib_out,<span class="stringliteral">"centre"</span>,centre)
<a name="l00042"></a>00042
<a name="l00043"></a>00043 ! write messages to a file
<a name="l00044"></a>00044 call grib_write(igrib_out,outfile)
<a name="l00045"></a>00045
<a name="l00046"></a>00046 call grib_release(igrib_out)
<a name="l00047"></a>00047
<a name="l00048"></a>00048 call grib_release(igrib_in)
<a name="l00049"></a>00049
<a name="l00050"></a>00050 call grib_close_file(infile)
<a name="l00051"></a>00051 call grib_close_file(outfile)
<a name="l00052"></a>00052 deallocate(message)
<a name="l00053"></a>00053
<a name="l00054"></a>00054 end program copy
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,58 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: Examples</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>grib_api Examples</h1>Here is a list of all examples:<ul>
<li><a class="el" href="clone_8f90-example.html">clone.f90</a>
<li><a class="el" href="copy__message_8f90-example.html">copy_message.f90</a>
<li><a class="el" href="count__messages_8f90-example.html">count_messages.f90</a>
<li><a class="el" href="get_8c-example.html">get.c</a>
<li><a class="el" href="get_8f90-example.html">get.f90</a>
<li><a class="el" href="get__data_8f90-example.html">get_data.f90</a>
<li><a class="el" href="get__fortran_8_f-example.html">get_fortran.F</a>
<li><a class="el" href="get__pl_8f90-example.html">get_pl.f90</a>
<li><a class="el" href="get__pv_8f90-example.html">get_pv.f90</a>
<li><a class="el" href="index_8f90-example.html">index.f90</a>
<li><a class="el" href="iterator_8c-example.html">iterator.c</a>
<li><a class="el" href="iterator__fortran_8_f-example.html">iterator_fortran.F</a>
<li><a class="el" href="keys__iterator_8c-example.html">keys_iterator.c</a>
<li><a class="el" href="keys__iterator_8f90-example.html">keys_iterator.f90</a>
<li><a class="el" href="keys__iterator__fortran_8_f-example.html">keys_iterator_fortran.F</a>
<li><a class="el" href="multi_8c-example.html">multi.c</a>
<li><a class="el" href="multi_8f90-example.html">multi.f90</a>
<li><a class="el" href="multi__fortran_8_f-example.html">multi_fortran.F</a>
<li><a class="el" href="multi__write_8c-example.html">multi_write.c</a>
<li><a class="el" href="multi__write_8f90-example.html">multi_write.f90</a>
<li><a class="el" href="nearest_8c-example.html">nearest.c</a>
<li><a class="el" href="nearest_8f90-example.html">nearest.f90</a>
<li><a class="el" href="precision_8c-example.html">precision.c</a>
<li><a class="el" href="precision_8f90-example.html">precision.f90</a>
<li><a class="el" href="precision__fortran_8_f-example.html">precision_fortran.F</a>
<li><a class="el" href="print__data_8c-example.html">print_data.c</a>
<li><a class="el" href="print__data_8f90-example.html">print_data.f90</a>
<li><a class="el" href="print__data__fortran_8_f-example.html">print_data_fortran.F</a>
<li><a class="el" href="samples_8f90-example.html">samples.f90</a>
<li><a class="el" href="set_8c-example.html">set.c</a>
<li><a class="el" href="set_8f90-example.html">set.f90</a>
<li><a class="el" href="set__bitmap_8f90-example.html">set_bitmap.f90</a>
<li><a class="el" href="set__fortran_8_f-example.html">set_fortran.F</a>
<li><a class="el" href="set__missing_8f90-example.html">set_missing.f90</a>
<li><a class="el" href="set__pv_8f90-example.html">set_pv.f90</a>
</ul>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,128 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: get.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>get.c</h1>get.c How to get values through the key names.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> * C Implementation: get</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Description: how to get values using keys.</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> * Author: Enrico Fucile</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> */</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00021"></a>00021
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>"</span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv) {
<a name="l00025"></a>00025 <span class="keywordtype">int</span> err = 0;
<a name="l00026"></a>00026 <span class="keywordtype">double</span> *values = NULL;
<a name="l00027"></a>00027 <span class="keywordtype">size_t</span> values_len= 0;
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="keywordtype">size_t</span> i = 0;
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="keywordtype">double</span> latitudeOfFirstGridPointInDegrees;
<a name="l00032"></a>00032 <span class="keywordtype">double</span> longitudeOfFirstGridPointInDegrees;
<a name="l00033"></a>00033 <span class="keywordtype">double</span> latitudeOfLastGridPointInDegrees;
<a name="l00034"></a>00034 <span class="keywordtype">double</span> longitudeOfLastGridPointInDegrees;
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="keywordtype">double</span> jDirectionIncrementInDegrees;
<a name="l00037"></a>00037 <span class="keywordtype">double</span> iDirectionIncrementInDegrees;
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="keywordtype">long</span> numberOfPointsAlongAParallel;
<a name="l00040"></a>00040 <span class="keywordtype">long</span> numberOfPointsAlongAMeridian;
<a name="l00041"></a>00041
<a name="l00042"></a>00042 <span class="keywordtype">double</span> average = 0;
<a name="l00043"></a>00043
<a name="l00044"></a>00044 FILE* in = NULL;
<a name="l00045"></a>00045 <span class="keywordtype">char</span>* filename = <span class="stringliteral">"../../data/regular_latlon_surface.grib1"</span>;
<a name="l00046"></a>00046 <a name="a0"></a><a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h = NULL;
<a name="l00047"></a>00047
<a name="l00048"></a>00048 in = fopen(filename,<span class="stringliteral">"r"</span>);
<a name="l00049"></a>00049 <span class="keywordflow">if</span>(!in) {
<a name="l00050"></a>00050 printf(<span class="stringliteral">"ERROR: unable to open file %s\n"</span>,filename);
<a name="l00051"></a>00051 <span class="keywordflow">return</span> 1;
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053
<a name="l00054"></a>00054 <span class="comment">/* create new handle from a message in a file*/</span>
<a name="l00055"></a>00055 h = <a name="a1"></a><a class="code" href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5" title="Create a handle from a file resource.">grib_handle_new_from_file</a>(0,in,&amp;err);
<a name="l00056"></a>00056 <span class="keywordflow">if</span> (h == NULL) {
<a name="l00057"></a>00057 printf(<span class="stringliteral">"Error: unable to create handle from file %s\n"</span>,filename);
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="comment">/* get as a long*/</span>
<a name="l00061"></a>00061 GRIB_CHECK(<a name="a2"></a><a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"numberOfPointsAlongAParallel"</span>,&amp;numberOfPointsAlongAParallel),0);
<a name="l00062"></a>00062 printf(<span class="stringliteral">"numberOfPointsAlongAParallel=%ld\n"</span>,numberOfPointsAlongAParallel);
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="comment">/* get as a long*/</span>
<a name="l00065"></a>00065 GRIB_CHECK(<a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"numberOfPointsAlongAMeridian"</span>,&amp;numberOfPointsAlongAMeridian),0);
<a name="l00066"></a>00066 printf(<span class="stringliteral">"numberOfPointsAlongAMeridian=%ld\n"</span>,numberOfPointsAlongAMeridian);
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="comment">/* get as a double*/</span>
<a name="l00069"></a>00069 GRIB_CHECK(<a name="a3"></a><a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"latitudeOfFirstGridPointInDegrees"</span>,&amp;latitudeOfFirstGridPointInDegrees),0);
<a name="l00070"></a>00070 printf(<span class="stringliteral">"latitudeOfFirstGridPointInDegrees=%g\n"</span>,latitudeOfFirstGridPointInDegrees);
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="comment">/* get as a double*/</span>
<a name="l00073"></a>00073 GRIB_CHECK(<a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"longitudeOfFirstGridPointInDegrees"</span>,&amp;longitudeOfFirstGridPointInDegrees),0);
<a name="l00074"></a>00074 printf(<span class="stringliteral">"longitudeOfFirstGridPointInDegrees=%g\n"</span>,longitudeOfFirstGridPointInDegrees);
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <span class="comment">/* get as a double*/</span>
<a name="l00077"></a>00077 GRIB_CHECK(<a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"latitudeOfLastGridPointInDegrees"</span>,&amp;latitudeOfLastGridPointInDegrees),0);
<a name="l00078"></a>00078 printf(<span class="stringliteral">"latitudeOfLastGridPointInDegrees=%g\n"</span>,latitudeOfLastGridPointInDegrees);
<a name="l00079"></a>00079
<a name="l00080"></a>00080 <span class="comment">/* get as a double*/</span>
<a name="l00081"></a>00081 GRIB_CHECK(<a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"longitudeOfLastGridPointInDegrees"</span>,&amp;longitudeOfLastGridPointInDegrees),0);
<a name="l00082"></a>00082 printf(<span class="stringliteral">"longitudeOfLastGridPointInDegrees=%g\n"</span>,longitudeOfLastGridPointInDegrees);
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="comment">/* get as a double*/</span>
<a name="l00085"></a>00085 GRIB_CHECK(<a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"jDirectionIncrementInDegrees"</span>,&amp;jDirectionIncrementInDegrees),0);
<a name="l00086"></a>00086 printf(<span class="stringliteral">"jDirectionIncrementInDegrees=%g\n"</span>,jDirectionIncrementInDegrees);
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="comment">/* get as a double*/</span>
<a name="l00089"></a>00089 GRIB_CHECK(<a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"iDirectionIncrementInDegrees"</span>,&amp;iDirectionIncrementInDegrees),0);
<a name="l00090"></a>00090 printf(<span class="stringliteral">"iDirectionIncrementInDegrees=%g\n"</span>,iDirectionIncrementInDegrees);
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="comment">/* get the size of the values array*/</span>
<a name="l00093"></a>00093 GRIB_CHECK(<a name="a4"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(h,<span class="stringliteral">"values"</span>,&amp;values_len),0);
<a name="l00094"></a>00094
<a name="l00095"></a>00095 values = malloc(values_len*<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="comment">/* get data values*/</span>
<a name="l00098"></a>00098 GRIB_CHECK(<a name="a5"></a><a class="code" href="group__get__set.html#g61f1029d7f37d51f33835e218d58378a" title="Get double array values from a key.">grib_get_double_array</a>(h,<span class="stringliteral">"values"</span>,values,&amp;values_len),0);
<a name="l00099"></a>00099
<a name="l00100"></a>00100 average = 0;
<a name="l00101"></a>00101 <span class="keywordflow">for</span>(i = 0; i &lt; values_len; i++)
<a name="l00102"></a>00102 average += values[i];
<a name="l00103"></a>00103
<a name="l00104"></a>00104 average /=(double)values_len;
<a name="l00105"></a>00105
<a name="l00106"></a>00106 free(values);
<a name="l00107"></a>00107
<a name="l00108"></a>00108 printf(<span class="stringliteral">"There are %d values, average is %g\n"</span>,(<span class="keywordtype">int</span>)values_len,average);
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <a name="a6"></a><a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<a name="l00111"></a>00111
<a name="l00112"></a>00112 fclose(in);
<a name="l00113"></a>00113 <span class="keywordflow">return</span> 0;
<a name="l00114"></a>00114 }
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,134 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: get.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>get.f90</h1>How to get values through the key names.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to <span class="keyword">get</span> values <span class="keyword">using</span> keys.
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 ! Author: Enrico Fucile
<a name="l00012"></a>00012 !
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 program <span class="keyword">get</span>
<a name="l00015"></a>00015 use grib_api
<a name="l00016"></a>00016 implicit none
<a name="l00017"></a>00017
<a name="l00018"></a>00018 integer :: ifile
<a name="l00019"></a>00019 integer :: iret
<a name="l00020"></a>00020 integer :: igrib
<a name="l00021"></a>00021 real :: latitudeOfFirstPointInDegrees
<a name="l00022"></a>00022 real :: longitudeOfFirstPointInDegrees
<a name="l00023"></a>00023 real :: latitudeOfLastPointInDegrees
<a name="l00024"></a>00024 real :: longitudeOfLastPointInDegrees
<a name="l00025"></a>00025 integer :: numberOfPointsAlongAParallel
<a name="l00026"></a>00026 integer :: numberOfPointsAlongAMeridian
<a name="l00027"></a>00027 real, dimension(:), allocatable :: values
<a name="l00028"></a>00028 integer :: numberOfValues
<a name="l00029"></a>00029 real :: average,min_val, max_val
<a name="l00030"></a>00030 integer :: is_missing
<a name="l00031"></a>00031
<a name="l00032"></a>00032 call grib_open_file(ifile, &amp;
<a name="l00033"></a>00033 '../../data/reduced_latlon_surface.grib1<span class="charliteral">','</span>r')
<a name="l00034"></a>00034
<a name="l00035"></a>00035 ! Loop on all the messages in a file.
<a name="l00036"></a>00036
<a name="l00037"></a>00037 ! a <span class="keyword">new</span> grib message is loaded from file
<a name="l00038"></a>00038 ! igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00039"></a>00039 call grib_new_from_file(ifile,igrib, iret)
<a name="l00040"></a>00040
<a name="l00041"></a>00041 LOOP: DO WHILE (iret /= <a name="a0"></a><a class="code" href="grib__api_8h.html#3bd3d72fe8bc116ca08c2d4b99203768" title="End of ressource reached.">GRIB_END_OF_FILE</a>)
<a name="l00042"></a>00042
<a name="l00043"></a>00043 !check if the value of the key is MISSING
<a name="l00044"></a>00044 is_missing=0;
<a name="l00045"></a>00045 call grib_is_missing(igrib,'numberOfPointsAlongAParallel', &amp;
<a name="l00046"></a>00046 is_missing);
<a name="l00047"></a>00047 if ( is_missing /= 1 ) then
<a name="l00048"></a>00048 ! get as a integer
<a name="l00049"></a>00049 call grib_get(igrib,'numberOfPointsAlongAParallel', &amp;
<a name="l00050"></a>00050 numberOfPointsAlongAParallel)
<a name="l00051"></a>00051 write(*,*) 'numberOfPointsAlongAParallel=', &amp;
<a name="l00052"></a>00052 numberOfPointsAlongAParallel
<a name="l00053"></a>00053 else
<a name="l00054"></a>00054 write(*,*) 'numberOfPointsAlongAParallel is missing'
<a name="l00055"></a>00055 endif
<a name="l00056"></a>00056 ! get as a integer
<a name="l00057"></a>00057 call grib_get(igrib,'numberOfPointsAlongAMeridian', &amp;
<a name="l00058"></a>00058 numberOfPointsAlongAMeridian)
<a name="l00059"></a>00059 write(*,*) 'numberOfPointsAlongAMeridian=', &amp;
<a name="l00060"></a>00060 numberOfPointsAlongAMeridian
<a name="l00061"></a>00061
<a name="l00062"></a>00062 ! get as a real
<a name="l00063"></a>00063 call grib_get(igrib, 'latitudeOfFirstGridPointInDegrees', &amp;
<a name="l00064"></a>00064 latitudeOfFirstPointInDegrees)
<a name="l00065"></a>00065 write(*,*) 'latitudeOfFirstGridPointInDegrees=', &amp;
<a name="l00066"></a>00066 latitudeOfFirstPointInDegrees
<a name="l00067"></a>00067
<a name="l00068"></a>00068 ! get as a real
<a name="l00069"></a>00069 call grib_get(igrib, 'longitudeOfFirstGridPointInDegrees', &amp;
<a name="l00070"></a>00070 longitudeOfFirstPointInDegrees)
<a name="l00071"></a>00071 write(*,*) 'longitudeOfFirstGridPointInDegrees=', &amp;
<a name="l00072"></a>00072 longitudeOfFirstPointInDegrees
<a name="l00073"></a>00073
<a name="l00074"></a>00074 ! get as a real
<a name="l00075"></a>00075 call grib_get(igrib, 'latitudeOfLastGridPointInDegrees', &amp;
<a name="l00076"></a>00076 latitudeOfLastPointInDegrees)
<a name="l00077"></a>00077 write(*,*) 'latitudeOfLastGridPointInDegrees=', &amp;
<a name="l00078"></a>00078 latitudeOfLastPointInDegrees
<a name="l00079"></a>00079
<a name="l00080"></a>00080 ! get as a real
<a name="l00081"></a>00081 call grib_get(igrib, 'longitudeOfLastGridPointInDegrees', &amp;
<a name="l00082"></a>00082 longitudeOfLastPointInDegrees)
<a name="l00083"></a>00083 write(*,*) 'longitudeOfLastGridPointInDegrees=', &amp;
<a name="l00084"></a>00084 longitudeOfLastPointInDegrees
<a name="l00085"></a>00085
<a name="l00086"></a>00086
<a name="l00087"></a>00087 ! get the size of the values array
<a name="l00088"></a>00088 call <a name="a1"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,'values',numberOfValues)
<a name="l00089"></a>00089 write(*,*) 'numberOfValues=',numberOfValues
<a name="l00090"></a>00090
<a name="l00091"></a>00091 allocate(values(numberOfValues), stat=iret)
<a name="l00092"></a>00092 ! get data values
<a name="l00093"></a>00093 call grib_get(igrib,'values',values)
<a name="l00094"></a>00094 call grib_get(igrib,'min',min_val) ! can also be obtained through minval(values)
<a name="l00095"></a>00095 call grib_get(igrib,'max',max_val) ! can also be obtained through maxval(values)
<a name="l00096"></a>00096 call grib_get(igrib,'average',average) ! can also be obtained through maxval(values)
<a name="l00097"></a>00097
<a name="l00098"></a>00098 write(*,*)'There are ',numberOfValues, &amp;
<a name="l00099"></a>00099 ' average is ',average, &amp;
<a name="l00100"></a>00100 ' min is ', min_val, &amp;
<a name="l00101"></a>00101 ' max is ', max_val
<a name="l00102"></a>00102
<a name="l00103"></a>00103 call grib_release(igrib)
<a name="l00104"></a>00104
<a name="l00105"></a>00105 call grib_new_from_file(ifile,igrib, iret)
<a name="l00106"></a>00106
<a name="l00107"></a>00107 end do LOOP
<a name="l00108"></a>00108
<a name="l00109"></a>00109 call grib_close_file(ifile)
<a name="l00110"></a>00110
<a name="l00111"></a>00111 deallocate(values)
<a name="l00112"></a>00112 end program get
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,90 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: get_data.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>get_data.f90</h1>How to get latitude/longitude/values.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to <span class="keyword">get</span> lat/lon/values.
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Enrico Fucile
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 program get_data
<a name="l00016"></a>00016 use grib_api
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer :: ifile
<a name="l00019"></a>00019 integer :: iret,i
<a name="l00020"></a>00020 real(kind=8),dimension(:),allocatable :: lats,lons,values
<a name="l00021"></a>00021 integer(4) :: numberOfPoints
<a name="l00022"></a>00022 real(8) :: missingValue=9999
<a name="l00023"></a>00023 integer :: count=0
<a name="l00024"></a>00024 character(len=256) :: filename
<a name="l00025"></a>00025
<a name="l00026"></a>00026 ! Message identifier.
<a name="l00027"></a>00027 integer :: igrib
<a name="l00028"></a>00028
<a name="l00029"></a>00029 ifile=5
<a name="l00030"></a>00030
<a name="l00031"></a>00031 call grib_open_file(ifile, &amp;
<a name="l00032"></a>00032 '../../data/reduced_latlon_surface.grib1','R')
<a name="l00033"></a>00033
<a name="l00034"></a>00034 ! Loop on all the messages in a file.
<a name="l00035"></a>00035
<a name="l00036"></a>00036 call grib_new_from_file(ifile,igrib,iret)
<a name="l00037"></a>00037
<a name="l00038"></a>00038 do while (iret/=<a name="a0"></a><a class="code" href="grib__api_8h.html#3bd3d72fe8bc116ca08c2d4b99203768" title="End of ressource reached.">GRIB_END_OF_FILE</a>)
<a name="l00039"></a>00039 count=count+1
<a name="l00040"></a>00040 print *, <span class="stringliteral">"===== Message #"</span>,count
<a name="l00041"></a>00041 call grib_get(igrib,'numberOfPoints',numberOfPoints)
<a name="l00042"></a>00042 call grib_set(igrib,'missingValue',missingValue)
<a name="l00043"></a>00043
<a name="l00044"></a>00044 allocate(lats(numberOfPoints))
<a name="l00045"></a>00045 allocate(lons(numberOfPoints))
<a name="l00046"></a>00046 allocate(values(numberOfPoints))
<a name="l00047"></a>00047
<a name="l00048"></a>00048 call grib_get_data(igrib,lats,lons,values)
<a name="l00049"></a>00049
<a name="l00050"></a>00050 do i=1,numberOfPoints
<a name="l00051"></a>00051 if (values(i) /= missingValue) then
<a name="l00052"></a>00052 print *, lats(i),lons(i),values(i)
<a name="l00053"></a>00053 end if
<a name="l00054"></a>00054 enddo
<a name="l00055"></a>00055
<a name="l00056"></a>00056 deallocate(lats)
<a name="l00057"></a>00057 deallocate(lons)
<a name="l00058"></a>00058 deallocate(values)
<a name="l00059"></a>00059
<a name="l00060"></a>00060 call grib_release(igrib)
<a name="l00061"></a>00061 call grib_new_from_file(ifile,igrib, iret)
<a name="l00062"></a>00062
<a name="l00063"></a>00063 end do
<a name="l00064"></a>00064
<a name="l00065"></a>00065
<a name="l00066"></a>00066 call grib_close_file(ifile)
<a name="l00067"></a>00067
<a name="l00068"></a>00068 end program
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,151 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: get_fortran.F</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>get_fortran.F</h1>get_fortran.F How to get values through the key names.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 C Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 C This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 C which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 C
<a name="l00005"></a>00005 C In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 C virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 C
<a name="l00008"></a>00008 C Fortran 77 Implementation: get_fortran
<a name="l00009"></a>00009 C
<a name="l00010"></a>00010 C Description: how to <span class="keyword">get</span> values <span class="keyword">using</span> keys.
<a name="l00011"></a>00011 C
<a name="l00012"></a>00012 C Author: Enrico Fucile
<a name="l00013"></a>00013 C
<a name="l00014"></a>00014 C
<a name="l00015"></a>00015 C
<a name="l00016"></a>00016 program <span class="keyword">get</span>
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer maxNumberOfValues
<a name="l00019"></a>00019 parameter( maxNumberOfValues = 10000 )
<a name="l00020"></a>00020 include 'grib_api_f77.h'
<a name="l00021"></a>00021 integer ifile
<a name="l00022"></a>00022 integer iret
<a name="l00023"></a>00023 integer igrib
<a name="l00024"></a>00024 integer i
<a name="l00025"></a>00025 real*8 latitudeOfFirstPointInDegrees
<a name="l00026"></a>00026 real*8 longitudeOfFirstPointInDegrees
<a name="l00027"></a>00027 real*8 latitudeOfLastPointInDegrees
<a name="l00028"></a>00028 real*8 longitudeOfLastPointInDegrees
<a name="l00029"></a>00029 real*8 jDirectionIncrementInDegrees
<a name="l00030"></a>00030 real*8 iDirectionIncrementInDegrees
<a name="l00031"></a>00031 integer*4 numberOfPointsAlongAParallel
<a name="l00032"></a>00032 integer*4 numberOfPointsAlongAMeridian
<a name="l00033"></a>00033 real*8 values(maxNumberOfValues)
<a name="l00034"></a>00034 integer*4 numberOfValues
<a name="l00035"></a>00035 real*8 average
<a name="l00036"></a>00036 character*256 error
<a name="l00037"></a>00037 integer*4 size
<a name="l00038"></a>00038
<a name="l00039"></a>00039 size=maxNumberOfValues
<a name="l00040"></a>00040 ifile=5
<a name="l00041"></a>00041
<a name="l00042"></a>00042 iret=grib_open_file(ifile
<a name="l00043"></a>00043 X,'../../data/regular_latlon_surface.grib1','r')
<a name="l00044"></a>00044 call grib_check(iret)
<a name="l00045"></a>00045
<a name="l00046"></a>00046 C a new grib message is loaded from file
<a name="l00047"></a>00047 C igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00048"></a>00048 call grib_check( grib_new_from_file(ifile,igrib) )
<a name="l00049"></a>00049
<a name="l00050"></a>00050 C get as a integer
<a name="l00051"></a>00051 call grib_check(grib_get_int(igrib,'numberOfPointsAlongAParallel'
<a name="l00052"></a>00052 X,numberOfPointsAlongAParallel) )
<a name="l00053"></a>00053 write(*,*) 'numberOfPointsAlongAParallel='
<a name="l00054"></a>00054 X,numberOfPointsAlongAParallel
<a name="l00055"></a>00055
<a name="l00056"></a>00056 C get as a integer
<a name="l00057"></a>00057 call grib_check( grib_get_int(igrib,'numberOfPointsAlongAMeridian'
<a name="l00058"></a>00058 X,numberOfPointsAlongAMeridian) )
<a name="l00059"></a>00059 write(*,*) 'numberOfPointsAlongAMeridian='
<a name="l00060"></a>00060 X,numberOfPointsAlongAMeridian
<a name="l00061"></a>00061
<a name="l00062"></a>00062 C get as a real8
<a name="l00063"></a>00063 call grib_check( grib_get_real8(igrib
<a name="l00064"></a>00064 X,'latitudeOfFirstGridPointInDegrees'
<a name="l00065"></a>00065 X,latitudeOfFirstPointInDegrees) )
<a name="l00066"></a>00066 write(*,*) 'latitudeOfFirstGridPointInDegrees='
<a name="l00067"></a>00067 X,latitudeOfFirstPointInDegrees
<a name="l00068"></a>00068
<a name="l00069"></a>00069 C get as a real8
<a name="l00070"></a>00070 call grib_check( grib_get_real8(igrib
<a name="l00071"></a>00071 X,'longitudeOfFirstGridPointInDegrees'
<a name="l00072"></a>00072 X,longitudeOfFirstPointInDegrees) )
<a name="l00073"></a>00073 write(*,*) 'longitudeOfFirstGridPointInDegrees='
<a name="l00074"></a>00074 X,longitudeOfFirstPointInDegrees
<a name="l00075"></a>00075
<a name="l00076"></a>00076 C get as a real8
<a name="l00077"></a>00077 call grib_check( grib_get_real8(igrib
<a name="l00078"></a>00078 X,'latitudeOfLastGridPointInDegrees'
<a name="l00079"></a>00079 X,latitudeOfLastPointInDegrees) )
<a name="l00080"></a>00080 write(*,*) 'latitudeOfLastGridPointInDegrees='
<a name="l00081"></a>00081 X,latitudeOfLastPointInDegrees
<a name="l00082"></a>00082
<a name="l00083"></a>00083 C get as a real8
<a name="l00084"></a>00084 call grib_check( grib_get_real8(igrib
<a name="l00085"></a>00085 X,'longitudeOfLastGridPointInDegrees'
<a name="l00086"></a>00086 X,longitudeOfLastPointInDegrees) )
<a name="l00087"></a>00087 write(*,*) 'longitudeOfLastGridPointInDegrees='
<a name="l00088"></a>00088 X,longitudeOfLastPointInDegrees
<a name="l00089"></a>00089
<a name="l00090"></a>00090 C get as a real8
<a name="l00091"></a>00091 call grib_check( grib_get_real8(igrib
<a name="l00092"></a>00092 X,'jDirectionIncrementInDegrees'
<a name="l00093"></a>00093 X,jDirectionIncrementInDegrees) )
<a name="l00094"></a>00094 write(*,*) 'jDirectionIncrementInDegrees='
<a name="l00095"></a>00095 X,jDirectionIncrementInDegrees
<a name="l00096"></a>00096
<a name="l00097"></a>00097 C get as a real8
<a name="l00098"></a>00098 call grib_check( grib_get_real8(igrib
<a name="l00099"></a>00099 X,'iDirectionIncrementInDegrees'
<a name="l00100"></a>00100 X,iDirectionIncrementInDegrees) )
<a name="l00101"></a>00101 write(*,*) 'iDirectionIncrementInDegrees='
<a name="l00102"></a>00102 X,iDirectionIncrementInDegrees
<a name="l00103"></a>00103
<a name="l00104"></a>00104 C get the size of the values array
<a name="l00105"></a>00105 call grib_check(<a name="a0"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,'values',numberOfValues))
<a name="l00106"></a>00106 write(*,*) 'numberOfValues=',numberOfValues
<a name="l00107"></a>00107
<a name="l00108"></a>00108 C get data values
<a name="l00109"></a>00109 call grib_check(grib_get_real8_array(igrib,'values',values,size))
<a name="l00110"></a>00110 if ( size .ne. numberOfValues ) then
<a name="l00111"></a>00111 write(*,*) 'ERROR: wrong numberOfValues'
<a name="l00112"></a>00112 stop
<a name="l00113"></a>00113 endif
<a name="l00114"></a>00114
<a name="l00115"></a>00115 average = 0
<a name="l00116"></a>00116 do i=1,numberOfValues
<a name="l00117"></a>00117 average = average + values(i);
<a name="l00118"></a>00118 enddo
<a name="l00119"></a>00119
<a name="l00120"></a>00120 average =average / numberOfValues
<a name="l00121"></a>00121
<a name="l00122"></a>00122 write(*,*)'There are ',numberOfValues
<a name="l00123"></a>00123 X,' average is ',average
<a name="l00124"></a>00124
<a name="l00125"></a>00125 call grib_check(grib_release(igrib))
<a name="l00126"></a>00126
<a name="l00127"></a>00127 call grib_check(grib_close_file(ifile))
<a name="l00128"></a>00128
<a name="l00129"></a>00129 end
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,70 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: get_pl.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>get_pl.f90</h1>How to get the list of number of points for each parallel in reduced grids.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to <span class="keyword">get</span> PL values.
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Anne Fouilloux
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 program get_pl
<a name="l00016"></a>00016 use grib_api
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer :: infile
<a name="l00019"></a>00019 integer :: igrib
<a name="l00020"></a>00020 integer :: PLPresent, nb_pl
<a name="l00021"></a>00021 real, dimension(:), allocatable :: pl
<a name="l00022"></a>00022
<a name="l00023"></a>00023
<a name="l00024"></a>00024 call grib_open_file(infile, &amp;
<a name="l00025"></a>00025 '../../data/reduced_gaussian_surface.grib1<span class="charliteral">','</span>r')
<a name="l00026"></a>00026
<a name="l00027"></a>00027 ! a <span class="keyword">new</span> grib message is loaded from file
<a name="l00028"></a>00028 ! igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00029"></a>00029 call grib_new_from_file(infile,igrib)
<a name="l00030"></a>00030
<a name="l00031"></a>00031 ! <span class="keyword">set</span> PVPresent as an integer
<a name="l00032"></a>00032 call grib_get(igrib,'PLPresent',PLPresent)
<a name="l00033"></a>00033 print*, "PLPresent= ", PLPresent
<a name="l00034"></a>00034 if (PLPresent == 1) then
<a name="l00035"></a>00035 call <a name="a0"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,'pl',nb_pl)
<a name="l00036"></a>00036 print*, "there are ", nb_pl, " PL values"
<a name="l00037"></a>00037 allocate(pl(nb_pl))
<a name="l00038"></a>00038 call grib_get(igrib,'pl',pl)
<a name="l00039"></a>00039 print*, "pl = ", pl
<a name="l00040"></a>00040 deallocate(pl)
<a name="l00041"></a>00041 else
<a name="l00042"></a>00042 print*, "There is no PL values in your GRIB message!"
<a name="l00043"></a>00043 end if
<a name="l00044"></a>00044 call grib_release(igrib)
<a name="l00045"></a>00045
<a name="l00046"></a>00046 call grib_close_file(infile)
<a name="l00047"></a>00047
<a name="l00048"></a>00048 end program get_pl
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,70 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: get_pv.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>get_pv.f90</h1>How to get the list of levels.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to <span class="keyword">get</span> PV values.
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Anne Fouilloux
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 program get_pv
<a name="l00016"></a>00016 use grib_api
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer :: infile
<a name="l00019"></a>00019 integer :: igrib
<a name="l00020"></a>00020 integer :: PVPresent, nb_pv
<a name="l00021"></a>00021 real, dimension(:), allocatable :: pv
<a name="l00022"></a>00022
<a name="l00023"></a>00023
<a name="l00024"></a>00024 call grib_open_file(infile, &amp;
<a name="l00025"></a>00025 '../../data/reduced_gaussian_model_level.grib1<span class="charliteral">','</span>r')
<a name="l00026"></a>00026
<a name="l00027"></a>00027 ! a <span class="keyword">new</span> grib message is loaded from file
<a name="l00028"></a>00028 ! igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00029"></a>00029 call grib_new_from_file(infile,igrib)
<a name="l00030"></a>00030
<a name="l00031"></a>00031 ! <span class="keyword">set</span> PVPresent as an integer
<a name="l00032"></a>00032 call grib_get(igrib,'PVPresent',PVPresent)
<a name="l00033"></a>00033 print*, "PVPresent = ", PVPresent
<a name="l00034"></a>00034 if (PVPresent == 1) then
<a name="l00035"></a>00035 call <a name="a0"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,'pv',nb_pv)
<a name="l00036"></a>00036 print*, "There are ", nb_pv, " PV values"
<a name="l00037"></a>00037 allocate(pv(nb_pv))
<a name="l00038"></a>00038 call grib_get(igrib,'pv',pv)
<a name="l00039"></a>00039 print*, "pv = ", pv
<a name="l00040"></a>00040 deallocate(pv)
<a name="l00041"></a>00041 else
<a name="l00042"></a>00042 print*, "There is no PV values in your GRIB message!"
<a name="l00043"></a>00043 end if
<a name="l00044"></a>00044 call grib_release(igrib)
<a name="l00045"></a>00045
<a name="l00046"></a>00046 call grib_close_file(infile)
<a name="l00047"></a>00047
<a name="l00048"></a>00048 end program get_pv
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,73 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: Data Fields</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li class="current"><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="globals.html"><span>All</span></a></li>
<li><a href="globals_func.html"><span>Functions</span></a></li>
<li class="current"><a href="globals_type.html"><span>Typedefs</span></a></li>
<li><a href="globals_defs.html"><span>Defines</span></a></li>
</ul>
</div>
&nbsp;
<p>
<ul>
<li>grib_context
: <a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_api.h</a>
<li>grib_data_eof_proc
: <a class="el" href="group__context.html#g49b4be77db1a3764ca291e7b45fce366">grib_api.h</a>
<li>grib_data_read_proc
: <a class="el" href="group__context.html#gfcaeb1a8fb78e0028906ee1e2ddbfcc0">grib_api.h</a>
<li>grib_data_seek_proc
: <a class="el" href="group__context.html#g9d4894f207e7f5d70533371915e45a2d">grib_api.h</a>
<li>grib_data_tell_proc
: <a class="el" href="group__context.html#g5fc575ad1d5736763f2d688b82597b09">grib_api.h</a>
<li>grib_data_write_proc
: <a class="el" href="group__context.html#g85f5907a2b006b370be8e176e92d0248">grib_api.h</a>
<li>grib_free_proc
: <a class="el" href="group__context.html#g807998f481ebb5ab8916b23669bc38ca">grib_api.h</a>
<li>grib_handle
: <a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_api.h</a>
<li>grib_index
: <a class="el" href="group__grib__index.html#g33fe0de8d4b8ef9ab3cced622f091e43">grib_api.h</a>
<li>grib_iterator
: <a class="el" href="grib__api_8h.html#8f20a42a04122a55dec71774c70a51c5">grib_api.h</a>
<li>grib_keys_iterator
: <a class="el" href="group__keys__iterator.html#gfa22412541f9d2df9680a82371036dbb">grib_api.h</a>
<li>grib_log_proc
: <a class="el" href="group__context.html#gba007477d7d085d602184ae4df95f994">grib_api.h</a>
<li>grib_malloc_proc
: <a class="el" href="group__context.html#ge40ef151522f628d0a0300861e1869e0">grib_api.h</a>
<li>grib_multi_handle
: <a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_api.h</a>
<li>grib_nearest
: <a class="el" href="grib__api_8h.html#1b47558cfe02835ba44213ee4d45fd9b">grib_api.h</a>
<li>grib_print_proc
: <a class="el" href="group__context.html#gd18d790f8aabf46e6b766eab07b535a0">grib_api.h</a>
<li>grib_realloc_proc
: <a class="el" href="group__context.html#gcfc03db8667b1019d896ab2ab47dc12d">grib_api.h</a>
</ul>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,281 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_compare</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_compare">grib_compare</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Compare grib messages contained in two files. If some differences are found it fails returning an error code. Floating point values are compared exactly by default, different tolerance can be defined see -P -A -R. Default behaviour: absolute error=0, bit-by-bit compare, same order in files.<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_compare [options] grib_file grib_file<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-r <br>
Compare files in which the messages are not in the same order. This option is time expensive. <br>
<br>
-b key,key,... <br>
All the keys in this list are skipped in the comparison. Bit-by-bit compare on. <br>
<br>
-e <br>
edition independent compare. It is used to compare grib edition 1 and 2. <br>
<br>
-c key[:l/d/s/n],key[:l/d/s/n],... <br>
Only the listed keys or namespaces (:n) are compared. The optional letter after the colon is used to force the type in the comparison: l-&gt;integer, d-&gt;float, s-&gt;string, n-&gt;namespace. See -a option. Incompatible with -H option. <br>
<br>
-a <br>
-c option modifier. The keys listed with the option -c will be added to the list of keys compared without -c. <br>
<br>
-H <br>
Compare only message headers. Bit-by-bit compare on. Incompatible with -c option. <br>
<br>
-R key1=relative_error1,key2=relative_error2,... <br>
Compare floating point values using the relative error as tolerance. key1=relative_error will compare key1 using relative_error1. all=relative_error will compare all the floating point keys using relative_error. Default all=0. <br>
<br>
-A absolute error <br>
Compare floating point values using the absolute error as tolerance. Default is absolute error=0 <br>
<br>
-P <br>
Compare data values using the packing error as tolerance. <br>
<br>
-T factor <br>
Compare data values using factor multipied by the tolerance specified in options -P -R -A. <br>
<br>
-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,... <br>
Where clause. Grib messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be specified. Default type is string. <br>
<br>
-f <br>
Force. Force the execution not to fail on error. <br>
<br>
-V <br>
Version. <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
-v <br>
Verbose. <br>
<br>
<h2><a class="anchor" name="grib_compare_examples">
grib_compare examples</a></h2>
<ol type=1>
<li>The default behaviour for grib_compare without any option is to perform a bit by bit comparison of the two messages. If the messages are found to be bitwise different then grib_compare switches to a "key based" mode to find out which coded keys are different. To see how grib_compare works we first set the shortName=2d (2 metre dew point temperature) in the file regular_latlon_surface.grib1<br>
<div class="fragment"><pre class="fragment">
&gt;grib_set -s shortName=2d regular_latlon_surface.grib1 2d.grib1
</pre></div> Then we can compare the two fields with grib_compare.<br>
<div class="fragment"><pre class="fragment">
&gt;grib_compare regular_latlon_surface.grib1 2d.grib1
-- GRIB #1 -- shortName=2t paramId=167 stepRange=0 levelType=sfc level=0 packingType=grid_simple gridType=regular_ll --
long [indicatorOfParameter]: [167] != [168]
</pre></div> In the output we see that the only "coded" key with different values in the two messages is indicatorOfParameter which is the relevant key for the parameter information. The comparison can be forced to be successful listing the keys with different values in the -b option. <div class="fragment"><pre class="fragment">
&gt;grib_compare -b indicatorOfParameter regular_latlon_surface.grib1 2d.grib1
</pre></div> <br>
<br>
</li><li>Two grib messages can be very different because they have different edition, but they can contain the same identical information in the header and the same data. To see how grib_compare can help in comparing messages with different edition we do <div class="fragment"><pre class="fragment">
&gt;grib_set edition=2 reduced_gaussian_model_level.grib1 reduced_gaussian_model_level.grib2
</pre></div> Then we compare the two fields with grib_compare.<br>
<div class="fragment"><pre class="fragment">
&gt;grib_compare reduced_gaussian_model_level.grib1 reduced_gaussian_model_level.grib2
-- GRIB #1 -- shortName=t paramId=130 stepRange=0 levelType=ml level=1 packingType=grid_simple gridType=reduced_gg --
long [totalLength]: [10908] != [10996]
long [editionNumber]: [1] != [2]
long [section1Length]: [52] != [21]
[table2Version] not found in 2nd field
[gridDefinition] not found in 2nd field
[indicatorOfParameter] not found in 2nd field
[indicatorOfTypeOfLevel] not found in 2nd field
[yearOfCentury] not found in 2nd field
[unitOfTimeRange] not found in 2nd field
[P1] not found in 2nd field
[P2] not found in 2nd field
[numberIncludedInAverage] not found in 2nd field
[numberMissingFromAveragesOrAccumulations] not found in 2nd field
[centuryOfReferenceTimeOfData] not found in 2nd field
[reservedNeedNotBePresent] not found in 2nd field
[localDefinitionNumber] not found in 2nd field
[perturbationNumber] not found in 2nd field
[numberOfForecastsInEnsemble] not found in 2nd field
[padding_local1_1] not found in 2nd field
long [section2Length]: [896] != [17]
[pvlLocation] not found in 2nd field
[dataRepresentationType] not found in 2nd field
long [latitudeOfFirstGridPoint]: [87864] != [87864000]
long [latitudeOfLastGridPoint]: [-87864] != [-87864000]
long [longitudeOfLastGridPoint]: [357188] != [357188000]
[padding_grid4_1] not found in 2nd field
long [section4Length]: [9948] != [770]
[dataFlag] not found in 2nd field
</pre></div> It is clear that the two messages are coded in a very different way. If we now add the -e option, the tool will compare only the higher level information common between the two messages. <div class="fragment"><pre class="fragment">
&gt;grib_compare -e reduced_gaussian_model_level.grib1 reduced_gaussian_model_level.grib2
</pre></div> The comparison is successful because the two messages contain the same information coded in two different ways. We can display the list of keys used by grib_compare adding the option -v (verbose). <div class="fragment"><pre class="fragment">
&gt;grib_compare -ve reduced_gaussian_model_level.grib1 reduced_gaussian_model_level.grib2
reduced_gaussian_model_level.grib2
comparing centre as string
comparing paramId as string
comparing shortName as string
comparing typeOfLevel as string
comparing level as long
comparing pv as double (184 values) tolerance=0
comparing latitudeOfFirstGridPointInDegrees as double (1 values) tolerance=0.0005
comparing longitudeOfFirstGridPointInDegrees as double (1 values) tolerance=0.0005
comparing latitudeOfLastGridPointInDegrees as double (1 values) tolerance=0.0005
comparing longitudeOfLastGridPointInDegrees as double (1 values) tolerance=0.0005
comparing iDirectionIncrementInDegrees is set to missing in both fields
comparing N as long
comparing iScansNegatively as long
comparing jScansPositively as long
comparing jPointsAreConsecutive as long
comparing pl as long
comparing gridType as string
comparing packedValues as double (6114 values) tolerance=0
comparing param as string
comparing levtype as string
comparing levelist as long
comparing date as long
comparing time as long
comparing step as long
comparing class as long
comparing type as long
comparing stream as long
comparing expver as string
comparing domain as string
1 of 1 grib messages in reduced_gaussian_model_level.grib2
1 of 1 total grib messages in 1 files
</pre></div> For each key the type used in the comparison is reported and for the floating point keys also the tolerance used is printed. <br>
<br>
</li><li>Some options are provided to compare only a set of keys in the messages. The option -H is used to compare only the headers coded in the message, it doesn't compare the data values. The option "-c key1:[l/d/s/n],key2:[l/d/s/n],... " can be used to compare a set of keys or namespaces. The letter after the colon is optional and it is used to force the type used in the comparison which is otherwise assumed to be the native type of the key. The possible types are:<ul>
<li>:l -&gt; integer (C type long)</li><li>:d -&gt; floating point (C type double)</li><li>:s -&gt; string</li><li>:n -&gt; namespace.</li></ul>
When the type "n" is used all the set of keys belonging to the specified namespace are compared assuming their own native type. To illustrate how these options work we change the values coded in a message using grib_filter with the following rules file (see <a class="el" href="grib_filter.html">grib_filter</a>). <div class="fragment"><pre class="fragment">
set bitsPerValue=10;
set values={1,2.5,3,4,5,6,70};
write "first.grib1";
set values={1,2.5,5,4,5,6,70};
write "second.grib1";
</pre></div> We first compare the two files using the -H option (only headers are compared). <div class="fragment"><pre class="fragment">
&gt;grib_compare -H first.grib1 second.grib1
</pre></div> The comparison is successful because the data are not compared. To compare only the data we have to compare the "data namespace". <div class="fragment"><pre class="fragment">
&gt;grib_compare -c data:n first.grib1 second.grib1
-- GRIB #1 -- shortName=t paramId=130 stepRange=0 levelType=ml level=1 packingType=grid_simple gridType=reduced_gg --
double [packedValues]: 1 out of 7 different, max absolute diff. = 2, relative diff. = 0.4
max diff. element 2: 3.00000000000000000000e+00 5.00000000000000000000e+00
tolerance=0 packingError: [0.04] [0.04]
values max= [70.04] [70.04] min= [1] [1]
</pre></div> The comparison is showing that one of seven values is different in a comparison with the (default) absolute tolerance=0. We can change the tolerance with the -A option: <div class="fragment"><pre class="fragment">
&gt;grib_compare -A 2 -c data:n first.grib1 second.grib1
</pre></div> and we see that the comparison is successful if the absolute tolerance is set to 2. We can also set the relative tolerance for each key with the option -R: <div class="fragment"><pre class="fragment">
&gt;grib_compare -R packedValues=0.4 -c data:n first.grib1 second.grib1
</pre></div> and we get again a successful comparison because the relative tolerance is bigger than the relative absolute difference of two corresponding values. Another possible choice for the tolerance is to be equal to the packingError, which is the error due to the packing algorithm. If we change the decimalPrecision of a packed field we introduce a packing error sometimes bigger than the original packing error. <div class="fragment"><pre class="fragment">
&gt;grib_set -s changeDecimalPrecision=0 first.grib1 third.grib1
</pre></div> and we compare the two fields using the -P option (tolerance=packingError). <div class="fragment"><pre class="fragment">
&gt;grib_compare -P -c data:n first.grib1 third.grib1
</pre></div> the comparison is successful because their difference is within the biggest of the two packing error. With the option -P the comparison is failing only if the original data coded are different, not if the packing precision is changed. If we try again to compare the fields without the -P option: <div class="fragment"><pre class="fragment">
&gt;grib_compare -c data:n first.grib1 third.grib1
-- GRIB #1 -- shortName=t paramId=130 stepRange=0 levelType=ml level=1 packingType=grid_simple gridType=reduced_gg --
double [packedValues]: 4 out of 7 different, max absolute diff. = 0.48, relative diff. = 0.16
max diff. element 1: 2.52000000000000001776e+00 3.00000000000000000000e+00
tolerance=0 packingError: [0.04] [0.5]
values max= [70.04] [70] min= [1] [1]
</pre></div> we see that some values are different and that the maximum absolute differenc is close to the biggest packing error (max diff=0.48 packingError=0.5). The packing error was chosen to be 0.5 by setting decimalPrecision to 0 which means that we don't need to preserve any decimal figure.<br>
<br>
</li><li>When we already know that the fields are not numerically identical, but have similar statistical characteristics we can compare their statistics namespaces: <div class="fragment"><pre class="fragment">
&gt;grib_compare -c statistics:n first.grib1 third.grib1
-- GRIB #1 -- shortName=t paramId=130 stepRange=0 levelType=ml level=1 packingType=grid_simple gridType=reduced_gg --
double [max]: [7.00400000000000062528e+01] != [7.00000000000000000000e+01]
absolute diff. = 0.04, relative diff. = 0.000571102
tolerance=0
double [avg]: [1.30914285714285707485e+01] != [1.31428571428571423496e+01]
absolute diff. = 0.0514286, relative diff. = 0.00391304
tolerance=0
double [sd]: [2.32994686809877009637e+01] != [2.32589679873534969090e+01]
absolute diff. = 0.0405007, relative diff. = 0.00173827
tolerance=0
double [skew]: [-1.41592875700515623549e+01] != [-1.41669971380493855406e+01]
absolute diff. = 0.00770957, relative diff. = 0.000544192
tolerance=0
double [kurt]: [7.32364710785659567271e-01] != [7.32723797489455375143e-01]
absolute diff. = 0.000359087, relative diff. = 0.000490071
tolerance=0
</pre></div> and we see that maximum, minimum, average, standard deviation, skewness and kurtosis are compared. While the values are different by 0.48 the statistics comparison shows that the difference in the statistical values is never bigger than 0.052 <div class="fragment"><pre class="fragment">
&gt;grib_compare -A 0.052 -c statistics:n first.grib1 third.grib1
</pre></div> The statistics namespace is available also for spherical harmonics data and provides information about the field in the geographic space computing them in the spectral space for performance reasons. <br>
<br>
</li><li>When a file contains several fields and some keys are different, it is useful to have a summary report of the keys found different in the messages. This can be obtained with the option -f. We change few keys in a file: <div class="fragment"><pre class="fragment">
&gt;grib_set -w typeOfLevel=surface -s step=48 tigge_pf_ecmwf.grib2 out.grib2
</pre></div> and comparing with the -f option: <div class="fragment"><pre class="fragment">
&gt;grib_compare -f tigge_pf_ecmwf.grib2 out.grib2
-- GRIB #9 -- shortName=skt paramId=235 stepRange=96 levelType=sfc level=0 packingType=grid_simple gridType=regular_ll --
long [forecastTime]: [96] != [48]
-- GRIB #10 -- shortName=sd paramId=228141 stepRange=96 levelType=sfc level=0 packingType=grid_simple gridType=regular_ll --
long [forecastTime]: [96] != [48]
-- GRIB #11 -- shortName=sf paramId=228144 stepRange=0-96 levelType=sfc level=0 packingType=grid_simple gridType=regular_ll --
long [dayOfEndOfOverallTimeInterval]: [26] != [24]
long [lengthOfTimeRange]: [96] != [48]
... output deleted
## ERRORS SUMMARY #######
##
## Summary of different key values
## forecastTime ( 3 different )
## dayOfEndOfOverallTimeInterval ( 11 different )
## lengthOfTimeRange ( 11 different )
##
## 14 different messages out of 38
</pre></div> we get a list of all the different messages in the files and a summary report of the different keys. <br>
<br>
</li><li>We can change the order of the messages in a file using grib_copy with the -B option: <div class="fragment"><pre class="fragment">
&gt;grib_copy -B typeOfLevel tigge_pf_ecmwf.grib2 out.grib2
</pre></div> If we now compare the two files: <div class="fragment"><pre class="fragment">
&gt;grib_compare -f tigge_pf_ecmwf.grib2 out.grib2
-- GRIB #1 -- shortName=10u paramId=165 stepRange=96 levelType=sfc level=10 packingType=grid_simple gridType=regular_ll --
long [discipline]: [0] != [2]
long [totalLength]: [1555] != [990]
long [parameterCategory]: [2] != [0]
long [parameterNumber]: [2] != [22]
long [scaledValueOfFirstFixedSurface]: [10] != [0]
long [typeOfSecondFixedSurface]: [255] != [106]
scaleFactorOfSecondFixedSurface is set to missing in 1st field is not missing in 2nd field
scaledValueOfSecondFixedSurface is set to missing in 1st field is not missing in 2nd field
long [numberOfValues]: [684] != [239]
double [referenceValue]: [-1.57229328155517578125e+01] != [4.15843811035156250000e+01]
absolute diff. = 57.3073, relative diff. = 1.3781
tolerance=3.8147e-06
long [binaryScaleFactor]: [-10] != [-15]
long [bitsPerValue]: [16] != [24]
long [section6Length]: [6] != [92]
long [bitMapIndicator]: [255] != [0]
long [section7Length]: [1373] != [722]
[codedValues] has different size: 1st field: 684, 2nd field: 239
... very long output
</pre></div> the comparison is failing because of the different order of the messages. We can use the -r option to compare the files assuming that the messages are not in the same order: <div class="fragment"><pre class="fragment">
&gt;grib_compare -r tigge_pf_ecmwf.grib2 out.grib2
</pre></div> and we have a successful comparison because for each message in the first file an identical message is found in the second file. This option should be used carefully as it is very time expensive.</li></ol>
<p>
<br>
<br>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,59 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_convert</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_convert">grib_convert</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
It converts grib messages applying the rules from a conversion_rules file. The rules are of the type "keyname = value;" and if blocks are allowed as if ( keyname1 == value1 || keyname2 != value2 &amp;&amp; keyname3 == value3 ) { keyname4 = value4; }<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_convert [options] conversion_rules grib_file grib_file ... output_grib_file<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-f <br>
Force. Force the execution not to fail on error. <br>
<br>
-M <br>
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
<br>
-g <br>
Copy GTS header. <br>
<br>
-G <br>
GRIBEX compatibility mode. <br>
<br>
-V <br>
Version. <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
-v <br>
Verbose. <br>
<br>
<h2><a class="anchor" name="grib_convert_examples">
grib_convert examples</a></h2>
The following grib_convert rules convert all the grib messages contained in the input files in grib edition 2 and if a 2 metre temperature is found also the keys contained in the culy bracket are changed.<br>
<div class="fragment"><pre class="fragment">editionNumber = 2;
<span class="keywordflow">if</span>( indicatorOfParameter == 11 &amp;&amp; indicatorOfTypeOfLevel == 105)
{
productDefinitionTemplateNumber = 1;
typeOfFirstFixedSurface = 103;
scaleFactorOfFirstFixedSurface = 0;
scaledValueOfFirstFixedSurface = 2;
}
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,82 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_copy</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_copy">grib_copy</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Copies the content of grib files printing values of some keys.<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_copy [options] grib_file grib_file ... output_grib_file<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-f <br>
Force. Force the execution not to fail on error. <br>
<br>
-r <br>
Repack data. Sometimes after setting some keys involving properties of the packing algorithm a repacking of data is needed. This repacking is performed setting this -r option. <br>
<br>
-p key[:{s/d/l}],key[:{s/d/l}],... <br>
Declaration of keys to print. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be requested. Default type is string. <br>
<br>
-P key[:{s/d/l}],key[:{s/d/l}],... <br>
As -p adding the declared keys to the default list. <br>
<br>
-w key[:{s/d/l}]=value,key[:{s/d/l}]=value,... <br>
Where clause. Only grib messages matching the key/value constraints are copied to the output_grib_file. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be defined. Default type is string. <br>
<br>
-B order by directive <br>
Order by. The output will be ordered according the order by directive. Order by example: "step asc, centre desc" (step ascending and centre discending) <br>
<br>
-V <br>
Version. <br>
<br>
-W width <br>
Minimum width of each column in output. Default is 10. <br>
<br>
-M <br>
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
<br>
-g <br>
Copy GTS header. <br>
<br>
-G <br>
GRIBEX compatibility mode. <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
-v <br>
Verbose. <br>
<br>
<h2><a class="anchor" name="grib_copy_examples">
grib_copy examples</a></h2>
<ol type=1>
<li>To copy only the pressure levels from a file<br>
<div class="fragment"><pre class="fragment">
&gt; grib_copy -w levtype=pl ../data/tigge_pf_ecmwf.grib2 out.grib
</pre></div><br>
</li><li>To copy only the fields that are not on pressure levels from a file<br>
<div class="fragment"><pre class="fragment">
&gt; grib_copy -w levtype!=pl ../data/tigge_pf_ecmwf.grib2 out.grib
</pre></div><br>
</li><li>A grib_file with multi field messages can be converted in single field messages with a simple grib_copy.<br>
<div class="fragment"><pre class="fragment">
&gt; grib_copy multi.grib simple.grib
</pre></div><br>
</li></ol>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,649 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_debug</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_debug">grib_debug</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Dump the content of a grib file in debug mode.<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_debug [options] grib_file grib_file ...<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-V <br>
Version. <br>
<br>
<h2><a class="anchor" name="grib_debug_examples">
grib_debug examples</a></h2>
Dumping in a WMO documentation style with hexadecimal octet values (-H)<br>
and with the aliases of each key listed in square brackets (-a).<br>
<br>
grib_dump -Ha ../data/reduced_gaussian_model_level.grib1<br>
<div class="fragment"><pre class="fragment">
***** FILE: ../data/reduced_gaussian_model_level.grib1
====================== MESSAGE 1 ( length=10142 ) ======================
====================== SECTION_0 ( length=0, padding=0 ) ======================
1-4 identifier = GRIB
5-7 totalLength = 10142 ( 0x00 0x27 0x9E )
8 editionNumber = 1 ( 0x01 ) [ls.edition]
====================== SECTION_1 ( length=52, padding=0 ) ======================
1-3 section1Length = 52 ( 0x00 0x00 0x34 )
4 gribTablesVersionNo = 128 ( 0x80 ) [table2Version]
5 identificationOfOriginatingGeneratingCentre = 98 ( 0x62 ) [European Center for Medium-Range Weather Forecasts (grib1/0.table) ] [ls.centre, identificationOfCentre, originatingCentre]
6 generatingProcessIdentifier = 128 ( 0x80 ) [generatingProcessIdentificationNumber, process]
7 gridDefinition = 255 ( 0xFF )
8 section1Flags = 128 [10000000]
9 indicatorOfParameter = 130 ( 0x82 ) [T Temperature K (grib1/2.98.128.table) ]
10 indicatorOfTypeOfLevel = 109 ( 0x6D ) [Hybrid level level number (2 octets) (grib1/3.table) ] [ls.levelType, typeOfLevel, typeOfFirstFixedSurface, mars.levtype]
11-12 lev = 1 ( 0x00 0x01 ) [topLevel, bottomLevel, ls.level, mars.levelist]
13 yearOfCentury = 7 ( 0x07 )
14 month = 3 ( 0x03 )
15 day = 18 ( 0x12 )
16 hour = 12 ( 0x0C )
17 minute = 0 ( 0x00 )
18 indicatorOfUnitOfTimeRange = 1 ( 0x01 ) [Hour (grib1/4.table) ]
19 periodOfTime = 0 ( 0x00 ) [P1]
20 periodOfTimeIntervals = 0 ( 0x00 ) [P2]
21 timeRangeIndicator = 0 ( 0x00 ) [Forecast product valid at reference time + P1 (P1&gt;0) (grib1/5.table) ]
22-23 numberIncludedInAverage = 0 ( 0x00 0x00 )
24 numberMissingFromAveragesOrAccumulations = 0 ( 0x00 )
25 centuryOfReferenceTimeOfData = 21 ( 0x15 )
26 identificationOfOriginatingGeneratingSubCentre = 0 ( 0x00 ) [Absent (grib1/0.table) ] [subCentre]
27-28 decimalScaleFactor = 2 ( 0x00 0x02 )
29-40 reservedNeedNotBePresent = 12 {
00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
} # pad reservedNeedNotBePresent
41 localDefinitionNumber = 1 ( 0x01 )
42 marsClass = 1 ( 0x01 ) [Operational archive (mars/class.table) ] [mars.class]
43 marsType = 2 ( 0x02 ) [Analysis (mars/type.table) ] [ls.dataType, mars.type]
44-45 marsStream = 1025 ( 0x04 0x01 ) [Atmospheric model (mars/stream.table) ] [mars.stream]
46-49 experimentVersionNumber = 0001 [mars.expver]
50 perturbationNumber = 0 ( 0x00 )
51 numberOfForecastsInEnsemble = 0 ( 0x00 )
52 padding_local1_1 = 1 {
00
} # pad padding_local1_1
====================== SECTION_2 ( length=896, padding=0 ) ======================
1-3 section2Length = 896 ( 0x00 0x03 0x80 )
4 numberOfVerticalCoordinateValues = 184 ( 0xB8 ) [NV, numberOfCoordinatesValues]
5 pvlLocation = 33 ( 0x21 )
6 dataRepresentationType = 4 ( 0x04 ) [Gaussian Latitude/Longitude Grid (grib1/6.table) ]
7-8 numberOfPointsAlongAParallel = MISSING ( 0xFF 0xFF ) [geography.Ni]
9-10 numberOfPointsAlongAMeridian = 64 ( 0x00 0x40 ) [geography.Nj]
11-13 latitudeOfFirstGridPoint = 87864 ( 0x01 0x57 0x38 ) [La1]
14-16 longitudeOfFirstGridPoint = 0 ( 0x00 0x00 0x00 ) [Lo1]
17 resolutionAndComponentFlags = 0 [00000000]
18-20 latitudeOfLastGridPoint = -87864 ( 0x81 0x57 0x38 ) [La2]
21-23 longitudeOfLastGridPoint = 357188 ( 0x05 0x73 0x44 ) [Lo2]
24-25 iDirectionIncrement = MISSING ( 0xFF 0xFF ) [Di]
26-27 numberOfParallelsBetweenAPoleAndTheEquator = 32 ( 0x00 0x20 )
28 scanningMode = 0 [00000000]
29-32 padding_grid4_1 = 4 {
00, 00, 00, 00
} # pad padding_grid4_1
33-768 pv = (184,736) {
0, 2.00004, 3.98083, 7.38719, 12.9083, 21.4136, 33.9529, 51.7466,
76.1677, 108.716, 150.986, 204.637, 271.356, 352.824, 450.686, 566.519,
701.813, 857.946, 1036.17, 1237.59, 1463.16, 1713.71, 1989.87, 2292.16,
2620.9, 2976.3, 3358.43, 3767.2, 4202.42, 4663.78, 5150.86, 5663.16,
6199.84, 6759.73, 7341.47, 7942.93, 8564.62, 9208.3, 9873.56, 10558.9,
11262.5, 11982.7, 12713.9, 13453.2, 14192, 14922.7, 15638.1, 16329.6,
16990.6, 17613.3, 18191, 18717, 19184.5, 19587.5, 19919.8, 20175.4,
20348.9, 20434.2, 20426.2, 20319, 20107, 19785.4, 19348.8, 18798.8,
18141.3, 17385.6, 16544.6, 15633.6, 14665.6, 13653.2, 12608.4, 11543.2,
10471.3, 9405.22, 8356.25, 7335.16, 6353.92, 5422.8, 4550.21, 3743.46,
3010.15, 2356.2, 1784.85, 1297.66, 895.194, 576.314, 336.772, 162.043,
54.2083, 6.57563, 0.00316, 0, 0, 0, 0, 0,
0, 0, 0, 0
... 84 more values
} # ibmfloat pv
769-896 pl = (64,128) {
20, 27, 36, 40, 45, 50, 60, 64,
72, 75, 80, 90, 90, 96, 100, 108,
108, 120, 120, 120, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 120, 120, 120, 108,
108, 100, 96, 90, 90, 80, 75, 72,
64, 60, 50, 45, 40, 36, 27, 20
} # unsigned pl
====================== SECTION_4 ( length=9182, padding=0 ) ======================
1-3 section4Length = 9182 ( 0x00 0x23 0xDE )
4 dataFlag = 0 [00000000]
5-6 binaryScaleFactor = 0 ( 0x00 0x00 )
7-10 referenceValue = 17402.8
11 numberOfBitsContainingEachPackedValue = 12 ( 0x0C ) [nbp, numberOfBits, bitsPerValue]
12-9182 values = (6114,9171) {
203.778, 203.468, 202.958, 202.348, 201.758, 201.278, 200.888, 200.558,
200.268, 200.078, 200.068, 200.318, 200.808, 201.458, 202.138, 202.758,
203.248, 203.588, 203.798, 203.878, 205.968, 205.418, 204.438, 203.218,
202.008, 201.128, 200.708, 200.598, 200.478, 200.228, 199.908, 199.528,
199.108, 198.708, 198.528, 198.748, 199.458, 200.488, 201.548, 202.478,
203.358, 204.178, 204.808, 205.198, 205.508, 205.838, 206.068, 207.338,
206.488, 205.198, 203.798, 202.548, 201.528, 200.848, 200.638, 200.818,
201.028, 200.888, 200.308, 199.638, 199.228, 199.018, 198.738, 198.328,
197.868, 197.358, 196.928, 196.858, 197.348, 198.368, 199.638, 200.758,
201.538, 202.288, 203.338, 204.438, 205.158, 205.558, 205.938, 206.438,
207.008, 207.468, 207.638, 207.178, 206.658, 205.398, 203.788, 202.468,
201.338, 200.298, 199.938, 200.318, 200.608, 200.478, 200.008, 199.208,
198.278, 197.708, 197.558, 197.318
... 6014 more values
} # data_g1simple_packing values
====================== SECTION_5 ( length=4, padding=0 ) ======================
1-4 7777 = 7777
</pre></div><br>
<br>
<br>
How to obtain all the key names available in a grib file.<br>
<br>
grib_dump -D ../data/regular_latlon_surface.grib1 <div class="fragment"><pre class="fragment">
***** FILE: ../data/regular_latlon_surface.grib1
====================== MESSAGE 1 ( length=1100 ) ======================
0-0 constant oneConstant = 1
0-0 constant oneMillionConstant = 1000000
0-0 offset_file offset = 0
0-0 count_file count = 1
0-0 count_total countTotal = 1
0-0 lookup kindOfProduct = 1196575042 [GRIB 1196575042 0-4]
0-0 lookup GRIBEditionNumber = 1 [? 1 7-1]
======&gt; section GRIB (1100,1100,0)
0-0 constant grib1divider = 1000
0-0 constant ieeeFloats = 0
0-0 transient dummy = 1
======&gt; section section_0 (0,0,0)
----&gt; label empty
&lt;===== section section_0
0-4 ascii identifier = GRIB
4-7 g1_message_length totalLength = 1100
7-8 unsigned editionNumber = 1 [ls.edition]
======&gt; section section_1 (52,52,0)
8-8 constant ECMWF = 98
8-8 position offsetSection1 = 8
8-11 section_length section1Length = 52
11-12 unsigned gribTablesVersionNo = 128 [table2Version]
12-13 codetable identificationOfOriginatingGeneratingCentre = 98 [European Center for Medium-Range Weather Forecasts (grib1/0.table) ] [ls.centre, identificationOfCentre, originatingCentre]
13-14 unsigned generatingProcessIdentifier = 128 [generatingProcessIdentificationNumber, process]
14-15 unsigned gridDefinition = 255
15-16 codeflag section1Flags = 128 [10000000:(1=1) Section 2 included;(2=0) Section 3 omited:grib1/1.table]
16-17 codetable indicatorOfParameter = 167 [2T 2 metre temperature K (grib1/2.98.128.table) ]
17-17 sprintf marsParam = 167.128 [mars.param, ls.param]
17-18 codetable indicatorOfTypeOfLevel = 1 [Surface (of the Earth, which includes sea surface) (grib1/3.table) ] [ls.levelType, typeOfLevel, typeOfFirstFixedSurface, mars.levtype]
18-20 unsigned lev = 0 [topLevel, bottomLevel, ls.level, mars.levelist]
20-21 unsigned yearOfCentury = 7
21-22 unsigned month = 3
22-23 unsigned day = 18
23-24 unsigned hour = 12
24-25 unsigned minute = 0
25-25 constant second = 0
25-26 codetable indicatorOfUnitOfTimeRange = 1 [Hour (grib1/4.table) ]
26-27 unsigned periodOfTime = 0 [P1]
27-28 unsigned periodOfTimeIntervals = 0 [P2]
28-29 codetable timeRangeIndicator = 0 [Forecast product valid at reference time + P1 (P1&gt;0) (grib1/5.table) ]
29-31 unsigned numberIncludedInAverage = 0
31-32 unsigned numberMissingFromAveragesOrAccumulations = 0
32-33 unsigned centuryOfReferenceTimeOfData = 21
33-34 codetable identificationOfOriginatingGeneratingSubCentre = 0 [Absent (grib1/0.table) ] [subCentre]
34-36 signed decimalScaleFactor = 0
36-36 transient setLocalDefinition = 0
36-48 pad reservedNeedNotBePresent = 12 {
00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
} # pad reservedNeedNotBePresent
48-48 g1date dataDate = 20070318 [mars.date, ls.date]
48-48 evaluate year = 2007
48-48 g1monthlydate monthlyDate = 20070301
48-48 time dataTime = 1200 [mars.time]
48-48 g1startstep marsStartStep = 0 [mars.startStep]
48-48 g1endstep marsEndStep = 0 [mars.endStep]
48-48 g1step marsStep = 0 [mars.step, ls.step, forecastTime]
48-48 g1verificationdate verificationDate = 20070318
48-48 g1monthlydate monthlyVerificationDate = 20070301
48-48 g1day_of_the_year_date dayOfTheYearDate = 2007-078
48-48 constant wrongPadding = 0
48-48 constant localUsePresent = 1
48-48 g1param parameter = 167
48-49 unsigned localDefinitionNumber = 1
======&gt; section localDefinition (11,11,0)
======&gt; section mars_labeling (8,8,0)
49-50 codetable marsClass = 1 [Operational archive (mars/class.table) ] [mars.class]
50-51 codetable marsType = 2 [Analysis (mars/type.table) ] [ls.dataType, mars.type]
51-53 codetable marsStream = 1025 [Atmospheric model (mars/stream.table) ] [mars.stream]
53-57 ksec1expver experimentVersionNumber = 0001 [mars.expver]
57-57 constant SimulationsOf30Days = s3
57-57 constant TYPE_S3 = 22
&lt;===== section mars_labeling
57-58 unsigned perturbationNumber = 0
58-59 unsigned numberOfForecastsInEnsemble = 0
59-60 pad padding_local1_1 = 1 {
00
} # pad padding_local1_1
&lt;===== section localDefinition
60-60 transient centreForTableNumber = 98
60-60 section_padding localExtensionPadding = 0 {}
60-60 section_padding section1Padding = 0 {}
60-60 padtoeven evenpadding_sec1 = 0 {}
60-60 concept grib1_short_name = 2T [ls.short_name]
60-60 concept grib1_name = 2_metre_temperature [name]
60-60 concept grib1_units = K [units]
&lt;===== section section_1
60-60 bit gridDescriptionSectionPresent = 1 [GDSPresent]
60-60 bit bitmapPresent = 0 [bitmapSectionPresent]
======&gt; section section_2 (32,32,0)
60-60 position offsetSection2 = 60
60-63 section_length section2Length = 32
63-64 unsigned numberOfVerticalCoordinateValues = 0 [NV, numberOfCoordinatesValues]
64-64 constant neitherPresent = 255
64-65 unsigned pvlLocation = 255
65-66 codetable dataRepresentationType = 0 [Latitude/Longitude Grid (grib1/6.table) ]
======&gt; section dataRepresentation (22,22,0)
66-66 constant gridDefinitionTemplateNumber = 0
66-68 unsigned numberOfPointsAlongAParallel = 16 [Ni]
68-70 unsigned numberOfPointsAlongAMeridian = 31 [Nj]
70-73 signed latitudeOfFirstGridPoint = 60000 [La1]
73-73 scale latitudeOfFirstGridPointInDegrees = 60 [geography.laFirst]
73-76 signed longitudeOfFirstGridPoint = 0 [Lo1]
76-76 scale longitudeOfFirstGridPointInDegrees = 0 [geography.loFirst]
76-77 codeflag resolutionAndComponentFlags = 128 [10000000:(1=1) Direction increments given;(2=0) Earth assumed spherical with radius = 6367.47 km;(5=0) u and v components resolved relative to easterly and northerly directions:grib1/7.table]
77-77 bit ijDirectionIncrementGiven = 1 [iDirectionIncrementGiven, jDirectionIncrementGiven, DiGiven, DjGiven]
77-77 bit earthIsOblate = 0
77-77 bit resolutionAndComponentFlags3 = 0
77-77 bit resolutionAndComponentFlags4 = 0
77-77 bit uvRelativeToGrid = 0
77-77 bit resolutionAndComponentFlags6 = 0
77-77 bit resolutionAndComponentFlags7 = 0
77-77 bit resolutionAndComponentFlags8 = 0
77-80 signed latitudeOfLastGridPoint = 0 [La2]
80-80 scale latitudeOfLastGridPointInDegrees = 0 [geography.laLast]
80-83 signed longitudeOfLastGridPoint = 30000 [Lo2]
83-83 transient longitudeOfLastGridPointG1to2 = 30000
83-83 scale longitudeOfLastGridPointInDegrees = 30 [geography.loLast]
83-85 unsigned iDirectionIncrement = 2000 [Di]
85-87 unsigned jDirectionIncrement = 2000 [Dj]
87-88 codeflag scanningMode = 0 [00000000:(1=0) Points scan in +i direction;(2=0) Points scan in -j direction;(3=0) Adjacent points in i direction are consecutive :grib1/8.table]
88-88 bit iScansNegatively = 0
88-88 bit jScansPositively = 0
88-88 bit jPointsAreConsecutive = 0
88-88 constant iScansPositively = 1
88-88 bit scanningMode4 = 0
88-88 bit scanningMode5 = 0
88-88 bit scanningMode6 = 0
88-88 bit scanningMode7 = 0
88-88 bit scanningMode8 = 0
88-88 latlon_increment jDirectionIncrementInDegrees = 2 [geography.jInc, geography.gridNorthSouth]
88-88 latlon_increment iDirectionIncrementInDegrees = 2 [geography.iInc, geography.gridWestEast]
----&gt; iterator ITERATOR
&lt;===== section dataRepresentation
88-88 position endGridDefinition = 88
88-88 transient PVPresent = 0
88-88 position offsetBeforePV = 88
88-88 position offsetBeforePL = 88
88-88 transient PLPresent = 0 [reducedGrid]
88-92 padto padding_sec2_1 = 4 {
00, 00, 00, 00
} # padto padding_sec2_1
92-92 padtoeven padding_sec2_3 = 0 {}
&lt;===== section section_2
92-92 position endOfHeadersMaker = 92
92-92 transient missingValue = 9999
92-92 constant tableReference = 0
======&gt; section section_4 (1004,1004,0)
92-92 position offsetSection4 = 92
92-95 g1_section4_length section4Length = 1004
95-95 g1_half_byte_codeflag halfByte = 8
95-96 codeflag dataFlag = 8 [00001000:(1=0) Grid-point data;(2=0) Simple packing;(3=0) Floating point values are represented;(4=0) No additional flags at octet 14:grib1/11.table]
96-98 signed binaryScaleFactor = -10
98-102 ibmfloat referenceValue = 269.587
102-103 unsigned numberOfBitsContainingEachPackedValue = 16 [nbp, numberOfBits, bitsPerValue]
103-103 bit sphericalHarmonics = 0
103-103 bit complexPacking = 0
103-103 bit integerPointValues = 0
103-103 bit additionalFlagPresent = 0
======&gt; section dataValues (993,993,0)
103-103 constant dataRepresentationTemplateNumber = 0
103-103 position offsetBeforeData = 103
103-103 constant bitMapIndicator = 255
103-1096 data_g1simple_packing values = (496,993) {
277.704, 277.797, 278.103, 274.598, 269.587, 278.345, 277.213, 278.19,
277.853, 276.747, 274.361, 273.636, 274.593, 273.782, 273.016, 274.316,
278.492, 278.792, 278.836, 278.333, 277.389, 278.525, 278.175, 277.255,
277.383, 278.047, 277.877, 276.213, 273.99, 278.333, 278.58, 277.642,
278.865, 278.997, 278.509, 278.983, 279.527, 279.414, 278.8, 278.749,
278.895, 279.056, 278.699, 278.426, 276.601, 277.491, 279.646, 279.198,
279.108, 279.156, 279.406, 279.527, 280.344, 280.869, 279.951, 281.621,
281.221, 280.676, 281.049, 280.354, 279.025, 278.192, 280.05, 280.375,
280.68, 281.269, 281.406, 281.483, 279.454, 280.641, 282.984, 282.578,
281.797, 281.542, 281.854, 281.5, 279.917, 280.529, 282.008, 281.102,
282.223, 282.727, 280.315, 278.539, 280.066, 280.789, 280.517, 282.883,
283.897, 285.161, 285.779, 285.847, 281.973, 282.869, 281.926, 280.816,
282.48, 281.894, 281.035, 281.722
... 396 more values
} # data_g1simple_packing values
&lt;===== section dataValues
1096-1096 size valuesCount = 496
1096-1096 concept typeOfGrid = regular_ll [ls.gridType]
1096-1096 concept typeOfPacking = grid_simple [ls.packingType, dataRepresentation]
1096-1096 padtoeven padding_sec4_1 = 0 {}
&lt;===== section section_4
======&gt; section section_5 (4,4,0)
----&gt; label gribSection5
1096-1096 position offsetSection5 = 1096
1096-1100 ascii 7777 = 7777
&lt;===== section section_5
&lt;===== section GRIB
</pre></div><br>
<br>
<br>
How to obtain a C code example from a grib file.<br>
<br>
grib_dump -C ../data/regular_latlon_surface.grib1<br>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>&gt;</span>
<span class="comment">/* This code was generated automatically */</span>
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc,<span class="keyword">const</span> <span class="keywordtype">char</span>** argv)
{
<a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h = NULL;
<span class="keywordtype">size_t</span> size = 0;
<span class="keywordtype">double</span>* v = NULL;
FILE* f = NULL;
<span class="keyword">const</span> <span class="keywordtype">char</span>* p = NULL;
<span class="keyword">const</span> <span class="keywordtype">void</span>* buffer = NULL;
<span class="keywordflow">if</span>(argc != 2) {
fprintf(stderr,<span class="stringliteral">"usage: %s out\n"</span>,argv[0]);
exit(1);
}
h = <a class="code" href="group__grib__handle.html#g11d247e5afa10bd52fb895dc4296143f" title="Create a handle from a read_only template resource.">grib_handle_new_from_template</a>(NULL,<span class="stringliteral">"GRIB2"</span>);
<span class="keywordflow">if</span>(!h) {
fprintf(stderr,<span class="stringliteral">"Cannot create grib handle\n"</span>);
exit(1);
}
<span class="comment">/* empty */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"editionNumber"</span>,1),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"gribTablesVersionNo"</span>,128),0);
<span class="comment">/* 98 = European Center for Medium-Range Weather Forecasts (grib1/0.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"identificationOfOriginatingGeneratingCentre"</span>,98),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"generatingProcessIdentifier"</span>,128),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"gridDefinition"</span>,255),0);
<span class="comment">/* 128 = 10000000</span>
<span class="comment"> (1=1) Section 2 included</span>
<span class="comment"> (2=0) Section 3 omited</span>
<span class="comment"> See grib1/1.table */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"section1Flags"</span>,128),0);
<span class="comment">/* 167 = 2T 2 metre temperature K (grib1/2.98.128.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"indicatorOfParameter"</span>,167),0);
<span class="comment">/* 1 = Surface (of the Earth, which includes sea surface) (grib1/3.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"indicatorOfTypeOfLevel"</span>,1),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"lev"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"yearOfCentury"</span>,7),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"month"</span>,3),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"day"</span>,18),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"hour"</span>,12),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"minute"</span>,0),0);
<span class="comment">/* 1 = Hour (grib1/4.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"indicatorOfUnitOfTimeRange"</span>,1),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"periodOfTime"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"periodOfTimeIntervals"</span>,0),0);
<span class="comment">/* 0 = Forecast product valid at reference time + P1 (P1&gt;0) (grib1/5.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"timeRangeIndicator"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberIncludedInAverage"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberMissingFromAveragesOrAccumulations"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"centuryOfReferenceTimeOfData"</span>,21),0);
<span class="comment">/* 0 = Absent (grib1/0.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"identificationOfOriginatingGeneratingSubCentre"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"decimalScaleFactor"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"localDefinitionNumber"</span>,1),0);
<span class="comment">/* 1 = Operational archive (mars/class.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"marsClass"</span>,1),0);
<span class="comment">/* 2 = Analysis (mars/type.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"marsType"</span>,2),0);
<span class="comment">/* 1025 = Atmospheric model (mars/stream.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"marsStream"</span>,1025),0);
p = <span class="stringliteral">"0001"</span>;
size = strlen(p)+1;
GRIB_CHECK(<a class="code" href="group__get__set.html#g78143cc64571b454b0aba14246e9a53a" title="Set a string value from a key.">grib_set_string</a>(h,<span class="stringliteral">"experimentVersionNumber"</span>,p,&amp;size),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"perturbationNumber"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberOfForecastsInEnsemble"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberOfVerticalCoordinateValues"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"pvlLocation"</span>,255),0);
<span class="comment">/* 0 = Latitude/Longitude Grid (grib1/6.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"dataRepresentationType"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberOfPointsAlongAParallel"</span>,16),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberOfPointsAlongAMeridian"</span>,31),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"latitudeOfFirstGridPoint"</span>,60000),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"longitudeOfFirstGridPoint"</span>,0),0);
<span class="comment">/* 128 = 10000000</span>
<span class="comment"> (1=1) Direction increments given</span>
<span class="comment"> (2=0) Earth assumed spherical with radius = 6367.47 km</span>
<span class="comment"> (5=0) u and v components resolved relative to easterly and northerly directions</span>
<span class="comment"> See grib1/7.table */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"resolutionAndComponentFlags"</span>,128),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"latitudeOfLastGridPoint"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"longitudeOfLastGridPoint"</span>,30000),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"iDirectionIncrement"</span>,2000),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"jDirectionIncrement"</span>,2000),0);
<span class="comment">/* 0 = 00000000</span>
<span class="comment"> (1=0) Points scan in +i direction</span>
<span class="comment"> (2=0) Points scan in -j direction</span>
<span class="comment"> (3=0) Adjacent points in i direction are consecutive </span>
<span class="comment"> See grib1/8.table */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"scanningMode"</span>,0),0);
<span class="comment">/* ITERATOR */</span>
<span class="comment">/* 8 = 00001000</span>
<span class="comment"> (1=0) Grid-point data</span>
<span class="comment"> (2=0) Simple packing</span>
<span class="comment"> (3=0) Floating point values are represented</span>
<span class="comment"> (4=0) No additional flags at octet 14</span>
<span class="comment"> See grib1/11.table */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"dataFlag"</span>,8),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberOfBitsContainingEachPackedValue"</span>,16),0);
size = 496;
v = (<span class="keywordtype">double</span>*)calloc(size,<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<span class="keywordflow">if</span>(!v) {
fprintf(stderr,<span class="stringliteral">"failed to allocate %d bytes\n"</span>,size*<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
exit(1);
}
v[ 0] = 277.704; v[ 1] = 277.797; v[ 2] = 278.103; v[ 3] = 274.598;
v[ 4] = 269.587; v[ 5] = 278.345; v[ 6] = 277.213; v[ 7] = 278.19;
v[ 8] = 277.853; v[ 9] = 276.747; v[ 10] = 274.361; v[ 11] = 273.636;
v[ 12] = 274.593; v[ 13] = 273.782; v[ 14] = 273.016; v[ 15] = 274.316;
v[ 16] = 278.492; v[ 17] = 278.792; v[ 18] = 278.836; v[ 19] = 278.333;
v[ 20] = 277.389; v[ 21] = 278.525; v[ 22] = 278.175; v[ 23] = 277.255;
v[ 24] = 277.383; v[ 25] = 278.047; v[ 26] = 277.877; v[ 27] = 276.213;
v[ 28] = 273.99; v[ 29] = 278.333; v[ 30] = 278.58; v[ 31] = 277.642;
v[ 32] = 278.865; v[ 33] = 278.997; v[ 34] = 278.509; v[ 35] = 278.983;
v[ 36] = 279.527; v[ 37] = 279.414; v[ 38] = 278.8; v[ 39] = 278.749;
v[ 40] = 278.895; v[ 41] = 279.056; v[ 42] = 278.699; v[ 43] = 278.426;
v[ 44] = 276.601; v[ 45] = 277.491; v[ 46] = 279.646; v[ 47] = 279.198;
v[ 48] = 279.108; v[ 49] = 279.156; v[ 50] = 279.406; v[ 51] = 279.527;
v[ 52] = 280.344; v[ 53] = 280.869; v[ 54] = 279.951; v[ 55] = 281.621;
v[ 56] = 281.221; v[ 57] = 280.676; v[ 58] = 281.049; v[ 59] = 280.354;
v[ 60] = 279.025; v[ 61] = 278.192; v[ 62] = 280.05; v[ 63] = 280.375;
v[ 64] = 280.68; v[ 65] = 281.269; v[ 66] = 281.406; v[ 67] = 281.483;
v[ 68] = 279.454; v[ 69] = 280.641; v[ 70] = 282.984; v[ 71] = 282.578;
v[ 72] = 281.797; v[ 73] = 281.542; v[ 74] = 281.854; v[ 75] = 281.5;
v[ 76] = 279.917; v[ 77] = 280.529; v[ 78] = 282.008; v[ 79] = 281.102;
v[ 80] = 282.223; v[ 81] = 282.727; v[ 82] = 280.315; v[ 83] = 278.539;
v[ 84] = 280.066; v[ 85] = 280.789; v[ 86] = 280.517; v[ 87] = 282.883;
v[ 88] = 283.897; v[ 89] = 285.161; v[ 90] = 285.779; v[ 91] = 285.847;
v[ 92] = 281.973; v[ 93] = 282.869; v[ 94] = 281.926; v[ 95] = 280.816;
v[ 96] = 282.48; v[ 97] = 281.894; v[ 98] = 281.035; v[ 99] = 281.722;
v[ 100] = 279.978; v[ 101] = 284.138; v[ 102] = 287.234; v[ 103] = 287.831;
v[ 104] = 288.452; v[ 105] = 289.882; v[ 106] = 287.776; v[ 107] = 287.946;
v[ 108] = 281.466; v[ 109] = 284.771; v[ 110] = 283.343; v[ 111] = 282.477;
v[ 112] = 284.723; v[ 113] = 280.869; v[ 114] = 285.693; v[ 115] = 284.132;
v[ 116] = 276.881; v[ 117] = 283.388; v[ 118] = 287.295; v[ 119] = 286.764;
v[ 120] = 291.798; v[ 121] = 291.607; v[ 122] = 290.086; v[ 123] = 286.769;
v[ 124] = 284.24; v[ 125] = 280.884; v[ 126] = 286.866; v[ 127] = 284.694;
v[ 128] = 285.417; v[ 129] = 283.823; v[ 130] = 289.898; v[ 131] = 290.317;
v[ 132] = 287.031; v[ 133] = 287.949; v[ 134] = 289.263; v[ 135] = 289.869;
v[ 136] = 289.926; v[ 137] = 289.535; v[ 138] = 289.817; v[ 139] = 287.768;
v[ 140] = 290.394; v[ 141] = 290.294; v[ 142] = 287.069; v[ 143] = 281.759;
v[ 144] = 289.132; v[ 145] = 287.316; v[ 146] = 287.548; v[ 147] = 287.181;
v[ 148] = 287.645; v[ 149] = 289.492; v[ 150] = 288.956; v[ 151] = 286.634;
v[ 152] = 289.7; v[ 153] = 289.189; v[ 154] = 287.704; v[ 155] = 291.151;
v[ 156] = 286.208; v[ 157] = 291.093; v[ 158] = 284.818; v[ 159] = 282.097;
v[ 160] = 289.244; v[ 161] = 288.263; v[ 162] = 289.545; v[ 163] = 290.018;
v[ 164] = 289.881; v[ 165] = 290.215; v[ 166] = 289.999; v[ 167] = 289.447;
v[ 168] = 284.105; v[ 169] = 290.686; v[ 170] = 288.128; v[ 171] = 290.241;
v[ 172] = 289.116; v[ 173] = 289.576; v[ 174] = 291.8; v[ 175] = 286.35;
v[ 176] = 289.239; v[ 177] = 289.525; v[ 178] = 289.45; v[ 179] = 290.114;
v[ 180] = 290.301; v[ 181] = 289.429; v[ 182] = 290.005; v[ 183] = 287.195;
v[ 184] = 289.823; v[ 185] = 290.313; v[ 186] = 290.792; v[ 187] = 286.693;
v[ 188] = 291.941; v[ 189] = 290.783; v[ 190] = 290.818; v[ 191] = 287.234;
v[ 192] = 287.001; v[ 193] = 287.49; v[ 194] = 286.791; v[ 195] = 286.71;
v[ 196] = 287.182; v[ 197] = 290.49; v[ 198] = 290.322; v[ 199] = 289.957;
v[ 200] = 290.056; v[ 201] = 289.915; v[ 202] = 289.917; v[ 203] = 290.251;
v[ 204] = 290.502; v[ 205] = 290.782; v[ 206] = 291.367; v[ 207] = 291.025;
v[ 208] = 290.326; v[ 209] = 285.912; v[ 210] = 290.003; v[ 211] = 294.341;
v[ 212] = 294.048; v[ 213] = 291.771; v[ 214] = 290.675; v[ 215] = 291.203;
v[ 216] = 291.478; v[ 217] = 290.939; v[ 218] = 290.555; v[ 219] = 289.821;
v[ 220] = 290.126; v[ 221] = 291.021; v[ 222] = 291.243; v[ 223] = 290.761;
v[ 224] = 291.05; v[ 225] = 291.556; v[ 226] = 292.386; v[ 227] = 293.149;
v[ 228] = 293.301; v[ 229] = 291.821; v[ 230] = 290.157; v[ 231] = 293.427;
v[ 232] = 292.629; v[ 233] = 292.25; v[ 234] = 294.59; v[ 235] = 296.421;
v[ 236] = 296.16; v[ 237] = 290.221; v[ 238] = 290.882; v[ 239] = 290.864;
v[ 240] = 294.69; v[ 241] = 294.224; v[ 242] = 294.332; v[ 243] = 293.917;
v[ 244] = 292.863; v[ 245] = 293.005; v[ 246] = 292.814; v[ 247] = 295.443;
v[ 248] = 296.665; v[ 249] = 298.566; v[ 250] = 298.846; v[ 251] = 298.165;
v[ 252] = 297.105; v[ 253] = 294.729; v[ 254] = 294.968; v[ 255] = 293.305;
v[ 256] = 298.003; v[ 257] = 296.402; v[ 258] = 295.03; v[ 259] = 295.649;
v[ 260] = 295.811; v[ 261] = 297.203; v[ 262] = 298.222; v[ 263] = 297.12;
v[ 264] = 299.167; v[ 265] = 298.919; v[ 266] = 298.372; v[ 267] = 297.932;
v[ 268] = 296.47; v[ 269] = 295.208; v[ 270] = 294.647; v[ 271] = 294.034;
v[ 272] = 300.407; v[ 273] = 301.659; v[ 274] = 300.621; v[ 275] = 297.093;
v[ 276] = 295.676; v[ 277] = 298.434; v[ 278] = 298.906; v[ 279] = 302.369;
v[ 280] = 300.815; v[ 281] = 299.277; v[ 282] = 298.643; v[ 283] = 298.381;
v[ 284] = 296.632; v[ 285] = 294.887; v[ 286] = 295.411; v[ 287] = 293.665;
v[ 288] = 303.051; v[ 289] = 304.741; v[ 290] = 304.555; v[ 291] = 301.901;
v[ 292] = 301.846; v[ 293] = 300.793; v[ 294] = 302.141; v[ 295] = 300.521;
v[ 296] = 300.74; v[ 297] = 301.164; v[ 298] = 299.811; v[ 299] = 298.146;
v[ 300] = 298.443; v[ 301] = 293.905; v[ 302] = 295.545; v[ 303] = 296.185;
v[ 304] = 306.254; v[ 305] = 307.698; v[ 306] = 307.503; v[ 307] = 304.62;
v[ 308] = 304.458; v[ 309] = 303.097; v[ 310] = 303.69; v[ 311] = 303.482;
v[ 312] = 303.514; v[ 313] = 304.001; v[ 314] = 299.346; v[ 315] = 298.529;
v[ 316] = 297.935; v[ 317] = 295.495; v[ 318] = 295.846; v[ 319] = 296.122;
v[ 320] = 309.596; v[ 321] = 308.059; v[ 322] = 305.473; v[ 323] = 305.581;
v[ 324] = 306.11; v[ 325] = 303.994; v[ 326] = 304.602; v[ 327] = 304.286;
v[ 328] = 304.18; v[ 329] = 305.511; v[ 330] = 300.083; v[ 331] = 299.69;
v[ 332] = 297.061; v[ 333] = 296.252; v[ 334] = 296.508; v[ 335] = 298.427;
v[ 336] = 309.837; v[ 337] = 309.568; v[ 338] = 308.175; v[ 339] = 306.983;
v[ 340] = 307.399; v[ 341] = 303.002; v[ 342] = 303.582; v[ 343] = 303.765;
v[ 344] = 304.829; v[ 345] = 303.815; v[ 346] = 302.952; v[ 347] = 301.263;
v[ 348] = 296.397; v[ 349] = 298.184; v[ 350] = 297.765; v[ 351] = 299.807;
v[ 352] = 311.829; v[ 353] = 309.43; v[ 354] = 307.672; v[ 355] = 307.068;
v[ 356] = 306.384; v[ 357] = 304.862; v[ 358] = 304.397; v[ 359] = 303.944;
v[ 360] = 304.673; v[ 361] = 304.326; v[ 362] = 303.948; v[ 363] = 302.827;
v[ 364] = 297.377; v[ 365] = 296.722; v[ 366] = 298.711; v[ 367] = 300.744;
v[ 368] = 310.353; v[ 369] = 309.716; v[ 370] = 309.28; v[ 371] = 308.163;
v[ 372] = 306.711; v[ 373] = 305.75; v[ 374] = 304.74; v[ 375] = 305.384;
v[ 376] = 304.885; v[ 377] = 305.735; v[ 378] = 307.71; v[ 379] = 303.764;
v[ 380] = 303.073; v[ 381] = 300.87; v[ 382] = 300.858; v[ 383] = 302.205;
v[ 384] = 311.264; v[ 385] = 311.085; v[ 386] = 310.432; v[ 387] = 308.94;
v[ 388] = 305.619; v[ 389] = 307; v[ 390] = 306.413; v[ 391] = 307.649;
v[ 392] = 308.429; v[ 393] = 309.358; v[ 394] = 309.365; v[ 395] = 307.933;
v[ 396] = 306.15; v[ 397] = 305.126; v[ 398] = 305.611; v[ 399] = 303.336;
v[ 400] = 309.947; v[ 401] = 309.562; v[ 402] = 309.339; v[ 403] = 310.316;
v[ 404] = 308.055; v[ 405] = 307.565; v[ 406] = 310.605; v[ 407] = 308.4;
v[ 408] = 309.219; v[ 409] = 310.801; v[ 410] = 310.525; v[ 411] = 309.65;
v[ 412] = 306.611; v[ 413] = 306.033; v[ 414] = 307.988; v[ 415] = 308.941;
v[ 416] = 308.4; v[ 417] = 307.615; v[ 418] = 307.404; v[ 419] = 308.381;
v[ 420] = 309.778; v[ 421] = 311.715; v[ 422] = 308.409; v[ 423] = 307.156;
v[ 424] = 308.715; v[ 425] = 307.201; v[ 426] = 310.448; v[ 427] = 309.24;
v[ 428] = 306.716; v[ 429] = 307.307; v[ 430] = 309.062; v[ 431] = 309.776;
v[ 432] = 303.033; v[ 433] = 302.76; v[ 434] = 303.071; v[ 435] = 306.578;
v[ 436] = 309.819; v[ 437] = 305.046; v[ 438] = 309.764; v[ 439] = 307.857;
v[ 440] = 301.171; v[ 441] = 302.783; v[ 442] = 301.107; v[ 443] = 300.429;
v[ 444] = 303.189; v[ 445] = 304.585; v[ 446] = 303.709; v[ 447] = 307.132;
v[ 448] = 302.315; v[ 449] = 302.922; v[ 450] = 302.593; v[ 451] = 302.476;
v[ 452] = 302.132; v[ 453] = 305.953; v[ 454] = 300.132; v[ 455] = 301.361;
v[ 456] = 302.355; v[ 457] = 304.042; v[ 458] = 302.175; v[ 459] = 297.057;
v[ 460] = 296.072; v[ 461] = 296.644; v[ 462] = 296.895; v[ 463] = 296.22;
v[ 464] = 300.897; v[ 465] = 300.839; v[ 466] = 300.899; v[ 467] = 301.941;
v[ 468] = 302.709; v[ 469] = 301.495; v[ 470] = 302.248; v[ 471] = 301.468;
v[ 472] = 303.598; v[ 473] = 304.599; v[ 474] = 299.779; v[ 475] = 297.9;
v[ 476] = 295.564; v[ 477] = 296.015; v[ 478] = 293.688; v[ 479] = 294.294;
v[ 480] = 300.801; v[ 481] = 300.724; v[ 482] = 301.204; v[ 483] = 302.463;
v[ 484] = 302.885; v[ 485] = 305.413; v[ 486] = 305.523; v[ 487] = 303.672;
v[ 488] = 304.547; v[ 489] = 303.334; v[ 490] = 301.616; v[ 491] = 298.654;
v[ 492] = 297.975; v[ 493] = 295.379; v[ 494] = 293.83; v[ 495] = 300.082;
GRIB_CHECK(<a class="code" href="group__get__set.html#ga24d87e236a2469309d1176ee5925d77" title="Set a double array from a key.">grib_set_double_array</a>(h,<span class="stringliteral">"values"</span>,v,size),0);
free(v);
<span class="comment">/* gribSection5 */</span>
<span class="comment">/* Save the message */</span>
f = fopen(argv[1],<span class="stringliteral">"w"</span>);
<span class="keywordflow">if</span>(!f) {
perror(argv[1]);
exit(1);
}
GRIB_CHECK(<a class="code" href="group__handling__coded__messages.html#g9d654bd4fc5f422c161edd0a140ea185" title="getting the message attached to a handle">grib_get_message</a>(h,&amp;buffer,&amp;size),0);
<span class="keywordflow">if</span>(fwrite(buffer,1,size,f) != size) {
perror(argv[1]);
exit(1);
}
<span class="keywordflow">if</span>(fclose(f)) {
perror(argv[1]);
exit(1);
}
<a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<span class="keywordflow">return</span> 0;
}
</pre></div><br>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,242 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_dump</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_dump">grib_dump</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Dump the content of a grib file in different formats.<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_dump [options] grib_file grib_file ...<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-O <br>
Octet mode. WMO documentation style dump. <br>
<br>
-D <br>
Debug mode. <br>
<br>
-P key[:{s/d/l}],key[:{s/d/l}],... <br>
As -p adding the declared keys to the default list. <br>
<br>
-d <br>
Print all data values. Available only in C mode <br>
<br>
-C <br>
C code mode. A C code program generating the grib message is dumped. <br>
<br>
-t <br>
Print type information. <br>
<br>
-H <br>
Print octet content in hexadecimal format. <br>
<br>
-a <br>
Dump aliases. <br>
<br>
-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,... <br>
Where clause. Grib messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be specified. Default type is string. <br>
<br>
-M <br>
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
-V <br>
Version. <br>
<br>
-G <br>
GRIBEX compatibility mode. <br>
<br>
<h2><a class="anchor" name="grib_dump_examples">
grib_dump examples</a></h2>
<ol type=1>
<li>To dump in a WMO documentation style with hexadecimal octet values (-H)<br>
<div class="fragment"><pre class="fragment">
&gt;grib_dump -H ../data/reduced_gaussian_model_level.grib1
</pre></div><br>
</li><li>To obtain all the key names available in a grib file.<br>
<div class="fragment"><pre class="fragment">
&gt; grib_dump -D ../data/regular_latlon_surface.grib1
</pre></div><br>
</li><li>To obtain a C code example from a grib file.<br>
<div class="fragment"><pre class="fragment">&gt;grib_dump -C ../data/regular_latlon_surface.grib1
<span class="preprocessor">#include &lt;<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>&gt;</span>
<span class="comment">/* This code was generated automatically */</span>
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc,<span class="keyword">const</span> <span class="keywordtype">char</span>** argv)
{
<a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h = NULL;
<span class="keywordtype">size_t</span> size = 0;
<span class="keywordtype">double</span>* vdouble = NULL;
<span class="keywordtype">long</span>* vlong = NULL;
FILE* f = NULL;
<span class="keyword">const</span> <span class="keywordtype">char</span>* p = NULL;
<span class="keyword">const</span> <span class="keywordtype">void</span>* buffer = NULL;
<span class="keywordflow">if</span>(argc != 2) {
fprintf(stderr,<span class="stringliteral">"usage: %s out\n"</span>,argv[0]);
exit(1);
}
h = <a class="code" href="group__grib__handle.html#gadefac64c19fb5ff06cf805ad4af06ff" title="Create a handle from a message contained in a samples directory.">grib_handle_new_from_samples</a>(NULL,<span class="stringliteral">"GRIB1"</span>);
<span class="keywordflow">if</span>(!h) {
fprintf(stderr,<span class="stringliteral">"Cannot create grib handle\n"</span>);
exit(1);
}
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"editionNumber"</span>,1),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"table2Version"</span>,128),0);
<span class="comment">/* 98 = European Center for Medium-Range Weather Forecasts (grib1/0.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"centre"</span>,98),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"generatingProcessIdentifier"</span>,130),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"gridDefinition"</span>,255),0);
<span class="comment">/* 128 = 10000000</span>
<span class="comment"> (1=1) Section 2 included</span>
<span class="comment"> (2=0) Section 3 omited</span>
<span class="comment"> See grib1/1.table */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"section1Flags"</span>,128),0);
<span class="comment">/* 167 = 2 metre temperature (K) (grib1/2.98.128.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"indicatorOfParameter"</span>,167),0);
<span class="comment">/* 1 = Surface (of the Earth, which includes sea surface) (grib1/3.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"indicatorOfTypeOfLevel"</span>,1),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"level"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"yearOfCentury"</span>,8),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"month"</span>,2),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"day"</span>,6),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"hour"</span>,12),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"minute"</span>,0),0);
<span class="comment">/* 1 = Hour (grib1/4.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"unitOfTimeRange"</span>,1),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"P1"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"P2"</span>,0),0);
<span class="comment">/* 0 = Forecast product valid at reference time + P1 (P1&gt;0) (grib1/5.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"timeRangeIndicator"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberIncludedInAverage"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberMissingFromAveragesOrAccumulations"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"centuryOfReferenceTimeOfData"</span>,21),0);
<span class="comment">/* 0 = Unknown code table entry (grib1/0.ecmf.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"subCentre"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"decimalScaleFactor"</span>,0),0);
<span class="comment">/* 1 = MARS labelling or ensemble forecast data (grib1/localDefinitionNumber.98.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"localDefinitionNumber"</span>,1),0);
<span class="comment">/* 1 = Operational archive (mars/class.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"marsClass"</span>,1),0);
<span class="comment">/* 2 = Analysis (mars/type.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"marsType"</span>,2),0);
<span class="comment">/* 1025 = Atmospheric model (mars/stream.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"marsStream"</span>,1025),0);
p = <span class="stringliteral">"0001"</span>;
size = strlen(p)+1;
GRIB_CHECK(<a class="code" href="group__get__set.html#g78143cc64571b454b0aba14246e9a53a" title="Set a string value from a key.">grib_set_string</a>(h,<span class="stringliteral">"experimentVersionNumber"</span>,p,&amp;size),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"perturbationNumber"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberOfForecastsInEnsemble"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"numberOfVerticalCoordinateValues"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"pvlLocation"</span>,255),0);
<span class="comment">/* 0 = Latitude/Longitude Grid (grib1/6.table) */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"dataRepresentationType"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"Ni"</span>,16),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"Nj"</span>,31),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"latitudeOfFirstGridPoint"</span>,60000),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"longitudeOfFirstGridPoint"</span>,0),0);
<span class="comment">/* 128 = 10000000</span>
<span class="comment"> (1=1) Direction increments given</span>
<span class="comment"> (2=0) Earth assumed spherical with radius = 6367.47 km</span>
<span class="comment"> (5=0) u and v components resolved relative to easterly and northerly directions</span>
<span class="comment"> See grib1/7.table */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"resolutionAndComponentFlags"</span>,128),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"latitudeOfLastGridPoint"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"longitudeOfLastGridPoint"</span>,30000),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"iDirectionIncrement"</span>,2000),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"jDirectionIncrement"</span>,2000),0);
<span class="comment">/* 0 = 00000000</span>
<span class="comment"> (1=0) Points scan in +i direction</span>
<span class="comment"> (2=0) Points scan in -j direction</span>
<span class="comment"> (3=0) Adjacent points in i direction are consecutive </span>
<span class="comment"> See grib1/8.table */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"scanningMode"</span>,0),0);
<span class="comment">/* ITERATOR */</span>
<span class="comment">/* NEAREST */</span>
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"bitsPerValue"</span>,16),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"sphericalHarmonics"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"complexPacking"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"integerPointValues"</span>,0),0);
GRIB_CHECK(<a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"additionalFlagPresent"</span>,0),0);
<span class="comment">/* gribSection5 */</span>
<span class="comment">/* Save the message */</span>
f = fopen(argv[1],<span class="stringliteral">"w"</span>);
<span class="keywordflow">if</span>(!f) {
perror(argv[1]);
exit(1);
}
GRIB_CHECK(<a class="code" href="group__handling__coded__messages.html#g9d654bd4fc5f422c161edd0a140ea185" title="getting the message attached to a handle">grib_get_message</a>(h,&amp;buffer,&amp;size),0);
<span class="keywordflow">if</span>(fwrite(buffer,1,size,f) != size) {
perror(argv[1]);
exit(1);
}
<span class="keywordflow">if</span>(fclose(f)) {
perror(argv[1]);
exit(1);
}
<a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<span class="keywordflow">return</span> 0;
}
</pre></div><br>
</li></ol>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,21 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_dump examples</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_dump_examples">grib_dump examples</a></h1>With the -O option you can get only the keys actually coded into the message, with the -a option the aliases of each key are printed. <a class="el" href="grib_dump.html">grib_dump</a> -Oa "grib_file" <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,34 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: Grib API examples</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_examples">Grib API examples</a></h1>The main features of the grib_api are explained here through some simple examples that can be taken as a starting point to write more complex programs.<br>
<h2><a class="anchor" name="fortran90">
Fortran 90</a></h2>
<ul>
<li><a class="el" href="index_8f90-example.html">index.f90</a> how to access a grib file through an index.</li><li><a class="el" href="get_8f90-example.html">get.f90</a> how to get values through the key names.</li><li><a class="el" href="count__messages_8f90-example.html">count_messages.f90</a> count the messages in a file and loop through them.</li><li><a class="el" href="get__pl_8f90-example.html">get_pl.f90</a> how to get the list of number of points for each parallel in reduced grids.</li><li><a class="el" href="get__pv_8f90-example.html">get_pv.f90</a> how to get the list of levels.</li><li><a class="el" href="get__data_8f90-example.html">get_data.f90</a> how to get latitude/longitude/values.</li><li><a class="el" href="set_8f90-example.html">set.f90</a> how to set values through the key names.</li><li><a class="el" href="set__bitmap_8f90-example.html">set_bitmap.f90</a> how to set and use a bitmap.</li><li><a class="el" href="set__missing_8f90-example.html">set_missing.f90</a> how to set a missing value in the header.</li><li><a class="el" href="set__pv_8f90-example.html">set_pv.f90</a> how to set the list of levels.</li><li><a class="el" href="samples_8f90-example.html">samples.f90</a> how to create a new message from a template.</li><li><a class="el" href="clone_8f90-example.html">clone.f90</a> how to clone a message.</li><li><a class="el" href="copy__message_8f90-example.html">copy_message.f90</a> how to copy a message in memory and create a new message.</li><li><a class="el" href="keys__iterator_8f90-example.html">keys_iterator.f90</a> how to get the names of all the keys defined in a message and how to iterate through them.</li><li><a class="el" href="precision_8f90-example.html">precision.f90</a> how to control precision when coding a grib field.</li><li><a class="el" href="multi__write_8f90-example.html">multi_write.f90</a> how to encode a grib message containing many fields.</li><li><a class="el" href="multi_8f90-example.html">multi.f90</a> how to decode a grib message containing many fields.</li><li><a class="el" href="print__data_8f90-example.html">print_data.f90</a> how to print all the data contained in a grib file.</li><li><a class="el" href="nearest_8f90-example.html">nearest.f90</a> how to find the nearest grid points.</li></ul>
<h2><a class="anchor" name="C">
C</a></h2>
<ul>
<li><a class="el" href="get_8c-example.html">get.c</a> is an example showing how to get values through the key names.</li><li><a class="el" href="set_8c-example.html">set.c</a> is an example illustrating how to set values through the key names.</li><li><a class="el" href="keys__iterator_8c-example.html">keys_iterator.c</a> explains how to get the names of all the keys defined in a message and how to iterate through them.</li><li><a class="el" href="iterator_8c-example.html">iterator.c</a> shows how to use an iterator on latitude, longitude, values.</li><li><a class="el" href="precision_8c-example.html">precision.c</a> illustrates how to control precision when coding a grib field.</li><li><a class="el" href="multi_8c-example.html">multi.c</a> is an example describing how to decode a grib message containing many fields.</li><li><a class="el" href="print__data_8c-example.html">print_data.c</a> is an example on how to print all the data contained in a grib file.</li><li><a class="el" href="nearest_8c-example.html">nearest.c</a> is an example on how to find the nearest grid points.</li><li><a class="el" href="multi__write_8c-example.html">multi_write.c</a> how to encode a grib message containing many fields.</li><li><a class="el" href="multi_8c-example.html">multi.c</a> how to decode a grib message containing many fields.</li></ul>
<h2><a class="anchor" name="fortran77">
Fortran 77</a></h2>
<ul>
<li><a class="el" href="get__fortran_8_f-example.html">get_fortran.F</a> is an example showing how to get values through the key names.</li><li><a class="el" href="set__fortran_8_f-example.html">set_fortran.F</a> is an example illustrating how to set values through the key names.</li><li><a class="el" href="keys__iterator__fortran_8_f-example.html">keys_iterator_fortran.F</a> explains how to get the names of all the keys defined in a message and how to iterate through them.</li><li><a class="el" href="iterator__fortran_8_f-example.html">iterator_fortran.F</a> shows how to use an iterator on latitude, longitude, values.</li><li><a class="el" href="precision__fortran_8_f-example.html">precision_fortran.F</a> illustrates how to control precision when coding a grib field.</li><li><a class="el" href="multi__fortran_8_f-example.html">multi_fortran.F</a> is an example describing how to decode a grib message containing many fields.</li><li><a class="el" href="print__data__fortran_8_f-example.html">print_data_fortran.F</a> is an example on how to print all the data contained in a grib file. </li></ul>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,124 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_filter</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_filter">grib_filter</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Apply the rules defined in rules_file to each grib message in the grib files provided as arguments.<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_filter [options] rules_file grib_file grib_file ...<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-f <br>
Force. Force the execution not to fail on error. <br>
<br>
-o output_grib_file <br>
Output grib is written to ouput_grib_file. If an ouput grib file is required and -o is not used, theouput grib is written to filtered.out <br>
<br>
-M <br>
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
<br>
-V <br>
Version. <br>
<br>
-g <br>
Copy GTS header. <br>
<br>
-G <br>
GRIBEX compatibility mode. <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
-v <br>
Verbose. <br>
<br>
<h2><a class="anchor" name="grib_filter_examples">
grib_filter examples</a></h2>
<ol type=1>
<li>The rules accepted by grib_filter are different from the grib_convert rules due to the kind of work grib_filter it is supposed to do.<br>
The main difference between grib_filter and grib_convert is that the convert is a 1 field in input 1 field in output tool, while the filter is a 1 field in input as many field you need in output. At this aim the filter syntax allows a write in the form: write "filename". So that it is possible repeating as many write you need or using a parametrised write to send the output to many files. <br>
The grib_filter processes sequentially all the grib messages contained in the input file and it applies the rules to each one. <br>
Since the filename used in the write statement can contain some key values, taken from the grib processed when applying the "write rule", several files are produced in output containing fields with the same value of the keys used in the file name. <br>
Indeed if we write a rules_file containing the only statement:<br>
<br>
<div class="fragment"><pre class="fragment">
write "../data/split/[centre]_[date]_[dataType]_[levelType].grib[editionNumber]";
</pre></div><br>
Applying this rules_file to the ../data/tigge_pf_ecmwf.grib2 grib file we obtain several files in the ../data/split directory containting fields splitted according their keys values<br>
<div class="fragment"><pre class="fragment">
&gt;grib_filter rules_file ../data/tigge_pf_ecmwf.grib2
&gt;ls ../data/split
ecmf_20060619_pf_sfc.grib2
ecmf_20060630_pf_sfc.grib2
ecmf_20070122_pf_pl.grib2
ecmf_20070122_pf_pt.grib2
ecmf_20070122_pf_pv.grib2
ecmf_20070122_pf_sfc.grib2
</pre></div><br>
</li><li>The key values in the file name can also be obtained in a different format by indicating explicitly the type required after a colon.<ul>
<li>:l for long</li><li>:d for double</li><li>:s for string</li></ul>
The following statement works in a slightly different way from the previous example, including in the output file name the long values for centre and dataType.<br>
<div class="fragment"><pre class="fragment">
write "../data/split/[centre:l]_[date]_[dataType:l]_[levelType].grib[editionNumber]";
</pre></div><br>
Running the same command again we obtain a different list of files.<br>
<div class="fragment"><pre class="fragment">
&gt;grib_filter rules_file ../data/tigge_pf_ecmwf.grib2
&gt;ls ../data/split
98_20060619_4_sfc.grib2
98_20060630_4_sfc.grib2
98_20070122_4_pl.grib2
98_20070122_4_pt.grib2
98_20070122_4_pv.grib2
98_20070122_4_sfc.grib2
</pre></div><br>
</li><li>Other statements are allowed in the grib_filter syntax:<ul>
<li>if ( condition ) { statement;}<br>
The condition can be made using ==,!= and joining single block conditions with || and &amp;&amp; <br>
The statement can be any valid statement also another nested condition<br>
</li><li>set keyname = keyvalue;</li><li>print "string to print also with key values like in the file name"</li><li>transient keyname1 = keyname2;</li><li>comments beginning with #</li></ul>
A complex example of grib_filter rules is the following to change temperature in a grib edition 1 file. <div class="fragment"><pre class="fragment">
# Temperature
if ( level == 850 &amp;&amp; indicatorOfParameter == 11 ) {
print "found indicatorOfParameter=[indicatorOfParameter] level=[level] date=[date]";
transient oldtype = type ;
set identificationOfOriginatingGeneratingSubCentre=98;
set gribTablesVersionNo = 128;
set indicatorOfParameter = 130;
set localDefinitionNumber=1;
set marsClass="od";
set marsStream="kwbc";
# Negatively/Positively Perturbed Forecast
if ( oldtype == 2 || oldtype == 3 ) {
set marsType="pf";
set experimentVersionNumber="4001";
}
# Control Forecast
if ( oldtype == 1 ) {
set marsType="cf";
set experimentVersionNumber="0001";
}
set numberOfForecastsInEnsemble=11;
write;
print "indicatorOfParameter=[indicatorOfParameter] level=[level] date=[date]";
print;
}
</pre></div><br>
</li></ol>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,80 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_get</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_get">grib_get</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Get values of some keys from a grib file. It is similar to grib_ls, but fails returning an error code when an error occurs (e.g. key not found).<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_get [options] grib_file grib_file ...<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-f <br>
Force. Force the execution not to fail on error. <br>
<br>
-p key[:{s/d/l}],key[:{s/d/l}],... <br>
Declaration of keys to print. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be requested. Default type is string. <br>
<br>
-F format <br>
C style format for floating point values. <br>
<br>
-l Latitude,Longitude[,MODE,file] <br>
Value close to the point of a Latitude/Longitude. Allowed values for MODE are: 4 (4 values in the nearest points are printed) Default 1 (the value at the nearest point is printed) file (file is used as mask. The closer point with mask value&gt;=0.5 is printed) <br>
<br>
-P key[:{s/d/l}],key[:{s/d/l}],... <br>
As -p adding the declared keys to the default list. <br>
<br>
-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,... <br>
Where clause. Grib messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be specified. Default type is string. <br>
<br>
-n namespace <br>
All the keys belonging to namespace are printed. <br>
<br>
-V <br>
Version. <br>
<br>
-W width <br>
Minimum width of each column in output. Default is 10. <br>
<br>
-m <br>
Mars keys are printed. <br>
<br>
-M <br>
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
<br>
-g <br>
Copy GTS header. <br>
<br>
-G <br>
GRIBEX compatibility mode. <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
<h2><a class="anchor" name="grib_get_examples">
grib_get examples</a></h2>
<ol type=1>
<li>grib_get fails if a key is not found.<br>
<div class="fragment"><pre class="fragment">
&gt;grib_get -p gribname ../data/tigge_pf_ecmwf.grib2
</pre></div></li><li>To get the step of the first GRIB message in a file: <br>
<div class="fragment"><pre class="fragment">
&gt;grib_get -w count=1 -p step ../data/tigge_pf_ecmwf.grib2
</pre></div> </li></ol>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,67 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_get_data</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_get_data">grib_get_data</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Print a latitude, longitude, data values list<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_get_data [options] grib_file grib_file ...<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-M <br>
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
<br>
-m missingValue <br>
The missing value is given through this option. Any string is allowed and it is printed in place of the missing values. Default is to skip the missing values. <br>
<br>
-p key[:{s/d/l}],key[:{s/d/l}],... <br>
Declaration of keys to print. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be requested. Default type is string. <br>
<br>
-R key1=relative_error1,key2=relative_error2,... <br>
Compare floating point values using the relative error as tolerance. key1=relative_error will compare key1 using relative_error1. all=relative_error will compare all the floating point keys using relative_error. Default all=0. <br>
<br>
-F format <br>
C style format for values. Default is "%.10e" <br>
<br>
-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,... <br>
Where clause. Grib messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be specified. Default type is string. <br>
<br>
-f <br>
Force. Force the execution not to fail on error. <br>
<br>
-G <br>
GRIBEX compatibility mode. <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
-V <br>
Version. <br>
<br>
<h2><a class="anchor" name="grib_get_data_examples">
grib_get_data examples</a></h2>
<ol type=1>
<li>To get a latitude, longitude, value list, skipping the missing values(=9999) <div class="fragment"><pre class="fragment">
&gt;grib_get_data ../data/reduced_gaussian_model_level.grib2
</pre></div></li><li>If you want to define your missing value=1111 and to print the string missing in place of it <div class="fragment"><pre class="fragment">
&gt;grib_get_data -m 1111:missing ../data/reduced_gaussian_model_level.grib2
</pre></div></li><li>If you want to print the value of other keys with the data value list <div class="fragment"><pre class="fragment">
&gt;grib_get_data -p centre,level,step ../data/reduced_gaussian_model_level.grib2
</pre></div> </li></ol>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,153 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_keys</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_keys">grib_keys</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Lists the keys available for a type of grib (-T option) or in a grib message from a file (-F option).<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_keys [options]<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-T type <br>
To print the keys available in the given grib type. For a list of the availeble types see -L option. <br>
<br>
-F file <br>
To print the keys available in the grib file. <br>
<br>
-x <br>
Print the extended set of keys. <br>
<br>
-c <br>
Print only coded keys. <br>
<br>
-L <br>
List of available types. <br>
<br>
-t <br>
Print type information. <br>
<br>
-a <br>
Dump aliases. <br>
<br>
<h2><a class="anchor" name="grib_keys_examples">
grib_keys examples</a></h2>
<ol type=1>
<li>With the -L option a list of the available templates is printed <br>
<div class="fragment"><pre class="fragment">
&gt; grib_keys -L \n
GRIB1
GRIB2
reduced_gg_ml_grib2
reduced_gg_pl_grib1
reduced_gg_sfc_grib1
reduced_gg_ml_grib1
reduced_gg_pl_grib2
reduced_gg_sfc_grib2
reduced_gg_sfc_jpeg_grib2
reduced_ll_sfc_grib1
reduced_ll_sfc_grib2
regular_gg_ml_grib1
regular_gg_ml_grib2
regular_gg_pl_grib1
regular_gg_pl_grib2
regular_ll_sfc_grib1
regular_ll_sfc_grib2
regular_ll_pl_grib1
regular_ll_pl_grib2
sh_ml_grib1
sh_ml_grib2
sh_pl_grib1
sh_pl_grib2
</pre></div><br>
</li><li>To print the standard set of key available for a given type<br>
<div class="fragment"><pre class="fragment">
&gt; grib_keys -T regular_ll_sfc_grib1
=================== regular_ll_sfc_grib1
editionNumber
====&gt; SECTION 1 &lt;====
table2Version
centre
generatingProcessIdentifier
indicatorOfParameter
marsParam (read only)
indicatorOfTypeOfLevel
level
timeRangeIndicator
subCentre
decimalScaleFactor
dataDate
dataTime
stepUnits
stepRange
startStep
endStep
localDefinitionNumber
marsClass
marsType
marsStream
experimentVersionNumber
perturbationNumber
numberOfForecastsInEnsemble
name (read only)
units (read only)
bitmapPresent
====&gt; SECTION 2 &lt;====
numberOfVerticalCoordinateValues
Ni
Nj
latitudeOfFirstGridPointInDegrees
longitudeOfFirstGridPointInDegrees
earthIsOblate
uvRelativeToGrid
latitudeOfLastGridPointInDegrees
longitudeOfLastGridPointInDegrees
DjInDegrees
DiInDegrees
iScansNegatively
jScansPositively
jPointsAreConsecutive
alternativeRowScanning (read only)
numberOfDataPoints (read only)
numberOfValues (read only)
missingValue
====&gt; SECTION 4 &lt;====
binaryScaleFactor (read only)
referenceValue (read only)
bitsPerValue
sphericalHarmonics
complexPacking
integerPointValues
additionalFlagPresent
typeOfPacking
values
numberOfCodedValues (read only)
maximum (read only)
minimum (read only)
average (read only)
numberOfMissing (read only)
standardDeviation (read only)
skewness (read only)
kurtosis (read only)
isConstant (read only)
typeOfGrid
getNumberOfValues (read only)
====&gt; SECTION 5 &lt;====
</pre></div><br>
</li></ol>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,95 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_ls</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_ls">grib_ls</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
List content of grib files printing values of some keys. It does not fail when a key is not found.<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_ls [options] grib_file grib_file ...<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-p key[:{s/d/l}],key[:{s/d/l}],... <br>
Declaration of keys to print. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be requested. Default type is string. <br>
<br>
-F format <br>
C style format for floating point values. <br>
<br>
-P key[:{s/d/l}],key[:{s/d/l}],... <br>
As -p adding the declared keys to the default list. <br>
<br>
-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,... <br>
Where clause. Grib messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be specified. Default type is string. <br>
<br>
-B order by directive <br>
Order by. The output will be ordered according the order by directive. Order by example: "step asc, centre desc" (step ascending and centre discending) <br>
<br>
-l Latitude,Longitude[,MODE,file] <br>
Value close to the point of a Latitude/Longitude. Allowed values for MODE are: 4 (4 values in the nearest points are printed) Default 1 (the value at the nearest point is printed) file (file is used as mask. The closer point with mask value&gt;=0.5 is printed) <br>
<br>
-i index <br>
Data value corresponding to the given index is printed. <br>
<br>
-n namespace <br>
All the keys belonging to namespace are printed. <br>
<br>
-m <br>
Mars keys are printed. <br>
<br>
-V <br>
Version. <br>
<br>
-W width <br>
Minimum width of each column in output. Default is 10. <br>
<br>
-M <br>
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
<br>
-g <br>
Copy GTS header. <br>
<br>
-G <br>
GRIBEX compatibility mode. <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
<h2><a class="anchor" name="grib_ls_examples">
grib_ls examples</a></h2>
<ol type=1>
<li>Without options a default list of keys is printed. <br>
The default list is different depending on the type of grib message. <br>
<div class="fragment"><pre class="fragment">
&gt; grib_ls ../data/reduced*.grib1 ../data/regular*.grib1 ../data/reduced*.grib2 \n
</pre></div><br>
</li><li>To print offset and count number in file use the keys offset and count<br>
Also the total count in a set of files is available as countTotal<br>
<div class="fragment"><pre class="fragment">
&gt; grib_ls -p offset,count,countTotal ../data/reduced*.grib1
</pre></div><br>
</li><li>To list only a subset of messages use the -w (where option).<br>
Only the pressure levels are listed with the following line.<br>
<div class="fragment"><pre class="fragment">
&gt; grib_ls -w levType=pl ../tigge_pf_ecmwf.grib2
</pre></div><br>
</li><li>All the grib messages not on pressure levels are listed as follows:<br>
<div class="fragment"><pre class="fragment">
&gt; grib_ls -w levType!=pl ../tigge_pf_ecmwf.grib2
</pre></div><br>
</li></ol>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,103 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: grib_set</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="grib_set">grib_set</a></h1><h2><a class="anchor" name="DESCRIPTION">
DESCRIPTION</a></h2>
Sets key/value pairs in the input grib file and writes each message to the output_grib_file. It fails when an error occurs (e.g. key not found).<h2><a class="anchor" name="USAGE">
USAGE</a></h2>
grib_set [options] grib_file grib_file ... output_grib_file<h2><a class="anchor" name="OPTIONS">
OPTIONS</a></h2>
-s key[:{s/d/l}]=value,key[:{s/d/l}]=value,... <br>
Key/values to set. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be defined. By default the native type is set. <br>
<br>
-r <br>
Repack data. Sometimes after setting some keys involving properties of the packing algorithm a repacking of data is needed. This repacking is performed setting this -r option. <br>
<br>
-d value <br>
Set all the data values to "value". <br>
<br>
-p key[:{s/d/l}],key[:{s/d/l}],... <br>
Declaration of keys to print. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be requested. Default type is string. <br>
<br>
-P key[:{s/d/l}],key[:{s/d/l}],... <br>
As -p adding the declared keys to the default list. <br>
<br>
-w key[:{s/d/l}]=value,key[:{s/d/l}]=value,... <br>
Where clause. Set is only executed for grib messages matching all the key/value constraints. If a grib message does not match the constraints it is copied unchanged to the output_grib_file. This behaviour can be changed setting the option -S. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be defined. Default type is string. <br>
<br>
-7 <br>
Does not fail when the message has wrong length <br>
<br>
-S <br>
Strict. Only grib messages matching all the constraints are copied to the output file <br>
<br>
-V <br>
Version. <br>
<br>
-M <br>
Multi-grib support off. Turn off support for multiple fields in single grib message <br>
<br>
-g <br>
Copy GTS header. <br>
<br>
-G <br>
GRIBEX compatibility mode. <br>
<br>
-f <br>
Force. Force the execution not to fail on error. <br>
<br>
-v <br>
Verbose. <br>
<br>
<h2><a class="anchor" name="grib_set_examples">
grib_set examples</a></h2>
<ol type=1>
<li>To set productDefinitionTemplateNumber=2 only for the fields with productDefinitionTemplateNumber=11 <br>
<div class="fragment"><pre class="fragment">
&gt;grib_set -s productDefinitionTemplateNumber=2 -w productDefinitionTemplateNumber=11 ../data/tigge_pf_ecmwf.grib2 out.grib2
</pre></div><br>
</li><li>To set productDefinitionTemplateNumber=2 only for the fields for which productDefinitionTemplateNumber is not equal to 11 <br>
<div class="fragment"><pre class="fragment">
&gt;grib_set -s productDefinitionTemplateNumber=2 -w productDefinitionTemplateNumber!=11 tigge_pf_ecmwf.grib2 out.grib2
</pre></div><br>
</li><li>When a key is not used all the bits of its value should be set to 1 to indicate that it is missing. Since the length (number of octet) is different from a key to another, the value that we have to code for missing keys is not unique. To give an easy way to set a key to missing a string "missing" or "MISSING" is accepted by grib_set as follows:<br>
<div class="fragment"><pre class="fragment">
&gt;grib_set -s scaleFactorOfFirstFixedSurface=missing,scaledValueOfFirstFixedSurface=MISSING ../data/regular_latlon_surface.grib2 out.grib2
</pre></div><br>
Since some values can not be set to missing you can get an error for those keys.</li><li>To set scaleFactorOfSecondFixedSurface to missing only for the fields for which scaleFactorOfSecondFixedSurface is not missing: <br>
<div class="fragment"><pre class="fragment">
&gt;grib_set -s scaleFactorOfSecondFixedSurface=missing -w scaleFactorOfSecondFixedSurface!=missing tigge_pf_ecmwf.grib2 out.grib2
</pre></div><br>
</li><li>It's possible to produce a grib edition 2 file from a grib edition 1 just changing the edition number with grib_set. At this stage of development all the geography parameters, level and time information is correctly translated, for the product definition extra set calls must be done. To do this properly <a class="el" href="grib_convert.html">grib_convert</a> is suggested. <br>
<div class="fragment"><pre class="fragment">
grib_set -s editionNumber=2 ../data/reduced_gaussian_pressure_level.grib1
</pre></div><br>
</li><li>With grib edition 2 is possible to compress data using the jpeg algorithm. To change packing algorithm from grid_simple (simple packing) to grid_jpeg (jpeg2000 packing):<br>
<div class="fragment"><pre class="fragment">
&gt;grib_set -s packingType=grid_jpeg ../data/regular_gaussian_model_level.grib2 out.grib2
</pre></div><br>
</li><li>It's possible to ask grib_api to calculate the number of bits per value needed to pack a given field with a fixed number of decimal digits of precision. For example if we want to pack a temperature expressed in Kelvin with 1 digits of precision after the decimal point we can set changeDecimalPrecision=1 <br>
<div class="fragment"><pre class="fragment">
&gt;grib_set -s changeDecimalPrecision=1 ../data/regular_latlon_surface.grib2 ../data/out.grib2
rm -f ../data/out.grib2 | true
./grib_set -s changeDecimalPrecision=1 ../data/regular_latlon_surface.grib2 ../data/out.grib2
</pre></div><br>
</li></ol>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,625 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: The grib_handle</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>The grib_handle</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">typedef struct <br>
<a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">typedef struct <br>
<a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#gc7f5cb6af67fd0a42bec5376d5b54682">grib_count_in_file</a> (<a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *c, FILE *f, int *n)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Counts the messages contained in a file resource. <a href="#gc7f5cb6af67fd0a42bec5376d5b54682"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5">grib_handle_new_from_file</a> (<a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *c, FILE *f, int *error)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a handle from a file resource. <a href="#g5e24f8499aa7e4178ccc25a5de3145c5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#gcf9ab4896fac2fbbe30a33b4d6028a01">grib_handle_new_from_message</a> (<a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *c, void *data, size_t data_len)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a handle from a user message in memory. <a href="#gcf9ab4896fac2fbbe30a33b4d6028a01"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g5990754a829e1d7a7ae4c5a1a8296bf2">grib_handle_new_from_multi_message</a> (<a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *c, void **data, size_t *data_len, int *error)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a handle from a user message in memory. <a href="#g5990754a829e1d7a7ae4c5a1a8296bf2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#gba8b4cc36b1a882c8a12716ef011d6be">grib_handle_new_from_message_copy</a> (<a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *c, const void *data, size_t data_len)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a handle from a user message. <a href="#gba8b4cc36b1a882c8a12716ef011d6be"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g11d247e5afa10bd52fb895dc4296143f">grib_handle_new_from_template</a> (<a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *c, const char *res_name)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a handle from a read_only template resource. <a href="#g11d247e5afa10bd52fb895dc4296143f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#gadefac64c19fb5ff06cf805ad4af06ff">grib_handle_new_from_samples</a> (<a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *c, const char *res_name)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a handle from a message contained in a samples directory. <a href="#gadefac64c19fb5ff06cf805ad4af06ff"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#ga63c93533fbbe2c8df482e19ca97c651">grib_handle_clone</a> (<a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Clone an existing handle using the context of the original handle, The message is copied and reparsed. <a href="#ga63c93533fbbe2c8df482e19ca97c651"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677">grib_handle_delete</a> (<a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Frees a handle, also frees the message if it is not a user message. <a href="#g0e4b2585f22247c49b930c1579257677"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g9e1911fcd2b32380937e2d60469d2d22">grib_multi_handle_new</a> (<a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *c)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create an empty multi field handle. <a href="#g9e1911fcd2b32380937e2d60469d2d22"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#gb723d513ef118d0f2d8c440e15387337">grib_multi_handle_append</a> (<a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h, int start_section, <a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> *mh)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Append the sections starting with start_section of the message pointed by h at the end of the multi field handle mh. <a href="#gb723d513ef118d0f2d8c440e15387337"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g706fb50a5a16b6932adb05d27a8ac626">grib_multi_handle_delete</a> (<a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> *mh)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Delete multi field handle. <a href="#g706fb50a5a16b6932adb05d27a8ac626"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__grib__handle.html#g48fc85388ca1ee23f6afa12bb0c125ed">grib_multi_handle_write</a> (<a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> *mh, FILE *f)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Write a multi field handle in a file. <a href="#g48fc85388ca1ee23f6afa12bb0c125ed"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The grib_handle is the structure giving access to parsed grib values by keys. <hr><h2>Typedef Documentation</h2>
<a class="anchor" name="g309a5ee24f4c730646d3f80ad0ef5f1b"></a><!-- doxytag: member="grib_api.h::grib_handle" ref="g309a5ee24f4c730646d3f80ad0ef5f1b" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef struct <a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> <a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Grib handle, structure giving access to parsed grib values by keys <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="get_8c-example.html#a0">get.c</a>, <a class="el" href="iterator_8c-example.html#a0">iterator.c</a>, <a class="el" href="keys__iterator_8c-example.html#a1">keys_iterator.c</a>, <a class="el" href="multi_8c-example.html#a0">multi.c</a>, <a class="el" href="multi__write_8c-example.html#a0">multi_write.c</a>, <a class="el" href="nearest_8c-example.html#a0">nearest.c</a>, <a class="el" href="precision_8c-example.html#a0">precision.c</a>, <a class="el" href="print__data_8c-example.html#a0">print_data.c</a>, and <a class="el" href="set_8c-example.html#a0">set.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="g569cc40caa2fa0c4e0e22f9a0ecf25f7"></a><!-- doxytag: member="grib_api.h::grib_multi_handle" ref="g569cc40caa2fa0c4e0e22f9a0ecf25f7" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef struct <a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> <a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Grib multi field handle, structure used to build multi fields messages. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="multi__write_8c-example.html#a1">multi_write.c</a>.</dl>
</div>
</div><p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="gc7f5cb6af67fd0a42bec5376d5b54682"></a><!-- doxytag: member="grib_api.h::grib_count_in_file" ref="gc7f5cb6af67fd0a42bec5376d5b54682" args="(grib_context *c, FILE *f, int *n)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int grib_count_in_file </td>
<td>(</td>
<td class="paramtype"><a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *&nbsp;</td>
<td class="paramname"> <em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">FILE *&nbsp;</td>
<td class="paramname"> <em>f</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *&nbsp;</td>
<td class="paramname"> <em>n</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Counts the messages contained in a file resource.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>: the context from wich the handle will be created (NULL for default context) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>f</em>&nbsp;</td><td>: the file resource </td></tr>
<tr><td valign="top"></td><td valign="top"><em>n</em>&nbsp;</td><td>: the number of messages in the file </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if OK, integer value on error </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="count__messages_8f90-example.html#a0">count_messages.f90</a>.</dl>
</div>
</div><p>
<a class="anchor" name="ga63c93533fbbe2c8df482e19ca97c651"></a><!-- doxytag: member="grib_api.h::grib_handle_clone" ref="ga63c93533fbbe2c8df482e19ca97c651" args="(grib_handle *h)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* grib_handle_clone </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td>
<td class="paramname"> <em>h</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Clone an existing handle using the context of the original handle, The message is copied and reparsed.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>h</em>&nbsp;</td><td>: The handle to be cloned </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the new handle, NULL if the message is invalid or a problem is encountered </dd></dl>
</div>
</div><p>
<a class="anchor" name="g0e4b2585f22247c49b930c1579257677"></a><!-- doxytag: member="grib_api.h::grib_handle_delete" ref="g0e4b2585f22247c49b930c1579257677" args="(grib_handle *h)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int grib_handle_delete </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td>
<td class="paramname"> <em>h</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Frees a handle, also frees the message if it is not a user message.
<p>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__grib__handle.html#gcf9ab4896fac2fbbe30a33b4d6028a01" title="Create a handle from a user message in memory.">grib_handle_new_from_message</a> </dd></dl>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>h</em>&nbsp;</td><td>: The handle to be deleted </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if OK, integer value on error </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="get_8c-example.html#a6">get.c</a>, <a class="el" href="iterator_8c-example.html#a8">iterator.c</a>, <a class="el" href="multi_8c-example.html#a4">multi.c</a>, <a class="el" href="multi__write_8c-example.html#a7">multi_write.c</a>, <a class="el" href="nearest_8c-example.html#a6">nearest.c</a>, <a class="el" href="precision_8c-example.html#a7">precision.c</a>, <a class="el" href="print__data_8c-example.html#a5">print_data.c</a>, and <a class="el" href="set_8c-example.html#a6">set.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="g5e24f8499aa7e4178ccc25a5de3145c5"></a><!-- doxytag: member="grib_api.h::grib_handle_new_from_file" ref="g5e24f8499aa7e4178ccc25a5de3145c5" args="(grib_context *c, FILE *f, int *error)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* grib_handle_new_from_file </td>
<td>(</td>
<td class="paramtype"><a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *&nbsp;</td>
<td class="paramname"> <em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">FILE *&nbsp;</td>
<td class="paramname"> <em>f</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *&nbsp;</td>
<td class="paramname"> <em>error</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a handle from a file resource.
<p>
The file is read until a message is found. The message is then copied. Remember always to delete the handle when it is not needed any more to avoid memory leaks.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>: the context from wich the handle will be created (NULL for default context) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>f</em>&nbsp;</td><td>: the file resource </td></tr>
<tr><td valign="top"></td><td valign="top"><em>error</em>&nbsp;</td><td>: error code set if the returned handle is NULL and the end of file is not reached </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the new handle, NULL if the resource is invalid or a problem is encountered </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="get_8c-example.html#a1">get.c</a>, <a class="el" href="iterator_8c-example.html#a2">iterator.c</a>, <a class="el" href="keys__iterator_8c-example.html#a3">keys_iterator.c</a>, <a class="el" href="multi_8c-example.html#a2">multi.c</a>, <a class="el" href="multi__write_8c-example.html#a2">multi_write.c</a>, <a class="el" href="precision_8c-example.html#a1">precision.c</a>, <a class="el" href="print__data_8c-example.html#a1">print_data.c</a>, and <a class="el" href="set_8c-example.html#a1">set.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="gcf9ab4896fac2fbbe30a33b4d6028a01"></a><!-- doxytag: member="grib_api.h::grib_handle_new_from_message" ref="gcf9ab4896fac2fbbe30a33b4d6028a01" args="(grib_context *c, void *data, size_t data_len)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* grib_handle_new_from_message </td>
<td>(</td>
<td class="paramtype"><a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *&nbsp;</td>
<td class="paramname"> <em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>data_len</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a handle from a user message in memory.
<p>
The message will not be freed at the end. The message will be copied as soon as a modification is needed.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>: the context from which the handle will be created (NULL for default context) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>: the actual message </td></tr>
<tr><td valign="top"></td><td valign="top"><em>data_len</em>&nbsp;</td><td>: the length of the message in number of bytes </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the new handle, NULL if the message is invalid or a problem is encountered </dd></dl>
</div>
</div><p>
<a class="anchor" name="gba8b4cc36b1a882c8a12716ef011d6be"></a><!-- doxytag: member="grib_api.h::grib_handle_new_from_message_copy" ref="gba8b4cc36b1a882c8a12716ef011d6be" args="(grib_context *c, const void *data, size_t data_len)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* grib_handle_new_from_message_copy </td>
<td>(</td>
<td class="paramtype"><a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *&nbsp;</td>
<td class="paramname"> <em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const void *&nbsp;</td>
<td class="paramname"> <em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>data_len</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a handle from a user message.
<p>
The message is copied and will be freed with the handle<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>: the context from wich the handle will be created (NULL for default context) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>: the actual message </td></tr>
<tr><td valign="top"></td><td valign="top"><em>data_len</em>&nbsp;</td><td>: the length of the message in number of bytes </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the new handle, NULL if the message is invalid or a problem is encountered </dd></dl>
</div>
</div><p>
<a class="anchor" name="g5990754a829e1d7a7ae4c5a1a8296bf2"></a><!-- doxytag: member="grib_api.h::grib_handle_new_from_multi_message" ref="g5990754a829e1d7a7ae4c5a1a8296bf2" args="(grib_context *c, void **data, size_t *data_len, int *error)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* grib_handle_new_from_multi_message </td>
<td>(</td>
<td class="paramtype"><a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *&nbsp;</td>
<td class="paramname"> <em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void **&nbsp;</td>
<td class="paramname"> <em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t *&nbsp;</td>
<td class="paramname"> <em>data_len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *&nbsp;</td>
<td class="paramname"> <em>error</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a handle from a user message in memory.
<p>
The message will not be freed at the end. The message will be copied as soon as a modification is needed. This function works also with multi field messages.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>: the context from which the handle will be created (NULL for default context) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>: the actual message </td></tr>
<tr><td valign="top"></td><td valign="top"><em>data_len</em>&nbsp;</td><td>: the length of the message in number of bytes </td></tr>
<tr><td valign="top"></td><td valign="top"><em>error</em>&nbsp;</td><td>: error code </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the new handle, NULL if the message is invalid or a problem is encountered </dd></dl>
</div>
</div><p>
<a class="anchor" name="gadefac64c19fb5ff06cf805ad4af06ff"></a><!-- doxytag: member="grib_api.h::grib_handle_new_from_samples" ref="gadefac64c19fb5ff06cf805ad4af06ff" args="(grib_context *c, const char *res_name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* grib_handle_new_from_samples </td>
<td>(</td>
<td class="paramtype"><a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *&nbsp;</td>
<td class="paramname"> <em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&nbsp;</td>
<td class="paramname"> <em>res_name</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a handle from a message contained in a samples directory.
<p>
The message is copied at the creation of the handle<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>: the context from wich the handle will be created (NULL for default context) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>res_name</em>&nbsp;</td><td>: the resource name </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the new handle, NULL if the resource is invalid or a problem is encountered </dd></dl>
</div>
</div><p>
<a class="anchor" name="g11d247e5afa10bd52fb895dc4296143f"></a><!-- doxytag: member="grib_api.h::grib_handle_new_from_template" ref="g11d247e5afa10bd52fb895dc4296143f" args="(grib_context *c, const char *res_name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* grib_handle_new_from_template </td>
<td>(</td>
<td class="paramtype"><a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *&nbsp;</td>
<td class="paramname"> <em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&nbsp;</td>
<td class="paramname"> <em>res_name</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a handle from a read_only template resource.
<p>
The message is copied at the creation of the handle<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>: the context from wich the handle will be created (NULL for default context) </td></tr>
<tr><td valign="top"></td><td valign="top"><em>res_name</em>&nbsp;</td><td>: the resource name </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the new handle, NULL if the resource is invalid or a problem is encountered </dd></dl>
</div>
</div><p>
<a class="anchor" name="gb723d513ef118d0f2d8c440e15387337"></a><!-- doxytag: member="grib_api.h::grib_multi_handle_append" ref="gb723d513ef118d0f2d8c440e15387337" args="(grib_handle *h, int start_section, grib_multi_handle *mh)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int grib_multi_handle_append </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *&nbsp;</td>
<td class="paramname"> <em>h</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>start_section</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> *&nbsp;</td>
<td class="paramname"> <em>mh</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Append the sections starting with start_section of the message pointed by h at the end of the multi field handle mh.
<p>
Remember always to delete the multi handle when it is not needed any more to avoid memory leaks.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>h</em>&nbsp;</td><td>: The handle from which the sections are copied. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>start_section</em>&nbsp;</td><td>: section number. Starting from this section all the sections to then end of the message will be copied. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>mh</em>&nbsp;</td><td>: The multi field handle on which the sections are appended. </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if OK, integer value on error </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="multi__write_8c-example.html#a5">multi_write.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="g706fb50a5a16b6932adb05d27a8ac626"></a><!-- doxytag: member="grib_api.h::grib_multi_handle_delete" ref="g706fb50a5a16b6932adb05d27a8ac626" args="(grib_multi_handle *mh)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int grib_multi_handle_delete </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> *&nbsp;</td>
<td class="paramname"> <em>mh</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Delete multi field handle.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>mh</em>&nbsp;</td><td>: The multi field handle to be deleted. </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if OK, integer value on error </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="multi__write_8c-example.html#a8">multi_write.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="g9e1911fcd2b32380937e2d60469d2d22"></a><!-- doxytag: member="grib_api.h::grib_multi_handle_new" ref="g9e1911fcd2b32380937e2d60469d2d22" args="(grib_context *c)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a>* grib_multi_handle_new </td>
<td>(</td>
<td class="paramtype"><a class="el" href="grib__api_8h.html#8e7f259b6dec023add23b2a5ddd93bad">grib_context</a> *&nbsp;</td>
<td class="paramname"> <em>c</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create an empty multi field handle.
<p>
Remember always to delete the multi handle when it is not needed any more to avoid memory leaks.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>: the context from wich the handle will be created (NULL for default context) </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="multi__write_8c-example.html#a3">multi_write.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="g48fc85388ca1ee23f6afa12bb0c125ed"></a><!-- doxytag: member="grib_api.h::grib_multi_handle_write" ref="g48fc85388ca1ee23f6afa12bb0c125ed" args="(grib_multi_handle *mh, FILE *f)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int grib_multi_handle_write </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__grib__handle.html#g569cc40caa2fa0c4e0e22f9a0ecf25f7">grib_multi_handle</a> *&nbsp;</td>
<td class="paramname"> <em>mh</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">FILE *&nbsp;</td>
<td class="paramname"> <em>f</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Write a multi field handle in a file.
<p>
Remember always to delete the multi handle when it is not needed any more to avoid memory leaks.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>mh</em>&nbsp;</td><td>: The multi field handle to be written. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>f</em>&nbsp;</td><td>: File on which the file handle is written. </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if OK, integer value on error </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="multi__write_8c-example.html#a6">multi_write.c</a>.</dl>
</div>
</div><p>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,103 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: iterator.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>iterator.c</h1>iterator.c How to use an iterator on latitude, longitude, values.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> * C Implementation: iterator</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Description: how to use an iterator on lat/lon/values.</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * Author: Enrico Fucile</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> */</span>
<a name="l00020"></a>00020
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00024"></a>00024
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>"</span>
<a name="l00026"></a>00026
<a name="l00027"></a>00027 <span class="keywordtype">void</span> usage(<span class="keywordtype">char</span>* prog) {
<a name="l00028"></a>00028 printf(<span class="stringliteral">"Usage: %s grib_file\n"</span>,prog);
<a name="l00029"></a>00029 exit(1);
<a name="l00030"></a>00030 }
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv) {
<a name="l00033"></a>00033 FILE* in = NULL;
<a name="l00034"></a>00034 <span class="keywordtype">int</span> err = 0;
<a name="l00035"></a>00035 <span class="keywordtype">double</span> lat,lon,value,missingValue=0;
<a name="l00036"></a>00036 <span class="keywordtype">int</span> n=0;
<a name="l00037"></a>00037 <span class="keywordtype">char</span>* filename = NULL;
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="comment">/* Message handle. Required in all the grib_api calls acting on a message.*/</span>
<a name="l00040"></a>00040 <a name="a0"></a><a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h = NULL;
<a name="l00041"></a>00041 <span class="comment">/* Iterator on lat/lon/values.*/</span>
<a name="l00042"></a>00042 <a name="a1"></a><a class="code" href="grib__api_8h.html#8f20a42a04122a55dec71774c70a51c5">grib_iterator</a>* iter=NULL;
<a name="l00043"></a>00043
<a name="l00044"></a>00044 <span class="keywordflow">if</span> (argc != 2) usage(argv[0]);
<a name="l00045"></a>00045
<a name="l00046"></a>00046 filename=strdup(argv[1]);
<a name="l00047"></a>00047
<a name="l00048"></a>00048 in = fopen(filename,<span class="stringliteral">"r"</span>);
<a name="l00049"></a>00049 <span class="keywordflow">if</span>(!in) {
<a name="l00050"></a>00050 printf(<span class="stringliteral">"ERROR: unable to open file %s\n"</span>,filename);
<a name="l00051"></a>00051 <span class="keywordflow">return</span> 1;
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053
<a name="l00054"></a>00054 <span class="comment">/* Loop on all the messages in a file.*/</span>
<a name="l00055"></a>00055 <span class="keywordflow">while</span> ((h = <a name="a2"></a><a class="code" href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5" title="Create a handle from a file resource.">grib_handle_new_from_file</a>(0,in,&amp;err)) != NULL ) {
<a name="l00056"></a>00056 <span class="comment">/* Check of errors after reading a message. */</span>
<a name="l00057"></a>00057 <span class="keywordflow">if</span> (err != <a name="a3"></a><a class="code" href="grib__api_8h.html#5ec59f24fc07a0e9d05768e908b9eb41" title="No error.">GRIB_SUCCESS</a>) GRIB_CHECK(err,0);
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="comment">/* Get the double representing the missing value in the field. */</span>
<a name="l00060"></a>00060 GRIB_CHECK(<a name="a4"></a><a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"missingValue"</span>,&amp;missingValue),0);
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="comment">/* A new iterator on lat/lon/values is created from the message handle h. */</span>
<a name="l00063"></a>00063 iter=<a name="a5"></a><a class="code" href="group__iterators.html#gefb1f87110bdce732edc9154cf0e7d58" title="Create a new iterator from a handle, using current geometry and values.">grib_iterator_new</a>(h,0,&amp;err);
<a name="l00064"></a>00064 <span class="keywordflow">if</span> (err != <a class="code" href="grib__api_8h.html#5ec59f24fc07a0e9d05768e908b9eb41" title="No error.">GRIB_SUCCESS</a>) GRIB_CHECK(err,0);
<a name="l00065"></a>00065
<a name="l00066"></a>00066 n = 0;
<a name="l00067"></a>00067 <span class="comment">/* Loop on all the lat/lon/values. */</span>
<a name="l00068"></a>00068 <span class="keywordflow">while</span>(<a name="a6"></a><a class="code" href="group__iterators.html#g4f73056dbfdda3de0060559b9b39ea34" title="Get the next value from an iterator.">grib_iterator_next</a>(iter,&amp;lat,&amp;lon,&amp;value)) {
<a name="l00069"></a>00069 <span class="comment">/* You can now print lat and lon, */</span>
<a name="l00070"></a>00070 printf(<span class="stringliteral">"- %d - lat=%f lon=%f value="</span>,n,lat,lon);
<a name="l00071"></a>00071 <span class="comment">/* decide what to print if a missing value is found. */</span>
<a name="l00072"></a>00072 <span class="keywordflow">if</span> (value == missingValue ) printf(<span class="stringliteral">"missing\n"</span>);
<a name="l00073"></a>00073 <span class="comment">/* and print the value if is not missing. */</span>
<a name="l00074"></a>00074 <span class="keywordflow">else</span> printf(<span class="stringliteral">"%f\n"</span>,value);
<a name="l00075"></a>00075 n++;
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="comment">/* At the end the iterator is deleted to free memory. */</span>
<a name="l00079"></a>00079 <a name="a7"></a><a class="code" href="group__iterators.html#gd46ed73a16af56e6f3b46fe86ee8a759" title="Frees an iterator from memory.">grib_iterator_delete</a>(iter);
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="comment">/* At the end the grib_handle is deleted to free memory. */</span>
<a name="l00082"></a>00082 <a name="a8"></a><a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084
<a name="l00085"></a>00085
<a name="l00086"></a>00086 fclose(in);
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="keywordflow">return</span> 0;
<a name="l00089"></a>00089 }
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,103 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: iterator_fortran.F</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>iterator_fortran.F</h1>iterator_fortran.F How to use an iterator on latitude, longitude, values.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 C Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 C This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 C which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 C
<a name="l00005"></a>00005 C In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 C virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 C
<a name="l00008"></a>00008 C
<a name="l00009"></a>00009 C Fortran 77 Implementation: iterator_fortran
<a name="l00010"></a>00010 C
<a name="l00011"></a>00011 C Description: how to use an iterator on lat/lon/values.
<a name="l00012"></a>00012 C
<a name="l00013"></a>00013 C
<a name="l00014"></a>00014 C Author: Enrico Fucile
<a name="l00015"></a>00015 C
<a name="l00016"></a>00016 C
<a name="l00017"></a>00017 C
<a name="l00018"></a>00018 program iterator
<a name="l00019"></a>00019 implicit none
<a name="l00020"></a>00020 include 'grib_api_f77.h'
<a name="l00021"></a>00021 integer ifile
<a name="l00022"></a>00022 integer iret,iter
<a name="l00023"></a>00023 real*8 lat,lon,value,missingValue
<a name="l00024"></a>00024 integer n,flags
<a name="l00025"></a>00025 character*256 filename
<a name="l00026"></a>00026 character*256 error
<a name="l00027"></a>00027
<a name="l00028"></a>00028 C Message identifier.
<a name="l00029"></a>00029 integer igrib
<a name="l00030"></a>00030
<a name="l00031"></a>00031 ifile=5
<a name="l00032"></a>00032
<a name="l00033"></a>00033 call grib_check(grib_open_file(ifile,
<a name="l00034"></a>00034 X'../../data/regular_latlon_surface.grib1<span class="charliteral">','</span>r'))
<a name="l00035"></a>00035
<a name="l00036"></a>00036 C Loop on all the messages in a file.
<a name="l00037"></a>00037 10 iret=grib_new_from_file(ifile,igrib)
<a name="l00038"></a>00038 if (igrib .eq. -1 ) then
<a name="l00039"></a>00039 if (iret .ne.0) then
<a name="l00040"></a>00040 call grib_check(iret)
<a name="l00041"></a>00041 endif
<a name="l00042"></a>00042 stop
<a name="l00043"></a>00043 endif
<a name="l00044"></a>00044
<a name="l00045"></a>00045 C get as a real8
<a name="l00046"></a>00046 call grib_check(grib_get_real8(igrib
<a name="l00047"></a>00047 X,'missingValue',missingValue))
<a name="l00048"></a>00048 write(*,*) 'missingValue=',missingValue
<a name="l00049"></a>00049
<a name="l00050"></a>00050 C A new iterator on lat/lon/values is created from the message igrib
<a name="l00051"></a>00051 flags = 0
<a name="l00052"></a>00052 call grib_check(<a name="a0"></a><a class="code" href="group__iterators.html#gefb1f87110bdce732edc9154cf0e7d58" title="Create a new iterator from a handle, using current geometry and values.">grib_iterator_new</a>(igrib,iter,flags))
<a name="l00053"></a>00053
<a name="l00054"></a>00054 n = 0
<a name="l00055"></a>00055 C Loop on all the lat/lon/values.
<a name="l00056"></a>00056 20 iret = <a name="a1"></a><a class="code" href="group__iterators.html#g4f73056dbfdda3de0060559b9b39ea34" title="Get the next value from an iterator.">grib_iterator_next</a>(iter,lat,lon,value)
<a name="l00057"></a>00057 if ( iret .eq. 0 ) goto 30
<a name="l00058"></a>00058 C You can now print lat and lon,
<a name="l00059"></a>00059 if ( value .eq. missingValue ) then
<a name="l00060"></a>00060 C decide what to print if a missing value is found.
<a name="l00061"></a>00061 write(*,*) "- ",n," - lat=",lat," lon=",lon," value=missing"
<a name="l00062"></a>00062 else
<a name="l00063"></a>00063 C or print the value if is not missing.
<a name="l00064"></a>00064 write(*,*) " ",n," lat=",lat," lon=",lon," value=",value
<a name="l00065"></a>00065 endif
<a name="l00066"></a>00066
<a name="l00067"></a>00067 n=n+1
<a name="l00068"></a>00068
<a name="l00069"></a>00069 goto 20
<a name="l00070"></a>00070 30 continue
<a name="l00071"></a>00071
<a name="l00072"></a>00072 C At the end the iterator is deleted to free memory.
<a name="l00073"></a>00073 call grib_check(<a name="a2"></a><a class="code" href="group__iterators.html#gd46ed73a16af56e6f3b46fe86ee8a759" title="Frees an iterator from memory.">grib_iterator_delete</a>(iter))
<a name="l00074"></a>00074
<a name="l00075"></a>00075 goto 10
<a name="l00076"></a>00076
<a name="l00077"></a>00077 call grib_check(grib_release(igrib))
<a name="l00078"></a>00078
<a name="l00079"></a>00079 call grib_check(grib_close_file(ifile))
<a name="l00080"></a>00080
<a name="l00081"></a>00081 end
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,88 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: Grib API keys</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="keys">Grib API keys</a></h1>The GRIBEX routine used at ECMWF to encode and decode GRIB messages works on a number based table to retrive all the information from the message. This approach forces the user either to learn a code table or to use the documentation intensively. With grib_api a key name based access is provided so that all the information contained in the GRIB message is retrieved through alphanumeric names. <br>
All the key names are built from the official WMO documentation on the GRIB edition 1 and 2 coding standard removing the spaces in the key description and capitalizing the initials so that the caption:<br>
<div class="fragment"><pre class="fragment">
identification of originating generating centre
</pre></div> is transformed into the key name<br>
<div class="fragment"><pre class="fragment">
identificationOfOriginatingGeneratingCentre
</pre></div><br>
Some short names (aliases) are also provided, e.g. "centre" is an alias for identificationOfOriginatingGeneratingCentre. The names are always easily releated to the meaning of their value.<br>
A different set of keys is available for each message because the content is different. It is easy to find the keys available in a message by using the GRIB tools (<a class="el" href="grib_dump.html">grib_dump) </a>or the library (<a class="el" href="keys__iterator_8c-example.html">keys_iterator.c</a>).<br>
<h2><a class="anchor" name="coded_computed">
Coded and Computed keys</a></h2>
There are two different types of keys: coded and computed. <br>
The coded keys are directly linked to octets of the GRIB message and their value is obtained by only decoding the octets. A list of all the coded keys in a message can be obtained using <a class="el" href="grib_dump.html">grib_dump</a> without any option (use the -a option to obtain also their aliases).<br>
The computed keys are obtained by combining other keys (coded or computed) and when their value is set all the related keys are set in a cascade process.<br>
These keys provide a synthesis of the information contained in the GRIB message and are a safe way to set complex attributes such as the type of grid or the type of packing. They are also helpful in the interpretation of some octets such as the scanning mode whose bits are related to the way of scanning the grid. In this case the computed keys:<br>
<div class="fragment"><pre class="fragment">
iScansNegatively
jScansPositively
jPointsAreConsecutive
alternativeRowScanning (available only for edition 2)
</pre></div><br>
will provide access to single bits of the scanning mode octect hiding its structure from the user.<br>
The keys can also have some attributes as <em>read</em> <em>only</em>, which means that the key cannot be set (e.g. 7777 at the end of the message), or <em>edition</em> <em>specific</em> that is the attribute of all the keys having different values in the two editions (e.g. longitudeOfFirstGridPoint) or being present in one edition only (e.g. alternativeRowScanning).<br>
Moreover there are some computed keys that cannot be "get" and can be considered as functions acting on the grib in some way. These keys are always characterised by a predicate in their name (e.g. setDecimalPrecision).<br>
For the computed keys we provide the following preliminary documentation that will be extended soon.<ul>
<li>MARS keywords.<br>
All MARS keywords are available. Some examples are:<ul>
<li>date</li><li>param</li><li>levtype</li><li>levelist</li><li>step</li><li>stream</li></ul>
</li><li>angles in degrees. <br>
All the angle variables are provided in two versions, a native one with the units coded into the GRIB file and an edition independent one in degrees. It is always better to work with the "in degrees" version that is always provided through the key which has the same name of the native version with the suffix InDegrees <div class="fragment"><pre class="fragment">
longitudeOfFirstGridPoint -&gt; longitudeOfFirstGridPointInDegrees
latitudeOfFirstGridPoint -&gt; latitudeOfFirstGridPointInDegrees
longitudeOfLastGridPoint -&gt; longitudeOfLastGridPointInDegrees
latitudeOfFirstGridPoint -&gt; latitudeOfLastGridPointInDegrees
latitudeOfFirstGridPoint -&gt; latitudeOfFirstGridPointInDegrees
iDirectionIncrement -&gt; iDirectionIncrementInDegrees
jDirectionIncrement -&gt; jDirectionIncrementInDegrees
</pre></div></li><li>gridType<br>
The type of grid computed from the grid description section.<ul>
<li>For both editions:<ul>
<li>regular_ll</li><li>reduced_ll</li><li>mercator</li><li>lambert</li><li>polar_stereographic</li><li>UTM</li><li>simple_polyconic</li><li>albers</li><li>miller</li><li>rotated_ll</li><li>stretched_ll</li><li>stretched_rotated_ll</li><li>regular_gg</li><li>rotated_gg</li><li>stretched_gg</li><li>stretched_rotated_gg</li><li>reduced_gg</li><li>sh</li><li>rotated_sh</li><li>stretched_sh</li><li>stretched_rotated_sh</li><li>space_view<br>
</li></ul>
</li><li>For edition 2 only:<ul>
<li>triangular_grid</li><li>equatorial_azimuthal_equidistant</li><li>azimuth_range</li><li>cross_section</li><li>Hovmoller</li><li>time_section</li></ul>
</li></ul>
</li></ul>
<p>
<ul>
<li>packingType<br>
The alghorithm used to pack data into the GRIB message.<br>
<ul>
<li>For GRIB edition 1:<ul>
<li>grid_simple</li><li>grid_simple_matrix</li><li>grid_simple_matrix_bitmap</li><li>grid_second_order</li><li>grid_second_order_different_width</li><li>spectral_complex</li><li>spectral_simple</li><li>grid_unknown</li><li>spectral_unknown<br>
</li></ul>
</li><li>For GRIB edition 2:<ul>
<li>grid_simple</li><li>grid_simple_matrix</li><li>grid_simple_matrix_bitmap</li><li>grid_complex</li><li>grid_complex_spatial_differencing</li><li>grid_jpeg</li><li>grid_png</li><li>grid_ieee</li><li>spectral_simple</li><li>spectral_complex</li><li>grid_simple_log_preprocessing</li></ul>
</li></ul>
</li></ul>
<p>
<ul>
<li>setDecimalPrecision<br>
is a function key used to set the decimal precision see the <a class="el" href="grib_set.html">grib_set</a> page for usage.</li></ul>
<p>
<ul>
<li>getNumberOfValues<br>
The number of values coded into the data section of the GRIB message </li></ul>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,115 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: keys_iterator.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>keys_iterator.c</h1>keys_iterator.c How to get the names of all the keys defined in a message and how to iterate through them.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> * C Implementation: keys_iterator</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Description:</span>
<a name="l00014"></a>00014 <span class="comment"> * Example on how to use keys_iterator functions and the</span>
<a name="l00015"></a>00015 <span class="comment"> * grib_keys_iterator structure to get all the available</span>
<a name="l00016"></a>00016 <span class="comment"> * keys in a message.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * Author: Enrico Fucile</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> *</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>"</span>
<a name="l00029"></a>00029
<a name="l00030"></a>00030 <span class="preprocessor">#define MAX_KEY_LEN 255</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span><span class="preprocessor">#define MAX_VAL_LEN 1024</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>
<a name="l00033"></a>00033 <span class="keyword">static</span> <span class="keywordtype">void</span> usage(<span class="keywordtype">char</span>* progname);
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
<a name="l00036"></a>00036 {
<a name="l00037"></a>00037 <span class="comment">/* To skip read only and not coded keys</span>
<a name="l00038"></a>00038 <span class="comment"> unsigned long key_iterator_filter_flags=GRIB_KEYS_ITERATOR_SKIP_READ_ONLY ||</span>
<a name="l00039"></a>00039 <span class="comment"> GRIB_KEYS_ITERATOR_SKIP_COMPUTED;</span>
<a name="l00040"></a>00040 <span class="comment"> */</span>
<a name="l00041"></a>00041 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> key_iterator_filter_flags=<a name="a0"></a><a class="code" href="group__keys__iterator.html#g0e4d2d943ddd61d0b877060e6fbea405">GRIB_KEYS_ITERATOR_ALL_KEYS</a>;
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="comment">/* valid name_spaces are ls and mars */</span>
<a name="l00044"></a>00044 <span class="keywordtype">char</span>* name_space=<span class="stringliteral">"ls"</span>;
<a name="l00045"></a>00045
<a name="l00046"></a>00046 <span class="comment">/* name_space=NULL to get all the keys */</span>
<a name="l00047"></a>00047 <span class="comment">/* char* name_space=0; */</span>
<a name="l00048"></a>00048
<a name="l00049"></a>00049 FILE* f;
<a name="l00050"></a>00050 <a name="a1"></a><a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* h=NULL;
<a name="l00051"></a>00051 <a name="a2"></a><a class="code" href="group__keys__iterator.html#gfa22412541f9d2df9680a82371036dbb">grib_keys_iterator</a>* kiter=NULL;
<a name="l00052"></a>00052 <span class="keywordtype">int</span> err=0;
<a name="l00053"></a>00053 <span class="keywordtype">int</span> grib_count=0;
<a name="l00054"></a>00054
<a name="l00055"></a>00055 <span class="keywordtype">char</span> value[MAX_VAL_LEN];
<a name="l00056"></a>00056 <span class="keywordtype">size_t</span> vlen=MAX_VAL_LEN;
<a name="l00057"></a>00057
<a name="l00058"></a>00058 <span class="keywordflow">if</span> (argc != 2) usage(argv[0]);
<a name="l00059"></a>00059
<a name="l00060"></a>00060 f = fopen(argv[1],<span class="stringliteral">"r"</span>);
<a name="l00061"></a>00061 <span class="keywordflow">if</span>(!f) {
<a name="l00062"></a>00062 perror(argv[1]);
<a name="l00063"></a>00063 exit(1);
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keywordflow">while</span>((h = <a name="a3"></a><a class="code" href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5" title="Create a handle from a file resource.">grib_handle_new_from_file</a>(0,f,&amp;err)) != NULL) {
<a name="l00067"></a>00067
<a name="l00068"></a>00068 grib_count++;
<a name="l00069"></a>00069 printf(<span class="stringliteral">"-- GRIB N. %d --\n"</span>,grib_count);
<a name="l00070"></a>00070 <span class="keywordflow">if</span>(!h) {
<a name="l00071"></a>00071 printf(<span class="stringliteral">"ERROR: Unable to create grib handle\n"</span>);
<a name="l00072"></a>00072 exit(1);
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074
<a name="l00075"></a>00075 kiter=<a name="a4"></a><a class="code" href="group__keys__iterator.html#g66a11d157fc81e1c27fc2acad0a5b1f4">grib_keys_iterator_new</a>(h,key_iterator_filter_flags,name_space);
<a name="l00076"></a>00076 <span class="keywordflow">if</span> (!kiter) {
<a name="l00077"></a>00077 printf(<span class="stringliteral">"ERROR: Unable to create keys iterator\n"</span>);
<a name="l00078"></a>00078 exit(1);
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="keywordflow">while</span>(<a name="a5"></a><a class="code" href="group__keys__iterator.html#g28f6ac808ecdc324fa3a47bc7b3f6dec">grib_keys_iterator_next</a>(kiter))
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083 <span class="keyword">const</span> <span class="keywordtype">char</span>* name = <a name="a6"></a><a class="code" href="group__keys__iterator.html#gec3348471f770965c07964e286249e12">grib_keys_iterator_get_name</a>(kiter);
<a name="l00084"></a>00084 vlen=MAX_VAL_LEN;
<a name="l00085"></a>00085 GRIB_CHECK(<a name="a7"></a><a class="code" href="group__get__set.html#g8aeaf9f930eea1cc0f15e92f18a25053" title="Get a string value from a key, if several keys of the same name are present, the...">grib_get_string</a>(h,name,value,&amp;vlen),name);
<a name="l00086"></a>00086 printf(<span class="stringliteral">"%s = %s\n"</span>,name,value);
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <a name="a8"></a><a class="code" href="group__keys__iterator.html#g79716d2b701c3dbb3d3a8e633f35a40a">grib_keys_iterator_delete</a>(kiter);
<a name="l00090"></a>00090
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="keywordflow">return</span> 0;
<a name="l00094"></a>00094
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keyword">static</span> <span class="keywordtype">void</span> usage(<span class="keywordtype">char</span>* progname) {
<a name="l00098"></a>00098 printf(<span class="stringliteral">"\nUsage: %s grib_file\n"</span>,progname);
<a name="l00099"></a>00099 exit(1);
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,86 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: keys_iterator.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>keys_iterator.f90</h1>How to get the names of all the keys defined in a message and how to iterate through them.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description:
<a name="l00010"></a>00010 ! How to use keys_iterator to <span class="keyword">get</span> all the available
<a name="l00011"></a>00011 ! keys in a message.
<a name="l00012"></a>00012 !
<a name="l00013"></a>00013 ! Author: Enrico Fucile
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 !
<a name="l00016"></a>00016 program keys_iterator
<a name="l00017"></a>00017 use grib_api
<a name="l00018"></a>00018 implicit none
<a name="l00019"></a>00019 character(len=20) :: name_space
<a name="l00020"></a>00020 integer :: kiter,ifile,igrib,iret
<a name="l00021"></a>00021 character(len=256) :: key
<a name="l00022"></a>00022 character(len=256) :: value
<a name="l00023"></a>00023 character(len=512) :: all
<a name="l00024"></a>00024 integer :: grib_count
<a name="l00025"></a>00025
<a name="l00026"></a>00026 call grib_open_file(ifile, &amp;
<a name="l00027"></a>00027 '../../data/regular_latlon_surface.grib1','r')
<a name="l00028"></a>00028
<a name="l00029"></a>00029 ! Loop on all the messages in a file.
<a name="l00030"></a>00030
<a name="l00031"></a>00031 call grib_new_from_file(ifile,igrib, iret)
<a name="l00032"></a>00032
<a name="l00033"></a>00033 do while (iret /= <a name="a0"></a><a class="code" href="grib__api_8h.html#3bd3d72fe8bc116ca08c2d4b99203768" title="End of ressource reached.">GRIB_END_OF_FILE</a>)
<a name="l00034"></a>00034
<a name="l00035"></a>00035 grib_count=grib_count+1
<a name="l00036"></a>00036 write(*,*) '-- GRIB N. ',grib_count,' --'
<a name="l00037"></a>00037
<a name="l00038"></a>00038 ! valid name_spaces are ls and mars
<a name="l00039"></a>00039 name_space='ls'
<a name="l00040"></a>00040
<a name="l00041"></a>00041 call <a name="a1"></a><a class="code" href="group__keys__iterator.html#g66a11d157fc81e1c27fc2acad0a5b1f4">grib_keys_iterator_new</a>(igrib,kiter,name_space)
<a name="l00042"></a>00042
<a name="l00043"></a>00043 do
<a name="l00044"></a>00044 call <a name="a2"></a><a class="code" href="group__keys__iterator.html#g28f6ac808ecdc324fa3a47bc7b3f6dec">grib_keys_iterator_next</a>(kiter, iret)
<a name="l00045"></a>00045
<a name="l00046"></a>00046 if (iret .ne. 1) exit
<a name="l00047"></a>00047
<a name="l00048"></a>00048 call <a name="a3"></a><a class="code" href="group__keys__iterator.html#gec3348471f770965c07964e286249e12">grib_keys_iterator_get_name</a>(kiter,key)
<a name="l00049"></a>00049 call grib_get(igrib,trim(key),value)
<a name="l00050"></a>00050 all=trim(key)<span class="comment">// ' = ' // trim(value)</span>
<a name="l00051"></a>00051 write(*,*) trim(all)
<a name="l00052"></a>00052
<a name="l00053"></a>00053 end do
<a name="l00054"></a>00054
<a name="l00055"></a>00055 call <a name="a4"></a><a class="code" href="group__keys__iterator.html#g79716d2b701c3dbb3d3a8e633f35a40a">grib_keys_iterator_delete</a>(kiter)
<a name="l00056"></a>00056 call grib_release(igrib)
<a name="l00057"></a>00057 call grib_new_from_file(ifile,igrib, iret)
<a name="l00058"></a>00058 end do
<a name="l00059"></a>00059
<a name="l00060"></a>00060
<a name="l00061"></a>00061 call grib_close_file(ifile)
<a name="l00062"></a>00062
<a name="l00063"></a>00063 end program keys_iterator
<a name="l00064"></a>00064
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,99 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: keys_iterator_fortran.F</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>keys_iterator_fortran.F</h1>keys_iterator_fortran.F How to get the names of all the keys defined in a message and how to iterate through them.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 C Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 C This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 C which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 C
<a name="l00005"></a>00005 C In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 C virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 C
<a name="l00008"></a>00008 C
<a name="l00009"></a>00009 C Fortran 77 Implementation: keys_iterator
<a name="l00010"></a>00010 C
<a name="l00011"></a>00011 C Description:
<a name="l00012"></a>00012 C Example on how to use keys_iterator functions and the
<a name="l00013"></a>00013 C <a name="a0"></a><a class="code" href="group__keys__iterator.html#gfa22412541f9d2df9680a82371036dbb">grib_keys_iterator</a> structure to <span class="keyword">get</span> all the available
<a name="l00014"></a>00014 C keys in a message.
<a name="l00015"></a>00015 C
<a name="l00016"></a>00016 C Author: Enrico Fucile
<a name="l00017"></a>00017 C
<a name="l00018"></a>00018 C
<a name="l00019"></a>00019 C
<a name="l00020"></a>00020 program keys_iterator
<a name="l00021"></a>00021 implicit none
<a name="l00022"></a>00022 include 'grib_api_f77.h'
<a name="l00023"></a>00023 character*20 name_space
<a name="l00024"></a>00024 integer kiter,ifile,igrib,iret
<a name="l00025"></a>00025 character*256 key
<a name="l00026"></a>00026 character*256 value
<a name="l00027"></a>00027 character*512 all
<a name="l00028"></a>00028 integer len,strlen
<a name="l00029"></a>00029 integer grib_count
<a name="l00030"></a>00030 len=256
<a name="l00031"></a>00031
<a name="l00032"></a>00032 ifile=5
<a name="l00033"></a>00033
<a name="l00034"></a>00034 call grib_check(grib_open_file(ifile,
<a name="l00035"></a>00035 X'../../data/regular_latlon_surface.grib1<span class="charliteral">','</span>r'))
<a name="l00036"></a>00036
<a name="l00037"></a>00037 grib_count=0
<a name="l00038"></a>00038 C Loop on all the messages in a file.
<a name="l00039"></a>00039 10 iret=grib_new_from_file(ifile,igrib)
<a name="l00040"></a>00040 if (igrib .eq. -1 ) then
<a name="l00041"></a>00041 if (iret .ne.0) then
<a name="l00042"></a>00042 call grib_check(iret)
<a name="l00043"></a>00043 endif
<a name="l00044"></a>00044 stop
<a name="l00045"></a>00045 endif
<a name="l00046"></a>00046
<a name="l00047"></a>00047 grib_count=grib_count+1
<a name="l00048"></a>00048 write(*,'("-- GRIB N.",I4," --")') grib_count
<a name="l00049"></a>00049
<a name="l00050"></a>00050 C valid name_spaces are ls and mars
<a name="l00051"></a>00051 name_space='ls'
<a name="l00052"></a>00052 C name_space=' ' to get all the keys */
<a name="l00053"></a>00053 C name_space=' '
<a name="l00054"></a>00054
<a name="l00055"></a>00055 call grib_check(
<a name="l00056"></a>00056 Xgrib_keys_iterator_new(igrib,kiter,name_space))
<a name="l00057"></a>00057 C call grib_check(grib_keys_iterator_skip_read_only(kiter))
<a name="l00058"></a>00058 C call grib_check(grib_keys_iterator_skip_function(kiter))
<a name="l00059"></a>00059 C call grib_check(grib_keys_iterator_skip_not_coded(kiter))
<a name="l00060"></a>00060
<a name="l00061"></a>00061 20 if (<a name="a1"></a><a class="code" href="group__keys__iterator.html#g28f6ac808ecdc324fa3a47bc7b3f6dec">grib_keys_iterator_next</a>(kiter) .ne. 1) goto 10
<a name="l00062"></a>00062
<a name="l00063"></a>00063 call grib_check(<a name="a2"></a><a class="code" href="group__keys__iterator.html#gec3348471f770965c07964e286249e12">grib_keys_iterator_get_name</a>(kiter,key))
<a name="l00064"></a>00064 call grib_check(<a name="a3"></a><a class="code" href="group__get__set.html#g8aeaf9f930eea1cc0f15e92f18a25053" title="Get a string value from a key, if several keys of the same name are present, the...">grib_get_string</a>(igrib,key,value))
<a name="l00065"></a>00065 all='|' <span class="comment">// trim(key)//'|' // ' = ' //'|' // trim(value) // '|' </span>
<a name="l00066"></a>00066 write(*,*) trim(all)
<a name="l00067"></a>00067
<a name="l00068"></a>00068 goto 20
<a name="l00069"></a>00069
<a name="l00070"></a>00070 call grib_check(<a name="a4"></a><a class="code" href="group__keys__iterator.html#g79716d2b701c3dbb3d3a8e633f35a40a">grib_keys_iterator_delete</a>(kiter))
<a name="l00071"></a>00071
<a name="l00072"></a>00072 call grib_check(grib_release(igrib))
<a name="l00073"></a>00073
<a name="l00074"></a>00074 call grib_check(grib_close_file(ifile))
<a name="l00075"></a>00075
<a name="l00076"></a>00076 end
<a name="l00077"></a>00077
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,85 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: multi.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>multi.c</h1>multi.c How to decode a grib message containing many fields.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> * C Implementation: multi </span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Description: How to decode grib messages containing multiple</span>
<a name="l00014"></a>00014 <span class="comment"> * fields. Try to turn on and off multi support to</span>
<a name="l00015"></a>00015 <span class="comment"> * see the difference. Default is OFF.</span>
<a name="l00016"></a>00016 <span class="comment"> * For all the tools defalut is multi support ON.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * Author: Enrico Fucile</span>
<a name="l00020"></a>00020 <span class="comment"> *</span>
<a name="l00021"></a>00021 <span class="comment"> *</span>
<a name="l00022"></a>00022 <span class="comment"> */</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>"</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv) {
<a name="l00029"></a>00029 <span class="keywordtype">int</span> err = 0;
<a name="l00030"></a>00030 <span class="keywordtype">long</span> parameterCategory=0,parameterNumber=0,discipline=0;
<a name="l00031"></a>00031 FILE* in = NULL;
<a name="l00032"></a>00032 <span class="keywordtype">char</span>* filename = <span class="stringliteral">"../../data/multi.grib2"</span>;
<a name="l00033"></a>00033 <a name="a0"></a><a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h = NULL;
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="comment">/* turn on support for multi fields messages */</span>
<a name="l00036"></a>00036 <a name="a1"></a><a class="code" href="group__context.html#g3266536e68ebb6d4bbc4a22b29f0e8ea" title="Turn on support for multiple fields in single grib messages.">grib_multi_support_on</a>(0);
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="comment">/* turn off support for multi fields messages */</span>
<a name="l00039"></a>00039 <span class="comment">/* grib_multi_support_off(0); */</span>
<a name="l00040"></a>00040
<a name="l00041"></a>00041 in = fopen(filename,<span class="stringliteral">"r"</span>);
<a name="l00042"></a>00042 <span class="keywordflow">if</span>(!in) {
<a name="l00043"></a>00043 printf(<span class="stringliteral">"ERROR: unable to open file %s\n"</span>,filename);
<a name="l00044"></a>00044 <span class="keywordflow">return</span> 1;
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="keywordflow">while</span> ((h = <a name="a2"></a><a class="code" href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5" title="Create a handle from a file resource.">grib_handle_new_from_file</a>(0,in,&amp;err)) != NULL ) {
<a name="l00049"></a>00049
<a name="l00050"></a>00050 GRIB_CHECK(err,0);
<a name="l00051"></a>00051
<a name="l00052"></a>00052 GRIB_CHECK(<a name="a3"></a><a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"discipline"</span>,&amp;discipline),0);
<a name="l00053"></a>00053 printf(<span class="stringliteral">"discipline=%ld\n"</span>,discipline);
<a name="l00054"></a>00054
<a name="l00055"></a>00055 GRIB_CHECK(<a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"parameterCategory"</span>,&amp;parameterCategory),0);
<a name="l00056"></a>00056 printf(<span class="stringliteral">"parameterCategory=%ld\n"</span>,parameterCategory);
<a name="l00057"></a>00057
<a name="l00058"></a>00058 GRIB_CHECK(<a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"parameterNumber"</span>,&amp;parameterNumber),0);
<a name="l00059"></a>00059 printf(<span class="stringliteral">"parameterNumber=%ld\n"</span>,parameterNumber);
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="keywordflow">if</span> ( discipline == 0 &amp;&amp; parameterCategory==2) {
<a name="l00062"></a>00062 <span class="keywordflow">if</span> (parameterNumber == 2) printf(<span class="stringliteral">"-------- u -------\n"</span>);
<a name="l00063"></a>00063 <span class="keywordflow">if</span> (parameterNumber == 3) printf(<span class="stringliteral">"-------- v -------\n"</span>);
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <a name="a4"></a><a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<a name="l00068"></a>00068
<a name="l00069"></a>00069 fclose(in);
<a name="l00070"></a>00070 <span class="keywordflow">return</span> 0;
<a name="l00071"></a>00071 }
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,72 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: multi.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>multi.f90</h1>How to decode a grib message containing many fields.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: How to decode grib messages containing multiple
<a name="l00010"></a>00010 ! fields. Try to turn on and off multi support to
<a name="l00011"></a>00011 ! see the difference. Default is OFF.
<a name="l00012"></a>00012 ! For all the tools defalut is multi support ON.
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 ! Author: Enrico Fucile
<a name="l00016"></a>00016 !
<a name="l00017"></a>00017 !
<a name="l00018"></a>00018 program multi
<a name="l00019"></a>00019 use grib_api
<a name="l00020"></a>00020 implicit none
<a name="l00021"></a>00021
<a name="l00022"></a>00022 integer :: iret
<a name="l00023"></a>00023 character(len = 256) :: error
<a name="l00024"></a>00024 integer(kind = 4) :: step
<a name="l00025"></a>00025 integer :: ifile,igrib
<a name="l00026"></a>00026
<a name="l00027"></a>00027 call grib_open_file(ifile, '../../data/multi_created.grib2','r')
<a name="l00028"></a>00028
<a name="l00029"></a>00029 ! turn on support for multi fields messages */
<a name="l00030"></a>00030 call <a name="a0"></a><a class="code" href="group__context.html#g3266536e68ebb6d4bbc4a22b29f0e8ea" title="Turn on support for multiple fields in single grib messages.">grib_multi_support_on</a>()
<a name="l00031"></a>00031
<a name="l00032"></a>00032 ! turn off support for multi fields messages */
<a name="l00033"></a>00033 !call <a name="a1"></a><a class="code" href="group__context.html#gc022270a99922ccc57147670ed2a58d4" title="Turn off support for multiple fields in single grib messages.">grib_multi_support_off</a>()
<a name="l00034"></a>00034
<a name="l00035"></a>00035 call grib_new_from_file(ifile,igrib, iret)
<a name="l00036"></a>00036 ! Loop on all the messages in a file.
<a name="l00037"></a>00037
<a name="l00038"></a>00038 write(*,*) 'step'
<a name="l00039"></a>00039 do while (iret /= <a name="a2"></a><a class="code" href="grib__api_8h.html#3bd3d72fe8bc116ca08c2d4b99203768" title="End of ressource reached.">GRIB_END_OF_FILE</a>)
<a name="l00040"></a>00040
<a name="l00041"></a>00041 call grib_get(igrib,'step', step)
<a name="l00042"></a>00042 write(*,'(i3)') step
<a name="l00043"></a>00043
<a name="l00044"></a>00044 call grib_new_from_file(ifile,igrib, iret)
<a name="l00045"></a>00045
<a name="l00046"></a>00046 end do
<a name="l00047"></a>00047 call grib_close_file(ifile)
<a name="l00048"></a>00048
<a name="l00049"></a>00049 end program multi
<a name="l00050"></a>00050
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,99 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: multi_fortran.F</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>multi_fortran.F</h1>multi_fortran.F How to decode a grib message containing many fields.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 C Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 C This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 C which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 C
<a name="l00005"></a>00005 C In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 C virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 C
<a name="l00008"></a>00008 C
<a name="l00009"></a>00009 C Fortran 77 Implementation: multi_fortran
<a name="l00010"></a>00010 C
<a name="l00011"></a>00011 C Description: How to decode grib messages containing multiple
<a name="l00012"></a>00012 C fields. Try to turn on and off multi support to
<a name="l00013"></a>00013 C see the difference. Default is OFF.
<a name="l00014"></a>00014 C For all the tools defalut is multi support ON.
<a name="l00015"></a>00015 C
<a name="l00016"></a>00016 C
<a name="l00017"></a>00017 C Author: Enrico Fucile
<a name="l00018"></a>00018 C
<a name="l00019"></a>00019 C
<a name="l00020"></a>00020 C
<a name="l00021"></a>00021 program multi
<a name="l00022"></a>00022 implicit none
<a name="l00023"></a>00023 include 'grib_api_f77.h'
<a name="l00024"></a>00024 integer iret
<a name="l00025"></a>00025 character*256 error
<a name="l00026"></a>00026 integer*4 parameterCategory,parameterNumber,discipline
<a name="l00027"></a>00027 integer ifile,igrib
<a name="l00028"></a>00028
<a name="l00029"></a>00029 call grib_check( grib_open_file(ifile
<a name="l00030"></a>00030 X,'../../data/multi.grib2<span class="charliteral">','</span>r'))
<a name="l00031"></a>00031
<a name="l00032"></a>00032 C turn on support for multi fields messages */
<a name="l00033"></a>00033 call grib_check(<a name="a0"></a><a class="code" href="group__context.html#g3266536e68ebb6d4bbc4a22b29f0e8ea" title="Turn on support for multiple fields in single grib messages.">grib_multi_support_on</a>())
<a name="l00034"></a>00034
<a name="l00035"></a>00035 C turn off support for multi fields messages */
<a name="l00036"></a>00036 C call grib_check(<a name="a1"></a><a class="code" href="group__context.html#gc022270a99922ccc57147670ed2a58d4" title="Turn off support for multiple fields in single grib messages.">grib_multi_support_off</a>())
<a name="l00037"></a>00037
<a name="l00038"></a>00038 C Loop on all the messages in a file.
<a name="l00039"></a>00039 10 iret=grib_new_from_file(ifile,igrib)
<a name="l00040"></a>00040 if (igrib .eq. -1 ) then
<a name="l00041"></a>00041 if (iret .ne.0) then
<a name="l00042"></a>00042 call grib_check(iret)
<a name="l00043"></a>00043 endif
<a name="l00044"></a>00044 stop
<a name="l00045"></a>00045 endif
<a name="l00046"></a>00046
<a name="l00047"></a>00047 C get as a integer*4
<a name="l00048"></a>00048 call grib_check(grib_get_int(igrib,'discipline',discipline))
<a name="l00049"></a>00049 write(*,*) 'discipline=',discipline
<a name="l00050"></a>00050
<a name="l00051"></a>00051 C get as a integer*4
<a name="l00052"></a>00052 call grib_check(grib_get_int(igrib,'parameterCategory'
<a name="l00053"></a>00053 X,parameterCategory))
<a name="l00054"></a>00054 write(*,*) 'parameterCategory=',parameterCategory
<a name="l00055"></a>00055
<a name="l00056"></a>00056 C get as a integer*4
<a name="l00057"></a>00057 call grib_check(grib_get_int(igrib,'parameterNumber'
<a name="l00058"></a>00058 X,parameterNumber))
<a name="l00059"></a>00059 write(*,*) 'parameterNumber=',parameterNumber
<a name="l00060"></a>00060
<a name="l00061"></a>00061 if ( discipline .eq. 0 .and. parameterCategory .eq. 2) then
<a name="l00062"></a>00062 if (parameterNumber .eq. 2) then
<a name="l00063"></a>00063 write(*,*) "-------- u -------"
<a name="l00064"></a>00064 endif
<a name="l00065"></a>00065 if (parameterNumber .eq. 3) then
<a name="l00066"></a>00066 write(*,*) "-------- v -------"
<a name="l00067"></a>00067 endif
<a name="l00068"></a>00068 endif
<a name="l00069"></a>00069
<a name="l00070"></a>00070 goto 10
<a name="l00071"></a>00071
<a name="l00072"></a>00072 call grib_check(grib_release(igrib))
<a name="l00073"></a>00073
<a name="l00074"></a>00074 call grib_check(grib_close_file(ifile))
<a name="l00075"></a>00075
<a name="l00076"></a>00076 end
<a name="l00077"></a>00077
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,107 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: nearest.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>nearest.c</h1>nearest.c How to find the nearest grid points.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> * C Implementation: fieldset</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Description: how to use a fieldset.</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * Author: Enrico Fucile</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> */</span>
<a name="l00020"></a>00020
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00024"></a>00024
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>"</span>
<a name="l00026"></a>00026
<a name="l00027"></a>00027 <span class="keywordtype">void</span> usage(<span class="keywordtype">char</span>* prog) {
<a name="l00028"></a>00028 printf(<span class="stringliteral">"Usage: %s grib_file grib_file ...\n"</span>,prog);
<a name="l00029"></a>00029 exit(1);
<a name="l00030"></a>00030 }
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv) {
<a name="l00033"></a>00033 <span class="keywordtype">int</span> err = 0;
<a name="l00034"></a>00034 <span class="keywordtype">long</span> step=0;
<a name="l00035"></a>00035 <span class="keywordtype">size_t</span> nfiles;
<a name="l00036"></a>00036 <span class="keywordtype">int</span> i=0;
<a name="l00037"></a>00037 grib_fieldset* <span class="keyword">set</span>=NULL;
<a name="l00038"></a>00038 <a name="a0"></a><a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a>* h=NULL;
<a name="l00039"></a>00039 <span class="keywordtype">char</span> param[20]={0,};
<a name="l00040"></a>00040 <span class="keywordtype">size_t</span> len=20;
<a name="l00041"></a>00041 <span class="keywordtype">double</span> lats[4]={0,};
<a name="l00042"></a>00042 <span class="keywordtype">double</span> lons[4]={0,};
<a name="l00043"></a>00043 <span class="keywordtype">double</span> values[4]={0,};
<a name="l00044"></a>00044 <span class="keywordtype">double</span> distances[4]={0,};
<a name="l00045"></a>00045 <span class="keywordtype">int</span> indexes[4]={0,};
<a name="l00046"></a>00046 <span class="keywordtype">char</span>* order_by=<span class="stringliteral">"param,step"</span>;
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="keywordtype">size_t</span> size=4;
<a name="l00049"></a>00049 <span class="keywordtype">double</span> lat=-40,lon=15;
<a name="l00050"></a>00050 <span class="keywordtype">int</span> mode=0;
<a name="l00051"></a>00051 <span class="keywordtype">int</span> count;
<a name="l00052"></a>00052 <span class="keywordtype">char</span>** filenames;
<a name="l00053"></a>00053 <a name="a1"></a><a class="code" href="grib__api_8h.html#1b47558cfe02835ba44213ee4d45fd9b">grib_nearest</a>* nearest=NULL;
<a name="l00054"></a>00054
<a name="l00055"></a>00055 <span class="keywordflow">if</span> (argc &lt; 2) usage(argv[0]);
<a name="l00056"></a>00056
<a name="l00057"></a>00057 nfiles=argc-1;
<a name="l00058"></a>00058 filenames=(<span class="keywordtype">char</span>**)malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>*)*nfiles);
<a name="l00059"></a>00059 <span class="keywordflow">for</span> (i=0;i&lt;nfiles;i++)
<a name="l00060"></a>00060 filenames[i]=(<span class="keywordtype">char</span>*)strdup(argv[i+1]);
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="keyword">set</span>=grib_fieldset_new_from_files(0,filenames,nfiles,0,0,0,order_by,&amp;err);
<a name="l00063"></a>00063 GRIB_CHECK(err,0);
<a name="l00064"></a>00064
<a name="l00065"></a>00065 printf(<span class="stringliteral">"\nordering by %s\n"</span>,order_by);
<a name="l00066"></a>00066 printf(<span class="stringliteral">"\n%d fields in the fieldset\n"</span>,grib_fieldset_count(<span class="keyword">set</span>));
<a name="l00067"></a>00067 printf(<span class="stringliteral">"n,step,param\n"</span>);
<a name="l00068"></a>00068
<a name="l00069"></a>00069 mode=GRIB_NEAREST_SAME_GRID | GRIB_NEAREST_SAME_POINT;
<a name="l00070"></a>00070 count=1;
<a name="l00071"></a>00071 <span class="keywordflow">while</span> ((h=grib_fieldset_next_handle(<span class="keyword">set</span>,&amp;err))!=NULL) {
<a name="l00072"></a>00072 GRIB_CHECK(<a name="a2"></a><a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"step"</span>,&amp;step),0);
<a name="l00073"></a>00073 len=20;
<a name="l00074"></a>00074 GRIB_CHECK(<a name="a3"></a><a class="code" href="group__get__set.html#g8aeaf9f930eea1cc0f15e92f18a25053" title="Get a string value from a key, if several keys of the same name are present, the...">grib_get_string</a>(h,<span class="stringliteral">"param"</span>,param,&amp;len),0);
<a name="l00075"></a>00075
<a name="l00076"></a>00076 printf(<span class="stringliteral">"%d %ld %s "</span>,count,step,param);
<a name="l00077"></a>00077 <span class="keywordflow">if</span> (!nearest) nearest=<a name="a4"></a><a class="code" href="group__iterators.html#g4bd616cf0d0c4f5f147f4a207ddc7687" title="Create a new nearest from a handle, using current geometry .">grib_nearest_new</a>(h,&amp;err);
<a name="l00078"></a>00078 GRIB_CHECK(err,0);
<a name="l00079"></a>00079 GRIB_CHECK(<a name="a5"></a><a class="code" href="group__iterators.html#g15043a2482608fb93a0385f3c3e86926" title="Find the 4 nearest points of a latitude longitude point.">grib_nearest_find</a>(nearest,h,lat,lon,mode,lats,lons,values,distances,indexes,&amp;size),0);
<a name="l00080"></a>00080 <span class="keywordflow">for</span> (i=0;i&lt;4;i++) printf(<span class="stringliteral">"%d %.2f %.2f %g %g - "</span>,
<a name="l00081"></a>00081 (<span class="keywordtype">int</span>)indexes[i],lats[i],lons[i],distances[i],values[i]);
<a name="l00082"></a>00082 printf(<span class="stringliteral">"\n"</span>);
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <a name="a6"></a><a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<a name="l00085"></a>00085 count++;
<a name="l00086"></a>00086 }
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="keywordflow">if</span> (nearest) <a name="a7"></a><a class="code" href="group__iterators.html#g2b3c0069013e1ad7b3e34f30b4659c15" title="Frees an nearest from memory.">grib_nearest_delete</a>(nearest);
<a name="l00089"></a>00089
<a name="l00090"></a>00090 <span class="keywordflow">if</span> (<span class="keyword">set</span>) grib_fieldset_delete(<span class="keyword">set</span>);
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="keywordflow">return</span> 0;
<a name="l00093"></a>00093 }
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,104 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: nearest.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>nearest.f90</h1>How to find the nearest grid points.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to use grib_find_nearest and grib_get_element
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Enrico Fucile
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 !
<a name="l00016"></a>00016 program find
<a name="l00017"></a>00017 use grib_api
<a name="l00018"></a>00018 implicit none
<a name="l00019"></a>00019 integer :: npoints
<a name="l00020"></a>00020 integer :: infile
<a name="l00021"></a>00021 integer :: igrib, ios, i
<a name="l00022"></a>00022 real(8), dimension(:), allocatable :: lats, lons
<a name="l00023"></a>00023 real(8), dimension(:), allocatable :: nearest_lats, nearest_lons
<a name="l00024"></a>00024 real(8), dimension(:), allocatable :: distances, values, lsm_values
<a name="l00025"></a>00025 integer(kind=kindOfInt), dimension(:), allocatable :: indexes
<a name="l00026"></a>00026 real(kind=8) :: value
<a name="l00027"></a>00027
<a name="l00028"></a>00028 ! initialization
<a name="l00029"></a>00029 open( unit=1, file=<span class="stringliteral">"../../data/list_points"</span>,form=<span class="stringliteral">"formatted"</span>,action=<span class="stringliteral">"read"</span>)
<a name="l00030"></a>00030 read(unit=1,fmt=*) npoints
<a name="l00031"></a>00031 allocate(lats(npoints))
<a name="l00032"></a>00032 allocate(lons(npoints))
<a name="l00033"></a>00033 allocate(nearest_lats(npoints))
<a name="l00034"></a>00034 allocate(nearest_lons(npoints))
<a name="l00035"></a>00035 allocate(distances(npoints))
<a name="l00036"></a>00036 allocate(lsm_values(npoints))
<a name="l00037"></a>00037 allocate(values(npoints))
<a name="l00038"></a>00038 allocate(indexes(npoints))
<a name="l00039"></a>00039 do i=1,npoints
<a name="l00040"></a>00040 read(unit=1,fmt=*, iostat=ios) lats(i), lons(i)
<a name="l00041"></a>00041 if (ios /= 0) then
<a name="l00042"></a>00042 npoints = i - 1
<a name="l00043"></a>00043 exit
<a name="l00044"></a>00044 end if
<a name="l00045"></a>00045 end do
<a name="l00046"></a>00046 close(unit=1)
<a name="l00047"></a>00047 call grib_open_file(infile, &amp;
<a name="l00048"></a>00048 '../../data/reduced_gaussian_lsm.grib1','r')
<a name="l00049"></a>00049
<a name="l00050"></a>00050 ! a new grib message is loaded from file
<a name="l00051"></a>00051 ! igrib is the grib id to be used in subsequent calls
<a name="l00052"></a>00052 call grib_new_from_file(infile,igrib)
<a name="l00053"></a>00053
<a name="l00054"></a>00054
<a name="l00055"></a>00055 call grib_find_nearest(igrib, .true., lats, lons, nearest_lats, nearest_lons,lsm_values, distances, indexes)
<a name="l00056"></a>00056 call grib_release(igrib)
<a name="l00057"></a>00057
<a name="l00058"></a>00058 call grib_close_file(infile)
<a name="l00059"></a>00059
<a name="l00060"></a>00060 ! will apply it to another GRIB
<a name="l00061"></a>00061 call grib_open_file(infile, &amp;
<a name="l00062"></a>00062 '../../data/reduced_gaussian_pressure_level.grib1','r')
<a name="l00063"></a>00063 call grib_new_from_file(infile,igrib)
<a name="l00064"></a>00064
<a name="l00065"></a>00065 call grib_get_element(igrib,<span class="stringliteral">"values"</span>, indexes, values)
<a name="l00066"></a>00066 call grib_release(igrib)
<a name="l00067"></a>00067 call grib_close_file(infile)
<a name="l00068"></a>00068
<a name="l00069"></a>00069 do i=1, npoints
<a name="l00070"></a>00070 print*,lats(i), lons(i), nearest_lats(i), nearest_lons(i), distances(i), lsm_values(i), values(i)
<a name="l00071"></a>00071 end do
<a name="l00072"></a>00072
<a name="l00073"></a>00073 deallocate(lats)
<a name="l00074"></a>00074 deallocate(lons)
<a name="l00075"></a>00075 deallocate(nearest_lats)
<a name="l00076"></a>00076 deallocate(nearest_lons)
<a name="l00077"></a>00077 deallocate(distances)
<a name="l00078"></a>00078 deallocate(lsm_values)
<a name="l00079"></a>00079 deallocate(values)
<a name="l00080"></a>00080 deallocate(indexes)
<a name="l00081"></a>00081
<a name="l00082"></a>00082 end program find
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,138 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: precision.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>precision.c</h1>precision.c How to control precision when coding a grib field.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> * C Implementation: precision</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Description: how to control decimal precision when packing fields.</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * Author: Enrico Fucile</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> */</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>"</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv) {
<a name="l00027"></a>00027 <span class="keywordtype">int</span> err = 0;
<a name="l00028"></a>00028 <span class="keywordtype">size_t</span> size=0;
<a name="l00029"></a>00029
<a name="l00030"></a>00030 FILE* in = NULL;
<a name="l00031"></a>00031 <span class="keywordtype">char</span>* infile = <span class="stringliteral">"../../data/regular_latlon_surface.grib1"</span>;
<a name="l00032"></a>00032 FILE* out = NULL;
<a name="l00033"></a>00033 <span class="keywordtype">char</span>* outfile = <span class="stringliteral">"out.grib1"</span>;
<a name="l00034"></a>00034 <a name="a0"></a><a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h = NULL;
<a name="l00035"></a>00035 <span class="keyword">const</span> <span class="keywordtype">void</span>* buffer = NULL;
<a name="l00036"></a>00036 <span class="keywordtype">double</span>* values1=NULL;
<a name="l00037"></a>00037 <span class="keywordtype">double</span>* values2=NULL;
<a name="l00038"></a>00038 <span class="keywordtype">double</span> maxa=0,a=0;
<a name="l00039"></a>00039 <span class="keywordtype">double</span> maxv=0,minv=0;
<a name="l00040"></a>00040 <span class="keywordtype">double</span> maxr=0,r=0;
<a name="l00041"></a>00041 <span class="keywordtype">long</span> decimalPrecision;
<a name="l00042"></a>00042 <span class="keywordtype">long</span> bitsPerValue1=0, bitsPerValue2=0;
<a name="l00043"></a>00043 <span class="keywordtype">int</span> i=0;
<a name="l00044"></a>00044
<a name="l00045"></a>00045 in = fopen(infile,<span class="stringliteral">"r"</span>);
<a name="l00046"></a>00046 <span class="keywordflow">if</span>(!in) {
<a name="l00047"></a>00047 printf(<span class="stringliteral">"ERROR: unable to open file %s\n"</span>,infile);
<a name="l00048"></a>00048 <span class="keywordflow">return</span> 1;
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050
<a name="l00051"></a>00051 out = fopen(outfile,<span class="stringliteral">"w"</span>);
<a name="l00052"></a>00052 <span class="keywordflow">if</span>(!in) {
<a name="l00053"></a>00053 printf(<span class="stringliteral">"ERROR: unable to open file %s\n"</span>,outfile);
<a name="l00054"></a>00054 <span class="keywordflow">return</span> 1;
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="comment">/* create a new handle from a message in a file */</span>
<a name="l00058"></a>00058 h = <a name="a1"></a><a class="code" href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5" title="Create a handle from a file resource.">grib_handle_new_from_file</a>(0,in,&amp;err);
<a name="l00059"></a>00059 <span class="keywordflow">if</span> (h == NULL) {
<a name="l00060"></a>00060 printf(<span class="stringliteral">"Error: unable to create handle from file %s\n"</span>,infile);
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="comment">/* bitsPerValue before changing the packing parameters */</span>
<a name="l00064"></a>00064 GRIB_CHECK(<a name="a2"></a><a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"bitsPerValue"</span>,&amp;bitsPerValue1),0);
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="comment">/* get the size of the values array*/</span>
<a name="l00067"></a>00067 GRIB_CHECK(<a name="a3"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(h,<span class="stringliteral">"values"</span>,&amp;size),0);
<a name="l00068"></a>00068
<a name="l00069"></a>00069 values1 = malloc(size*<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00070"></a>00070 <span class="comment">/* get data values before changing the packing parameters*/</span>
<a name="l00071"></a>00071 GRIB_CHECK(<a name="a4"></a><a class="code" href="group__get__set.html#g61f1029d7f37d51f33835e218d58378a" title="Get double array values from a key.">grib_get_double_array</a>(h,<span class="stringliteral">"values"</span>,values1,&amp;size),0);
<a name="l00072"></a>00072
<a name="l00073"></a>00073 <span class="comment">/* changing decimal precition to 2 means that 2 decimal digits</span>
<a name="l00074"></a>00074 <span class="comment"> are preserved when packing. */</span>
<a name="l00075"></a>00075 decimalPrecision=2;
<a name="l00076"></a>00076 GRIB_CHECK(<a name="a5"></a><a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"changeDecimalPrecision"</span>,decimalPrecision),0);
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="comment">/* bitsPerValue after changing the packing parameters */</span>
<a name="l00079"></a>00079 GRIB_CHECK(<a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"bitsPerValue"</span>,&amp;bitsPerValue2),0);
<a name="l00080"></a>00080
<a name="l00081"></a>00081 values2 = malloc(size*<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00082"></a>00082 <span class="comment">/* get data values after changing the packing parameters*/</span>
<a name="l00083"></a>00083 GRIB_CHECK(<a class="code" href="group__get__set.html#g61f1029d7f37d51f33835e218d58378a" title="Get double array values from a key.">grib_get_double_array</a>(h,<span class="stringliteral">"values"</span>,values2,&amp;size),0);
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="comment">/* computing error */</span>
<a name="l00086"></a>00086 maxa=0;
<a name="l00087"></a>00087 maxr=0;
<a name="l00088"></a>00088 maxv=values2[0];
<a name="l00089"></a>00089 minv=maxv;
<a name="l00090"></a>00090 <span class="keywordflow">for</span> (i=0;i&lt;size;i++) {
<a name="l00091"></a>00091 a=fabs(values2[i]-values1[i]);
<a name="l00092"></a>00092 <span class="keywordflow">if</span> ( values2[i] &gt; maxv ) maxv=values2[i];
<a name="l00093"></a>00093 <span class="keywordflow">if</span> ( values2[i] &lt; maxv ) minv=values2[i];
<a name="l00094"></a>00094 <span class="keywordflow">if</span> ( values2[i] !=0 ) r=fabs((values2[i]-values1[i])/values2[i]);
<a name="l00095"></a>00095 <span class="keywordflow">if</span> ( a &gt; maxa ) maxa=a;
<a name="l00096"></a>00096 <span class="keywordflow">if</span> ( r &gt; maxr ) maxr=r;
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098 printf(<span class="stringliteral">"max absolute error = %g\n"</span>,maxa);
<a name="l00099"></a>00099 printf(<span class="stringliteral">"max relative error = %g\n"</span>,maxr);
<a name="l00100"></a>00100 printf(<span class="stringliteral">"min value = %g\n"</span>,minv);
<a name="l00101"></a>00101 printf(<span class="stringliteral">"max value = %g\n"</span>,maxv);
<a name="l00102"></a>00102
<a name="l00103"></a>00103 printf(<span class="stringliteral">"old number of bits per value=%ld\n"</span>,(<span class="keywordtype">long</span>)bitsPerValue1);
<a name="l00104"></a>00104 printf(<span class="stringliteral">"new number of bits per value=%ld\n"</span>,(<span class="keywordtype">long</span>)bitsPerValue2);
<a name="l00105"></a>00105
<a name="l00106"></a>00106 <span class="comment">/* get the coded message in a buffer */</span>
<a name="l00107"></a>00107 GRIB_CHECK(<a name="a6"></a><a class="code" href="group__handling__coded__messages.html#g9d654bd4fc5f422c161edd0a140ea185" title="getting the message attached to a handle">grib_get_message</a>(h,&amp;buffer,&amp;size),0);
<a name="l00108"></a>00108
<a name="l00109"></a>00109 <span class="comment">/* write the buffer in a file*/</span>
<a name="l00110"></a>00110 <span class="keywordflow">if</span>(fwrite(buffer,1,size,out) != size)
<a name="l00111"></a>00111 {
<a name="l00112"></a>00112 perror(argv[1]);
<a name="l00113"></a>00113 exit(1);
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115
<a name="l00116"></a>00116 <span class="comment">/* delete handle */</span>
<a name="l00117"></a>00117 <a name="a7"></a><a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<a name="l00118"></a>00118
<a name="l00119"></a>00119 fclose(in);
<a name="l00120"></a>00120 fclose(out);
<a name="l00121"></a>00121
<a name="l00122"></a>00122 <span class="keywordflow">return</span> 0;
<a name="l00123"></a>00123 }
<a name="l00124"></a>00124
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,119 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: precision.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>precision.f90</h1>How to control precision when coding a grib field.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 !
<a name="l00010"></a>00010 ! Description: how to control decimal precision when packing fields.
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 !
<a name="l00013"></a>00013 ! Author: Enrico Fucile
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 !
<a name="l00016"></a>00016 !
<a name="l00017"></a>00017 program precision
<a name="l00018"></a>00018 use grib_api
<a name="l00019"></a>00019 implicit none
<a name="l00020"></a>00020 integer(kind = 4) :: size
<a name="l00021"></a>00021 integer :: infile,outfile
<a name="l00022"></a>00022 integer :: igrib
<a name="l00023"></a>00023 real(kind = 8), dimension(:), allocatable :: values1
<a name="l00024"></a>00024 real(kind = 8), dimension(:), allocatable :: values2
<a name="l00025"></a>00025 real(kind = 8) :: maxa,a,maxv,minv,maxr,r
<a name="l00026"></a>00026 integer( kind = 4) :: decimalPrecision,bitsPerValue1,bitsPerValue2
<a name="l00027"></a>00027 integer :: i, iret
<a name="l00028"></a>00028
<a name="l00029"></a>00029 call grib_open_file(infile, &amp;
<a name="l00030"></a>00030 '../../data/regular_latlon_surface_constant.grib1','r')
<a name="l00031"></a>00031
<a name="l00032"></a>00032 call grib_open_file(outfile, &amp;
<a name="l00033"></a>00033 '../../data/regular_latlon_surface_prec.grib1','w')
<a name="l00034"></a>00034
<a name="l00035"></a>00035 ! a new grib message is loaded from file
<a name="l00036"></a>00036 ! igrib is the grib id to be used in subsequent calls
<a name="l00037"></a>00037 call grib_new_from_file(infile,igrib)
<a name="l00038"></a>00038
<a name="l00039"></a>00039 ! bitsPerValue before changing the packing parameters
<a name="l00040"></a>00040 call grib_get(igrib,'bitsPerValue',bitsPerValue1)
<a name="l00041"></a>00041
<a name="l00042"></a>00042 ! get the size of the values array
<a name="l00043"></a>00043 call <a name="a0"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,<span class="stringliteral">"values"</span>,size)
<a name="l00044"></a>00044
<a name="l00045"></a>00045 allocate(values1(size), stat=iret)
<a name="l00046"></a>00046 allocate(values2(size), stat=iret)
<a name="l00047"></a>00047 ! get data values before changing the packing parameters*/
<a name="l00048"></a>00048 call grib_get(igrib,<span class="stringliteral">"values"</span>,values1)
<a name="l00049"></a>00049
<a name="l00050"></a>00050 ! setting decimal precision=2 means that 2 decimal digits
<a name="l00051"></a>00051 ! are preserved when packing.
<a name="l00052"></a>00052 decimalPrecision=2
<a name="l00053"></a>00053 call grib_set(igrib,<span class="stringliteral">"changeDecimalPrecision"</span>, &amp;
<a name="l00054"></a>00054 decimalPrecision)
<a name="l00055"></a>00055
<a name="l00056"></a>00056 ! bitsPerValue after changing the packing parameters
<a name="l00057"></a>00057 call grib_get(igrib,<span class="stringliteral">"bitsPerValue"</span>,bitsPerValue2)
<a name="l00058"></a>00058
<a name="l00059"></a>00059 ! get data values after changing the packing parameters
<a name="l00060"></a>00060 call grib_get(igrib,<span class="stringliteral">"values"</span>,values2)
<a name="l00061"></a>00061
<a name="l00062"></a>00062 ! computing error
<a name="l00063"></a>00063 maxa=0
<a name="l00064"></a>00064 maxr=0
<a name="l00065"></a>00065 maxv=values2(1)
<a name="l00066"></a>00066 minv=maxv
<a name="l00067"></a>00067 do i=1,size
<a name="l00068"></a>00068 a=abs(values2(i)-values1(i))
<a name="l00069"></a>00069 if ( values2(i) .gt. maxv ) maxv=values2(i)
<a name="l00070"></a>00070 if ( values2(i) .lt. maxv ) minv=values2(i)
<a name="l00071"></a>00071 if ( values2(i) .ne. 0 ) then
<a name="l00072"></a>00072 r=abs((values2(i)-values1(i))/values2(i))
<a name="l00073"></a>00073 endif
<a name="l00074"></a>00074 if ( a .gt. maxa ) maxa=a
<a name="l00075"></a>00075 if ( r .gt. maxr ) maxr=r
<a name="l00076"></a>00076 enddo
<a name="l00077"></a>00077 write(*,*) <span class="stringliteral">"max absolute error = "</span>,maxa
<a name="l00078"></a>00078 write(*,*) <span class="stringliteral">"max relative error = "</span>,maxr
<a name="l00079"></a>00079 write(*,*) <span class="stringliteral">"min value = "</span>,minv
<a name="l00080"></a>00080 write(*,*) <span class="stringliteral">"max value = "</span>,maxv
<a name="l00081"></a>00081
<a name="l00082"></a>00082 write(*,*) <span class="stringliteral">"old number of bits per value="</span>,bitsPerValue1
<a name="l00083"></a>00083 write(*,*) <span class="stringliteral">"new number of bits per value="</span>,bitsPerValue2
<a name="l00084"></a>00084
<a name="l00085"></a>00085 ! write modified message to a file
<a name="l00086"></a>00086 call grib_write(igrib,outfile)
<a name="l00087"></a>00087
<a name="l00088"></a>00088 call grib_release(igrib)
<a name="l00089"></a>00089
<a name="l00090"></a>00090 call grib_close_file(infile)
<a name="l00091"></a>00091
<a name="l00092"></a>00092 call grib_close_file(outfile)
<a name="l00093"></a>00093
<a name="l00094"></a>00094 deallocate(values1)
<a name="l00095"></a>00095 deallocate(values2)
<a name="l00096"></a>00096 end program precision
<a name="l00097"></a>00097
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,118 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: precision_fortran.F</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>precision_fortran.F</h1>precision_fortran.F How to control precision when coding a grib field.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 C Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 C This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 C which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 C
<a name="l00005"></a>00005 C In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 C virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 C
<a name="l00008"></a>00008 C
<a name="l00009"></a>00009 C Fortran 77 Implementation: precision
<a name="l00010"></a>00010 C
<a name="l00011"></a>00011 C Description: how to control <span class="keyword">decimal precision</span> when packing fields.
<a name="l00012"></a>00012 C
<a name="l00013"></a>00013 C
<a name="l00014"></a>00014 C Author: Enrico Fucile
<a name="l00015"></a>00015 C
<a name="l00016"></a>00016 C
<a name="l00017"></a>00017 C
<a name="l00018"></a>00018 program precision
<a name="l00019"></a>00019 implicit none
<a name="l00020"></a>00020 integer maxNumberOfValues
<a name="l00021"></a>00021 parameter (maxNumberOfValues=10000)
<a name="l00022"></a>00022 include 'grib_api_f77.h'
<a name="l00023"></a>00023 integer*4 size
<a name="l00024"></a>00024 integer infile,outfile
<a name="l00025"></a>00025 integer igrib
<a name="l00026"></a>00026 real*8 values1(maxNumberOfValues)
<a name="l00027"></a>00027 real*8 values2(maxNumberOfValues)
<a name="l00028"></a>00028 real*8 maxa,a,maxv,minv,maxr,r
<a name="l00029"></a>00029 integer*4 decimalPrecision,bitsPerValue1,bitsPerValue2
<a name="l00030"></a>00030 integer i
<a name="l00031"></a>00031
<a name="l00032"></a>00032 call grib_check(grib_open_file(infile
<a name="l00033"></a>00033 X,'../../data/regular_latlon_surface.grib1','r'))
<a name="l00034"></a>00034
<a name="l00035"></a>00035 call grib_check(grib_open_file(outfile
<a name="l00036"></a>00036 X,'../../data/regular_latlon_surface_prec.grib1','w'))
<a name="l00037"></a>00037
<a name="l00038"></a>00038 C a new grib message is loaded from file
<a name="l00039"></a>00039 C igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00040"></a>00040 call grib_check(grib_new_from_file(infile,igrib))
<a name="l00041"></a>00041
<a name="l00042"></a>00042 C bitsPerValue before changing the packing parameters
<a name="l00043"></a>00043 call grib_check(grib_get_int(igrib,'bitsPerValue',bitsPerValue1))
<a name="l00044"></a>00044
<a name="l00045"></a>00045 C get the size of the values array
<a name="l00046"></a>00046 call grib_check(<a name="a0"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,"values",size))
<a name="l00047"></a>00047
<a name="l00048"></a>00048 C get data values before changing the packing parameters*/
<a name="l00049"></a>00049 call grib_check(grib_get_real8_array(igrib,"values",values1,size))
<a name="l00050"></a>00050
<a name="l00051"></a>00051 C setting decimal precision=2 means that 2 decimal digits
<a name="l00052"></a>00052 C are preserved when packing.
<a name="l00053"></a>00053 decimalPrecision=2
<a name="l00054"></a>00054 call grib_check(grib_set_int(igrib,"changeDecimalPrecision"
<a name="l00055"></a>00055 X,decimalPrecision))
<a name="l00056"></a>00056
<a name="l00057"></a>00057 C bitsPerValue after changing the packing parameters
<a name="l00058"></a>00058 call grib_check(grib_get_int(igrib,"bitsPerValue",bitsPerValue2))
<a name="l00059"></a>00059
<a name="l00060"></a>00060 C get data values after changing the packing parameters
<a name="l00061"></a>00061 call grib_check(grib_get_real8_array(igrib,"values",values2,size))
<a name="l00062"></a>00062
<a name="l00063"></a>00063 C computing error
<a name="l00064"></a>00064 maxa=0
<a name="l00065"></a>00065 maxr=0
<a name="l00066"></a>00066 maxv=values2(1)
<a name="l00067"></a>00067 minv=maxv
<a name="l00068"></a>00068 do i=1,size
<a name="l00069"></a>00069 a=abs(values2(i)-values1(i))
<a name="l00070"></a>00070 if ( values2(i) .gt. maxv ) maxv=values2(i)
<a name="l00071"></a>00071 if ( values2(i) .lt. maxv ) minv=values2(i)
<a name="l00072"></a>00072 if ( values2(i) .ne. 0 ) then
<a name="l00073"></a>00073 r=abs((values2(i)-values1(i))/values2(i))
<a name="l00074"></a>00074 endif
<a name="l00075"></a>00075 if ( a .gt. maxa ) maxa=a
<a name="l00076"></a>00076 if ( r .gt. maxr ) maxr=r
<a name="l00077"></a>00077 enddo
<a name="l00078"></a>00078 write(*,*) "max absolute error = ",maxa
<a name="l00079"></a>00079 write(*,*) "max relative error = ",maxr
<a name="l00080"></a>00080 write(*,*) "min value = ",minv
<a name="l00081"></a>00081 write(*,*) "max value = ",maxv
<a name="l00082"></a>00082
<a name="l00083"></a>00083 write(*,*) "old number of bits per value=",bitsPerValue1
<a name="l00084"></a>00084 write(*,*) "new number of bits per value=",bitsPerValue2
<a name="l00085"></a>00085
<a name="l00086"></a>00086 C write modified message to a file
<a name="l00087"></a>00087 call grib_check(grib_write(igrib,outfile))
<a name="l00088"></a>00088
<a name="l00089"></a>00089 call grib_check(grib_release(igrib))
<a name="l00090"></a>00090
<a name="l00091"></a>00091 call grib_check(grib_close_file(infile))
<a name="l00092"></a>00092
<a name="l00093"></a>00093 call grib_check(grib_close_file(outfile))
<a name="l00094"></a>00094
<a name="l00095"></a>00095 end
<a name="l00096"></a>00096
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,94 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: print_data.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>print_data.c</h1>print_data.c How to print all the data from a grib message.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> * C Implementation: print_data</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Description: prints all the data contained in a grib file</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> * Author: Enrico Fucile</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> */</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00021"></a>00021
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>"</span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="keywordtype">void</span> usage(<span class="keywordtype">char</span>* prog) {
<a name="l00025"></a>00025 printf(<span class="stringliteral">"usage: %s filename\n"</span>,prog);
<a name="l00026"></a>00026 exit(1);
<a name="l00027"></a>00027 }
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv) {
<a name="l00030"></a>00030 <span class="keywordtype">int</span> err = 0,i;
<a name="l00031"></a>00031 <span class="keywordtype">double</span> *values = NULL;
<a name="l00032"></a>00032 <span class="keywordtype">double</span> max,min,average;
<a name="l00033"></a>00033 <span class="keywordtype">size_t</span> values_len= 0;
<a name="l00034"></a>00034
<a name="l00035"></a>00035 FILE* in = NULL;
<a name="l00036"></a>00036 <span class="keywordtype">char</span>* filename ;
<a name="l00037"></a>00037 <a name="a0"></a><a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h = NULL;
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="keywordflow">if</span> (argc&lt;2) usage(argv[0]);
<a name="l00040"></a>00040 filename=argv[1];
<a name="l00041"></a>00041
<a name="l00042"></a>00042 in = fopen(filename,<span class="stringliteral">"r"</span>);
<a name="l00043"></a>00043 <span class="keywordflow">if</span>(!in) {
<a name="l00044"></a>00044 printf(<span class="stringliteral">"ERROR: unable to open file %s\n"</span>,filename);
<a name="l00045"></a>00045 <span class="keywordflow">return</span> 1;
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="comment">/* create new handle from a message in a file*/</span>
<a name="l00049"></a>00049 h = <a name="a1"></a><a class="code" href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5" title="Create a handle from a file resource.">grib_handle_new_from_file</a>(0,in,&amp;err);
<a name="l00050"></a>00050 <span class="keywordflow">if</span> (h == NULL) {
<a name="l00051"></a>00051 printf(<span class="stringliteral">"Error: unable to create handle from file %s\n"</span>,filename);
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053
<a name="l00054"></a>00054
<a name="l00055"></a>00055 <span class="comment">/* get the size of the values array*/</span>
<a name="l00056"></a>00056 GRIB_CHECK(<a name="a2"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(h,<span class="stringliteral">"values"</span>,&amp;values_len),0);
<a name="l00057"></a>00057
<a name="l00058"></a>00058 values = malloc(values_len*<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="comment">/* get data values*/</span>
<a name="l00061"></a>00061 GRIB_CHECK(<a name="a3"></a><a class="code" href="group__get__set.html#g61f1029d7f37d51f33835e218d58378a" title="Get double array values from a key.">grib_get_double_array</a>(h,<span class="stringliteral">"values"</span>,values,&amp;values_len),0);
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="keywordflow">for</span>(i = 0; i &lt; values_len; i++)
<a name="l00064"></a>00064 printf(<span class="stringliteral">"%d %.10e\n"</span>,i+1,values[i]);
<a name="l00065"></a>00065
<a name="l00066"></a>00066 free(values);
<a name="l00067"></a>00067
<a name="l00068"></a>00068
<a name="l00069"></a>00069 GRIB_CHECK(<a name="a4"></a><a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"max"</span>,&amp;max),0);
<a name="l00070"></a>00070 GRIB_CHECK(<a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"min"</span>,&amp;min),0);
<a name="l00071"></a>00071 GRIB_CHECK(<a class="code" href="group__get__set.html#g5d9eeda38bf59ee3fa9ce3f92e65009e" title="Get a double value from a key, if several keys of the same name are present, the...">grib_get_double</a>(h,<span class="stringliteral">"average"</span>,&amp;average),0);
<a name="l00072"></a>00072
<a name="l00073"></a>00073 printf(<span class="stringliteral">"%d values found in %s\n"</span>,(<span class="keywordtype">int</span>)values_len,filename);
<a name="l00074"></a>00074 printf(<span class="stringliteral">"max=%.10e min=%.10e average=%.10e\n"</span>,max,min,average);
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <a name="a5"></a><a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<a name="l00077"></a>00077
<a name="l00078"></a>00078 fclose(in);
<a name="l00079"></a>00079 <span class="keywordflow">return</span> 0;
<a name="l00080"></a>00080 }
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,88 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: print_data.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>print_data.f90</h1>How to print all the data contained in a grib file.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: prints all the data contained in a grib file
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Anne Fouilloux
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 program print_data
<a name="l00016"></a>00016 use grib_api
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer :: ifile
<a name="l00019"></a>00019 integer :: iret
<a name="l00020"></a>00020 integer :: igrib
<a name="l00021"></a>00021 integer :: i
<a name="l00022"></a>00022 real(kind=8), dimension(:), allocatable :: values
<a name="l00023"></a>00023 integer(kind=4) :: numberOfValues
<a name="l00024"></a>00024 real(kind=8) :: average
<a name="l00025"></a>00025 real(kind=8) :: max
<a name="l00026"></a>00026 real(kind=8) :: min
<a name="l00027"></a>00027 character(len=256) :: error
<a name="l00028"></a>00028
<a name="l00029"></a>00029 call grib_open_file(ifile, &amp;
<a name="l00030"></a>00030 '../../data/constant_field.grib1','r')
<a name="l00031"></a>00031
<a name="l00032"></a>00032 ! a new grib message is loaded from file
<a name="l00033"></a>00033 ! igrib is the grib id to be used in subsequent calls
<a name="l00034"></a>00034 call grib_new_from_file(ifile,igrib)
<a name="l00035"></a>00035
<a name="l00036"></a>00036
<a name="l00037"></a>00037 ! get the size of the values array
<a name="l00038"></a>00038 call <a name="a0"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,'values',numberOfValues)
<a name="l00039"></a>00039
<a name="l00040"></a>00040 ! get data values
<a name="l00041"></a>00041 print*, 'number of values ', numberOfValues
<a name="l00042"></a>00042 allocate(values(numberOfValues), stat=iret)
<a name="l00043"></a>00043
<a name="l00044"></a>00044 call grib_get(igrib,'values',values)
<a name="l00045"></a>00045
<a name="l00046"></a>00046 do i=1,numberOfValues
<a name="l00047"></a>00047 write(*,*)' ',i,values(i)
<a name="l00048"></a>00048 enddo
<a name="l00049"></a>00049
<a name="l00050"></a>00050
<a name="l00051"></a>00051 write(*,*)numberOfValues,' values found '
<a name="l00052"></a>00052
<a name="l00053"></a>00053 call grib_get(igrib,'max',max)
<a name="l00054"></a>00054 write(*,*) 'max=',max
<a name="l00055"></a>00055 call grib_get(igrib,'min',min)
<a name="l00056"></a>00056 write(*,*) 'min=',min
<a name="l00057"></a>00057 call grib_get(igrib,'average',average)
<a name="l00058"></a>00058 write(*,*) 'average=',average
<a name="l00059"></a>00059
<a name="l00060"></a>00060 call grib_release(igrib)
<a name="l00061"></a>00061
<a name="l00062"></a>00062 call grib_close_file(ifile)
<a name="l00063"></a>00063
<a name="l00064"></a>00064 deallocate(values)
<a name="l00065"></a>00065
<a name="l00066"></a>00066 end program print_data
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,101 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: print_data_fortran.F</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>print_data_fortran.F</h1>print_data_fortran.F How to print all the data from a grib message.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 C Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 C
<a name="l00008"></a>00008 C Fortran 77 Implementation: print_data_fortran
<a name="l00009"></a>00009 C
<a name="l00010"></a>00010 C Description: prints all the data contained in a grib file
<a name="l00011"></a>00011 C
<a name="l00012"></a>00012 C Author: Enrico Fucile
<a name="l00013"></a>00013 C
<a name="l00014"></a>00014 C
<a name="l00015"></a>00015 C
<a name="l00016"></a>00016 program print_data_fortran
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer maxNumberOfValues
<a name="l00019"></a>00019 parameter( maxNumberOfValues = 100000 )
<a name="l00020"></a>00020 include 'grib_api_f77.h'
<a name="l00021"></a>00021 integer ifile
<a name="l00022"></a>00022 integer iret
<a name="l00023"></a>00023 integer igrib
<a name="l00024"></a>00024 integer i
<a name="l00025"></a>00025 real*8 values(maxNumberOfValues)
<a name="l00026"></a>00026 integer*4 numberOfValues
<a name="l00027"></a>00027 real*8 average
<a name="l00028"></a>00028 real*8 max
<a name="l00029"></a>00029 real*8 min
<a name="l00030"></a>00030 character*256 error
<a name="l00031"></a>00031 integer*4 size
<a name="l00032"></a>00032
<a name="l00033"></a>00033 size=maxNumberOfValues
<a name="l00034"></a>00034 ifile=5
<a name="l00035"></a>00035
<a name="l00036"></a>00036 iret=grib_open_file(ifile
<a name="l00037"></a>00037 X,'../../data/constant_field.grib1','r')
<a name="l00038"></a>00038 call grib_check(iret)
<a name="l00039"></a>00039
<a name="l00040"></a>00040 C a new grib message is loaded from file
<a name="l00041"></a>00041 C igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00042"></a>00042 call grib_check( grib_new_from_file(ifile,igrib) )
<a name="l00043"></a>00043
<a name="l00044"></a>00044
<a name="l00045"></a>00045 C get the size of the values array
<a name="l00046"></a>00046 call grib_check(<a name="a0"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,'values',numberOfValues))
<a name="l00047"></a>00047 if ( numberOfValues .gt. maxNumberOfValues ) then
<a name="l00048"></a>00048 write(*,*)'ERROR: maxNumberOfValues too small numberOfValues=',
<a name="l00049"></a>00049 XnumberOfValues
<a name="l00050"></a>00050 stop
<a name="l00051"></a>00051 endif
<a name="l00052"></a>00052
<a name="l00053"></a>00053 C get data values
<a name="l00054"></a>00054 call grib_check(grib_get_real8_array(igrib,'values',values,size))
<a name="l00055"></a>00055 if ( size .ne. numberOfValues ) then
<a name="l00056"></a>00056 write(*,*) 'ERROR: wrong numberOfValues'
<a name="l00057"></a>00057 stop
<a name="l00058"></a>00058 endif
<a name="l00059"></a>00059
<a name="l00060"></a>00060 do i=1,numberOfValues
<a name="l00061"></a>00061 write(*,*)' ',i,values(i)
<a name="l00062"></a>00062 enddo
<a name="l00063"></a>00063
<a name="l00064"></a>00064 average =average / numberOfValues
<a name="l00065"></a>00065
<a name="l00066"></a>00066 write(*,*)numberOfValues,' values found '
<a name="l00067"></a>00067
<a name="l00068"></a>00068 call grib_check(grib_get_real8(igrib,'max',max))
<a name="l00069"></a>00069 write(*,*) 'max=',max
<a name="l00070"></a>00070 call grib_check(grib_get_real8(igrib,'min',min))
<a name="l00071"></a>00071 write(*,*) 'min=',min
<a name="l00072"></a>00072 call grib_check(grib_get_real8(igrib,'average',average))
<a name="l00073"></a>00073 write(*,*) 'average=',average
<a name="l00074"></a>00074
<a name="l00075"></a>00075 call grib_check(grib_release(igrib))
<a name="l00076"></a>00076
<a name="l00077"></a>00077 call grib_check(grib_close_file(ifile))
<a name="l00078"></a>00078
<a name="l00079"></a>00079 end
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:21 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,100 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: set.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>set.c</h1>set.c How to set values through the key names.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> * C Implementation: set</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Description: how to set key values.</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * Author: Enrico Fucile</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> */</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="grib__api_8h.html" title="Copyright 2005-2016 ECMWF.">grib_api.h</a>"</span>
<a name="l00024"></a>00024
<a name="l00025"></a>00025 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv) {
<a name="l00026"></a>00026 <span class="keywordtype">int</span> err = 0;
<a name="l00027"></a>00027 <span class="keywordtype">long</span> centre=80;
<a name="l00028"></a>00028 <span class="keywordtype">long</span> long_value=0;
<a name="l00029"></a>00029 <span class="keywordtype">char</span> string_value[100];
<a name="l00030"></a>00030 <span class="keywordtype">size_t</span> len = <span class="keyword">sizeof</span>(string_value)/<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>);
<a name="l00031"></a>00031 <span class="keywordtype">size_t</span> size=0;
<a name="l00032"></a>00032
<a name="l00033"></a>00033 FILE* in = NULL;
<a name="l00034"></a>00034 <span class="keywordtype">char</span>* infile = <span class="stringliteral">"../../data/regular_latlon_surface.grib1"</span>;
<a name="l00035"></a>00035 FILE* out = NULL;
<a name="l00036"></a>00036 <span class="keywordtype">char</span>* outfile = <span class="stringliteral">"out.grib1"</span>;
<a name="l00037"></a>00037 <a name="a0"></a><a class="code" href="group__grib__handle.html#g309a5ee24f4c730646d3f80ad0ef5f1b">grib_handle</a> *h = NULL;
<a name="l00038"></a>00038 <span class="keyword">const</span> <span class="keywordtype">void</span>* buffer = NULL;
<a name="l00039"></a>00039
<a name="l00040"></a>00040 in = fopen(infile,<span class="stringliteral">"r"</span>);
<a name="l00041"></a>00041 <span class="keywordflow">if</span>(!in) {
<a name="l00042"></a>00042 printf(<span class="stringliteral">"ERROR: unable to open file %s\n"</span>,infile);
<a name="l00043"></a>00043 <span class="keywordflow">return</span> 1;
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045
<a name="l00046"></a>00046 out = fopen(outfile,<span class="stringliteral">"w"</span>);
<a name="l00047"></a>00047 <span class="keywordflow">if</span>(!in) {
<a name="l00048"></a>00048 printf(<span class="stringliteral">"ERROR: unable to open file %s\n"</span>,outfile);
<a name="l00049"></a>00049 <span class="keywordflow">return</span> 1;
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="comment">/* create a new handle from a message in a file */</span>
<a name="l00053"></a>00053 h = <a name="a1"></a><a class="code" href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5" title="Create a handle from a file resource.">grib_handle_new_from_file</a>(0,in,&amp;err);
<a name="l00054"></a>00054 <span class="keywordflow">if</span> (h == NULL) {
<a name="l00055"></a>00055 printf(<span class="stringliteral">"Error: unable to create handle from file %s\n"</span>,infile);
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057
<a name="l00058"></a>00058 <span class="comment">/* set centre as a long */</span>
<a name="l00059"></a>00059 GRIB_CHECK(<a name="a2"></a><a class="code" href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2" title="Set a long value from a key.">grib_set_long</a>(h,<span class="stringliteral">"centre"</span>,centre),0);
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="comment">/* get centre as a long */</span>
<a name="l00062"></a>00062 GRIB_CHECK(<a name="a3"></a><a class="code" href="group__get__set.html#g03cfa6762312face1a3cc3ef23e16526" title="Get a long value from a key, if several keys of the same name are present, the last...">grib_get_long</a>(h,<span class="stringliteral">"centre"</span>,&amp;long_value),0);
<a name="l00063"></a>00063 printf(<span class="stringliteral">"centre long value=%ld\n"</span>,long_value);
<a name="l00064"></a>00064
<a name="l00065"></a>00065 <span class="comment">/* get centre as a string */</span>
<a name="l00066"></a>00066 GRIB_CHECK(<a name="a4"></a><a class="code" href="group__get__set.html#g8aeaf9f930eea1cc0f15e92f18a25053" title="Get a string value from a key, if several keys of the same name are present, the...">grib_get_string</a>(h,<span class="stringliteral">"centre"</span>,string_value,&amp;len),0);
<a name="l00067"></a>00067 printf(<span class="stringliteral">"centre string value=%s\n"</span>,string_value);
<a name="l00068"></a>00068
<a name="l00069"></a>00069 <span class="comment">/* get the coded message in a buffer */</span>
<a name="l00070"></a>00070 GRIB_CHECK(<a name="a5"></a><a class="code" href="group__handling__coded__messages.html#g9d654bd4fc5f422c161edd0a140ea185" title="getting the message attached to a handle">grib_get_message</a>(h,&amp;buffer,&amp;size),0);
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="comment">/* write the buffer in a file*/</span>
<a name="l00073"></a>00073 <span class="keywordflow">if</span>(fwrite(buffer,1,size,out) != size)
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075 perror(argv[1]);
<a name="l00076"></a>00076 exit(1);
<a name="l00077"></a>00077 }
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <span class="comment">/* delete handle */</span>
<a name="l00080"></a>00080 <a name="a6"></a><a class="code" href="group__grib__handle.html#g0e4b2585f22247c49b930c1579257677" title="Frees a handle, also frees the message if it is not a user message.">grib_handle_delete</a>(h);
<a name="l00081"></a>00081
<a name="l00082"></a>00082 fclose(in);
<a name="l00083"></a>00083 fclose(out);
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="keywordflow">return</span> 0;
<a name="l00086"></a>00086 }
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,107 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: set.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>set.f90</h1>How to set values through the key names.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to <span class="keyword">set</span> key values.
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Anne Fouilloux
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 program <span class="keyword">set</span>
<a name="l00016"></a>00016 use grib_api
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer(kind = 4) :: centre, date
<a name="l00019"></a>00019 integer :: infile,outfile
<a name="l00020"></a>00020 integer :: igrib
<a name="l00021"></a>00021
<a name="l00022"></a>00022
<a name="l00023"></a>00023 centre = 80
<a name="l00024"></a>00024 call current_date(date)
<a name="l00025"></a>00025 call grib_open_file(infile, &amp;
<a name="l00026"></a>00026 '../../data/regular_latlon_surface_constant.grib1','r')
<a name="l00027"></a>00027
<a name="l00028"></a>00028 call grib_open_file(outfile, &amp;
<a name="l00029"></a>00029 'out.grib1','w')
<a name="l00030"></a>00030
<a name="l00031"></a>00031 ! a new grib message is loaded from file
<a name="l00032"></a>00032 ! igrib is the grib id to be used in subsequent calls
<a name="l00033"></a>00033 call grib_new_from_file(infile,igrib)
<a name="l00034"></a>00034
<a name="l00035"></a>00035 call grib_set(igrib,'date',date)
<a name="l00036"></a>00036 ! set centre as a integer */
<a name="l00037"></a>00037 call grib_set(igrib,'centre',centre)
<a name="l00038"></a>00038
<a name="l00039"></a>00039 ! check if it is correct in the actual GRIB message
<a name="l00040"></a>00040
<a name="l00041"></a>00041 call check_settings(igrib)
<a name="l00042"></a>00042
<a name="l00043"></a>00043 ! write modified message to a file
<a name="l00044"></a>00044 call grib_write(igrib,outfile)
<a name="l00045"></a>00045
<a name="l00046"></a>00046 call grib_release(igrib)
<a name="l00047"></a>00047
<a name="l00048"></a>00048 call grib_close_file(infile)
<a name="l00049"></a>00049
<a name="l00050"></a>00050 call grib_close_file(outfile)
<a name="l00051"></a>00051
<a name="l00052"></a>00052 contains
<a name="l00053"></a>00053
<a name="l00054"></a>00054 !======================================
<a name="l00055"></a>00055 subroutine current_date(date)
<a name="l00056"></a>00056 integer, intent(out) :: date
<a name="l00057"></a>00057
<a name="l00058"></a>00058 integer :: val_date(8)
<a name="l00059"></a>00059 call date_and_time ( values = val_date)
<a name="l00060"></a>00060
<a name="l00061"></a>00061 date = val_date(1)* 10000 + val_date(2)*100 + val_date(3)
<a name="l00062"></a>00062 end subroutine current_date
<a name="l00063"></a>00063 !======================================
<a name="l00064"></a>00064 subroutine check_settings(gribid)
<a name="l00065"></a>00065 use grib_api
<a name="l00066"></a>00066 implicit none
<a name="l00067"></a>00067 integer, intent(in) :: gribid
<a name="l00068"></a>00068
<a name="l00069"></a>00069 integer(kind = 4) :: int_value
<a name="l00070"></a>00070 character(len = 10) :: string_value
<a name="l00071"></a>00071
<a name="l00072"></a>00072 ! get centre as a integer
<a name="l00073"></a>00073 call grib_get(gribid,'centre',int_value)
<a name="l00074"></a>00074 write(*,*) <span class="stringliteral">"get centre as a integer - centre = "</span>,int_value
<a name="l00075"></a>00075
<a name="l00076"></a>00076 ! get centre as a string
<a name="l00077"></a>00077 call grib_get(gribid,'centre',string_value)
<a name="l00078"></a>00078 write(*,*) <span class="stringliteral">"get centre as a string - centre = "</span>,string_value
<a name="l00079"></a>00079
<a name="l00080"></a>00080 ! get date as a string
<a name="l00081"></a>00081 call grib_get(gribid,'dataDate',string_value)
<a name="l00082"></a>00082 write(*,*) <span class="stringliteral">"get date as a string - date = "</span>,string_value
<a name="l00083"></a>00083
<a name="l00084"></a>00084 end subroutine check_settings
<a name="l00085"></a>00085 end program set
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,102 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: set_bitmap.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>set_bitmap.f90</h1>How to set and use a bitmap.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to <span class="keyword">set</span> a bitmap in a grib message
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Enrico Fucile
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 program set_bitmap
<a name="l00016"></a>00016 use grib_api
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer :: infile,outfile
<a name="l00019"></a>00019 integer :: igrib, iret
<a name="l00020"></a>00020 integer :: numberOfValues
<a name="l00021"></a>00021 real, dimension(:), allocatable :: values
<a name="l00022"></a>00022 real :: missingValue
<a name="l00023"></a>00023 logical :: grib1Example
<a name="l00024"></a>00024
<a name="l00025"></a>00025 grib1Example=.true.
<a name="l00026"></a>00026
<a name="l00027"></a>00027 <span class="keywordflow">if</span> (grib1Example) then
<a name="l00028"></a>00028 ! GRIB 1 example
<a name="l00029"></a>00029 call grib_open_file(infile,'../../data/regular_latlon_surface.grib1<span class="charliteral">','</span>r')
<a name="l00030"></a>00030 else
<a name="l00031"></a>00031 ! GRIB 2 example
<a name="l00032"></a>00032 call grib_open_file(infile,'../../data/regular_latlon_surface.grib2','r')
<a name="l00033"></a>00033 end if
<a name="l00034"></a>00034
<a name="l00035"></a>00035 call grib_open_file(outfile,'out.grib','w')
<a name="l00036"></a>00036
<a name="l00037"></a>00037 ! a new grib message is loaded from file
<a name="l00038"></a>00038 ! igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00039"></a>00039 call grib_new_from_file(infile,igrib)
<a name="l00040"></a>00040
<a name="l00041"></a>00041 ! The missingValue is not coded in the message.
<a name="l00042"></a>00042 ! It is a value we define as a placeholder for a missing value
<a name="l00043"></a>00043 ! in a point of the grid.
<a name="l00044"></a>00044 ! It should be choosen in a way that it cannot be confused
<a name="l00045"></a>00045 ! with a valid field value
<a name="l00046"></a>00046 missingValue=9999
<a name="l00047"></a>00047 call grib_set(igrib, 'missingValue',missingValue)
<a name="l00048"></a>00048 write(*,*) 'missingValue=',missingValue
<a name="l00049"></a>00049
<a name="l00050"></a>00050 ! get the size of the values array
<a name="l00051"></a>00051 call <a name="a0"></a><a class="code" href="group__get__set.html#g18b622ed86b24d5e5fcab70c309fc245" title="Get the number of coded value from a key, if several keys of the same name are present...">grib_get_size</a>(igrib,'values',numberOfValues)
<a name="l00052"></a>00052 write(*,*) 'numberOfValues=',numberOfValues
<a name="l00053"></a>00053
<a name="l00054"></a>00054 allocate(values(numberOfValues), stat=iret)
<a name="l00055"></a>00055
<a name="l00056"></a>00056 ! get data values
<a name="l00057"></a>00057 call grib_get(igrib,'values',values)
<a name="l00058"></a>00058
<a name="l00059"></a>00059 ! enable bitmap
<a name="l00060"></a>00060 call grib_set(igrib,"bitmapPresent",1)
<a name="l00061"></a>00061
<a name="l00062"></a>00062 ! some values are missing
<a name="l00063"></a>00063 values(1:10) = missingValue
<a name="l00064"></a>00064
<a name="l00065"></a>00065 ! set the values (the bitmap will be automatically built)
<a name="l00066"></a>00066 call grib_set(igrib,'values', values)
<a name="l00067"></a>00067
<a name="l00068"></a>00068 ! write modified message to a file
<a name="l00069"></a>00069 call grib_write(igrib,outfile)
<a name="l00070"></a>00070
<a name="l00071"></a>00071 ! FREE MEMORY
<a name="l00072"></a>00072 call grib_release(igrib)
<a name="l00073"></a>00073
<a name="l00074"></a>00074 call grib_close_file(infile)
<a name="l00075"></a>00075
<a name="l00076"></a>00076 call grib_close_file(outfile)
<a name="l00077"></a>00077
<a name="l00078"></a>00078 deallocate(values)
<a name="l00079"></a>00079
<a name="l00080"></a>00080 end program set_bitmap
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,89 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: set_fortran.F</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>set_fortran.F</h1>set_fortran.F How to set values through the key names.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 C Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 C This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 C which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 C
<a name="l00005"></a>00005 C In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 C virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 C
<a name="l00008"></a>00008 C
<a name="l00009"></a>00009 C Fortran 77 Implementation: set_fortran
<a name="l00010"></a>00010 C
<a name="l00011"></a>00011 C Description: how to <span class="keyword">set</span> key values.
<a name="l00012"></a>00012 C
<a name="l00013"></a>00013 C
<a name="l00014"></a>00014 C Author: Enrico Fucile
<a name="l00015"></a>00015 C
<a name="l00016"></a>00016 C
<a name="l00017"></a>00017 C
<a name="l00018"></a>00018 program <span class="keyword">set</span>
<a name="l00019"></a>00019 implicit none
<a name="l00020"></a>00020 include 'grib_api_f77.h'
<a name="l00021"></a>00021 integer err
<a name="l00022"></a>00022 integer*4 centre
<a name="l00023"></a>00023 integer*4 int_value
<a name="l00024"></a>00024 character*10 string_value
<a name="l00025"></a>00025 character*20 string_centre
<a name="l00026"></a>00026 integer len
<a name="l00027"></a>00027 integer size
<a name="l00028"></a>00028 integer infile,outfile
<a name="l00029"></a>00029 integer igrib,iret
<a name="l00030"></a>00030 character*256 error
<a name="l00031"></a>00031
<a name="l00032"></a>00032 infile=5
<a name="l00033"></a>00033 outfile=6
<a name="l00034"></a>00034
<a name="l00035"></a>00035 call grib_check(grib_open_file(infile
<a name="l00036"></a>00036 X,'../../data/regular_latlon_surface.grib1<span class="charliteral">','</span>r'))
<a name="l00037"></a>00037
<a name="l00038"></a>00038 call grib_check(grib_open_file(outfile
<a name="l00039"></a>00039 X,'../../data/out.grib1','w'))
<a name="l00040"></a>00040
<a name="l00041"></a>00041 C a new grib message is loaded from file
<a name="l00042"></a>00042 C igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00043"></a>00043 call grib_check(grib_new_from_file(infile,igrib))
<a name="l00044"></a>00044
<a name="l00045"></a>00045 C set centre as a <span class="keywordtype">long</span> */
<a name="l00046"></a>00046 centre=80
<a name="l00047"></a>00047 call grib_check(grib_set_int(igrib,'centre',centre))
<a name="l00048"></a>00048
<a name="l00049"></a>00049 C get centre as a integer*4
<a name="l00050"></a>00050 call grib_check(grib_get_int(igrib,'centre',int_value))
<a name="l00051"></a>00051 write(*,*) 'centre=',int_value
<a name="l00052"></a>00052
<a name="l00053"></a>00053 C get centre as a <span class="keywordtype">string</span>
<a name="l00054"></a>00054 call grib_check(<a name="a0"></a><a class="code" href="group__get__set.html#g8aeaf9f930eea1cc0f15e92f18a25053" title="Get a string value from a key, if several keys of the same name are present, the...">grib_get_string</a>(igrib,'centre',string_value))
<a name="l00055"></a>00055 string_centre='centre='<span class="comment">//string_value</span>
<a name="l00056"></a>00056 write(*,*) string_centre
<a name="l00057"></a>00057
<a name="l00058"></a>00058 C write modified message to a file
<a name="l00059"></a>00059 call grib_check(grib_write(igrib,outfile))
<a name="l00060"></a>00060
<a name="l00061"></a>00061 call grib_check(grib_release(igrib))
<a name="l00062"></a>00062
<a name="l00063"></a>00063 call grib_check(grib_close_file(infile))
<a name="l00064"></a>00064
<a name="l00065"></a>00065 call grib_check(grib_close_file(outfile))
<a name="l00066"></a>00066
<a name="l00067"></a>00067 end
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,69 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: set_missing.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>set_missing.f90</h1>How to set a missing value in the header.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to <span class="keyword">set</span> missing a key value.
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Enrico Fucile
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 !
<a name="l00016"></a>00016 program <span class="keyword">set</span>
<a name="l00017"></a>00017 use grib_api
<a name="l00018"></a>00018 implicit none
<a name="l00019"></a>00019 integer :: infile,outfile
<a name="l00020"></a>00020 integer :: igrib
<a name="l00021"></a>00021
<a name="l00022"></a>00022 infile=5
<a name="l00023"></a>00023 outfile=6
<a name="l00024"></a>00024
<a name="l00025"></a>00025 call grib_open_file(infile, &amp;
<a name="l00026"></a>00026 '../../data/reduced_gaussian_pressure_level.grib2<span class="charliteral">','</span>r')
<a name="l00027"></a>00027
<a name="l00028"></a>00028 call grib_open_file(outfile, &amp;
<a name="l00029"></a>00029 'out_surface_level.grib2','w')
<a name="l00030"></a>00030
<a name="l00031"></a>00031 ! a new grib message is loaded from file
<a name="l00032"></a>00032 ! igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00033"></a>00033 call grib_new_from_file(infile,igrib)
<a name="l00034"></a>00034
<a name="l00035"></a>00035 call grib_set(igrib,'typeOfFirstFixedSurface','sfc')
<a name="l00036"></a>00036 call grib_set_missing(igrib,'scaleFactorOfFirstFixedSurface')
<a name="l00037"></a>00037 call grib_set_missing(igrib,'scaledValueOfFirstFixedSurface')
<a name="l00038"></a>00038
<a name="l00039"></a>00039 call grib_write(igrib,outfile)
<a name="l00040"></a>00040
<a name="l00041"></a>00041 call grib_release(igrib)
<a name="l00042"></a>00042
<a name="l00043"></a>00043 call grib_close_file(infile)
<a name="l00044"></a>00044
<a name="l00045"></a>00045 call grib_close_file(outfile)
<a name="l00046"></a>00046
<a name="l00047"></a>00047 end program set
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

View File

@ -1,96 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: set_pv.f90</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1>set_pv.f90</h1>How to set the list of levels.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ! Copyright 2005-2016 ECMWF
<a name="l00002"></a>00002 ! This software is licensed under the terms of the Apache Licence Version 2.0
<a name="l00003"></a>00003 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
<a name="l00004"></a>00004 !
<a name="l00005"></a>00005 ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
<a name="l00006"></a>00006 ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
<a name="l00007"></a>00007 !
<a name="l00008"></a>00008 !
<a name="l00009"></a>00009 ! Description: how to <span class="keyword">set</span> pv values.
<a name="l00010"></a>00010 !
<a name="l00011"></a>00011 !
<a name="l00012"></a>00012 ! Author: Anne Fouilloux
<a name="l00013"></a>00013 !
<a name="l00014"></a>00014 !
<a name="l00015"></a>00015 program set_pv
<a name="l00016"></a>00016 use grib_api
<a name="l00017"></a>00017 implicit none
<a name="l00018"></a>00018 integer :: numberOfLevels
<a name="l00019"></a>00019 integer :: numberOfCoefficients
<a name="l00020"></a>00020 integer :: outfile, igrib
<a name="l00021"></a>00021 integer :: i, ios
<a name="l00022"></a>00022 real, dimension(:),allocatable :: pv
<a name="l00023"></a>00023
<a name="l00024"></a>00024 numberOfLevels=60
<a name="l00025"></a>00025 numberOfCoefficients=2*(numberOfLevels+1)
<a name="l00026"></a>00026
<a name="l00027"></a>00027 allocate(pv(numberOfCoefficients))
<a name="l00028"></a>00028
<a name="l00029"></a>00029 ! read the model level coefficients from file
<a name="l00030"></a>00030 open( unit=1, file=<span class="stringliteral">"../../data/60_model_levels"</span>, &amp;
<a name="l00031"></a>00031 form=<span class="stringliteral">"formatted"</span>,action=<span class="stringliteral">"read"</span>)
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="keywordflow">do</span> i=1,numberOfCoefficients,2
<a name="l00034"></a>00034 read(unit=1,fmt=*, iostat=ios) pv(i), pv(i+1)
<a name="l00035"></a>00035 if (ios /= 0) then
<a name="l00036"></a>00036 print *, "I/O error: ",ios
<a name="l00037"></a>00037 exit
<a name="l00038"></a>00038 end if
<a name="l00039"></a>00039 end do
<a name="l00040"></a>00040
<a name="l00041"></a>00041 ! print coefficients
<a name="l00042"></a>00042 !do i=1,numberOfCoefficients,2
<a name="l00043"></a>00043 ! print *," a=",pv(i)," b=",pv(i+1)
<a name="l00044"></a>00044 !end do
<a name="l00045"></a>00045
<a name="l00046"></a>00046 close(unit=1)
<a name="l00047"></a>00047
<a name="l00048"></a>00048 call grib_open_file(outfile, 'out.grib1','w')
<a name="l00049"></a>00049
<a name="l00050"></a>00050 ! a new grib message is loaded from file
<a name="l00051"></a>00051 ! igrib is the grib <span class="keywordtype">id</span> to be used in subsequent calls
<a name="l00052"></a>00052 call grib_new_from_samples(igrib, "reduced_gg_sfc_grib1")
<a name="l00053"></a>00053
<a name="l00054"></a>00054 ! set levtype to ml (model level)
<a name="l00055"></a>00055 call grib_set(igrib,'levtype','ml')
<a name="l00056"></a>00056
<a name="l00057"></a>00057 ! set level
<a name="l00058"></a>00058 call grib_set(igrib,'level',2)
<a name="l00059"></a>00059
<a name="l00060"></a>00060 ! set PVPresent as an integer
<a name="l00061"></a>00061 call grib_set(igrib,'PVPresent',1)
<a name="l00062"></a>00062
<a name="l00063"></a>00063 call grib_set(igrib,'pv',pv)
<a name="l00064"></a>00064
<a name="l00065"></a>00065 ! write modified message to a file
<a name="l00066"></a>00066 call grib_write(igrib,outfile)
<a name="l00067"></a>00067
<a name="l00068"></a>00068 ! FREE MEMORY
<a name="l00069"></a>00069 call grib_release(igrib)
<a name="l00070"></a>00070 deallocate(pv)
<a name="l00071"></a>00071
<a name="l00072"></a>00072 call grib_close_file(outfile)
<a name="l00073"></a>00073
<a name="l00074"></a>00074 end program set_pv
</pre></div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,26 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>grib_api: Grib tools</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<h1><a class="anchor" name="tools">Grib tools</a></h1>The following command line tools are provided to help users in all interactive and batch processing of grib data.<br>
Use of the tools is recommended whenever possible. They provide a ready and tested solution for many situations and their use will avoid the need to write new cod and thus speeding up your work.<br>
To make easier their use the tools are provided with a common set of options so that it's quick to apply the same options to different tools. We suggest to begin with <a class="el" href="grib_dump.html">grib_dump</a>, <a class="el" href="grib_ls.html">grib_ls</a> and <a class="el" href="grib_get.html">grib_get</a> to inspect the content of some files and then to learn about the other tools to change the content of the grib message (<a class="el" href="grib_set.html">grib_set</a>, <a class="el" href="grib_convert.html">grib_convert</a>, <a class="el" href="grib_filter.html">grib_filter</a>) or to copy some messages from a file (<a class="el" href="grib_copy.html">grib_copy</a>) or to get a latitude/longitude/values list of data. A smart compare tool (<a class="el" href="grib_compare.html">grib_compare</a>) is also provided to compare grib messages focusing on some keys or comparing data with a given precision.<p>
<ul>
<li><a class="el" href="grib_dump.html">grib_dump</a></li><li><a class="el" href="grib_ls.html">grib_ls</a></li><li><a class="el" href="grib_get.html">grib_get</a></li><li><a class="el" href="grib_copy.html">grib_copy</a></li><li><a class="el" href="grib_set.html">grib_set</a></li><li><a class="el" href="grib_convert.html">grib_convert</a></li><li><a class="el" href="grib_filter.html">grib_filter</a></li><li><a class="el" href="grib_compare.html">grib_compare</a></li><li><a class="el" href="grib_get_data.html">grib_get_data</a></li><li><a class="el" href="grib_keys.html">grib_keys</a> </li></ul>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 22 15:18:22 2009 for grib_api by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>