Changeset 990


Ignore:
Timestamp:
11/16/16 14:53:24 (7 years ago)
Author:
mhnguyen
Message:

Adding new attributes for fields: cell_methods and cell_methods_mode

cell_methods defines the string appearing in cell_methods meta data of a field
cell_methods_mode specifies modes to write out cell_methods. This attribute is only taken place if only if cell_methods is not empty()
+) overwrite: cell_methods string replaces default value of cell_methods meta data (Also default behavior if only cell_methods is defined)
+) prefix: concatenate cell_methods string as prefix of cell_methods meta data
+) suffix: concatenate cell_methods string as suffix of cell_methods meta data
+) none: do nothing

Test
+) On Curie
+) Work

Location:
XIOS/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/config/field_attribute.conf

    r887 r990  
    3333DECLARE_ATTRIBUTE(bool,      ts_enabled) 
    3434DECLARE_ATTRIBUTE(CDuration, ts_split_freq) 
     35 
     36DECLARE_ATTRIBUTE(StdString, cell_methods) 
     37DECLARE_ENUM4(cell_methods_mode,  overwrite, prefix, suffix, none) 
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r989 r990  
    16751675           for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ; 
    16761676 
     1677           bool alreadyAddCellMethod = false; 
     1678           StdString cellMethodsPrefix(""), cellMethodsSuffix(""); 
     1679           if (!field->cell_methods.isEmpty()) 
     1680           { 
     1681              StdString cellMethodString = field->cell_methods; 
     1682              if (field->cell_methods_mode.isEmpty() || 
     1683                 (CField::cell_methods_mode_attr::overwrite == field->cell_methods_mode)) 
     1684              { 
     1685                SuperClassWriter::addAttribute("cell_methods", cellMethodString, &fieldid); 
     1686                alreadyAddCellMethod = true; 
     1687              } 
     1688              else 
     1689              { 
     1690                switch (field->cell_methods_mode) 
     1691                { 
     1692                  case (CField::cell_methods_mode_attr::prefix): 
     1693                    cellMethodsPrefix = cellMethodString; 
     1694                    cellMethodsPrefix += " "; 
     1695                    break; 
     1696                  case (CField::cell_methods_mode_attr::suffix): 
     1697                    cellMethodsSuffix = " "; 
     1698                    cellMethodsSuffix += cellMethodString; 
     1699                    break; 
     1700                  case (CField::cell_methods_mode_attr::none): 
     1701                    break; 
     1702                  default: 
     1703                    break; 
     1704                } 
     1705              } 
     1706           } 
     1707 
    16771708 
    16781709           if (wtime) 
     
    16871718              SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid); 
    16881719 
    1689               StdString cellMethods = "time: "; 
     1720              StdString cellMethods(cellMethodsPrefix + "time: "); 
    16901721              if (field->operation.getValue() == "instant") cellMethods += "point"; 
    16911722              else if (field->operation.getValue() == "average") cellMethods += "mean"; 
     
    16941725              if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar)) 
    16951726                cellMethods += " (interval: " + freqOpStr + ")"; 
    1696               SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); 
     1727              cellMethods += cellMethodsSuffix; 
     1728              if (!alreadyAddCellMethod) 
     1729                SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); 
    16971730           } 
    16981731 
Note: See TracChangeset for help on using the changeset viewer.