cdm/src/main/java/ucar/nc2/NetcdfFileWriter.java
public Dimension addDimension(Group g, String dimName, int length, boolean isUnlimited, boolean isVariableLength) {
    if (!defineMode) throw new UnsupportedOperationException("not in define mode");
    if (!isValidObjectName(dimName))
      throw new IllegalArgumentException("illegal dimension name " + dimName);

    Dimension dim = new Dimension(dimName, length, true, isUnlimited, isVariableLength);
    ncfile.addDimension(g, dim);
    return dim;
  }
public Dimension addDimension(Group g, String dimName, int length, boolean isUnlimited, boolean isVariableLength) {
    if (!defineMode) throw new UnsupportedOperationException("not in define mode");
    if (!isValidObjectName(dimName))
      throw new IllegalArgumentException("illegal dimension name " + dimName);

    Dimension dim = new Dimension(dimName, length, true, isUnlimited, isVariableLength);
    ncfile.addDimension(g, dim);
    return dim;
  }
public Dimension addDimension ( Group g , String dimName , int length , boolean isUnlimited , boolean isVariableLength ) { if ( ! defineMode ) throw new UnsupportedOperationException ( "not in define mode" ) ; if ( ! isValidObjectName ( dimName ) ) throw new IllegalArgumentException ( "illegal dimension name " + dimName ) ; Dimension dim = new Dimension ( dimName , length , true , isUnlimited , isVariableLength ) ; ncfile . addDimension ( g , dim ) ; return dim ; }
Add a shared Dimension to the file. Must be in define mode.

@param dimName          name of dimension
@param length           size of dimension.
@param isUnlimited      if dimension is unlimited
@param isVariableLength if dimension is variable length
@return the created dimension
Add a shared Dimension to the file . Must be in define mode .