visad/src/main/java/ucar/nc2/iosp/gempak/GempakGridReader.java
public int getGridPackingType(int gridNumber) throws IOException {
    // See DM_RDTR
    int irow = 1;  // Always 1 for grids
    if ((gridNumber < 1) || (gridNumber > dmLabel.kcol)) {
      logWarning("bad grid number " + gridNumber);
      return -9;
    }
    int iprt = getPartNumber("GRID");
    if (iprt == 0) {
      logWarning("couldn't find part: GRID");
      return -10;
    }
    // gotta subtract 1 because parts are 1 but List is 0 based
    DMPart part = parts.get(iprt - 1);
    // check for valid data type
    if (part.ktyprt != MDGRID) {
      logWarning("Not a valid type: "
              + GempakUtil.getDataType(part.ktyprt));
      return -21;
    }
    int ilenhd = part.klnhdr;
    int ipoint = dmLabel.kpdata
            + (irow - 1) * dmLabel.kcol * dmLabel.kprt
            + (gridNumber - 1) * dmLabel.kprt + (iprt - 1);
    // From DM_RPKG
    int istart = DM_RINT(ipoint);
    if (istart == 0) {
      return -15;
    }
    int length = DM_RINT(istart);
    int isword = istart + 1;
    if (length <= ilenhd) {
      logWarning("length (" + length + ") is less than header length ("
              + ilenhd + ")");
      return -15;
    } else if (Math.abs(length) > 10000000) {
      logWarning("length is huge: " + length);
      return -34;
    }
    int[] header = new int[ilenhd];
    DM_RINT(isword, header);
    // int nword = length - ilenhd;
    isword += ilenhd;
    // read the data packing type
    return DM_RINT(isword);
  }
public int getGridPackingType(int gridNumber) throws IOException {
    // See DM_RDTR
    int irow = 1;  // Always 1 for grids
    if ((gridNumber < 1) || (gridNumber > dmLabel.kcol)) {
      logWarning("bad grid number " + gridNumber);
      return -9;
    }
    int iprt = getPartNumber("GRID");
    if (iprt == 0) {
      logWarning("couldn't find part: GRID");
      return -10;
    }
    // gotta subtract 1 because parts are 1 but List is 0 based
    DMPart part = parts.get(iprt - 1);
    // check for valid data type
    if (part.ktyprt != MDGRID) {
      logWarning("Not a valid type: "
              + GempakUtil.getDataType(part.ktyprt));
      return -21;
    }
    int ilenhd = part.klnhdr;
    int ipoint = dmLabel.kpdata
            + (irow - 1) * dmLabel.kcol * dmLabel.kprt
            + (gridNumber - 1) * dmLabel.kprt + (iprt - 1);
    // From DM_RPKG
    int istart = DM_RINT(ipoint);
    if (istart == 0) {
      return -15;
    }
    int length = DM_RINT(istart);
    int isword = istart + 1;
    if (length <= ilenhd) {
      logWarning("length (" + length + ") is less than header length ("
              + ilenhd + ")");
      return -15;
    } else if (Math.abs(length) > 10000000) {
      logWarning("length is huge: " + length);
      return -34;
    }
    int[] header = new int[ilenhd];
    DM_RINT(isword, header);
    // int nword = length - ilenhd;
    isword += ilenhd;
    // read the data packing type
    return DM_RINT(isword);
  }
Get the grid packing type

@param gridNumber grid number
@return packing type or error number
@throws IOException problem reading file