<aname="l00057"></a>00057 <spanclass="comment">/* create a new handle from a message in a file */</span>
<aname="l00058"></a>00058 h = <aname="a1"></a><aclass="code"href="group__grib__handle.html#g5e24f8499aa7e4178ccc25a5de3145c5"title="Create a handle from a file resource.">grib_handle_new_from_file</a>(0,in,&err);
<aname="l00060"></a>00060 printf(<spanclass="stringliteral">"Error: unable to create handle from file %s\n"</span>,infile);
<aname="l00061"></a>00061 }
<aname="l00062"></a>00062
<aname="l00063"></a>00063 <spanclass="comment">/* bitsPerValue before changing the packing parameters */</span>
<aname="l00064"></a>00064 GRIB_CHECK(<aname="a2"></a><aclass="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,<spanclass="stringliteral">"bitsPerValue"</span>,&bitsPerValue1),0);
<aname="l00065"></a>00065
<aname="l00066"></a>00066 <spanclass="comment">/* get the size of the values array*/</span>
<aname="l00067"></a>00067 GRIB_CHECK(<aname="a3"></a><aclass="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,<spanclass="stringliteral">"values"</span>,&size),0);
<aname="l00070"></a>00070 <spanclass="comment">/* get data values before changing the packing parameters*/</span>
<aname="l00071"></a>00071 GRIB_CHECK(<aname="a4"></a><aclass="code"href="group__get__set.html#g61f1029d7f37d51f33835e218d58378a"title="Get double array values from a key.">grib_get_double_array</a>(h,<spanclass="stringliteral">"values"</span>,values1,&size),0);
<aname="l00072"></a>00072
<aname="l00073"></a>00073 <spanclass="comment">/* changing decimal precition to 2 means that 2 decimal digits</span>
<aname="l00074"></a>00074 <spanclass="comment"> are preserved when packing. */</span>
<aname="l00075"></a>00075 decimalPrecision=2;
<aname="l00076"></a>00076 GRIB_CHECK(<aname="a5"></a><aclass="code"href="group__get__set.html#g94c33cfe90c3aa887fb8e14f0bd87fe2"title="Set a long value from a key.">grib_set_long</a>(h,<spanclass="stringliteral">"changeDecimalPrecision"</span>,decimalPrecision),0);
<aname="l00077"></a>00077
<aname="l00078"></a>00078 <spanclass="comment">/* bitsPerValue after changing the packing parameters */</span>
<aname="l00079"></a>00079 GRIB_CHECK(<aclass="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,<spanclass="stringliteral">"bitsPerValue"</span>,&bitsPerValue2),0);
<aname="l00082"></a>00082 <spanclass="comment">/* get data values after changing the packing parameters*/</span>
<aname="l00083"></a>00083 GRIB_CHECK(<aclass="code"href="group__get__set.html#g61f1029d7f37d51f33835e218d58378a"title="Get double array values from a key.">grib_get_double_array</a>(h,<spanclass="stringliteral">"values"</span>,values2,&size),0);
<aname="l00100"></a>00100 printf(<spanclass="stringliteral">"min value = %g\n"</span>,minv);
<aname="l00101"></a>00101 printf(<spanclass="stringliteral">"max value = %g\n"</span>,maxv);
<aname="l00102"></a>00102
<aname="l00103"></a>00103 printf(<spanclass="stringliteral">"old number of bits per value=%ld\n"</span>,(<spanclass="keywordtype">long</span>)bitsPerValue1);
<aname="l00104"></a>00104 printf(<spanclass="stringliteral">"new number of bits per value=%ld\n"</span>,(<spanclass="keywordtype">long</span>)bitsPerValue2);
<aname="l00105"></a>00105
<aname="l00106"></a>00106 <spanclass="comment">/* get the coded message in a buffer */</span>
<aname="l00107"></a>00107 GRIB_CHECK(<aname="a6"></a><aclass="code"href="group__handling__coded__messages.html#g9d654bd4fc5f422c161edd0a140ea185"title="getting the message attached to a handle">grib_get_message</a>(h,&buffer,&size),0);
<aname="l00108"></a>00108
<aname="l00109"></a>00109 <spanclass="comment">/* write the buffer in a file*/</span>
<aname="l00117"></a>00117 <aname="a7"></a><aclass="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);