opendap/src/main/java/ucar/nc2/dods/DODSNetcdfFile.java
protected void reGroup()
          throws DAP2Exception
  {
    assert (RC.getUseGroups());
    Group rootgroup = this.getRootGroup();

    // Start by moving global attributes
    // An issue to be addressed is that some attributes that should be attached
    // to variables, instead get made global with name var.att.
    Object[] gattlist = rootgroup.getAttributes().toArray();
    for (Object att : gattlist) {
      Attribute ncatt = (Attribute) att;
      String dodsname = ncatt.getDODSName();
      NamePieces pieces = parseName(dodsname);
      if (pieces.var != null) {
        // Figure out which variable to which this attribute should be moved.
        // In the event that there is no matching
        // variable, then keep the attribute as is.
        String searchname = pieces.var;
        if (pieces.prefix != null) searchname = pieces.prefix + '/' + searchname;
        Variable v = findVariable(searchname);
        if (v != null) {
          // move attribute
          rootgroup.remove(ncatt);
          v.addAttribute(ncatt);
          // change attribute name to remove var.
          String newname = pieces.name;
          ncatt.setName(newname);
        }
      } else if (pieces.prefix != null) {
        // We have a true group global name to move to proper group
        // convert prefix to an actual group
        Group g = rootgroup.makeRelativeGroup(this, dodsname, true);
        rootgroup.remove(ncatt);
        g.addAttribute(ncatt);
        if (OLDGROUPCODE) {
          ncatt.setName(pieces.name);
        }
      }
    }

    Object[] varlist = rootgroup.getVariables().toArray();

    if (false) {    // This should have been done by computegroup()
      // Now move variables
      for (Object var : varlist) {
        if (var instanceof DODSVariable) {
          DODSVariable v = (DODSVariable) var;
          reGroupVariable(rootgroup, v);
        } else
          throw new DAP2Exception("regroup: unexpected variable type: "
                  + var.getClass().getCanonicalName());
      }
    }

    // In theory, we should be able to fix variable attributes
    // by just removing the group prefix. However, there is the issue
    // that attribute names sometimes have as a suffix varname.attname.
    // So, we should use that to adjust the attribute to attach to that
    // variable.
    for (Object var : varlist) {
      reGroupVariableAttributes(rootgroup, (Variable) var);
    }
  }
protected void reGroup()
          throws DAP2Exception
  {
    assert (RC.getUseGroups());
    Group rootgroup = this.getRootGroup();

    // Start by moving global attributes
    // An issue to be addressed is that some attributes that should be attached
    // to variables, instead get made global with name var.att.
    Object[] gattlist = rootgroup.getAttributes().toArray();
    for (Object att : gattlist) {
      Attribute ncatt = (Attribute) att;
      String dodsname = ncatt.getDODSName();
      NamePieces pieces = parseName(dodsname);
      if (pieces.var != null) {
        // Figure out which variable to which this attribute should be moved.
        // In the event that there is no matching
        // variable, then keep the attribute as is.
        String searchname = pieces.var;
        if (pieces.prefix != null) searchname = pieces.prefix + '/' + searchname;
        Variable v = findVariable(searchname);
        if (v != null) {
          // move attribute
          rootgroup.remove(ncatt);
          v.addAttribute(ncatt);
          // change attribute name to remove var.
          String newname = pieces.name;
          ncatt.setName(newname);
        }
      } else if (pieces.prefix != null) {
        // We have a true group global name to move to proper group
        // convert prefix to an actual group
        Group g = rootgroup.makeRelativeGroup(this, dodsname, true);
        rootgroup.remove(ncatt);
        g.addAttribute(ncatt);
        if (OLDGROUPCODE) {
          ncatt.setName(pieces.name);
        }
      }
    }

    Object[] varlist = rootgroup.getVariables().toArray();

    if (false) {    // This should have been done by computegroup()
      // Now move variables
      for (Object var : varlist) {
        if (var instanceof DODSVariable) {
          DODSVariable v = (DODSVariable) var;
          reGroupVariable(rootgroup, v);
        } else
          throw new DAP2Exception("regroup: unexpected variable type: "
                  + var.getClass().getCanonicalName());
      }
    }

    // In theory, we should be able to fix variable attributes
    // by just removing the group prefix. However, there is the issue
    // that attribute names sometimes have as a suffix varname.attname.
    // So, we should use that to adjust the attribute to attach to that
    // variable.
    for (Object var : varlist) {
      reGroupVariableAttributes(rootgroup, (Variable) var);
    }
  }
Go thru the variables/structure-variables and their attributes
and move to the proper groups.