diff --git a/ChangeLog b/ChangeLog index 65dcb44f3e7aae97c5aa75d6352b8a48caba2333..ab893a7580f659d0dd9f98a1c0fe90ec69b1e774 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2019-05-23 Uwe Schulzweida + * using CGRIBEX library version 1.9.3 * Version 1.9.7 released 2019-04-01 Uwe Schulzweida diff --git a/src/cgribexlib.c b/src/cgribexlib.c index 7f2128f7daf07f7cf0d4827fd8168b29f5820cd2..a0f040cdc3b8b2f73d702c0335f9801f8e6f8994 100644 --- a/src/cgribexlib.c +++ b/src/cgribexlib.c @@ -1,7 +1,7 @@ -/* Automatically generated by m214003 at 2019-01-29, do not edit */ +/* Automatically generated by m214003 at 2019-04-15, do not edit */ -/* CGRIBEXLIB_VERSION="1.9.2" */ +/* CGRIBEXLIB_VERSION="1.9.3" */ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) || defined (__clang__) #pragma GCC diagnostic push @@ -75,7 +75,7 @@ #endif -#if defined (VECTORCODE) +#ifdef VECTORCODE #ifdef INT32 # define GRIBPACK unsigned INT32 # define PACK_GRIB packInt32 @@ -8508,7 +8508,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i #endif long i; -#if defined (VECTORCODE) +#ifdef VECTORCODE GRIBPACK *lgrib = NULL; if ( numBits%8 == 0 ) @@ -8740,7 +8740,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i #endif long i; -#if defined (VECTORCODE) +#ifdef VECTORCODE GRIBPACK *lgrib = NULL; if ( numBits%8 == 0 ) @@ -8866,7 +8866,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2, { // int imisng = 0; bool ReducedGrid = false, VertCoorTab = false; -#if defined (VECTORCODE) +#ifdef VECTORCODE unsigned char *igrib; GRIBPACK *lgrib = NULL; size_t lGribLen = 0; @@ -9523,7 +9523,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int * GRIBPACK *imask = (GRIBPACK*) Malloc((size_t)imaskSize*sizeof(GRIBPACK)); -#if defined (VECTORCODE) +#ifdef VECTORCODE (void) UNPACK_GRIB(BMS_Bitmap, imask, imaskSize/8, -1L); GRIBPACK *pbitmap = imask; #else @@ -9693,7 +9693,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char *gds, int *isec0, int *isec2, T *fsec2, { // int imisng = 0; bool ReducedGrid = false, VertCoorTab = false; -#if defined (VECTORCODE) +#ifdef VECTORCODE unsigned char *igrib; GRIBPACK *lgrib = NULL; size_t lGribLen = 0; @@ -10350,7 +10350,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int * GRIBPACK *imask = (GRIBPACK*) Malloc((size_t)imaskSize*sizeof(GRIBPACK)); -#if defined (VECTORCODE) +#ifdef VECTORCODE (void) UNPACK_GRIB(BMS_Bitmap, imask, imaskSize/8, -1L); GRIBPACK *pbitmap = imask; #else @@ -11965,14 +11965,13 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2) long z = *gribLen; int exponent, mantissa; int ival; - int pvoffset = 0xFF; int gdslen = 32; if ( ISEC2_GridType == GRIB1_GTYPE_LCC ) gdslen += 10; if ( ISEC2_GridType == GRIB1_GTYPE_LATLON_ROT ) gdslen += 10; - if ( ISEC2_NumVCP || ISEC2_Reduced ) pvoffset = gdslen + 1; + const int pvoffset = (ISEC2_NumVCP || ISEC2_Reduced) ? gdslen + 1 : 0xFF; if ( ISEC2_Reduced ) gdslen += 2 * ISEC2_NumLat; @@ -12028,7 +12027,7 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2) ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN || ISEC2_GridType == GRIB1_GTYPE_LATLON_ROT ) { - int numlon = ISEC2_Reduced ? 0xFFFF : ISEC2_NumLon; + const int numlon = ISEC2_Reduced ? 0xFFFF : ISEC2_NumLon; Put2Byte(numlon); /* 6- 7 Number of Longitudes */ Put2Byte(ISEC2_NumLat); /* 8- 9 Number of Latitudes */ @@ -12037,8 +12036,8 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2) Put1Byte(ISEC2_ResFlag); /* 16 Resolution flag */ Put3Int(ISEC2_LastLat); Put3Int(ISEC2_LastLon); - unsigned lonIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LonIncr; - unsigned latIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LatIncr; + const unsigned lonIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LonIncr; + const unsigned latIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LatIncr; Put2Byte(lonIncr); /* 23-24 i - direction increment */ if ( ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN ) Put2Byte(ISEC2_NumPar); /* 25-26 Latitudes Pole->Equator */ @@ -12088,12 +12087,12 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4, Message("Missing value = NaN is unsupported!"); } - long bitmapSize = ISEC4_NumValues; - long imaskSize = ((bitmapSize+7)>>3)<<3; + const long bitmapSize = ISEC4_NumValues; + const long imaskSize = ((bitmapSize+7)>>3)<<3; GRIBPACK *bitmap = &lGrib[z+6]; long fsec4size = 0; -#if defined (VECTORCODE) +#ifdef VECTORCODE unsigned int *imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int)); memset(imask, 0, imaskSize*sizeof(int)); @@ -12146,8 +12145,8 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4, } #endif - long bmsLen = imaskSize/8 + 6; - long bmsUnusedBits = imaskSize - bitmapSize; + const long bmsLen = imaskSize/8 + 6; + const long bmsUnusedBits = imaskSize - bitmapSize; Put3Byte(bmsLen); /* 0- 2 Length of Block 3 Byte 0 */ Put1Byte(bmsUnusedBits); @@ -12203,8 +12202,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise /* Complex packing supported for spherical harmonics. */ - bool lcomplex = ( lspherc && ( isec4[3] == 64 ) ) || - ( lspherc && isec2 && ( isec2[5] == 2 ) ); + const bool lcomplex = ( lspherc && ( isec4[3] == 64 ) ) || + ( lspherc && isec2 && ( isec2[5] == 2 ) ); /* Check input specification is consistent */ @@ -12237,7 +12236,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise if ( decscale ) { - T scale = (T) pow(10.0, (double) decscale); + const T scale = (T) pow(10.0, (double) decscale); for ( long i = 0; i < datasize; ++i ) data[i] *= scale; } @@ -12245,8 +12244,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise { if ( lcomplex ) { - int jup = isubset; - int ioff = (jup+1)*(jup+2); + const int jup = isubset; + const int ioff = (jup+1)*(jup+2); bds_ext = 4 + 3 + 4*ioff; PackStart = ioff; Flag = 192; @@ -12265,9 +12264,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise if ( lspherc && lcomplex ) { - int pcStart, pcScale; - pcStart = isubset; - pcScale = isec4[16]; + const int pcStart = isubset; + const int pcScale = isec4[16]; TEMPLATE(scale_complex,T)(data, pcStart, pcScale, itrunc, 0); TEMPLATE(gather_complex,T)(data, (size_t)pcStart, (size_t)itrunc, (size_t)datasize); } @@ -12277,40 +12275,39 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise TEMPLATE(minmax_val,T)(data+PackStart, datasize-PackStart, &fmin, &fmax); double zref = (double)fmin; - + if (!(zref < DBL_MAX && zref > -DBL_MAX)) + { + gprintf(__func__, "Minimum value out of range: %g!", zref); + return (707); + } if ( CGRIBEX_Const && !lspherc ) { if ( IS_EQUAL(fmin, fmax) ) nbpv = 0; } - long blockLength = (*datstart) + (nbpv*(datasize - PackStart) + 7)/8; blockLength += blockLength & 1; - long unused_bits = blockLength*8 - (*datstart)*8 - nbpv*(datasize - PackStart); + const long unused_bits = blockLength*8 - (*datstart)*8 - nbpv*(datasize - PackStart); Flag += unused_bits; /* - Adjust number of bits per value if full integer length to - avoid hitting most significant bit (sign bit). + Adjust number of bits per value if full integer length to avoid hitting most significant bit (sign bit). */ /* if( nbpv == ibits ) nbpv = nbpv - 1; */ /* - Calculate the binary scaling factor to spread the range of - values over the number of bits per value. - Limit scaling to 2**-126 to 2**127 (using IEEE 32-bit floats - as a guideline). + Calculate the binary scaling factor to spread the range of values over the number of bits per value. + Limit scaling to 2**-126 to 2**127 (using IEEE 32-bit floatsas a guideline). */ - double range = fabs(fmax - fmin); + const double range = fabs(fmax - fmin); if ( fabs(fmin) < FLT_MIN ) fmin = 0; /* - Have to allow tolerance in comparisons on some platforms - (eg vpp700 and linux), such as 0.9999999999999999 = 1.0, - to avoid clipping ranges which are a power of 2. + Have to allow tolerance in comparisons on some platforms (eg vpp700 and linux), + such as 0.9999999999999999 = 1.0, to avoid clipping ranges which are a power of 2. */ if ( range <= jpepsln ) { @@ -12326,8 +12323,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise } else if ( range > 1.0 ) { - double rangec = range + jpepsln, - p2 = 2.0; + const double rangec = range + jpepsln; + double p2 = 2.0; int jloop = 1; while ( jloop < 128 && p2 <= rangec ) { @@ -12345,7 +12342,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise } else { - double rangec = range - jpepsln, p05 = 0.5; + const double rangec = range - jpepsln; + double p05 = 0.5; int jloop = 1; while ( jloop < 127 && p05 >= rangec ) { @@ -12364,7 +12362,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise } } - uint64_t max_nbpv_pow2 = (uint64_t) ((1ULL << nbpv) - 1); + const uint64_t max_nbpv_pow2 = (uint64_t) ((1ULL << nbpv) - 1); if ( binscale != 0 ) { @@ -12386,7 +12384,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise { if ( lcomplex ) { - int jup = isubset; + const int jup = isubset; int ioff = (int)z + bds_ext; if ( ioff > 0xFFFF ) ioff = 0; Put2Byte(ioff); @@ -12433,31 +12431,31 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int * unsigned char *CGrib = (unsigned char *) kgrib; - bool gdsIncluded = ISEC1_Sec2Or3Flag & 128; - bool bmsIncluded = ISEC1_Sec2Or3Flag & 64; + const bool gdsIncluded = ISEC1_Sec2Or3Flag & 128; + const bool bmsIncluded = ISEC1_Sec2Or3Flag & 64; // set max header len size_t len = 16384; // add data len - size_t numBytes = (size_t)((ISEC4_NumBits+7)>>3); + const size_t numBytes = (size_t)((ISEC4_NumBits+7)>>3); len += numBytes*(size_t)klenp; // add bitmap len if ( bmsIncluded ) len += (size_t)((klenp+7)>>3); -#if defined (VECTORCODE) +#ifdef VECTORCODE GRIBPACK *lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK)); if ( lGrib == NULL ) SysError("No Memory!"); #else GRIBPACK *lGrib = CGrib; #endif - long isLen = 8; + const long isLen = 8; encodeIS(lGrib, &gribLen); GRIBPACK *lpds = &lGrib[isLen]; - long pdsLen = getPdsLen(isec1); + const long pdsLen = getPdsLen(isec1); encodePDS(lpds, pdsLen, isec1); gribLen += pdsLen; @@ -12490,7 +12488,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int * fsec4size = ISEC4_NumValues; } - long bdsstart = gribLen; + const long bdsstart = gribLen; int status = TEMPLATE(encodeBDS,T)(lGrib, &gribLen, ISEC1_DecScaleFactor, isec2, isec4, fsec4size, fsec4, &datstart, &datsize, ISEC1_Parameter); if ( status ) @@ -12504,7 +12502,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int * if ( (size_t) gribLen > (size_t)kleng*sizeof(int) ) Error("kgrib buffer too small! kleng = %d gribLen = %d", kleng, gribLen); -#if defined (VECTORCODE) +#ifdef VECTORCODE if ( (size_t) gribLen > len ) Error("lGrib buffer too small! len = %d gribLen = %d", len, gribLen); @@ -12542,14 +12540,13 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2) long z = *gribLen; int exponent, mantissa; int ival; - int pvoffset = 0xFF; int gdslen = 32; if ( ISEC2_GridType == GRIB1_GTYPE_LCC ) gdslen += 10; if ( ISEC2_GridType == GRIB1_GTYPE_LATLON_ROT ) gdslen += 10; - if ( ISEC2_NumVCP || ISEC2_Reduced ) pvoffset = gdslen + 1; + const int pvoffset = (ISEC2_NumVCP || ISEC2_Reduced) ? gdslen + 1 : 0xFF; if ( ISEC2_Reduced ) gdslen += 2 * ISEC2_NumLat; @@ -12605,7 +12602,7 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2) ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN || ISEC2_GridType == GRIB1_GTYPE_LATLON_ROT ) { - int numlon = ISEC2_Reduced ? 0xFFFF : ISEC2_NumLon; + const int numlon = ISEC2_Reduced ? 0xFFFF : ISEC2_NumLon; Put2Byte(numlon); /* 6- 7 Number of Longitudes */ Put2Byte(ISEC2_NumLat); /* 8- 9 Number of Latitudes */ @@ -12614,8 +12611,8 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2) Put1Byte(ISEC2_ResFlag); /* 16 Resolution flag */ Put3Int(ISEC2_LastLat); Put3Int(ISEC2_LastLon); - unsigned lonIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LonIncr; - unsigned latIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LatIncr; + const unsigned lonIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LonIncr; + const unsigned latIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LatIncr; Put2Byte(lonIncr); /* 23-24 i - direction increment */ if ( ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN ) Put2Byte(ISEC2_NumPar); /* 25-26 Latitudes Pole->Equator */ @@ -12665,12 +12662,12 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4, Message("Missing value = NaN is unsupported!"); } - long bitmapSize = ISEC4_NumValues; - long imaskSize = ((bitmapSize+7)>>3)<<3; + const long bitmapSize = ISEC4_NumValues; + const long imaskSize = ((bitmapSize+7)>>3)<<3; GRIBPACK *bitmap = &lGrib[z+6]; long fsec4size = 0; -#if defined (VECTORCODE) +#ifdef VECTORCODE unsigned int *imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int)); memset(imask, 0, imaskSize*sizeof(int)); @@ -12723,8 +12720,8 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4, } #endif - long bmsLen = imaskSize/8 + 6; - long bmsUnusedBits = imaskSize - bitmapSize; + const long bmsLen = imaskSize/8 + 6; + const long bmsUnusedBits = imaskSize - bitmapSize; Put3Byte(bmsLen); /* 0- 2 Length of Block 3 Byte 0 */ Put1Byte(bmsUnusedBits); @@ -12780,8 +12777,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise /* Complex packing supported for spherical harmonics. */ - bool lcomplex = ( lspherc && ( isec4[3] == 64 ) ) || - ( lspherc && isec2 && ( isec2[5] == 2 ) ); + const bool lcomplex = ( lspherc && ( isec4[3] == 64 ) ) || + ( lspherc && isec2 && ( isec2[5] == 2 ) ); /* Check input specification is consistent */ @@ -12814,7 +12811,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise if ( decscale ) { - T scale = (T) pow(10.0, (double) decscale); + const T scale = (T) pow(10.0, (double) decscale); for ( long i = 0; i < datasize; ++i ) data[i] *= scale; } @@ -12822,8 +12819,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise { if ( lcomplex ) { - int jup = isubset; - int ioff = (jup+1)*(jup+2); + const int jup = isubset; + const int ioff = (jup+1)*(jup+2); bds_ext = 4 + 3 + 4*ioff; PackStart = ioff; Flag = 192; @@ -12842,9 +12839,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise if ( lspherc && lcomplex ) { - int pcStart, pcScale; - pcStart = isubset; - pcScale = isec4[16]; + const int pcStart = isubset; + const int pcScale = isec4[16]; TEMPLATE(scale_complex,T)(data, pcStart, pcScale, itrunc, 0); TEMPLATE(gather_complex,T)(data, (size_t)pcStart, (size_t)itrunc, (size_t)datasize); } @@ -12854,40 +12850,39 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise TEMPLATE(minmax_val,T)(data+PackStart, datasize-PackStart, &fmin, &fmax); double zref = (double)fmin; - + if (!(zref < DBL_MAX && zref > -DBL_MAX)) + { + gprintf(__func__, "Minimum value out of range: %g!", zref); + return (707); + } if ( CGRIBEX_Const && !lspherc ) { if ( IS_EQUAL(fmin, fmax) ) nbpv = 0; } - long blockLength = (*datstart) + (nbpv*(datasize - PackStart) + 7)/8; blockLength += blockLength & 1; - long unused_bits = blockLength*8 - (*datstart)*8 - nbpv*(datasize - PackStart); + const long unused_bits = blockLength*8 - (*datstart)*8 - nbpv*(datasize - PackStart); Flag += unused_bits; /* - Adjust number of bits per value if full integer length to - avoid hitting most significant bit (sign bit). + Adjust number of bits per value if full integer length to avoid hitting most significant bit (sign bit). */ /* if( nbpv == ibits ) nbpv = nbpv - 1; */ /* - Calculate the binary scaling factor to spread the range of - values over the number of bits per value. - Limit scaling to 2**-126 to 2**127 (using IEEE 32-bit floats - as a guideline). + Calculate the binary scaling factor to spread the range of values over the number of bits per value. + Limit scaling to 2**-126 to 2**127 (using IEEE 32-bit floatsas a guideline). */ - double range = fabs(fmax - fmin); + const double range = fabs(fmax - fmin); if ( fabs(fmin) < FLT_MIN ) fmin = 0; /* - Have to allow tolerance in comparisons on some platforms - (eg vpp700 and linux), such as 0.9999999999999999 = 1.0, - to avoid clipping ranges which are a power of 2. + Have to allow tolerance in comparisons on some platforms (eg vpp700 and linux), + such as 0.9999999999999999 = 1.0, to avoid clipping ranges which are a power of 2. */ if ( range <= jpepsln ) { @@ -12903,8 +12898,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise } else if ( range > 1.0 ) { - double rangec = range + jpepsln, - p2 = 2.0; + const double rangec = range + jpepsln; + double p2 = 2.0; int jloop = 1; while ( jloop < 128 && p2 <= rangec ) { @@ -12922,7 +12917,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise } else { - double rangec = range - jpepsln, p05 = 0.5; + const double rangec = range - jpepsln; + double p05 = 0.5; int jloop = 1; while ( jloop < 127 && p05 >= rangec ) { @@ -12941,7 +12937,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise } } - uint64_t max_nbpv_pow2 = (uint64_t) ((1ULL << nbpv) - 1); + const uint64_t max_nbpv_pow2 = (uint64_t) ((1ULL << nbpv) - 1); if ( binscale != 0 ) { @@ -12963,7 +12959,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise { if ( lcomplex ) { - int jup = isubset; + const int jup = isubset; int ioff = (int)z + bds_ext; if ( ioff > 0xFFFF ) ioff = 0; Put2Byte(ioff); @@ -13010,31 +13006,31 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int * unsigned char *CGrib = (unsigned char *) kgrib; - bool gdsIncluded = ISEC1_Sec2Or3Flag & 128; - bool bmsIncluded = ISEC1_Sec2Or3Flag & 64; + const bool gdsIncluded = ISEC1_Sec2Or3Flag & 128; + const bool bmsIncluded = ISEC1_Sec2Or3Flag & 64; // set max header len size_t len = 16384; // add data len - size_t numBytes = (size_t)((ISEC4_NumBits+7)>>3); + const size_t numBytes = (size_t)((ISEC4_NumBits+7)>>3); len += numBytes*(size_t)klenp; // add bitmap len if ( bmsIncluded ) len += (size_t)((klenp+7)>>3); -#if defined (VECTORCODE) +#ifdef VECTORCODE GRIBPACK *lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK)); if ( lGrib == NULL ) SysError("No Memory!"); #else GRIBPACK *lGrib = CGrib; #endif - long isLen = 8; + const long isLen = 8; encodeIS(lGrib, &gribLen); GRIBPACK *lpds = &lGrib[isLen]; - long pdsLen = getPdsLen(isec1); + const long pdsLen = getPdsLen(isec1); encodePDS(lpds, pdsLen, isec1); gribLen += pdsLen; @@ -13067,7 +13063,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int * fsec4size = ISEC4_NumValues; } - long bdsstart = gribLen; + const long bdsstart = gribLen; int status = TEMPLATE(encodeBDS,T)(lGrib, &gribLen, ISEC1_DecScaleFactor, isec2, isec4, fsec4size, fsec4, &datstart, &datsize, ISEC1_Parameter); if ( status ) @@ -13081,7 +13077,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int * if ( (size_t) gribLen > (size_t)kleng*sizeof(int) ) Error("kgrib buffer too small! kleng = %d gribLen = %d", kleng, gribLen); -#if defined (VECTORCODE) +#ifdef VECTORCODE if ( (size_t) gribLen > len ) Error("lGrib buffer too small! len = %d gribLen = %d", len, gribLen); @@ -13111,7 +13107,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.9.2"; +static const char grb_libvers[] = "1.9.3"; const char * cgribexLibraryVersion(void) {