visad/src/main/java/ucar/nc2/iosp/gempak/GempakFileReader.java
public RData DM_RDTR(int irow, int icol, String partName,
                       int decimalScale)
          throws IOException {

    int ipoint = -1;
    if ((irow < 1) || (irow > dmLabel.krow) || (icol < 1)
            || (icol > dmLabel.kcol)) {
      System.out.println("bad row/column number " + irow + "/" + icol);
      return null;
    }
    //System.out.println("reading row " + irow + ", column " + icol);
    int iprt = getPartNumber(partName);
    if (iprt == 0) {
      System.out.println("couldn't find part: " + partName);
      return null;
    }
    // gotta subtract 1 because parts are 1 but List is 0 based
    DMPart part = parts.get(iprt - 1);
    // check for valid real data type
    if ((part.ktyprt != MDREAL) && (part.ktyprt != MDGRID)
            && (part.ktyprt != MDRPCK)) {
      System.out.println("Not a valid type");
      return null;
    }
    int ilenhd = part.klnhdr;
    ipoint = dmLabel.kpdata + (irow - 1) * dmLabel.kcol * dmLabel.kprt
            + (icol - 1) * dmLabel.kprt + (iprt - 1);

    float[] rdata;
    int[] header = null;
    int istart = DM_RINT(ipoint);
    if (istart == 0) {
      return null;
    }
    // start catching up here because some files are incorrectly written
    try {
      int length = DM_RINT(istart);
      int isword = istart + 1;
      if (length <= ilenhd) {
        //System.out.println("length (" + length
        //                   + ") is less than header length (" + ilenhd
        //                   + ")");
        return null;
      } else if (Math.abs(length) > 10000000) {
        //System.out.println("length is huge");
        return null;
      }
      header = new int[ilenhd];
      DM_RINT(isword, header);
      int nword = length - ilenhd;
      isword += header.length;
      if (part.ktyprt == MDREAL) {
        rdata = new float[nword];
        DM_RFLT(isword, rdata);
      } else if (part.ktyprt == MDGRID) {
        rdata = DM_RPKG(isword, nword, decimalScale);
      } else {  //  packed ints
        int[] idata = new int[nword];
        DM_RINT(isword, idata);
        rdata = DM_UNPK(part, idata);
      }
    } catch (EOFException eof) {
      //System.err.println("reading off end of file");
      rdata = null;
    }
    RData rd = null;
    if (rdata != null) {
      rd = new RData(header, rdata);
    }

    return rd;

  }
public RData DM_RDTR(int irow, int icol, String partName,
                       int decimalScale)
          throws IOException {

    int ipoint = -1;
    if ((irow < 1) || (irow > dmLabel.krow) || (icol < 1)
            || (icol > dmLabel.kcol)) {
      System.out.println("bad row/column number " + irow + "/" + icol);
      return null;
    }
    //System.out.println("reading row " + irow + ", column " + icol);
    int iprt = getPartNumber(partName);
    if (iprt == 0) {
      System.out.println("couldn't find part: " + partName);
      return null;
    }
    // gotta subtract 1 because parts are 1 but List is 0 based
    DMPart part = parts.get(iprt - 1);
    // check for valid real data type
    if ((part.ktyprt != MDREAL) && (part.ktyprt != MDGRID)
            && (part.ktyprt != MDRPCK)) {
      System.out.println("Not a valid type");
      return null;
    }
    int ilenhd = part.klnhdr;
    ipoint = dmLabel.kpdata + (irow - 1) * dmLabel.kcol * dmLabel.kprt
            + (icol - 1) * dmLabel.kprt + (iprt - 1);

    float[] rdata;
    int[] header = null;
    int istart = DM_RINT(ipoint);
    if (istart == 0) {
      return null;
    }
    // start catching up here because some files are incorrectly written
    try {
      int length = DM_RINT(istart);
      int isword = istart + 1;
      if (length <= ilenhd) {
        //System.out.println("length (" + length
        //                   + ") is less than header length (" + ilenhd
        //                   + ")");
        return null;
      } else if (Math.abs(length) > 10000000) {
        //System.out.println("length is huge");
        return null;
      }
      header = new int[ilenhd];
      DM_RINT(isword, header);
      int nword = length - ilenhd;
      isword += header.length;
      if (part.ktyprt == MDREAL) {
        rdata = new float[nword];
        DM_RFLT(isword, rdata);
      } else if (part.ktyprt == MDGRID) {
        rdata = DM_RPKG(isword, nword, decimalScale);
      } else {  //  packed ints
        int[] idata = new int[nword];
        DM_RINT(isword, idata);
        rdata = DM_UNPK(part, idata);
      }
    } catch (EOFException eof) {
      //System.err.println("reading off end of file");
      rdata = null;
    }
    RData rd = null;
    if (rdata != null) {
      rd = new RData(header, rdata);
    }

    return rd;

  }
Read the real (float) data

@param irow         row to read
@param icol         column to read
@param partName     part name
@param decimalScale scaling factor (power of 10);
@return the header and data array  or null;
@throws IOException problem reading file