void formatBuf(
  int formatPass,
  HBuffer fmtBuf)
throws HdfException
{
  setFormatEntry( formatPass, true, fmtBuf); // BaseBlk: set blkPos, buf pos

  // We need to use version 2 to support the
  // messages: link, link info, group info

  // Write it out


  if (formatPass == 1) {
    if (! isVariable) {
      hdrMsgList.add( new MsgGroupInfo( this, hdfFile));
      hdrMsgList.add( new MsgLinkInfo( this, hdfFile));
    }
    if (subGroupList != null) {
      for (HdfGroup subGroup : subGroupList) {
        hdrMsgList.add( new MsgLinkit(
          linkCreationOrder++,
          subGroup,
          this,
          hdfFile));
      }
    }
    if (subVariableList != null) {
      for (HdfGroup subGroup : subVariableList) {
        hdrMsgList.add( new MsgLinkit(
          linkCreationOrder++,
          subGroup,
          this,
          hdfFile));
      }
    }
  }

  // There is some needlessly twisted code
  // in the HDF5 H5Odbg.c.
  // It requires that the length of the chunklen field
  // be "appropriate" for the chunk0Len value, meaning
  // if  0 <= chunk0Len <= 255 the chunklen field must be
  // exactly 1 byte, if chunk0Len <= 65535 the field must be
  // exactly 2 bytes, etc.
  //
  // So we cannot always specify that the chunklen field size = 8.
  // This implies we must know chunk0Len before laying out
  // chunk0 ... as I said, a bit twisted.
  //
  // So we lay out the HdfGroup twice on each formatPass.
  // The first layout uses a temp HBuffer and just gets
  // us the chunk0Len.
  // The second layout is for real and uses fmtBuf.

  HBuffer tempHbuf = new HBuffer(
    null,                 // outChannel
    0,                    // compressionLevel
    hdfFile);

  int svIndent = hdfFile.indent;
  hdfFile.indent += 6;
  if (hdfFile.bugs >= 5) prtIndent("Start HdfGroup temp layout");

  // Find chunk0Len
  // Use formatPass = 0 so MsgLayout and MsgLinkit don't call addWork.
  long chunk0Len = 0;
  chunk0Len = layoutVersion2(
    0, chunk0Len, tempHbuf);  // formatPass = 0
  if (hdfFile.bugs >= 5) prtIndent("End HdfGroup temp layout");
  hdfFile.indent = svIndent;

  // Layout for real
  layoutVersion2( formatPass, chunk0Len, fmtBuf);

  noteFormatExit( fmtBuf);         // BaseBlk: print debug
} // end formatBuf