cdm/src/main/java/ucar/nc2/Variable.java
public void setDimension(int idx, Dimension dim) {
    if (immutable) throw new IllegalStateException("Cant modify");
    dimensions.set(idx, dim);
    resetShape();
  }
public void setDimension(int idx, Dimension dim) {
    if (immutable) throw new IllegalStateException("Cant modify");
    dimensions.set(idx, dim);
    resetShape();
  }
Replace a dimension with an equivalent one.

@param idx index into dimension array
@param dim to set