legacy/src/main/java/ucar/nc2/NetcdfFileWriteable.java
public Variable addVariable(String varName, DataType dataType, String dims) {
    // parse the list
    ArrayList<Dimension> list = new ArrayList<Dimension>();
    StringTokenizer stoker = new StringTokenizer(dims);
    while (stoker.hasMoreTokens()) {
      String tok = stoker.nextToken();
      Dimension d = rootGroup.findDimension(tok);
      if (null == d)
        throw new IllegalArgumentException("Cant find dimension " + tok);
      list.add(d);
    }

    return addVariable(varName, dataType, list);
  }
public Variable addVariable(String varName, DataType dataType, String dims) {
    // parse the list
    ArrayList<Dimension> list = new ArrayList<Dimension>();
    StringTokenizer stoker = new StringTokenizer(dims);
    while (stoker.hasMoreTokens()) {
      String tok = stoker.nextToken();
      Dimension d = rootGroup.findDimension(tok);
      if (null == d)
        throw new IllegalArgumentException("Cant find dimension " + tok);
      list.add(d);
    }

    return addVariable(varName, dataType, list);
  }
public Variable addVariable ( String varName , DataType dataType , String dims ) { // parse the list ArrayList < Dimension > list = new ArrayList < Dimension > ( ) ; StringTokenizer stoker = new StringTokenizer ( dims ) ; while ( stoker . hasMoreTokens ( ) ) { String tok = stoker . nextToken ( ) ; Dimension d = rootGroup . findDimension ( tok ) ; if ( null == d ) throw new IllegalArgumentException ( "Cant find dimension " + tok ) ; list . add ( d ) ; } return addVariable ( varName , dataType , list ) ; }
Add a variable to the file. Must be in define mode.

@param varName  name of Variable, must be unique with the file.
@param dataType type of underlying element
@param dims     names of Dimensions for the variable, blank seperated.
Must already have been added. Use an empty string for a scalar variable.
@return the Variable that has been added
Add a variable to the file . Must be in define mode .