legacy/src/main/java/ucar/nc2/NetcdfFileWriteable.java
public Dimension addDimension(String dimName, int length) {
    if (!defineMode)
      throw new UnsupportedOperationException("not in define mode");
    if (length <= 0)
      throw new IllegalArgumentException("dimension length must be > 0 :"+length);
    if (!N3iosp.isValidNetcdfObjectName(dimName))
      throw new IllegalArgumentException("illegal netCDF-3 dimension name: "+dimName);

    Dimension dim = new Dimension(dimName, length, true, false, false);
    super.addDimension(null, dim);
    return dim;
  }
public Dimension addDimension(String dimName, int length) {
    if (!defineMode)
      throw new UnsupportedOperationException("not in define mode");
    if (length <= 0)
      throw new IllegalArgumentException("dimension length must be > 0 :"+length);
    if (!N3iosp.isValidNetcdfObjectName(dimName))
      throw new IllegalArgumentException("illegal netCDF-3 dimension name: "+dimName);

    Dimension dim = new Dimension(dimName, length, true, false, false);
    super.addDimension(null, dim);
    return dim;
  }
Add a Dimension to the file. Must be in define mode.

@param dimName name of dimension
@param length  size of dimension.
@return the created dimension