From 0233d43d504a6a1f7040b54525cc8c68a488da40 Mon Sep 17 00:00:00 2001 From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de> Date: Tue, 9 Feb 2010 09:06:00 +0000 Subject: [PATCH] Version 1.4.2 --- ChangeLog | 4 + configure | 20 +- configure.ac | 2 +- src/cdi.inc | 45 +++- src/cdiFortran.c | 9 + src/cgribexlib.c | 615 +++++++++++++++++------------------------------ 6 files changed, 280 insertions(+), 415 deletions(-) diff --git a/ChangeLog b/ChangeLog index 473491e1a..c1b91e6af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-02-08 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> + + * Version 1.4.2 released + 2010-01-25 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> * added support for timerange 1,2,3,4,5 (GRIB1) diff --git a/configure b/configure index dd9ec4d6b..0d8618017 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for cdi 1.4.1.6. +# Generated by GNU Autoconf 2.61 for cdi 1.4.2. # # Report bugs to <Uwe.Schulzweida@zmaw.de>. # @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='cdi' PACKAGE_TARNAME='cdi' -PACKAGE_VERSION='1.4.1.6' -PACKAGE_STRING='cdi 1.4.1.6' +PACKAGE_VERSION='1.4.2' +PACKAGE_STRING='cdi 1.4.2' PACKAGE_BUGREPORT='Uwe.Schulzweida@zmaw.de' # Factoring default headers for most tests. @@ -1258,7 +1258,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures cdi 1.4.1.6 to adapt to many kinds of systems. +\`configure' configures cdi 1.4.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1329,7 +1329,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of cdi 1.4.1.6:";; + short | recursive ) echo "Configuration of cdi 1.4.2:";; esac cat <<\_ACEOF @@ -1462,7 +1462,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -cdi configure 1.4.1.6 +cdi configure 1.4.2 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1476,7 +1476,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by cdi $as_me 1.4.1.6, which was +It was created by cdi $as_me 1.4.2, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2303,7 +2303,7 @@ fi # Define the identity of the package. PACKAGE='cdi' - VERSION='1.4.1.6' + VERSION='1.4.2' cat >>confdefs.h <<_ACEOF @@ -9031,7 +9031,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by cdi $as_me 1.4.1.6, which was +This file was extended by cdi $as_me 1.4.2, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -9084,7 +9084,7 @@ Report bugs to <bug-autoconf@gnu.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -cdi config.status 1.4.1.6 +cdi config.status 1.4.2 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index 1e9b7dde7..4e786c532 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script. -AC_INIT(cdi, 1.4.1.6, Uwe.Schulzweida@zmaw.de) +AC_INIT(cdi, 1.4.2, Uwe.Schulzweida@zmaw.de) echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}" diff --git a/src/cdi.inc b/src/cdi.inc index b15a6a26d..611cc1704 100644 --- a/src/cdi.inc +++ b/src/cdi.inc @@ -4,15 +4,13 @@ ! ! Author: ! ------- -! Uwe Schulzweida, MPI-MET, Hamburg, January 2010 +! Uwe Schulzweida, MPI-MET, Hamburg, February 2010 ! INTEGER CDI_UNDEFID PARAMETER (CDI_UNDEFID = -1) INTEGER CDI_GLOBAL PARAMETER (CDI_GLOBAL = -1) - INTEGER CDI_UNDEFPARAM - PARAMETER (CDI_UNDEFPARAM = 2147483647) ! ! Byte order ! @@ -269,6 +267,27 @@ INTEGER TUNIT_QUARTER PARAMETER (TUNIT_QUARTER = 7) ! +! TSTEP types +! + INTEGER TSTEP_INSTANT + PARAMETER (TSTEP_INSTANT = 1) + INTEGER TSTEP_AVG + PARAMETER (TSTEP_AVG = 2) + INTEGER TSTEP_ACCUM + PARAMETER (TSTEP_ACCUM = 3) + INTEGER TSTEP_MAX + PARAMETER (TSTEP_MAX = 4) + INTEGER TSTEP_MIN + PARAMETER (TSTEP_MIN = 5) + INTEGER TSTEP_DIFF + PARAMETER (TSTEP_DIFF = 6) + INTEGER TSTEP_RANGE + PARAMETER (TSTEP_RANGE = 7) + INTEGER TSTEP_INSTANT2 + PARAMETER (TSTEP_INSTANT2 = 8) + INTEGER TSTEP_INSTANT3 + PARAMETER (TSTEP_INSTANT3 = 9) +! ! CALENDAR types ! INTEGER CALENDAR_STANDARD @@ -315,6 +334,15 @@ ! ! CDI converter routines ! +! +! parameter +! +! cdiParamToString +! (INTEGER param, +! CHARACTER*(*) paramstr, +! INTEGER maxlen) + EXTERNAL cdiParamToString + ! cdiDecodeParam ! (INTEGER param, ! INTEGER pnum, @@ -879,6 +907,17 @@ ! INTEGER varID) EXTERNAL vlistInqVarAddoffset +! vlistDefVarTsteptype +! (INTEGER vlistID, +! INTEGER varID, +! INTEGER tsteptype) + EXTERNAL vlistDefVarTsteptype + + INTEGER vlistInqVarTsteptype +! (INTEGER vlistID, +! INTEGER varID) + EXTERNAL vlistInqVarTsteptype + ! vlistDefVarTimave ! (INTEGER vlistID, ! INTEGER varID, diff --git a/src/cdiFortran.c b/src/cdiFortran.c index 34e60caf5..39b1f406e 100644 --- a/src/cdiFortran.c +++ b/src/cdiFortran.c @@ -46,6 +46,9 @@ /* TUNIT types */ +/* TSTEP types */ + + /* CALENDAR types */ @@ -61,6 +64,10 @@ FCALLSCSUB2 (cdiDefGlobal, CDIDEFGLOBAL, cdidefglobal, STRING, INT) /* CDI converter routines */ + +/* parameter */ + +FCALLSCSUB3 (cdiParamToString, CDIPARAMTOSTRING, cdiparamtostring, INT, PSTRING, INT) FCALLSCSUB4 (cdiDecodeParam, CDIDECODEPARAM, cdidecodeparam, INT, PINT, PINT, PINT) FCALLSCFUN3 (INT, cdiEncodeParam, CDIENCODEPARAM, cdiencodeparam, INT, INT, INT) FCALLSCSUB4 (cdiDecodeDate, CDIDECODEDATE, cdidecodedate, INT, PINT, PINT, PINT) @@ -181,6 +188,8 @@ FCALLSCSUB3 (vlistDefVarScalefactor, VLISTDEFVARSCALEFACTOR, vlistdefvarscalefac FCALLSCFUN2 (DOUBLE, vlistInqVarScalefactor, VLISTINQVARSCALEFACTOR, vlistinqvarscalefactor, INT, INT) FCALLSCSUB3 (vlistDefVarAddoffset, VLISTDEFVARADDOFFSET, vlistdefvaraddoffset, INT, INT, DOUBLE) FCALLSCFUN2 (DOUBLE, vlistInqVarAddoffset, VLISTINQVARADDOFFSET, vlistinqvaraddoffset, INT, INT) +FCALLSCSUB3 (vlistDefVarTsteptype, VLISTDEFVARTSTEPTYPE, vlistdefvartsteptype, INT, INT, INT) +FCALLSCFUN2 (INT, vlistInqVarTsteptype, VLISTINQVARTSTEPTYPE, vlistinqvartsteptype, INT, INT) FCALLSCSUB3 (vlistDefVarTimave, VLISTDEFVARTIMAVE, vlistdefvartimave, INT, INT, INT) FCALLSCFUN2 (INT, vlistInqVarTimave, VLISTINQVARTIMAVE, vlistinqvartimave, INT, INT) FCALLSCSUB3 (vlistDefVarTimaccu, VLISTDEFVARTIMACCU, vlistdefvartimaccu, INT, INT, INT) diff --git a/src/cgribexlib.c b/src/cgribexlib.c index 54dbdd02e..9dc295467 100644 --- a/src/cgribexlib.c +++ b/src/cgribexlib.c @@ -1,5 +1,5 @@ -/* Automatically generated by m214003 at 2010-01-18, do not edit */ +/* Automatically generated by m214003 at 2010-02-08, do not edit */ /* CGRIBEXLIB_VERSION="1.4.2" */ @@ -232,8 +232,8 @@ void gribDecode(int *isec0, int *isec1, int *isec2, double *fsec2, int *isec3, #define GDS_Len ((gds) == NULL ? 0 : GET_UINT3(gds[ 0], gds[ 1], gds[ 2])) #define GDS_NV GET_UINT1(gds[ 3]) #define GDS_PVPL GET_UINT1(gds[ 4]) -#define GDS_PV ((gds[3] == 0) ? -1 : (int) gds[4] - 1) -#define GDS_PL ((gds[4] == 255) ? -1 : (int) gds[3] * 4 + (int) gds[4] - 1) +#define GDS_PV ((gds[3] == 0) ? -1 : (int) gds[4] - 1) +#define GDS_PL ((gds[4] == 0xFF) ? -1 : (int) gds[3] * 4 + (int) gds[4] - 1) #define GDS_GridType GET_UINT1(gds[ 5]) @@ -992,7 +992,6 @@ LABEL900: - int gribRefDate(int *isec1) { int date, ryear, rmonth, rday; @@ -2765,14 +2764,6 @@ void gribPrintSec4Wave(int *isec4) } -#define COMP_Z 1 -#define COMP_JASPER 3 - -/* #define COMPRESS COMP_Z */ - -/* #define HAVE_LIBZ 1 */ -/* #define HAVE_LIBJASPER 1 */ - int BitsPerInt = (int) (sizeof(int) * 8); @@ -3117,7 +3108,7 @@ void encodeGDS(GRIBPACK *lGrib, long *gribLen, int *isec2, double *fsec2) int exponent, mantissa; long i; int ival; - int pvoffset = 255; + int pvoffset = 0xFF; int gdslen = 32; unsigned lonIncr, latIncr; @@ -3183,7 +3174,7 @@ void encodeGDS(GRIBPACK *lGrib, long *gribLen, int *isec2, double *fsec2) { int numlon; if ( ISEC2_Reduced ) - numlon = 65535; + numlon = 0xFFFF; else numlon = ISEC2_NumLon; @@ -3197,8 +3188,8 @@ void encodeGDS(GRIBPACK *lGrib, long *gribLen, int *isec2, double *fsec2) Put3Int(ISEC2_LastLon); if ( ISEC2_ResFlag == 0 ) { - lonIncr = 65535; - latIncr = 65535; + lonIncr = 0xFFFF; + latIncr = 0xFFFF; } else { @@ -3361,7 +3352,7 @@ void encode_double_array_common(int NumBits, long PackStart, long datasize, GRIB if ( cbits == 8 ) { jbits -= 8; - lGrib[z++] = (ipval >> jbits) & 255; + lGrib[z++] = (ipval >> jbits) & 0xFF; } else { @@ -3487,7 +3478,7 @@ void encode_double_array(int NumBits, long PackStart, long datasize, GRIBPACK *l } else { - Error(func, "Unimplemented packing factor %d", NumBits); + Error(func, "Unimplemented packing factor %d!", NumBits); } *gz = z; @@ -3776,179 +3767,6 @@ void gribEncode(int *isec0, int *isec1, int *isec2, double *fsec2, int *isec3, (void) PACK_GRIB(lGrib, (unsigned char *)CGrib, gribLen, -1L); #endif -#if COMPRESS == COMP_Z -# if defined (HAVE_LIBZ) - { -# include <zlib.h> - int status; - int level = 6; - Bytef *dest, *source; - uLongf destLen, sourceLen; - /* z_stream strm; */ - - destLen = len; - sourceLen = datsize; - dest = (char *) lGrib; - source = CGrib + datstart; - - /* deflateInit2 (&strm, 6, Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY); */ - /* Perform compression from the source to the destination buffer */ - status = compress2(dest, &destLen, source, sourceLen, level); - /* fprintf(stderr, "compress %ld %ld\n", (long) sourceLen, (long) destLen); */ - - /* Check for various zlib errors */ - if (Z_BUF_ERROR==status) - Warning(func, "overflow"); - else if (Z_MEM_ERROR==status) - Warning(func, "deflate memory error"); - else if (Z_OK!=status) - Warning(func, "other deflate error"); - - if ( destLen < datsize ) - { - long zz; - memcpy(CGrib + datstart, dest, destLen); - gribLen = datstart + destLen; - destLen += (bdsend - bdsstart - datsize); - CGrib[bdsstart ] = 255 & (destLen >> 16); - CGrib[bdsstart+1] = 255 & (destLen >> 8); - CGrib[bdsstart+2] = 255 & (destLen); - - CGrib[gribLen++] = 0; - CGrib[gribLen++] = '7'; - CGrib[gribLen++] = '7'; - CGrib[gribLen++] = '7'; - CGrib[gribLen++] = '7'; - - CGrib[4] = 255 & (gribLen >> 16); - CGrib[5] = 255 & (gribLen >> 8); - CGrib[6] = 255 & (gribLen); - - zz = gribLen; - while ( zz & 7 ) CGrib[zz++] = 0; - } - } -# else - { - static int libzwarn = 1; - if ( libzwarn ) - { - Warning(func, "Compression disabled, zlib not available!"); - libzwarn = 0; - } - } -# endif -#elif COMPRESS == COMP_JASPER -# if defined (HAVE_LIBJASPER) - { -# include <jasper/jasper.h> - int status; - char *dest, *source; - size_t destLen, sourceLen; - int width, height, nbits; - int ier,rwcnt; - jas_image_t image; - jas_stream_t *jpcstream,*istream; - jas_image_cmpt_t cmpt,*pcmpt; -#define MAXOPTSSIZE 1024 - char opts[MAXOPTSSIZE]; - - opts[0]=(char)0; /* lossless compression !*/ - - destLen = len; - sourceLen = datsize; - dest = (char *) lGrib; - source = CGrib + datstart; - - width = fsec4size/8; - height = 8; - nbits = ISEC4_NumBits; - - /* Initialize the JasPer image structure describing the grayscale */ - /* image to encode into the JPEG2000 code stream.*/ - - image.tlx_=0; - image.tly_=0; - - image.brx_=(jas_image_coord_t)width; - image.bry_=(jas_image_coord_t)height; - - image.numcmpts_=1; - image.maxcmpts_=1; - - image.clrspc_=JAS_CLRSPC_SGRAY; /* grayscale Image */ - image.cmprof_=0; - - image.inmem_=1; - - cmpt.tlx_=0; - cmpt.tly_=0; - cmpt.hstep_=1; - cmpt.vstep_=1; - - cmpt.width_=(jas_image_coord_t)width; - cmpt.height_=(jas_image_coord_t)height; - cmpt.type_=JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y); - - cmpt.prec_=nbits; - cmpt.sgnd_=0; - cmpt.cps_=(nbits+7)/8; - - pcmpt=&cmpt; - image.cmpts_=&pcmpt; - - /* Open a JasPer stream containing the input grayscale values */ - - istream=jas_stream_memopen(source, height*width*cmpt.cps_); - cmpt.stream_=istream; - - /* Open an output stream that will contain the encoded jpeg2000 */ - /* code stream. */ - - jpcstream=jas_stream_memopen(dest, destLen); - - /* Encode image. */ - - status=jpc_encode(&image, jpcstream, opts); - if ( status != 0 ) - Warning(func, "jasper error: %d", status); - - /* Clean up JasPer work structures. */ - - destLen=jpcstream->rwcnt_; - ier=jas_stream_close(istream); - ier=jas_stream_close(jpcstream); - - /* - fprintf(stderr, "%3d %3d %5d %2d in: %5d out: %5d\n", ISEC1_Parameter, ISEC1_Level1, fsec4size, ISEC4_NumBits, sourceLen, destLen); - */ - if ( destLen < datsize ) - { - long zz; - memcpy(CGrib + datstart, dest, destLen); - gribLen = datstart + destLen; - destLen += (bdsend - bdsstart - datsize); - CGrib[bdsstart ] = 255 & (destLen >> 16); - CGrib[bdsstart+1] = 255 & (destLen >> 8); - CGrib[bdsstart+2] = 255 & (destLen); - - CGrib[gribLen++] = 0; - CGrib[gribLen++] = '7'; - CGrib[gribLen++] = '7'; - CGrib[gribLen++] = '7'; - CGrib[gribLen++] = '7'; - - CGrib[4] = 255 & (gribLen >> 16); - CGrib[5] = 255 & (gribLen >> 8); - CGrib[6] = 255 & (gribLen); - - zz = gribLen; - while ( zz & 7 ) CGrib[zz++] = 0; - } - } -#endif -#endif - #if defined (VECTORCODE) free(lGrib); #endif @@ -4259,9 +4077,9 @@ int decodeGDS(unsigned char *gds, int *isec0, int *isec2, double *fsec2, int df gdsLen = GDS_Len; ipvpl = GDS_PVPL; - if ( ipvpl == 0 ) ipvpl = 255; + if ( ipvpl == 0 ) ipvpl = 0xFF; - if ( ipvpl != 255 ) + if ( ipvpl != 0xFF ) { /* Either vct or reduced grid */ if ( GDS_NV != 0 ) { /* we have vct */ @@ -4606,7 +4424,7 @@ int decodeBDS(int decscale, unsigned char *bds, int *isec2, int *isec4, long i; int bds_flag, bds_rep, jscale, imiss; int bds_ubits; - int ioff; + int ioff = 0; int iexp, imant; int pcStart, pcScale; int zoff; @@ -4679,7 +4497,7 @@ int decodeBDS(int decscale, unsigned char *bds, int *isec2, int *isec4, iexp = bds[ 6]; imant = GET_UINT3(bds[ 7], bds[ 8], bds[ 9]); - imiss = (jscale == 65535 && iexp == 255 && imant == 16777215); + imiss = (jscale == 0xFFFF && iexp == 0xFF && imant == 0xFFFFFF); /* convert reference value and scale factor. */ @@ -4705,84 +4523,82 @@ int decodeBDS(int decscale, unsigned char *bds, int *isec2, int *isec4, /* if data is in spherical harmonic form, distinguish */ /* between simple/complex packing (cplx = 0/1) */ - if ( bds_rep == 1 && cplx == 0 ) + if ( bds_rep == 1 ) { - /* no unpacked binary data present */ - - jup = kup = mup = 0; - - /* octet number of start of packed data */ - /* calculated from start of block 4 - 1 */ + if ( cplx == 0 ) + { + /* no unpacked binary data present */ - locnd = zoff + 15; + jup = kup = mup = 0; - /* get real (0,0) coefficient in grib format and */ - /* convert to floating point. */ + /* octet number of start of packed data */ + /* calculated from start of block 4 - 1 */ - if ( dfunc != 'J' ) - { - if ( imiss ) *fpdata++ = 0.0; - else *fpdata++ = BDS_RealCoef; - } - } + locnd = zoff + 15; - ioff = bds_rep; + /* get real (0,0) coefficient in grib format and */ + /* convert to floating point. */ - if ( bds_rep == 1 && cplx == 1 ) - { - /* scaling factor */ - isec4[16] = BDS_Power; + if ( dfunc != 'J' ) + { + if ( imiss ) *fpdata++ = 0.0; + else *fpdata++ = BDS_RealCoef; + } - /* pentagonal resolution parameters of the */ - /* unpacked section of data field */ + ioff = bds_rep; + } + else /* complex packed spherical harmonics */ + { + /* scaling factor */ + isec4[16] = BDS_Power; - jup = bds[zoff+15]; - kup = bds[zoff+16]; - mup = bds[zoff+17]; + /* pentagonal resolution parameters of the */ + /* unpacked section of data field */ - isec4[zoff+17] = jup; - isec4[zoff+18] = kup; - isec4[zoff+19] = mup; + jup = bds[zoff+15]; + kup = bds[zoff+16]; + mup = bds[zoff+17]; - /* unpacked binary data */ + isec4[zoff+17] = jup; + isec4[zoff+18] = kup; + isec4[zoff+19] = mup; - locnd = zoff + 18; + /* unpacked binary data */ - if ( dfunc != 'J' ) - for (i = 0; i < ((jup+1)*(jup+2)); i++) - { - iexp = (bds[locnd+4*i ]); - imant =((bds[locnd+4*i+1]) << 16) + - ((bds[locnd+4*i+2]) << 8) + - (bds[locnd+4*i+3]); + locnd = zoff + 18; - if ( imiss ) *fpdata++ = 0.0; - else *fpdata++ = decfp2(iexp,imant); - } + if ( dfunc != 'J' ) + for (i = 0; i < ((jup+1)*(jup+2)); i++) + { + iexp = (bds[locnd+4*i ]); + imant =((bds[locnd+4*i+1]) << 16) + + ((bds[locnd+4*i+2]) << 8) + + (bds[locnd+4*i+3]); - locnd = zoff + 18 + 4*(jup+1)*(jup+2); - ioff = (jup+1)*(jup+2); + if ( imiss ) *fpdata++ = 0.0; + else *fpdata++ = decfp2(iexp,imant); + } + + locnd = zoff + 18 + 4*(jup+1)*(jup+2); + ioff = (jup+1)*(jup+2); + } } - /* Decode data values to floating point and store in fsec4. */ - /* first calculate the number of data values. */ + /* Decode data values to floating point and store in fsec4. */ + /* First calculate the number of data values. */ /* Take into account that spherical harmonics can be packed */ /* simple (cplx = 0) or complex (cplx = 1) */ jlend = bdsLen - locnd; if ( ISEC4_NumBits == 0 ) { - if ( jlend > 1 ) - Error(func, "Number of bits per data value = 0"); + if ( jlend > 1 ) Error(func, "Number of bits per data value = 0"); jlend = ISEC2_NumLon*ISEC2_NumLat; } else { - if ( jlend > 0x10000000 ) /* 2GB/8 */ - jlend = (jlend*8. - bds_ubits) / ISEC4_NumBits; - else - jlend = (jlend*8 - bds_ubits) / ISEC4_NumBits; + jlend = (jlend*8 - bds_ubits) / ISEC4_NumBits; } @@ -4792,13 +4608,7 @@ int decodeBDS(int decscale, unsigned char *bds, int *isec2, int *isec4, if ( bds_aflag ) { size_t len; - /* - if ( bds_rep == 0 ) - ISEC4_NumValues = ISEC2_NumLon*ISEC2_NumLat; - else - ISEC4_NumValues = (ISEC2_PentaJ+1)*(ISEC2_PentaJ+2); - */ - /* ISEC4_NumValues = GET_UINT3(bds[17],bds[18],bds[19])*8/ISEC4_NumBits;*/ + if ( gribrec_len(bds[14], bds[15], bds[16]) > JP23SET ) len = ((size_t) ((bds[17]<<24)+(bds[18]<<16)+(bds[19]<<8)+bds[20])); else @@ -5718,24 +5528,24 @@ void scaleComplex(double *fpdata, int pcStart, int pcScale, int truncation) index = 0; - for (m = 0; m < pcStart; m++) - for (n = m; n <= truncation; n++) - { - if ( n >= pcStart ) - { - fpdata[index ] *= scale[n]; - fpdata[index+1] *= scale[n]; - } - index += 2; - } + for ( m = 0; m < pcStart; m++ ) + for ( n = m; n <= truncation; n++ ) + { + if ( n >= pcStart ) + { + fpdata[index ] *= scale[n]; + fpdata[index+1] *= scale[n]; + } + index += 2; + } - for (m = pcStart; m <= truncation; m++) - for (n = m; n <= truncation; n++) - { - fpdata[index ] *= scale[n]; - fpdata[index+1] *= scale[n]; - index += 2; - } + for ( m = pcStart; m <= truncation; m++ ) + for ( n = m; n <= truncation; n++ ) + { + fpdata[index ] *= scale[n]; + fpdata[index+1] *= scale[n]; + index += 2; + } free(scale); } @@ -5755,28 +5565,30 @@ void scatterComplex(double *fpdata, int pcStart, int truncation, int dimSP) index = inext = 0; - for (m = 0; m <= pcStart; m++) - for (n = m; n <= truncation; n++) - { - if ( pcStart >= n ) - { - fphelp[index ] = fpdata[inext++]; - fphelp[index+1] = fpdata[inext++]; - } - index += 2; - } + for ( m = 0; m <= pcStart; m++ ) + for ( n = m; n <= truncation; n++ ) + { + if ( pcStart >= n ) + { + fphelp[index ] = fpdata[inext++]; + fphelp[index+1] = fpdata[inext++]; + } + index += 2; + } + index = 0; - for (m = 0; m <= truncation; m++) - for (n = m; n <= truncation; n++) - { - if ( n > pcStart ) - { - fphelp[index ] = fpdata[inext++]; - fphelp[index+1] = fpdata[inext++]; - } - index += 2; - } - for (m = 0; m < dimSP; m++) fpdata[m] = fphelp[m]; + for ( m = 0; m <= truncation; m++ ) + for ( n = m; n <= truncation; n++ ) + { + if ( n > pcStart ) + { + fphelp[index ] = fpdata[inext++]; + fphelp[index+1] = fpdata[inext++]; + } + index += 2; + } + + for ( m = 0; m < dimSP; m++ ) fpdata[m] = fphelp[m]; free(fphelp); } @@ -6904,14 +6716,14 @@ long packInt64(unsigned INT64 *up, unsigned char *cp, long bc, long tc) #endif for ( i = 0 ; i < inner ; i++ ) { - upi = ( ip0[j] << 56 ) - | ( ( ip1[j] & 255 ) << 48 ) - | ( ( ip2[j] & 255 ) << 40 ) - | ( ( ip3[j] & 255 ) << 32 ) - | ( ( ip4[j] & 255 ) << 24 ) ; - up0[i] = upi | ( ( ip5[j] & 255 ) << 16 ) - | ( ( ip6[j] & 255 ) << 8 ) - | ( ip7[j] & 255 ) ; + upi = ( ip0[j] << 56 ) + | ( ( ip1[j] & 0xFF ) << 48 ) + | ( ( ip2[j] & 0xFF ) << 40 ) + | ( ( ip3[j] & 0xFF ) << 32 ) + | ( ( ip4[j] & 0xFF ) << 24 ) ; + up0[i] = upi | ( ( ip5[j] & 0xFF ) << 16 ) + | ( ( ip6[j] & 0xFF ) << 8 ) + | ( ip7[j] & 0xFF ) ; j += ipack; } } @@ -6919,14 +6731,14 @@ long packInt64(unsigned INT64 *up, unsigned char *cp, long bc, long tc) { for ( i = 0 ; i < inner ; i++ ) { - upi = ( ip7[j] << 56 ) - | ( ( ip6[j] & 255 ) << 48 ) - | ( ( ip5[j] & 255 ) << 40 ) - | ( ( ip4[j] & 255 ) << 32 ) - | ( ( ip3[j] & 255 ) << 24 ) ; - up0[i] = upi | ( ( ip2[j] & 255 ) << 16 ) - | ( ( ip1[j] & 255 ) << 8 ) - | ( ip0[j] & 255 ) ; + upi = ( ip7[j] << 56 ) + | ( ( ip6[j] & 0xFF ) << 48 ) + | ( ( ip5[j] & 0xFF ) << 40 ) + | ( ( ip4[j] & 0xFF ) << 32 ) + | ( ( ip3[j] & 0xFF ) << 24 ) ; + up0[i] = upi | ( ( ip2[j] & 0xFF ) << 16 ) + | ( ( ip1[j] & 0xFF ) << 8 ) + | ( ip0[j] & 0xFF ) ; j += ipack; } } @@ -7012,14 +6824,14 @@ long unpackInt64(unsigned char *cp, unsigned INT64 *up, long bc, long tc) #endif for ( i = 0 ; i < inner ; i++ ) { - ip0[j] = (up0[i] >> 56) & 255; - ip1[j] = (up0[i] >> 48) & 255; - ip2[j] = (up0[i] >> 40) & 255; - ip3[j] = (up0[i] >> 32) & 255; - ip4[j] = (up0[i] >> 24) & 255; - ip5[j] = (up0[i] >> 16) & 255; - ip6[j] = (up0[i] >> 8) & 255; - ip7[j] = (up0[i]) & 255; + ip0[j] = (up0[i] >> 56) & 0xFF; + ip1[j] = (up0[i] >> 48) & 0xFF; + ip2[j] = (up0[i] >> 40) & 0xFF; + ip3[j] = (up0[i] >> 32) & 0xFF; + ip4[j] = (up0[i] >> 24) & 0xFF; + ip5[j] = (up0[i] >> 16) & 0xFF; + ip6[j] = (up0[i] >> 8) & 0xFF; + ip7[j] = (up0[i]) & 0xFF; j += ipack; } @@ -7028,14 +6840,14 @@ long unpackInt64(unsigned char *cp, unsigned INT64 *up, long bc, long tc) { for ( i = 0 ; i < inner ; i++ ) { - ip7[j] = (up0[i] >> 56) & 255; - ip6[j] = (up0[i] >> 48) & 255; - ip5[j] = (up0[i] >> 40) & 255; - ip4[j] = (up0[i] >> 32) & 255; - ip3[j] = (up0[i] >> 24) & 255; - ip2[j] = (up0[i] >> 16) & 255; - ip1[j] = (up0[i] >> 8) & 255; - ip0[j] = (up0[i]) & 255; + ip7[j] = (up0[i] >> 56) & 0xFF; + ip6[j] = (up0[i] >> 48) & 0xFF; + ip5[j] = (up0[i] >> 40) & 0xFF; + ip4[j] = (up0[i] >> 32) & 0xFF; + ip3[j] = (up0[i] >> 24) & 0xFF; + ip2[j] = (up0[i] >> 16) & 0xFF; + ip1[j] = (up0[i] >> 8) & 0xFF; + ip0[j] = (up0[i]) & 0xFF; j += ipack; } @@ -7112,10 +6924,10 @@ long packInt32(unsigned INT32 *up, unsigned char *cp, long bc, long tc) #endif for ( i = 0 ; i < inner ; i++ ) { - up0[i] = ( ip0[j] << 24 ) - | ( ( ip1[j] & 255 ) << 16 ) - | ( ( ip2[j] & 255 ) << 8 ) - | ( ip3[j] & 255 ) ; + up0[i] = ( ip0[j] << 24 ) + | ( ( ip1[j] & 0xFF ) << 16 ) + | ( ( ip2[j] & 0xFF ) << 8 ) + | ( ip3[j] & 0xFF ) ; j += ipack; } } @@ -7123,10 +6935,10 @@ long packInt32(unsigned INT32 *up, unsigned char *cp, long bc, long tc) { for ( i = 0 ; i < inner ; i++ ) { - up0[i] = ( ip3[j] << 24 ) - | ( ( ip2[j] & 255 ) << 16 ) - | ( ( ip1[j] & 255 ) << 8 ) - | ( ip0[j] & 255 ) ; + up0[i] = ( ip3[j] << 24 ) + | ( ( ip2[j] & 0xFF ) << 16 ) + | ( ( ip1[j] & 0xFF ) << 8 ) + | ( ip0[j] & 0xFF ) ; j += ipack; } } @@ -7210,10 +7022,10 @@ long unpackInt32(unsigned char *cp, unsigned INT32 *up, long bc, long tc) #endif for ( i = 0 ; i < inner ; i++ ) { - ip0[j] = (up0[i] >> 24) & 255; - ip1[j] = (up0[i] >> 16) & 255; - ip2[j] = (up0[i] >> 8) & 255; - ip3[j] = (up0[i]) & 255; + ip0[j] = (up0[i] >> 24) & 0xFF; + ip1[j] = (up0[i] >> 16) & 0xFF; + ip2[j] = (up0[i] >> 8) & 0xFF; + ip3[j] = (up0[i]) & 0xFF; j += ipack; } @@ -7222,10 +7034,10 @@ long unpackInt32(unsigned char *cp, unsigned INT32 *up, long bc, long tc) { for ( i = 0 ; i < inner ; i++ ) { - ip3[j] = (up0[i] >> 24) & 255; - ip2[j] = (up0[i] >> 16) & 255; - ip1[j] = (up0[i] >> 8) & 255; - ip0[j] = (up0[i]) & 255; + ip3[j] = (up0[i] >> 24) & 0xFF; + ip2[j] = (up0[i] >> 16) & 0xFF; + ip1[j] = (up0[i] >> 8) & 0xFF; + ip0[j] = (up0[i]) & 0xFF; j += ipack; } @@ -7243,6 +7055,7 @@ long unpackInt32(unsigned char *cp, unsigned INT32 *up, long bc, long tc) *cp0 = (unsigned char) tc; } */ + return (bc); } #endif @@ -8501,17 +8314,17 @@ int gribBzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbuf fprintf(stderr, "z>>> %d %d %d %d <<<\n", (int) bds[0+datstart+12], (int)bds[1+datstart+12], (int)bds[2+datstart+12], (int)bds[3+datstart+12]); */ - bds[14] = 255 & (gribLenOld >> 16); - bds[15] = 255 & (gribLenOld >> 8); - bds[16] = 255 & (gribLenOld); + bds[14] = 0xFF & (gribLenOld >> 16); + bds[15] = 0xFF & (gribLenOld >> 8); + bds[16] = 0xFF & (gribLenOld); - bds[17] = 255 & (sourceLen >> 16); - bds[18] = 255 & (sourceLen >> 8); - bds[19] = 255 & (sourceLen); + bds[17] = 0xFF & (sourceLen >> 16); + bds[18] = 0xFF & (sourceLen >> 8); + bds[19] = 0xFF & (sourceLen); - bds[20] = 255 & (destLen >> 16); - bds[21] = 255 & (destLen >> 8); - bds[22] = 255 & (destLen); + bds[20] = 0xFF & (destLen >> 16); + bds[21] = 0xFF & (destLen >> 8); + bds[22] = 0xFF & (destLen); bdsLen = datstart + 12 + destLen; @@ -8526,9 +8339,9 @@ int gribBzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbuf bds[bdsLen++] = 0; } - bds[0] = 255 & (bdsLen >> 16); - bds[1] = 255 & (bdsLen >> 8); - bds[2] = 255 & (bdsLen); + bds[0] = 0xFF & (bdsLen >> 16); + bds[1] = 0xFF & (bdsLen >> 8); + bds[2] = 0xFF & (bdsLen); gribLen = (bds - dbuf) + bdsLen; @@ -8537,9 +8350,9 @@ int gribBzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbuf dbuf[gribLen++] = '7'; dbuf[gribLen++] = '7'; - dbuf[4] = 255 & (gribLen >> 16); - dbuf[5] = 255 & (gribLen >> 8); - dbuf[6] = 255 & (gribLen); + dbuf[4] = 0xFF & (gribLen >> 16); + dbuf[5] = 0xFF & (gribLen >> 8); + dbuf[6] = 0xFF & (gribLen); zz = gribLen; while ( zz & 7 ) dbuf[zz++] = 0; @@ -8809,33 +8622,33 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs } gribLenOld = gribLenOld / (-120); gribLenOld = JP23SET - gribLenOld + 1; - bds[14] = 255 & (gribLenOld >> 16); - bds[15] = 255 & (gribLenOld >> 8); - bds[16] = 255 & (gribLenOld); - - bds[17] = 255 & (sourceLen >> 24); - bds[18] = 255 & (sourceLen >> 16); - bds[19] = 255 & (sourceLen >> 8); - bds[20] = 255 & (sourceLen); - - bds[21] = 255 & (destLen >> 24); - bds[22] = 255 & (destLen >> 16); - bds[23] = 255 & (destLen >> 8); - bds[24] = 255 & (destLen); + bds[14] = 0xFF & (gribLenOld >> 16); + bds[15] = 0xFF & (gribLenOld >> 8); + bds[16] = 0xFF & (gribLenOld); + + bds[17] = 0xFF & (sourceLen >> 24); + bds[18] = 0xFF & (sourceLen >> 16); + bds[19] = 0xFF & (sourceLen >> 8); + bds[20] = 0xFF & (sourceLen); + + bds[21] = 0xFF & (destLen >> 24); + bds[22] = 0xFF & (destLen >> 16); + bds[23] = 0xFF & (destLen >> 8); + bds[24] = 0xFF & (destLen); } else { - bds[14] = 255 & (gribLenOld >> 16); - bds[15] = 255 & (gribLenOld >> 8); - bds[16] = 255 & (gribLenOld); + bds[14] = 0xFF & (gribLenOld >> 16); + bds[15] = 0xFF & (gribLenOld >> 8); + bds[16] = 0xFF & (gribLenOld); - bds[17] = 255 & (sourceLen >> 16); - bds[18] = 255 & (sourceLen >> 8); - bds[19] = 255 & (sourceLen); + bds[17] = 0xFF & (sourceLen >> 16); + bds[18] = 0xFF & (sourceLen >> 8); + bds[19] = 0xFF & (sourceLen); - bds[20] = 255 & (destLen >> 16); - bds[21] = 255 & (destLen >> 8); - bds[22] = 255 & (destLen); + bds[20] = 0xFF & (destLen >> 16); + bds[21] = 0xFF & (destLen >> 8); + bds[22] = 0xFF & (destLen); } bdsLen = datstart + bds_zoffset + destLen; @@ -8851,9 +8664,9 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs bds[bdsLen++] = 0; } - bds[0] = 255 & (bdsLen >> 16); - bds[1] = 255 & (bdsLen >> 8); - bds[2] = 255 & (bdsLen); + bds[0] = 0xFF & (bdsLen >> 16); + bds[1] = 0xFF & (bdsLen >> 8); + bds[2] = 0xFF & (bdsLen); gribLen = (bds - dbuf) + bdsLen; @@ -8880,21 +8693,21 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs itemp = gribLen / (-120); itemp = JP23SET - itemp + 1; - dbuf[4] = 255 & (itemp >> 16); - dbuf[5] = 255 & (itemp >> 8); - dbuf[6] = 255 & (itemp); + dbuf[4] = 0xFF & (itemp >> 16); + dbuf[5] = 0xFF & (itemp >> 8); + dbuf[6] = 0xFF & (itemp); bdslen = gribLen - bdslen; - bds[0] = 255 & (bdsLen >> 16); - bds[1] = 255 & (bdsLen >> 8); - bds[2] = 255 & (bdsLen); + bds[0] = 0xFF & (bdsLen >> 16); + bds[1] = 0xFF & (bdsLen >> 8); + bds[2] = 0xFF & (bdsLen); } else { - dbuf[4] = 255 & (gribLen >> 16); - dbuf[5] = 255 & (gribLen >> 8); - dbuf[6] = 255 & (gribLen); + dbuf[4] = 0xFF & (gribLen >> 16); + dbuf[5] = 0xFF & (gribLen >> 8); + dbuf[6] = 0xFF & (gribLen); } } /* @@ -9072,9 +8885,9 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu bds[bdsLen++] = 0; } - bds[0] = 255 & (bdsLen >> 16); - bds[1] = 255 & (bdsLen >> 8); - bds[2] = 255 & (bdsLen); + bds[0] = 0xFF & (bdsLen >> 16); + bds[1] = 0xFF & (bdsLen >> 8); + bds[2] = 0xFF & (bdsLen); gribLen = (bds - dbuf) + bdsLen; @@ -9103,21 +8916,21 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu itemp = gribLen / (-120); itemp = JP23SET - itemp + 1; - dbuf[4] = 255 & (itemp >> 16); - dbuf[5] = 255 & (itemp >> 8); - dbuf[6] = 255 & (itemp); + dbuf[4] = 0xFF & (itemp >> 16); + dbuf[5] = 0xFF & (itemp >> 8); + dbuf[6] = 0xFF & (itemp); bdsLen = gribLen - bdsLen; - bds[0] = 255 & (bdsLen >> 16); - bds[1] = 255 & (bdsLen >> 8); - bds[2] = 255 & (bdsLen); + bds[0] = 0xFF & (bdsLen >> 16); + bds[1] = 0xFF & (bdsLen >> 8); + bds[2] = 0xFF & (bdsLen); } else { - dbuf[4] = 255 & (recLen >> 16); - dbuf[5] = 255 & (recLen >> 8); - dbuf[6] = 255 & (recLen); + dbuf[4] = 0xFF & (recLen >> 16); + dbuf[5] = 0xFF & (recLen >> 8); + dbuf[6] = 0xFF & (recLen); } /* fprintf(stderr, "recLen, gribLen, bdsLen %d %d %d\n", recLen, gribLen, bdsLen); @@ -9137,7 +8950,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu return (gribLen); } -static const char grb_libvers[] = "1.4.2" " of ""Jan 18 2010"" ""15:34:52"; +static const char grb_libvers[] = "1.4.2" " of ""Feb 8 2010"" ""12:11:32"; const char * cgribexLibraryVersion(void) { -- GitLab