Ignore:
Timestamp:
10/16/12 13:04:44 (12 years ago)
Author:
ymipsl
Message:

Major Update

  • redesign Type and attribute manipulation
  • add enumerate type and attribute
  • use blitz class array instead of boost class array

YM

File:
1 edited

Legend:

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

    r352 r369  
    2424      , last_Write(), last_operation() 
    2525      , foperation() 
    26       , data(new CArray<double, 1>(boost::extents[0])) 
    27    { /* Ne rien faire de plus */ } 
     26      { /* Ne rien faire de plus */ } 
    2827 
    2928   CField::CField(const StdString & id) 
     
    3534      , last_Write(), last_operation() 
    3635      , foperation() 
    37       , data(new CArray<double, 1>(boost::extents[0])) 
    3836   { /* Ne rien faire de plus */ } 
    3937 
     
    4341//      this->file.reset() ; 
    4442      this->foperation.reset() ; 
    45       this->data.reset() ; 
    4643   } 
    4744 
     
    5047   bool CField::updateDataServer 
    5148      (const CDate & currDate, 
    52        const std::deque<ARRAY(double, 1)> storedClient) 
     49       const std::deque< CArray<double, 1>* > storedClient) 
    5350   { 
    5451      const CDate opeDate      = *last_operation + freq_operation; 
     
    5754      if (opeDate <= currDate) 
    5855      { 
    59          if (this->data->num_elements() != this->grid->storeIndex[0]->num_elements()) 
     56         if (this->data.numElements() != this->grid->storeIndex[0]->numElements()) 
    6057         { 
    61             this->data->resize(boost::extents[this->grid->storeIndex[0] ->num_elements()]); 
     58            this->data.resize(this->grid->storeIndex[0] ->numElements()); 
    6259         }   
    63          ARRAY_CREATE(input, double, 1, [this->data->num_elements()]); 
     60         CArray<double,1> input(data.numElements()) ; 
    6461         this->grid->inputFieldServer(storedClient, input);           
    6562         (*this->foperation)(input); 
     
    103100    CEventClient event(getType(),EVENT_ID_UPDATE_DATA) ; 
    104101     
    105     map<int,ARRAY(int, 1)>::iterator it ; 
     102    map<int,CArray<int, 1>* >::iterator it ; 
    106103    list<shared_ptr<CMessage> > list_msg ; 
    107     list<ARRAY(double,1) > list_data ; 
     104    list< CArray<double,1>* > list_data ; 
    108105     
    109106    for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 
    110107    { 
    111108      int rank=(*it).first ; 
    112       ARRAY(int,1) index=(*it).second ; 
    113       ARRAY_CREATE(data_tmp,double,1,[index->num_elements()]) ; 
    114       for(int n=0;n<data_tmp->num_elements();n++) (*data_tmp)[n]=(*data)[(*index)[n]] ; 
     109      CArray<int,1>& index = *(it->second) ; 
     110      CArray<double,1> data_tmp(index.numElements()) ; 
     111       
     112      for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 
    115113      list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
    116       list_data.push_back(data_tmp) ; 
    117       *list_msg.back()<<getId()<<list_data.back() ; 
     114      list_data.push_back(new CArray<double,1>(data_tmp)) ; 
     115      *list_msg.back()<<getId()<<*list_data.back() ; 
    118116      event.push(rank,grid->nbSenders[rank],*list_msg.back()) ; 
    119117    } 
    120118    client->sendEvent(event) ; 
     119     
     120    for(list< CArray<double,1>* >::iterator it=list_data.begin();it!=list_data.end();it++) delete *it ; 
    121121  } 
    122122   
     
    145145    if (data_srv.empty()) 
    146146    { 
    147       for(map<int,ARRAY(int, 1)>::iterator it=grid->out_i_fromClient.begin();it!=grid->out_i_fromClient.end();it++) 
     147      for(map<int, CArray<int, 1>* >::iterator it=grid->out_i_fromClient.begin();it!=grid->out_i_fromClient.end();it++) 
    148148      { 
    149149        int rank=it->first ; 
    150         ARRAY_CREATE(data_tmp,double,1,[it->second->num_elements()]) ; 
    151         data_srv.insert(pair<int, ARRAY(double,1)>(rank,data_tmp)) ; 
    152         foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(data_srv[rank])))) ; 
     150        CArray<double,1> data_tmp(it->second->numElements()) ; 
     151        data_srv.insert( pair<int, CArray<double,1>* >(rank, new CArray<double,1>(data_tmp) ) ) ; 
     152        foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(*data_srv[rank])))) ; 
    153153      } 
    154154    } 
     
    165165      for(int n=0;n<ranks.size();n++) 
    166166      { 
    167         ARRAY_CREATE(data_tmp,double,1,[0]) ; 
     167        CArray<double,1> data_tmp ; 
    168168        *buffers[n]>>data_tmp ; 
    169169        (*foperation_srv[ranks[n]])(data_tmp) ; 
     
    187187  void CField::writeField(void) 
    188188  { 
    189     if (! grid->domain->isEmpty() || getRelFile()->type.getValue()=="one_file") 
     189//    if (! grid->domain->isEmpty() || getRelFile()->type.getValue()=="one_file") 
     190    if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
    190191    { 
    191192      getRelFile()->checkFile(); 
     
    305306   //---------------------------------------------------------------- 
    306307    
    307    ARRAY(double, 1) CField::getData(void) const 
     308   CArray<double, 1> CField::getData(void) const 
    308309   { 
    309310      return(this->data); 
     
    410411         const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep();  
    411412         *this->last_operation   = *this->last_operation - toffset;   
     413         cout<<operation<<endl ; 
    412414          
    413415#define DECLARE_FUNCTOR(MType, mtype)              \ 
     
    429431    
    430432   //---------------------------------------------------------------- 
    431     
     433/* 
    432434   void CField::fromBinary(StdIStream & is) 
    433435   { 
    434436      SuperClass::fromBinary(is); 
    435437#define CLEAR_ATT(name_)\ 
    436       SuperClassAttribute::operator[](#name_)->clear() 
     438      SuperClassAttribute::operator[](#name_)->reset() 
    437439 
    438440         CLEAR_ATT(domain_ref); 
     
    441443 
    442444   } 
    443  
     445*/ 
    444446   //---------------------------------------------------------------- 
    445447 
     
    537539   } 
    538540    
    539    void CField::outputField(ARRAY(double,3) fieldOut) 
    540    { 
    541       map<int,ARRAY(double,1)>::iterator it; 
     541   void CField::outputField(CArray<double,3>& fieldOut) 
     542   { 
     543      map<int, CArray<double,1>* >::iterator it; 
    542544      for(it=data_srv.begin();it!=data_srv.end();it++) 
    543          grid->outputField(it->first,it->second, fieldOut) ; 
    544        
    545    } 
    546     
    547    void CField::outputField(ARRAY(double,2) fieldOut) 
    548    { 
    549       map<int,ARRAY(double,1)>::iterator it; 
     545         grid->outputField(it->first,*it->second, fieldOut) ; 
     546       
     547   } 
     548    
     549   void CField::outputField(CArray<double,2>& fieldOut) 
     550   { 
     551      map<int, CArray<double,1>* >::iterator it; 
    550552 
    551553      for(it=data_srv.begin();it!=data_srv.end();it++) 
    552554      { 
    553          grid->outputField(it->first,it->second, fieldOut) ; 
     555         grid->outputField(it->first,*it->second, fieldOut) ; 
    554556      } 
    555557   } 
Note: See TracChangeset for help on using the changeset viewer.