cdm/src/main/java/ucar/nc2/Variable.java
public void setDimensions(String dimString) {
    if (immutable) throw new IllegalStateException("Cant modify");
    try {
      setDimensions(Dimension.makeDimensionsList(getParentGroup(), dimString));
      //this.dimensions = Dimension.makeDimensionsList(getParentGroup(), dimString);
      resetShape();
    } catch (IllegalStateException e) {
      throw new IllegalArgumentException("Variable " + getFullName() + " setDimensions = '" + dimString +
              "' FAILED: " + e.getMessage() + " file = " + getDatasetLocation());
    }
  }
public void setDimensions(String dimString) {
    if (immutable) throw new IllegalStateException("Cant modify");
    try {
      setDimensions(Dimension.makeDimensionsList(getParentGroup(), dimString));
      //this.dimensions = Dimension.makeDimensionsList(getParentGroup(), dimString);
      resetShape();
    } catch (IllegalStateException e) {
      throw new IllegalArgumentException("Variable " + getFullName() + " setDimensions = '" + dimString +
              "' FAILED: " + e.getMessage() + " file = " + getDatasetLocation());
    }
  }
Set the dimensions using the dimensions names. The dimension is searched for recursively in the parent groups.

@param dimString : whitespace separated list of dimension names, or '*' for Dimension.UNKNOWN, or number for anon dimension. null or empty String is a scalar.