Ignore:
Timestamp:
02/03/14 14:16:20 (10 years ago)
Author:
ymipsl
Message:

Enhancement : user defined global and field attribute can be output in the netcdfcf file.
A variable child element inclosed into a file element will be output as a global file attribute.
A variable child element inclosed into a field element will be output as a field attribute.

+ variable fortran interface added

YM

File:
1 edited

Legend:

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

    r470 r472  
    2727      , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL) 
    2828      , processed(false) 
    29       { /* Ne rien faire de plus */ } 
     29      { setVirtualVariableGroup() ; } 
    3030 
    3131   CField::CField(const StdString & id) 
     
    3939      , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL) 
    4040      , processed(false) 
    41    { /* Ne rien faire de plus */ } 
     41   { setVirtualVariableGroup() ; } 
    4242 
    4343   CField::~CField(void) 
     
    5151   } 
    5252 
     53 
     54  //---------------------------------------------------------------- 
     55 
     56   void CField::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 
     57   {  
     58      this->vVariableGroup = newVVariableGroup;  
     59   } 
     60  
     61   void CField::setVirtualVariableGroup(void) 
     62   { 
     63      this->setVirtualVariableGroup(CVariableGroup::create()); 
     64   } 
     65   
     66   CVariableGroup* CField::getVirtualVariableGroup(void) const 
     67   { 
     68      return (this->vVariableGroup); 
     69   } 
     70 
     71  
     72   std::vector<CVariable*> CField::getAllVariables(void) const 
     73   { 
     74      return (this->vVariableGroup->getAllChildren()); 
     75   } 
     76    
     77   void CField::solveDescInheritance(bool apply, const CAttributeMap * const parent) 
     78   { 
     79      SuperClassAttribute::setAttributes(parent,apply); 
     80      this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 
     81   } 
     82   //---------------------------------------------------------------- 
    5383   //---------------------------------------------------------------- 
    5484 
     
    93123          return true ; 
    94124          break ; 
     125 
     126            case EVENT_ID_ADD_VARIABLE : 
     127             recvAddVariable(event) ; 
     128             return true ; 
     129             break ; 
     130          
     131           case EVENT_ID_ADD_VARIABLE_GROUP : 
     132             recvAddVariableGroup(event) ; 
     133             return true ; 
     134             break ;  
    95135  
    96136        default : 
     
    658698      SuperClass::parse(node); 
    659699      node.getContent(this->content) ; 
     700      if (node.goToChildElement()) 
     701      { 
     702        do 
     703        { 
     704          if (node.getElementName()=="variable" || node.getElementName()=="variable_group") this->getVirtualVariableGroup()->parseChild(node); 
     705        } while (node.goToNextElement()) ; 
     706        node.goToParentElement(); 
     707      } 
     708 
    660709    } 
    661710     
     
    782831    } 
    783832  } 
     833 
     834 
     835 
     836   CVariable* CField::addVariable(const string& id) 
     837   { 
     838     return vVariableGroup->createChild(id) ; 
     839   } 
     840 
     841   CVariableGroup* CField::addVariableGroup(const string& id) 
     842   { 
     843     return vVariableGroup->createChildGroup(id) ; 
     844   } 
     845 
     846 
     847   void CField::sendAddVariable(const string& id) 
     848   { 
     849    CContext* context=CContext::getCurrent() ; 
     850     
     851    if (! context->hasServer ) 
     852    { 
     853       CContextClient* client=context->client ; 
     854 
     855       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ;    
     856       if (client->isServerLeader()) 
     857       { 
     858         CMessage msg ; 
     859         msg<<this->getId() ; 
     860         msg<<id ; 
     861         event.push(client->getServerLeader(),1,msg) ; 
     862         client->sendEvent(event) ; 
     863       } 
     864       else client->sendEvent(event) ; 
     865    } 
     866       
     867   } 
     868  
     869    
     870   void CField::sendAddVariableGroup(const string& id) 
     871   { 
     872    CContext* context=CContext::getCurrent() ; 
     873    if (! context->hasServer ) 
     874    { 
     875       CContextClient* client=context->client ; 
     876 
     877       CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ;    
     878       if (client->isServerLeader()) 
     879       { 
     880         CMessage msg ; 
     881         msg<<this->getId() ; 
     882         msg<<id ; 
     883         event.push(client->getServerLeader(),1,msg) ; 
     884         client->sendEvent(event) ; 
     885       } 
     886       else client->sendEvent(event) ; 
     887    } 
     888       
     889   } 
     890    
     891   void CField::recvAddVariable(CEventServer& event) 
     892   { 
     893       
     894      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     895      string id; 
     896      *buffer>>id ; 
     897      get(id)->recvAddVariable(*buffer) ; 
     898   } 
     899    
     900    
     901   void CField::recvAddVariable(CBufferIn& buffer) 
     902   { 
     903      string id ; 
     904      buffer>>id ; 
     905      addVariable(id) ; 
     906   } 
     907 
     908   void CField::recvAddVariableGroup(CEventServer& event) 
     909   { 
     910       
     911      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     912      string id; 
     913      *buffer>>id ; 
     914      get(id)->recvAddVariableGroup(*buffer) ; 
     915   } 
     916    
     917    
     918   void CField::recvAddVariableGroup(CBufferIn& buffer) 
     919   { 
     920      string id ; 
     921      buffer>>id ; 
     922      addVariableGroup(id) ; 
     923   } 
     924 
     925 
     926 
    784927   
    785928} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.