cdm/src/main/java/ucar/nc2/Attribute.java
protected void writeCDL(Formatter f, boolean strict, String parentname) {
    if(strict && (isString() || this.getEnumType() != null))
      // Force type explicitly for string.
      f.format("string "); //note lower case and trailing blank
    if(strict && parentname != null) f.format(NetcdfFile.makeValidCDLName(parentname));
    f.format(":");
    f.format("%s", strict ? NetcdfFile.makeValidCDLName(getShortName()) : getShortName());
    if (isString()) {
      f.format(" = ");
      for(int i = 0; i < getLength(); i++) {
        if(i != 0) f.format(", ");
        String val = getStringValue(i);
        if(val != null)
          f.format("\"%s\"", encodeString(val));
      }
    } else if(getEnumType() != null) {
      f.format(" = ");
      for (int i = 0; i < getLength(); i++) {
        if(i != 0) f.format(", ");
        EnumTypedef en = getEnumType();
        String econst = getStringValue(i);
        Integer ecint = en.lookupEnumInt(econst);
        if(ecint == null)
           throw new ForbiddenConversionException("Illegal enum constant: "+econst);
        f.format("\"%s\"", encodeString(econst));
      }
    } else {
      f.format(" = ");
      for (int i = 0; i < getLength(); i++) {
        if (i != 0) f.format(", ");

        Number number = getNumericValue(i);
        if (dataType.isUnsigned()) {
          // 'number' is unsigned, but will be treated as signed when we print it below, because Java only has signed
          // types. If it is large enough ( >= 2^(BIT_WIDTH-1) ), its most-significant bit will be interpreted as the
          // sign bit, which will result in an invalid (negative) value being printed. To prevent that, we're going
          // to widen the number before printing it.
          number = DataType.widenNumber(number);
        }
        f.format("%s", number);

        if (dataType.isUnsigned()) {
          f.format("U");
        }

        if (dataType == DataType.FLOAT)
          f.format("f");
        else if (dataType == DataType.SHORT || dataType == DataType.USHORT) {
          f.format("S");
        } else if (dataType == DataType.BYTE || dataType == DataType.UBYTE) {
          f.format("B");
        } else if (dataType == DataType.LONG || dataType == DataType.ULONG) {
          f.format("L");
        }
      }
    }
  }
protected void writeCDL(Formatter f, boolean strict, String parentname) {
    if(strict && (isString() || this.getEnumType() != null))
      // Force type explicitly for string.
      f.format("string "); //note lower case and trailing blank
    if(strict && parentname != null) f.format(NetcdfFile.makeValidCDLName(parentname));
    f.format(":");
    f.format("%s", strict ? NetcdfFile.makeValidCDLName(getShortName()) : getShortName());
    if (isString()) {
      f.format(" = ");
      for(int i = 0; i < getLength(); i++) {
        if(i != 0) f.format(", ");
        String val = getStringValue(i);
        if(val != null)
          f.format("\"%s\"", encodeString(val));
      }
    } else if(getEnumType() != null) {
      f.format(" = ");
      for (int i = 0; i < getLength(); i++) {
        if(i != 0) f.format(", ");
        EnumTypedef en = getEnumType();
        String econst = getStringValue(i);
        Integer ecint = en.lookupEnumInt(econst);
        if(ecint == null)
           throw new ForbiddenConversionException("Illegal enum constant: "+econst);
        f.format("\"%s\"", encodeString(econst));
      }
    } else {
      f.format(" = ");
      for (int i = 0; i < getLength(); i++) {
        if (i != 0) f.format(", ");

        Number number = getNumericValue(i);
        if (dataType.isUnsigned()) {
          // 'number' is unsigned, but will be treated as signed when we print it below, because Java only has signed
          // types. If it is large enough ( >= 2^(BIT_WIDTH-1) ), its most-significant bit will be interpreted as the
          // sign bit, which will result in an invalid (negative) value being printed. To prevent that, we're going
          // to widen the number before printing it.
          number = DataType.widenNumber(number);
        }
        f.format("%s", number);

        if (dataType.isUnsigned()) {
          f.format("U");
        }

        if (dataType == DataType.FLOAT)
          f.format("f");
        else if (dataType == DataType.SHORT || dataType == DataType.USHORT) {
          f.format("S");
        } else if (dataType == DataType.BYTE || dataType == DataType.UBYTE) {
          f.format("B");
        } else if (dataType == DataType.LONG || dataType == DataType.ULONG) {
          f.format("L");
        }
      }
    }
  }
Write CDL representation into f

@param f      write into this
@param strict if true, create strict CDL, escaping names