Commit 3694b304 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cgribexlib update.

parent 59b3ebb0
/* Automatically generated by m214003 at 2016-02-19, do not edit */
/* Automatically generated by m214003 at 2016-05-23, do not edit */
/* CGRIBEXLIB_VERSION="1.7.4" */
/* CGRIBEXLIB_VERSION="1.7.5" */
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) || defined (__clang__)
#pragma GCC diagnostic push
......@@ -367,6 +367,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
#ifndef _GRIB_ENCODE_H
#define _GRIB_ENCODE_H
#include <limits.h>
#define PutnZero(n) \
{ \
......@@ -389,6 +390,11 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
#define Put2Int(Value) {ival = Value; if ( ival < 0 ) ival = 0x8000 - ival; Put2Byte(ival);}
#define Put3Int(Value) {ival = Value; if ( ival < 0 ) ival = 0x800000 - ival; Put3Byte(ival);}
enum {
BitsPerInt = (int) (sizeof(int) * CHAR_BIT),
};
#define Put1Real(Value) \
{ \
confp3(Value, &exponent, &mantissa, BitsPerInt, 1); \
......@@ -7259,8 +7265,8 @@ void TEMPLATE(scm0,T)(T *pdl, T *pdr, T *pfl, T *pfr, int klg)
zbeta = pdr[jl] / (pfr[jl] - pfl[jl]);
if ( zalpha <= 0.0 ) pdl[jl] = 0.0;
if ( zbeta <= 0.0 ) pdr[jl] = 0.0;
if ( zalpha > zfac ) pdl[jl] = zfac * (pfr[jl] - pfl[jl]);
if ( zbeta > zfac ) pdr[jl] = zfac * (pfr[jl] - pfl[jl]);
if ( zalpha > zfac ) pdl[jl] = (T)(zfac * (pfr[jl] - pfl[jl]));
if ( zbeta > zfac ) pdr[jl] = (T)(zfac * (pfr[jl] - pfl[jl]));
}
else
{
......@@ -8020,8 +8026,8 @@ void TEMPLATE(scm0,T)(T *pdl, T *pdr, T *pfl, T *pfr, int klg)
zbeta = pdr[jl] / (pfr[jl] - pfl[jl]);
if ( zalpha <= 0.0 ) pdl[jl] = 0.0;
if ( zbeta <= 0.0 ) pdr[jl] = 0.0;
if ( zalpha > zfac ) pdl[jl] = zfac * (pfr[jl] - pfl[jl]);
if ( zbeta > zfac ) pdr[jl] = zfac * (pfr[jl] - pfl[jl]);
if ( zalpha > zfac ) pdl[jl] = (T)(zfac * (pfr[jl] - pfl[jl]));
if ( zbeta > zfac ) pdr[jl] = (T)(zfac * (pfr[jl] - pfl[jl]));
}
else
{
......@@ -9282,11 +9288,6 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
{
/* int imisng = 0; */
int ReducedGrid = FALSE, VertCoorTab = FALSE;
int locnv = 0, locnl;
int jlenl;
int iexp, imant;
int ipvpl, ipl;
int gdsLen = 0;
#if defined (VECTORCODE)
unsigned char *igrib;
GRIBPACK *lgrib = NULL;
......@@ -9297,9 +9298,9 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
memset(isec2, 0, 22*sizeof(int));
gdsLen = GDS_Len;
int gdsLen = GDS_Len;
ipvpl = GDS_PVPL;
int ipvpl = GDS_PVPL;
if ( ipvpl == 0 ) ipvpl = 0xFF;
if ( ipvpl != 0xFF )
......@@ -9307,7 +9308,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
if ( GDS_NV != 0 )
{ /* we have vct */
VertCoorTab = TRUE;
ipl = 4*GDS_NV + ipvpl - 1;
int ipl = 4*GDS_NV + ipvpl - 1;
if ( ipl < gdsLen )
{
ReducedGrid = TRUE;
......@@ -9323,14 +9324,13 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
if ( ISEC0_GRIB_Version == 0 )
{
if ((gdsLen - 32) > 0) VertCoorTab = TRUE;
else VertCoorTab = FALSE;
VertCoorTab = (gdsLen - 32) > 0;
}
if ( ReducedGrid )
{
locnl = GDS_PVPL - 1 + (VertCoorTab * 4 * GDS_NV);
jlenl = (gdsLen - locnl) >> 1;
int locnl = GDS_PVPL - 1 + (VertCoorTab * 4 * GDS_NV);
int jlenl = (gdsLen - locnl) >> 1;
if ( jlenl == GDS_NumLat )
{
*numGridVals = 0;
......@@ -9469,6 +9469,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
if ( VertCoorTab == TRUE )
{
int locnv;
if ( ISEC0_GRIB_Version == 0 )
{
locnv = 32;
......@@ -9487,10 +9488,10 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
if ( ISEC2_NumVCP > 0 ) (void) UNPACK_GRIB(igrib, lgrib, lGribLen, -1L);
for ( int i = 0; i < ISEC2_NumVCP; i++ )
{
iexp = (lgrib[4*i ]);
imant =((lgrib[4*i+1]) << 16) +
((lgrib[4*i+2]) << 8) +
(lgrib[4*i+3]);
int iexp = (lgrib[4*i ]);
int imant =(((lgrib[4*i+1]) << 16) +
((lgrib[4*i+2]) << 8) +
( lgrib[4*i+3]));
fsec2[10+i] = POW_2_M24 * imant * ldexp(1.0, 4 * (iexp - 64));
}
......@@ -9498,10 +9499,10 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
#else
for ( int i = 0; i < ISEC2_NumVCP; i++ )
{
iexp = (gds[locnv+4*i ]);
imant =((gds[locnv+4*i+1]) << 16) +
((gds[locnv+4*i+2]) << 8) +
(gds[locnv+4*i+3]);
int iexp = (gds[locnv+4*i ]);
int imant =(((gds[locnv+4*i+1]) << 16) +
((gds[locnv+4*i+2]) << 8) +
( gds[locnv+4*i+3]));
fsec2[10+i] = (T)decfp2(iexp,imant);
}
#endif
......@@ -9601,7 +9602,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
if ( ! (dfunc == 'J') && imiss == 0 )
{
fmin = BDS_RefValue;
fmin = (T)BDS_RefValue;
zscale = TEMPLATE(ldexp,T)((T)1.0, jscale);
}
......@@ -10203,11 +10204,6 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
{
/* int imisng = 0; */
int ReducedGrid = FALSE, VertCoorTab = FALSE;
int locnv = 0, locnl;
int jlenl;
int iexp, imant;
int ipvpl, ipl;
int gdsLen = 0;
#if defined (VECTORCODE)
unsigned char *igrib;
GRIBPACK *lgrib = NULL;
......@@ -10218,9 +10214,9 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
memset(isec2, 0, 22*sizeof(int));
gdsLen = GDS_Len;
int gdsLen = GDS_Len;
ipvpl = GDS_PVPL;
int ipvpl = GDS_PVPL;
if ( ipvpl == 0 ) ipvpl = 0xFF;
if ( ipvpl != 0xFF )
......@@ -10228,7 +10224,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
if ( GDS_NV != 0 )
{ /* we have vct */
VertCoorTab = TRUE;
ipl = 4*GDS_NV + ipvpl - 1;
int ipl = 4*GDS_NV + ipvpl - 1;
if ( ipl < gdsLen )
{
ReducedGrid = TRUE;
......@@ -10244,14 +10240,13 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
if ( ISEC0_GRIB_Version == 0 )
{
if ((gdsLen - 32) > 0) VertCoorTab = TRUE;
else VertCoorTab = FALSE;
VertCoorTab = (gdsLen - 32) > 0;
}
if ( ReducedGrid )
{
locnl = GDS_PVPL - 1 + (VertCoorTab * 4 * GDS_NV);
jlenl = (gdsLen - locnl) >> 1;
int locnl = GDS_PVPL - 1 + (VertCoorTab * 4 * GDS_NV);
int jlenl = (gdsLen - locnl) >> 1;
if ( jlenl == GDS_NumLat )
{
*numGridVals = 0;
......@@ -10390,6 +10385,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
if ( VertCoorTab == TRUE )
{
int locnv;
if ( ISEC0_GRIB_Version == 0 )
{
locnv = 32;
......@@ -10408,10 +10404,10 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
if ( ISEC2_NumVCP > 0 ) (void) UNPACK_GRIB(igrib, lgrib, lGribLen, -1L);
for ( int i = 0; i < ISEC2_NumVCP; i++ )
{
iexp = (lgrib[4*i ]);
imant =((lgrib[4*i+1]) << 16) +
((lgrib[4*i+2]) << 8) +
(lgrib[4*i+3]);
int iexp = (lgrib[4*i ]);
int imant =(((lgrib[4*i+1]) << 16) +
((lgrib[4*i+2]) << 8) +
( lgrib[4*i+3]));
fsec2[10+i] = POW_2_M24 * imant * ldexp(1.0, 4 * (iexp - 64));
}
......@@ -10419,10 +10415,10 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2,
#else
for ( int i = 0; i < ISEC2_NumVCP; i++ )
{
iexp = (gds[locnv+4*i ]);
imant =((gds[locnv+4*i+1]) << 16) +
((gds[locnv+4*i+2]) << 8) +
(gds[locnv+4*i+3]);
int iexp = (gds[locnv+4*i ]);
int imant =(((gds[locnv+4*i+1]) << 16) +
((gds[locnv+4*i+2]) << 8) +
( gds[locnv+4*i+3]));
fsec2[10+i] = (T)decfp2(iexp,imant);
}
#endif
......@@ -10522,7 +10518,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
if ( ! (dfunc == 'J') && imiss == 0 )
{
fmin = BDS_RefValue;
fmin = (T)BDS_RefValue;
zscale = TEMPLATE(ldexp,T)((T)1.0, jscale);
}
......@@ -11450,7 +11446,6 @@ void encodePDS(GRIBPACK *lpds, long pdsLen, int *isec1)
}
}
int BitsPerInt = (int) (sizeof(int) * 8);
......@@ -12777,7 +12772,6 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
*datasize = fsec4size;
}
/* GRIB BLOCK 4 - BINARY DATA SECTION */
static
int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *isec2, int *isec4, long datasize, T *data,
......@@ -12792,20 +12786,17 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
int ival;
long PackStart = 0, Flag = 0;
int binscale = 0;
int nbpv;
int bds_head = 11;
int bds_ext = 0;
/* ibits = BitsPerInt; */
int exponent, mantissa;
int lspherc = FALSE, lcomplex = FALSE;
int lspherc = FALSE;
int isubset = 0, itemp = 0, itrunc = 0;
T factor = 1, fmin, fmax;
double zref;
double range;
double jpepsln = 1.0e-12; /* -----> tolerance used to check equality */
/* of floating point numbers - needed */
/* on some platforms (eg vpp700, linux) */
extern int CGRIBEX_Const; /* 1: Don't pack constant fields on regular grids */
const double jpepsln = 1.0e-12; /* -----> tolerance used to check equality */
/* of floating point numbers - needed */
/* on some platforms (eg vpp700, linux) */
extern int CGRIBEX_Const; /* 1: Don't pack constant fields on regular grids */
if ( isec2 )
{
......@@ -12828,8 +12819,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
/* Complex packing supported for spherical harmonics. */
lcomplex = ( lspherc && ( isec4[3] == 64 ) ) ||
( lspherc && isec2 && ( isec2[5] == 2 ) );
int lcomplex = ( lspherc && ( isec4[3] == 64 ) ) ||
( lspherc && isec2 && ( isec2[5] == 2 ) );
/* Check input specification is consistent */
......@@ -12887,7 +12878,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
*datstart = bds_head + bds_ext;
nbpv = numBits = ISEC4_NumBits;
int nbpv = numBits = ISEC4_NumBits;
if ( lspherc && lcomplex )
{
......@@ -12902,7 +12893,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
TEMPLATE(minmax_val,T)(data+PackStart, datasize-PackStart, &fmin, &fmax);
zref = (double)fmin;
double zref = (double)fmin;
if ( CGRIBEX_Const && !lspherc )
......@@ -12930,7 +12921,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
Limit scaling to 2**-126 to 2**127 (using IEEE 32-bit floats
as a guideline).
*/
range = fabs(fmax - fmin);
double range = fabs(fmax - fmin);
if ( fabs(fmin) < FLT_MIN ) fmin = 0;
/*
......@@ -12954,7 +12945,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
{
double rangec = range + jpepsln,
p2 = 2.0;
long jloop = 1;
int jloop = 1;
while ( jloop < 128 && p2 <= rangec )
{
p2 *= 2.0;
......@@ -12972,7 +12963,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
else
{
double rangec = range - jpepsln, p05 = 0.5;
long jloop = 1;
int jloop = 1;
while ( jloop < 127 && p05 >= rangec )
{
p05 *= 0.5;
......@@ -12994,12 +12985,9 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
if ( binscale != 0 )
{
if ( binscale < 0 )
while ( (uint64_t)(ldexp(range, -binscale)+0.5) > max_nbpv_pow2 ) binscale++;
else
while ( (uint64_t)(ldexp(range, -binscale)+0.5) > max_nbpv_pow2 ) binscale--;
while ( (uint64_t)(ldexp(range, -binscale)+0.5) > max_nbpv_pow2 ) binscale++;
factor = intpow2(-binscale);
factor = (T)intpow2(-binscale);
}
ref2ibm(&zref, BitsPerInt);
......@@ -13393,7 +13381,6 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
*datasize = fsec4size;
}
/* GRIB BLOCK 4 - BINARY DATA SECTION */
static
int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *isec2, int *isec4, long datasize, T *data,
......@@ -13408,20 +13395,17 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
int ival;
long PackStart = 0, Flag = 0;
int binscale = 0;
int nbpv;
int bds_head = 11;
int bds_ext = 0;
/* ibits = BitsPerInt; */
int exponent, mantissa;
int lspherc = FALSE, lcomplex = FALSE;
int lspherc = FALSE;
int isubset = 0, itemp = 0, itrunc = 0;
T factor = 1, fmin, fmax;
double zref;
double range;
double jpepsln = 1.0e-12; /* -----> tolerance used to check equality */
/* of floating point numbers - needed */
/* on some platforms (eg vpp700, linux) */
extern int CGRIBEX_Const; /* 1: Don't pack constant fields on regular grids */
const double jpepsln = 1.0e-12; /* -----> tolerance used to check equality */
/* of floating point numbers - needed */
/* on some platforms (eg vpp700, linux) */
extern int CGRIBEX_Const; /* 1: Don't pack constant fields on regular grids */
if ( isec2 )
{
......@@ -13444,8 +13428,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
/* Complex packing supported for spherical harmonics. */
lcomplex = ( lspherc && ( isec4[3] == 64 ) ) ||
( lspherc && isec2 && ( isec2[5] == 2 ) );
int lcomplex = ( lspherc && ( isec4[3] == 64 ) ) ||
( lspherc && isec2 && ( isec2[5] == 2 ) );
/* Check input specification is consistent */
......@@ -13503,7 +13487,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
*datstart = bds_head + bds_ext;
nbpv = numBits = ISEC4_NumBits;
int nbpv = numBits = ISEC4_NumBits;
if ( lspherc && lcomplex )
{
......@@ -13518,7 +13502,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
TEMPLATE(minmax_val,T)(data+PackStart, datasize-PackStart, &fmin, &fmax);
zref = (double)fmin;
double zref = (double)fmin;
if ( CGRIBEX_Const && !lspherc )
......@@ -13546,7 +13530,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
Limit scaling to 2**-126 to 2**127 (using IEEE 32-bit floats
as a guideline).
*/
range = fabs(fmax - fmin);
double range = fabs(fmax - fmin);
if ( fabs(fmin) < FLT_MIN ) fmin = 0;
/*
......@@ -13570,7 +13554,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
{
double rangec = range + jpepsln,
p2 = 2.0;
long jloop = 1;
int jloop = 1;
while ( jloop < 128 && p2 <= rangec )
{
p2 *= 2.0;
......@@ -13588,7 +13572,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
else
{
double rangec = range - jpepsln, p05 = 0.5;
long jloop = 1;
int jloop = 1;
while ( jloop < 127 && p05 >= rangec )
{
p05 *= 0.5;
......@@ -13610,12 +13594,9 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
if ( binscale != 0 )
{
if ( binscale < 0 )
while ( (uint64_t)(ldexp(range, -binscale)+0.5) > max_nbpv_pow2 ) binscale++;
else
while ( (uint64_t)(ldexp(range, -binscale)+0.5) > max_nbpv_pow2 ) binscale--;
while ( (uint64_t)(ldexp(range, -binscale)+0.5) > max_nbpv_pow2 ) binscale++;
factor = intpow2(-binscale);
factor = (T)intpow2(-binscale);
}
ref2ibm(&zref, BitsPerInt);
......@@ -13784,7 +13765,7 @@ void encode_dummy(void)
(void) encode_array_unrolled_double(0, 0, 0, NULL, NULL, 0, 0, NULL);
(void) encode_array_unrolled_float(0, 0, 0, NULL, NULL, 0, 0, NULL);
}
static const char grb_libvers[] = "1.7.4" " of ""Feb 19 2016"" ""11:03:41";
static const char grb_libvers[] = "1.7.5" " of ""May 23 2016"" ""19:12:55";
const char *
cgribexLibraryVersion(void)
{
......
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