visad/src/main/java/ucar/nc2/iosp/gempak/GempakGridReader.java
private float[] unpackGrib1Data(int iiword, int nword, int kxky,
                                  int nbits, float ref, float scale,
                                  boolean miss, int decimalScale)
          throws IOException {
    //System.out.println("decimal scale = " + decimalScale);
    float[] values = new float[kxky];
    bitPos = 0;
    bitBuf = 0;
    next = 0;
    ch1 = 0;
    ch2 = 0;
    ch3 = 0;
    ch4 = 0;
    rf.seek(getOffset(iiword));
    int idat;
    // save a pow call if we can
    float scaleFactor = (decimalScale == 0)
            ? 1.f
            : (float) Math.pow(10.0, -decimalScale);
    //float scaleFactor = (float) Math.pow(10.0, -decimalScale);
    for (int i = 0; i < values.length; i++) {
      idat = bits2UInt(nbits);
      if (miss && (idat == IMISSD)) {
        values[i] = IMISSD;
      } else {
        values[i] = (ref + scale * idat) * scaleFactor;
      }
            /*
            if (i < 25) {
                System.out.println("values[" + i + "] = " + values[i]);
            }
            */
    }
    return values;
  }
private float[] unpackGrib1Data(int iiword, int nword, int kxky,
                                  int nbits, float ref, float scale,
                                  boolean miss, int decimalScale)
          throws IOException {
    //System.out.println("decimal scale = " + decimalScale);
    float[] values = new float[kxky];
    bitPos = 0;
    bitBuf = 0;
    next = 0;
    ch1 = 0;
    ch2 = 0;
    ch3 = 0;
    ch4 = 0;
    rf.seek(getOffset(iiword));
    int idat;
    // save a pow call if we can
    float scaleFactor = (decimalScale == 0)
            ? 1.f
            : (float) Math.pow(10.0, -decimalScale);
    //float scaleFactor = (float) Math.pow(10.0, -decimalScale);
    for (int i = 0; i < values.length; i++) {
      idat = bits2UInt(nbits);
      if (miss && (idat == IMISSD)) {
        values[i] = IMISSD;
      } else {
        values[i] = (ref + scale * idat) * scaleFactor;
      }
            /*
            if (i < 25) {
                System.out.println("values[" + i + "] = " + values[i]);
            }
            */
    }
    return values;
  }
private float [ ] unpackGrib1Data ( int iiword , int nword , int kxky , int nbits , float ref , float scale , boolean miss , int decimalScale ) throws IOException { //System.out.println("decimal scale = " + decimalScale); float [ ] values = new float [ kxky ] ; bitPos = 0 ; bitBuf = 0 ; next = 0 ; ch1 = 0 ; ch2 = 0 ; ch3 = 0 ; ch4 = 0 ; rf . seek ( getOffset ( iiword ) ) ; int idat ; // save a pow call if we can float scaleFactor = ( decimalScale == 0 ) ? 1.f : ( float ) Math . pow ( 10.0 , - decimalScale ) ; //float scaleFactor = (float) Math.pow(10.0, -decimalScale); for ( int i = 0 ; i < values . length ; i ++ ) { idat = bits2UInt ( nbits ) ; if ( miss && ( idat == IMISSD ) ) { values [ i ] = IMISSD ; } else { values [ i ] = ( ref + scale * idat ) * scaleFactor ; } /*
            if (i < 25) {
                System.out.println("values[" + i + "] = " + values[i]);
            }
            */ } return values ; }
Read packed Grib1 data using ucar.grib code

@param iiword       Starting word  (FORTRAN 1 based)
@param nword        number of words
@param kxky         size of grid (kx*ky)
@param nbits        number of bits per word
@param ref          reference value
@param scale        scale value
@param miss         replace missing
@param decimalScale scale of the values
@return unpacked data
@throws IOException problem reading file
Read packed Grib1 data using ucar . grib code