Changeset 369 for XIOS/trunk/src/node/field.cpp
- Timestamp:
- 10/16/12 13:04:44 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/field.cpp
r352 r369 24 24 , last_Write(), last_operation() 25 25 , foperation() 26 , data(new CArray<double, 1>(boost::extents[0])) 27 { /* Ne rien faire de plus */ } 26 { /* Ne rien faire de plus */ } 28 27 29 28 CField::CField(const StdString & id) … … 35 34 , last_Write(), last_operation() 36 35 , foperation() 37 , data(new CArray<double, 1>(boost::extents[0]))38 36 { /* Ne rien faire de plus */ } 39 37 … … 43 41 // this->file.reset() ; 44 42 this->foperation.reset() ; 45 this->data.reset() ;46 43 } 47 44 … … 50 47 bool CField::updateDataServer 51 48 (const CDate & currDate, 52 const std::deque< ARRAY(double, 1)> storedClient)49 const std::deque< CArray<double, 1>* > storedClient) 53 50 { 54 51 const CDate opeDate = *last_operation + freq_operation; … … 57 54 if (opeDate <= currDate) 58 55 { 59 if (this->data ->num_elements() != this->grid->storeIndex[0]->num_elements())56 if (this->data.numElements() != this->grid->storeIndex[0]->numElements()) 60 57 { 61 this->data ->resize(boost::extents[this->grid->storeIndex[0] ->num_elements()]);58 this->data.resize(this->grid->storeIndex[0] ->numElements()); 62 59 } 63 ARRAY_CREATE(input, double, 1, [this->data->num_elements()]);60 CArray<double,1> input(data.numElements()) ; 64 61 this->grid->inputFieldServer(storedClient, input); 65 62 (*this->foperation)(input); … … 103 100 CEventClient event(getType(),EVENT_ID_UPDATE_DATA) ; 104 101 105 map<int, ARRAY(int, 1)>::iterator it ;102 map<int,CArray<int, 1>* >::iterator it ; 106 103 list<shared_ptr<CMessage> > list_msg ; 107 list< ARRAY(double,1)> list_data ;104 list< CArray<double,1>* > list_data ; 108 105 109 106 for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 110 107 { 111 108 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)) ; 115 113 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() ; 118 116 event.push(rank,grid->nbSenders[rank],*list_msg.back()) ; 119 117 } 120 118 client->sendEvent(event) ; 119 120 for(list< CArray<double,1>* >::iterator it=list_data.begin();it!=list_data.end();it++) delete *it ; 121 121 } 122 122 … … 145 145 if (data_srv.empty()) 146 146 { 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++) 148 148 { 149 149 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])))) ; 153 153 } 154 154 } … … 165 165 for(int n=0;n<ranks.size();n++) 166 166 { 167 ARRAY_CREATE(data_tmp,double,1,[0]);167 CArray<double,1> data_tmp ; 168 168 *buffers[n]>>data_tmp ; 169 169 (*foperation_srv[ranks[n]])(data_tmp) ; … … 187 187 void CField::writeField(void) 188 188 { 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) 190 191 { 191 192 getRelFile()->checkFile(); … … 305 306 //---------------------------------------------------------------- 306 307 307 ARRAY(double, 1)CField::getData(void) const308 CArray<double, 1> CField::getData(void) const 308 309 { 309 310 return(this->data); … … 410 411 const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep(); 411 412 *this->last_operation = *this->last_operation - toffset; 413 cout<<operation<<endl ; 412 414 413 415 #define DECLARE_FUNCTOR(MType, mtype) \ … … 429 431 430 432 //---------------------------------------------------------------- 431 433 /* 432 434 void CField::fromBinary(StdIStream & is) 433 435 { 434 436 SuperClass::fromBinary(is); 435 437 #define CLEAR_ATT(name_)\ 436 SuperClassAttribute::operator[](#name_)-> clear()438 SuperClassAttribute::operator[](#name_)->reset() 437 439 438 440 CLEAR_ATT(domain_ref); … … 441 443 442 444 } 443 445 */ 444 446 //---------------------------------------------------------------- 445 447 … … 537 539 } 538 540 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; 542 544 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; 550 552 551 553 for(it=data_srv.begin();it!=data_srv.end();it++) 552 554 { 553 grid->outputField(it->first, it->second, fieldOut) ;555 grid->outputField(it->first,*it->second, fieldOut) ; 554 556 } 555 557 }
Note: See TracChangeset
for help on using the changeset viewer.