Commit 09c69651 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cgribexlib update

parent 86a77af9
2011-08-25 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using CGRIBEX library version 1.5.1
2011-08-15 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* streamFilesuffix: added suffix for filetype NC4C (bug fix)
......
/* Automatically generated by m214003 at 2011-02-15, do not edit */
/* Automatically generated by m214003 at 2011-08-25, do not edit */
/* CGRIBEXLIB_VERSION="1.5.0" */
/* CGRIBEXLIB_VERSION="1.5.1" */
#if defined (HAVE_CONFIG_H)
# include "config.h"
......@@ -3262,9 +3262,7 @@ void encodeBMS(GRIBPACK *lGrib, long *gribLen, double *fsec3, int *isec4, double
long bmsLen, bmsUnusedBits;
long fsec4size;
long z = *gribLen;
#ifdef VECTORCODE
unsigned int *imask;
#endif
static int lmissvalinfo = 1;
/* unsigned int c, imask; */
......@@ -4415,13 +4413,20 @@ void decode_double_array_common(unsigned char *igrib, long jlend, int NumBits,
unsigned char *bits = igrib;
unsigned int jmask;
long i;
int tbits = 0;
unsigned int tbits = 0;
int n_bits = NumBits;
int t_bits = 0;
jmask = (1 << n_bits) - 1;
for ( i = 0; i < jlend; i++ )
{
if (n_bits - t_bits > 8)
{
tbits = (tbits << 16) | (bits[0] << 8) | (bits[1]);
bits += 2;
t_bits += 16;
}
while ( t_bits < n_bits )
{
tbits = (tbits * 256) + *bits++;
......@@ -4435,6 +4440,54 @@ void decode_double_array_common(unsigned char *igrib, long jlend, int NumBits,
fpdata[i] = fmin + zscale*fpdata[i];
}
static unsigned int mask[] = {0,1,3,7,15,31,63,127,255};
static double shift[9] = {1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0};
static
void decode_double_array_common2(unsigned char *igrib, long jlend, int NumBits,
double fmin, double zscale, double *fpdata)
{
/* code from wgrib routine BDS_unpack */
unsigned char *bits = igrib;
unsigned int map_mask;
long i;
int n_bits = NumBits;
int c_bits, j_bits;
double jj;
/* older unoptimized code, not often used */
c_bits = 8;
map_mask = 128;
for ( i = 0; i < jlend; i++ )
{
jj = 0.0;
j_bits = n_bits;
while (c_bits <= j_bits)
{
if (c_bits == 8)
{
jj = jj * 256.0 + (double) (*bits++);
j_bits -= 8;
}
else
{
jj = (jj * shift[c_bits]) + (double) (*bits & mask[c_bits]);
bits++;
j_bits -= c_bits;
c_bits = 8;
}
}
if (j_bits)
{
c_bits -= j_bits;
jj = (jj * shift[j_bits]) + (double) ((*bits >> c_bits) & mask[j_bits]);
}
fpdata[i] = fmin + zscale*jj;
}
}
static
void decode_double_array(unsigned char *igrib, long jlend, int numBits,
double fmin, double zscale, double *fpdata)
......@@ -4492,9 +4545,13 @@ void decode_double_array(unsigned char *igrib, long jlend, int numBits,
{
decode_double_array_common(igrib, jlend, numBits, fmin, zscale, fpdata);
}
else if ( numBits > 25 && numBits < 32 )
{
decode_double_array_common2(igrib, jlend, numBits, fmin, zscale, fpdata);
}
else
{
fprintf(stderr," Unimplemented packing factor %d\n", numBits);
fprintf(stderr," Unimplemented packing factor %d!\n", numBits);
exit(EXIT_FAILURE);
}
......@@ -4536,9 +4593,13 @@ void decode_double_array(unsigned char *igrib, long jlend, int numBits,
{
decode_double_array_common(igrib, jlend, numBits, fmin, zscale, fpdata);
}
else if ( numBits > 25 && numBits < 32 )
{
decode_double_array_common2(igrib, jlend, numBits, fmin, zscale, fpdata);
}
else
{
fprintf(stderr," Unimplemented packing factor %d\n", numBits);
fprintf(stderr," Unimplemented packing factor %d!\n", numBits);
exit(EXIT_FAILURE);
}
#endif
......@@ -9081,18 +9142,9 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
return (gribLen);
}
static const char grb_libvers[] = "1.5.0" " of ""Feb 15 2011"" ""10:23:39";
static const char grb_libvers[] = "1.5.1" " of ""Aug 25 2011"" ""09:32:29";
const char *
cgribexLibraryVersion(void)
{
return (grb_libvers);
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
......@@ -2236,12 +2236,12 @@ void grid_check_cyclic(grid_t *gridptr)
for ( k2 = 0; k2 < 4; ++k2 )
{
val2 = xbounds[i2+k2];
if ( val1 < 1 && val2 > 300 ) val1 += 360;
if ( val2 < 1 && val1 > 300 ) val2 += 360;
if ( val1 < -179 && val2 > 120 ) val1 += 360;
if ( val2 < -179 && val1 > 120 ) val2 += 360;
if ( fabs(val1-val2) < 0.001 )
{
nc++;
......@@ -2249,6 +2249,7 @@ void grid_check_cyclic(grid_t *gridptr)
}
}
}
if ( nc < 1 )
{
gridptr->isCyclic = FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment