cdm/src/main/java/ucar/nc2/NetcdfFileWriter.java
public Attribute addGroupAttribute(Group g, Attribute att) {
    if (!defineMode) throw new UnsupportedOperationException("not in define mode");

    if (!isValidObjectName(att.getShortName())) {
      String attName = createValidObjectName(att.getShortName());
      log.warn("illegal attribute name= " + att.getShortName() + " change to " + attName);
      att = new Attribute(attName, att.getValues());
    }

    return ncfile.addAttribute(g, att);
  }
public Attribute addGroupAttribute(Group g, Attribute att) {
    if (!defineMode) throw new UnsupportedOperationException("not in define mode");

    if (!isValidObjectName(att.getShortName())) {
      String attName = createValidObjectName(att.getShortName());
      log.warn("illegal attribute name= " + att.getShortName() + " change to " + attName);
      att = new Attribute(attName, att.getValues());
    }

    return ncfile.addAttribute(g, att);
  }
public Attribute addGroupAttribute ( Group g , Attribute att ) { if ( ! defineMode ) throw new UnsupportedOperationException ( "not in define mode" ) ; if ( ! isValidObjectName ( att . getShortName ( ) ) ) { String attName = createValidObjectName ( att . getShortName ( ) ) ; log . warn ( "illegal attribute name= " + att . getShortName ( ) + " change to " + attName ) ; att = new Attribute ( attName , att . getValues ( ) ) ; } return ncfile . addAttribute ( g , att ) ; }
Add a Global attribute to the file. Must be in define mode.

@param g   the group to add to. if null, use root group
@param att the attribute.
@return the created attribute
Add a Global attribute to the file . Must be in define mode .