visad/src/main/java/ucar/nc2/iosp/gempak/GempakFileReader.java
protected void readHeaders() throws IOException {
    if (dmLabel == null) {
      return;
    }
    headers = new DMHeaders();
    List<int[]> rowHeaders = new ArrayList<>(dmLabel.krow);
    int istart = dmLabel.kprowh;

    // first word is a valid flag so we have to add 1 to size
    int[] header;
    for (int i = 0; i < dmLabel.krow; i++) {
      header = new int[dmLabel.krkeys + 1];
      DM_RINT(istart, header);
      if (header[0] != IMISSD) {
        headers.lstrw = i;
      }
      rowHeaders.add(header);
      istart += header.length;
    }
    headers.rowHeaders = rowHeaders;
    List<int[]> colHeaders = new ArrayList<>(dmLabel.kcol);
    istart = dmLabel.kpcolh;
    for (int i = 0; i < dmLabel.kcol; i++) {
      header = new int[dmLabel.kckeys + 1];
      DM_RINT(istart, header);
      if (header[0] != IMISSD) {
        headers.lstcl = i;
      }
      colHeaders.add(header);
      istart += header.length;
    }
    headers.colHeaders = colHeaders;


    // some of the words are characters
    if (needToSwap) {
      int[] keyLoc = new int[swapKeys.length];
      String[] keyType = new String[swapKeys.length];
      boolean haveRow = false;
      boolean haveCol = false;
      for (int i = 0; i < swapKeys.length; i++) {
        Key key = findKey(swapKeys[i]);
        keyLoc[i] = (key != null)
                ? key.loc + 1
                : 0;
        keyType[i] = (key != null)
                ? key.type
                : "";
        if (keyType[i].equals(ROW)) {
          haveRow = true;
        }
        if (keyType[i].equals(COL)) {
          haveCol = true;
        }
      }
      if (haveRow) {
        for (int[] toCheck : headers.rowHeaders) {
          for (int j = 0; j < swapKeys.length; j++) {
            if (keyType[j].equals(ROW)) {
              if (swapKeys[j].equals("GVCD")
                      && !(toCheck[keyLoc[j]]
                      > GempakUtil.vertCoords.length)) {
                continue;
              }
              GempakUtil.swp4(toCheck, keyLoc[j], swapNum[j]);
            }
          }
        }
      }
      if (haveCol) {
        for (int[] toCheck : headers.colHeaders) {
          for (int j = 0; j < swapKeys.length; j++) {
            if (keyType[j].equals(COL)) {
              if (swapKeys[j].equals("GVCD")
                      && !(toCheck[keyLoc[j]]
                      > GempakUtil.vertCoords.length)) {
                continue;
              }
              GempakUtil.swp4(toCheck, keyLoc[j], swapNum[j]);
            }
          }
        }
      }
    }
  }
protected void readHeaders() throws IOException {
    if (dmLabel == null) {
      return;
    }
    headers = new DMHeaders();
    List<int[]> rowHeaders = new ArrayList<>(dmLabel.krow);
    int istart = dmLabel.kprowh;

    // first word is a valid flag so we have to add 1 to size
    int[] header;
    for (int i = 0; i < dmLabel.krow; i++) {
      header = new int[dmLabel.krkeys + 1];
      DM_RINT(istart, header);
      if (header[0] != IMISSD) {
        headers.lstrw = i;
      }
      rowHeaders.add(header);
      istart += header.length;
    }
    headers.rowHeaders = rowHeaders;
    List<int[]> colHeaders = new ArrayList<>(dmLabel.kcol);
    istart = dmLabel.kpcolh;
    for (int i = 0; i < dmLabel.kcol; i++) {
      header = new int[dmLabel.kckeys + 1];
      DM_RINT(istart, header);
      if (header[0] != IMISSD) {
        headers.lstcl = i;
      }
      colHeaders.add(header);
      istart += header.length;
    }
    headers.colHeaders = colHeaders;


    // some of the words are characters
    if (needToSwap) {
      int[] keyLoc = new int[swapKeys.length];
      String[] keyType = new String[swapKeys.length];
      boolean haveRow = false;
      boolean haveCol = false;
      for (int i = 0; i < swapKeys.length; i++) {
        Key key = findKey(swapKeys[i]);
        keyLoc[i] = (key != null)
                ? key.loc + 1
                : 0;
        keyType[i] = (key != null)
                ? key.type
                : "";
        if (keyType[i].equals(ROW)) {
          haveRow = true;
        }
        if (keyType[i].equals(COL)) {
          haveCol = true;
        }
      }
      if (haveRow) {
        for (int[] toCheck : headers.rowHeaders) {
          for (int j = 0; j < swapKeys.length; j++) {
            if (keyType[j].equals(ROW)) {
              if (swapKeys[j].equals("GVCD")
                      && !(toCheck[keyLoc[j]]
                      > GempakUtil.vertCoords.length)) {
                continue;
              }
              GempakUtil.swp4(toCheck, keyLoc[j], swapNum[j]);
            }
          }
        }
      }
      if (haveCol) {
        for (int[] toCheck : headers.colHeaders) {
          for (int j = 0; j < swapKeys.length; j++) {
            if (keyType[j].equals(COL)) {
              if (swapKeys[j].equals("GVCD")
                      && !(toCheck[keyLoc[j]]
                      > GempakUtil.vertCoords.length)) {
                continue;
              }
              GempakUtil.swp4(toCheck, keyLoc[j], swapNum[j]);
            }
          }
        }
      }
    }
  }
Read the headers (DM_RHDA)

@throws IOException problem reading file