Ignore:
Timestamp:
02/07/17 11:52:03 (7 years ago)
Author:
ymipsl
Message:
  • Add label attribute for axis
  • if label attribute is present, then only only string label for each level will be output in netcdf file, ie value and bounds will not be output.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/axis.cpp

    r995 r1050  
    2727      , isDistributed_(false), hasBounds_(false), isCompressible_(false) 
    2828      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    29       , transformationMap_(), hasValue(false) 
     29      , transformationMap_(), hasValue(false), hasLabel(false) 
    3030   { 
    3131   } 
     
    3737      , isDistributed_(false), hasBounds_(false), isCompressible_(false) 
    3838      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    39       , transformationMap_(), hasValue(false) 
     39      , transformationMap_(), hasValue(false), hasLabel(false) 
    4040   { 
    4141   } 
     
    176176         if (hasBounds_) 
    177177           sizeValEvent += CArray<double,2>::size(2 * it->second.size()); 
     178  
     179         if (hasLabel) 
     180           sizeValEvent += CArray<StdString,1>::size(it->second.size()); 
    178181 
    179182         size_t size = CEventClient::headerSize + getId().size() + sizeof(size_t) + std::max(sizeIndexEvent, sizeValEvent); 
     
    261264      this->checkMask(); 
    262265      this->checkBounds(); 
     266      this->checkLabel(); 
    263267 
    264268      isDistributed_ = (!this->begin.isEmpty() && !this->n.isEmpty() && (this->begin + this->n < this->n_glo)) || 
     
    333337  } 
    334338 
     339  void CAxis::checkLabel() 
     340  { 
     341    if (!label.isEmpty()) 
     342    { 
     343      if (label.extent(0) != n) 
     344        ERROR("CAxis::checkLabel(void)", 
     345              << "The label array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension of axis size." << std::endl 
     346              << "Axis size is " << n.getValue() << "." << std::endl 
     347              << "label size is "<< label.extent(0)<<  " ."); 
     348      hasLabel = true; 
     349    } 
     350    else hasLabel = false; 
     351  } 
    335352  void CAxis::checkEligibilityForCompressedOutput() 
    336353  { 
     
    657674    list<CArray<double,1> > list_val; 
    658675    list<CArray<double,2> > list_bounds; 
     676    list<CArray<StdString,1> > list_label; 
    659677 
    660678    std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     
    675693        list_bounds.push_back(CArray<double,2>(2,nbData)); 
    676694      } 
     695       
     696      if (hasLabel) 
     697      { 
     698        list_label.push_back(CArray<StdString,1>(nbData)); 
     699      } 
    677700 
    678701      CArray<int,1>& indi = list_indi.back(); 
     
    693716          boundsVal(1, n) = bounds(1,n); 
    694717        } 
     718         
     719        if (hasLabel) 
     720        { 
     721          CArray<StdString,1>& labelVal = list_label.back(); 
     722          labelVal(n) = label(n); 
     723        } 
    695724      } 
    696725 
     
    716745      { 
    717746        list_msgsVal.back() << list_bounds.back(); 
     747      } 
     748  
     749      if (hasLabel) 
     750      { 
     751        list_msgsVal.back() << list_label.back(); 
    718752      } 
    719753 
     
    783817    CArray<double,1> val; 
    784818    CArray<double,2> boundsVal; 
     819    CArray<StdString,1> labelVal; 
    785820 
    786821    buffer >> val; 
    787822    if (hasBounds_) buffer >> boundsVal; 
     823    if (hasLabel) buffer >> labelVal; 
    788824 
    789825    int i, j, ind_srv; 
     
    798834        bound_srv(1,ind_srv) = boundsVal(1, ind); 
    799835      } 
     836 
     837      if (hasLabel) 
     838      { 
     839        label_srv(ind_srv) = labelVal( ind); 
     840      } 
     841 
    800842    } 
    801843  } 
     
    836878        bound_srv(0,ind) = bounds(0,ind); 
    837879        bound_srv(1,ind) = bounds(1,ind); 
     880      } 
     881      if (hasLabel) 
     882      { 
     883        label_srv(ind) = label(ind); 
    838884      } 
    839885    } 
     
    927973      value_srv.resize(zoom_size_srv); 
    928974      if (hasBounds_)  bound_srv.resize(2,zoom_size_srv); 
     975      if (hasLabel)  label_srv.resize(zoom_size_srv); 
    929976    } 
    930977  } 
Note: See TracChangeset for help on using the changeset viewer.