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/grid.cpp

    r352 r369  
    1111#include "context.hpp" 
    1212#include "context_client.hpp" 
     13#include "array_new.hpp" 
    1314 
    1415namespace xios { 
     
    3233 //     this->axis.reset() ; 
    3334//      this->domain.reset() ; 
    34        
    35       for (StdSize i = 0; i < this->storeIndex.size(); i++) 
    36       { 
    37          this->storeIndex[i].reset(); 
    38          this->out_i_index[i].reset(); 
    39          this->out_j_index[i].reset(); 
    40          this->out_l_index[i].reset(); 
    41       } 
     35    deque< CArray<int, 1>* >::iterator it ; 
     36     
     37    for(deque< CArray<int,1>* >::iterator it=storeIndex.begin(); it!=storeIndex.end();it++)  delete *it ; 
     38    for(deque< CArray<int,1>* >::iterator it=out_i_index.begin();it!=out_i_index.end();it++) delete *it ; 
     39    for(deque< CArray<int,1>* >::iterator it=out_j_index.begin();it!=out_j_index.end();it++) delete *it ; 
     40    for(deque< CArray<int,1>* >::iterator it=out_l_index.begin();it!=out_l_index.end();it++) delete *it ; 
     41 
     42    for(map<int,CArray<int,1>* >::iterator it=out_i_fromClient.begin();it!=out_i_fromClient.end();it++) delete it->second ; 
     43    for(map<int,CArray<int,1>* >::iterator it=out_j_fromClient.begin();it!=out_j_fromClient.end();it++) delete it->second ; 
     44    for(map<int,CArray<int,1>* >::iterator it=out_l_fromClient.begin();it!=out_l_fromClient.end();it++) delete it->second ; 
     45 
    4246   } 
    4347 
     
    5054   //---------------------------------------------------------------- 
    5155 
    52    const std::deque<ARRAY(int, 1)> & CGrid::getStoreIndex(void) const 
     56   const std::deque< CArray<int,1>* > & CGrid::getStoreIndex(void) const 
    5357   {  
    5458      return (this->storeIndex ); 
     
    5761   //--------------------------------------------------------------- 
    5862 
    59    const std::deque<ARRAY(int, 1)> & CGrid::getOutIIndex(void)  const 
     63   const std::deque< CArray<int,1>* > & CGrid::getOutIIndex(void)  const 
    6064   {  
    6165      return (this->out_i_index );  
     
    6468   //--------------------------------------------------------------- 
    6569 
    66    const std::deque<ARRAY(int, 1)> & CGrid::getOutJIndex(void)  const 
     70   const std::deque< CArray<int,1>* > & CGrid::getOutJIndex(void)  const 
    6771   {  
    6872      return (this->out_j_index );  
     
    7175   //--------------------------------------------------------------- 
    7276 
    73    const std::deque<ARRAY(int, 1)> & CGrid::getOutLIndex(void)  const 
     77   const std::deque< CArray<int,1>* > & CGrid::getOutLIndex(void)  const 
    7478   {  
    7579      return (this->out_l_index );  
     
    155159   StdSize CGrid::getDataSize(void) const 
    156160   { 
    157       StdSize retvalue ; 
    158       retvalue=domain->data_ni.getValue() ; 
     161      StdSize retvalue=domain->data_ni.getValue() ; 
    159162      if (domain->data_dim.getValue()==2) retvalue*=domain->data_nj.getValue() ; 
    160163      if (this->withAxis) retvalue*=this->axis->size.getValue() ; 
     
    177180          
    178181         this->computeIndex() ; 
    179          ARRAY_CREATE(storeIndex_ , int, 1, [0]); 
    180          ARRAY_CREATE(out_l_index_, int, 1, [0]); 
    181          ARRAY_CREATE(out_i_index_, int, 1, [0]); 
    182          ARRAY_CREATE(out_j_index_, int, 1, [0]); 
    183                   
    184          this->storeIndex .push_front(storeIndex_); 
    185          this->out_i_index.push_front(out_i_index_); 
    186          this->out_j_index.push_front(out_j_index_); 
    187          this->out_l_index.push_front(out_l_index_); 
     182 
     183         this->storeIndex.push_front(new CArray<int,1>() ); 
     184         this->out_i_index.push_front(new CArray<int,1>()); 
     185         this->out_j_index.push_front(new CArray<int,1>()); 
     186         this->out_l_index.push_front(new CArray<int,1>()); 
    188187      } 
    189188//      this->computeIndexServer(); 
     
    245244                             ? domain->data_jbegin.getValue() : -1; 
    246245 
    247       ARRAY(int, 1) data_i_index = domain->data_i_index.getValue() , 
    248                     data_j_index = domain->data_j_index.getValue() ; 
    249  
    250  
    251       ARRAY(bool, 2) mask = domain->mask.getValue() ; 
    252       ARRAY(int, 2) local_mask =  this->domain->getLocalMask(); 
     246      CArray<int,1> data_i_index = domain->data_i_index ; 
     247      CArray<int,1> data_j_index = domain->data_j_index ; 
     248       
     249 
     250      CArray<bool,2>& mask = domain->mask ; 
     251      CArray<int,2>& local_mask = domain->local_mask ; 
     252       
    253253 
    254254      int indexCount = 0; 
     
    258258         for(int n = 0, i = 0, j = 0; n < data_n_index; n++) 
    259259         { 
    260             int temp_i = (*data_i_index)[n] + data_ibegin, 
     260            int temp_i = data_i_index(n) + data_ibegin, 
    261261                temp_j = (data_dim == 1) ? -1 
    262                        : (*data_j_index)[n] + data_jbegin; 
     262                       : data_j_index(n) + data_jbegin; 
    263263            i = (data_dim == 1) ? (temp_i - 1) % ni 
    264264                                : (temp_i - 1) ; 
     
    268268            if ((l >=lbegin && l<= lend) && 
    269269                (i >= 0 && i < ni) && 
    270                 (j >= 0 && j < nj) && (*mask)[i][j]) 
     270                (j >= 0 && j < nj) && mask(i,j)) 
    271271               indexCount++ ; 
    272272         } 
    273273      } 
    274274       
    275       ARRAY_ASSIGN(this->storeIndex[0] , int, 1, [indexCount]); 
    276       ARRAY_ASSIGN(this->out_l_index[0], int, 1, [indexCount]); 
    277       ARRAY_ASSIGN(this->out_i_index[0], int, 1, [indexCount]); 
    278       ARRAY_ASSIGN(this->out_j_index[0], int, 1, [indexCount]); 
    279        
    280       ARRAY_ASSIGN(storeIndex_client,int,1,[indexCount]); 
    281       ARRAY_ASSIGN(out_i_client,int,1,[indexCount]); 
    282       ARRAY_ASSIGN(out_j_client,int,1,[indexCount]); 
    283       ARRAY_ASSIGN(out_l_client,int,1,[indexCount]); 
     275      storeIndex[0]  = new CArray<int,1>(indexCount) ; 
     276      out_i_index[0] = new CArray<int,1>(indexCount) ; 
     277      out_j_index[0] = new CArray<int,1>(indexCount) ; 
     278      out_l_index[0] = new CArray<int,1>(indexCount) ; 
     279       
     280      storeIndex_client.resize(indexCount) ; 
     281      out_i_client.resize(indexCount) ; 
     282      out_j_client.resize(indexCount) ; 
     283      out_l_client.resize(indexCount) ; 
    284284       
    285285       
     
    288288         for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) 
    289289         { 
    290             int temp_i = (*data_i_index)[n] + data_ibegin, 
     290            int temp_i = data_i_index(n) + data_ibegin, 
    291291                temp_j = (data_dim == 1) ? -1 
    292                        : (*data_j_index)[n] + data_jbegin; 
     292                       : data_j_index(n) + data_jbegin; 
    293293            i = (data_dim == 1) ? (temp_i - 1) % ni 
    294294                                : (temp_i - 1) ; 
     
    298298            if ((l >= lbegin && l <= lend) && 
    299299                (i >= 0 && i < ni) && 
    300                 (j >= 0 && j < nj) && (*mask)[i][j]) 
     300                (j >= 0 && j < nj) && mask(i,j)) 
    301301            { 
    302                (*this->storeIndex[0]) [indexCount] = count ; 
    303                (*this->out_l_index[0])[indexCount] = l ; 
    304                (*this->out_i_index[0])[indexCount] = i ; 
    305                (*this->out_j_index[0])[indexCount] = j ; 
     302               (*storeIndex[0])(indexCount) = count ; 
     303               (*out_l_index[0])(indexCount) = l ; 
     304               (*out_i_index[0])(indexCount) = i ; 
     305               (*out_j_index[0])(indexCount) = j ; 
    306306                
    307                (*storeIndex_client)[indexCount] = count ; 
    308                (*out_i_client)[indexCount]=i+domain->ibegin_client-1 ; 
    309                (*out_j_client)[indexCount]=j+domain->jbegin_client-1 ; 
    310                (*out_l_client)[indexCount]=l-lbegin ; 
     307               storeIndex_client(indexCount) = count ; 
     308               out_i_client(indexCount)=i+domain->ibegin_client-1 ; 
     309               out_j_client(indexCount)=j+domain->jbegin_client-1 ; 
     310               out_l_client(indexCount)=l-lbegin ; 
    311311               indexCount++ ; 
    312312            } 
     
    340340   //---------------------------------------------------------------- 
    341341 
    342    void CGrid::outputField(int rank, const ARRAY(double, 1) stored,  ARRAY(double, 3) field)  
    343    { 
    344       ARRAY(int,1) out_i=out_i_fromClient[rank] ; 
    345       ARRAY(int,1) out_j=out_j_fromClient[rank] ; 
    346       ARRAY(int,1) out_l=out_l_fromClient[rank] ; 
    347        
    348       for(StdSize n = 0; n < stored->num_elements(); n++) 
    349          (*field)[(*out_i)[n]][(*out_j)[n]][(*out_l)[n]] = (*stored)[n] ; 
    350    } 
    351  
    352    void CGrid::outputField(int rank, const ARRAY(double, 1) stored,  ARRAY(double, 2) field)  
    353    { 
    354       ARRAY(int,1) out_i=out_i_fromClient[rank] ; 
    355       ARRAY(int,1) out_j=out_j_fromClient[rank] ; 
    356  
    357        for(StdSize n = 0; n < stored->num_elements(); n++) 
    358          (*field)[(*out_i)[n]][(*out_j)[n]] = (*stored)[n] ; 
    359    } 
    360  
    361    //--------------------------------------------------------------- 
    362  
    363    void CGrid::outputField(int rank,const ARRAY(double, 1) stored,  ARRAY(double, 1) field) 
    364    { 
    365       ARRAY(int,1) out_i = out_i_fromClient[rank] ; 
    366       for(StdSize n = 0; n < stored->num_elements(); n++) 
    367          (*field)[(*out_i)[n]] = (*stored)[n] ; 
     342   void CGrid::outputField(int rank, const CArray<double, 1>& stored,  CArray<double, 3>& field)  
     343   { 
     344      CArray<int,1>& out_i=*out_i_fromClient[rank] ; 
     345      CArray<int,1>& out_j=*out_j_fromClient[rank] ; 
     346      CArray<int,1>& out_l=*out_l_fromClient[rank] ; 
     347       
     348      for(StdSize n = 0; n < stored.numElements(); n++) 
     349         field(out_i(n), out_j(n), out_l(n)) = stored(n) ; 
     350   } 
     351 
     352   void CGrid::outputField(int rank, const CArray<double, 1>& stored,  CArray<double, 2>& field)  
     353   { 
     354      CArray<int,1>& out_i=*out_i_fromClient[rank] ; 
     355      CArray<int,1>& out_j=*out_j_fromClient[rank] ; 
     356       
     357      for(StdSize n = 0; n < stored.numElements(); n++) 
     358         field(out_i(n), out_j(n)) = stored(n) ;   } 
     359 
     360   //--------------------------------------------------------------- 
     361 
     362   void CGrid::outputField(int rank,const CArray<double, 1>& stored,  CArray<double, 1>& field) 
     363   { 
     364      CArray<int,1>& out_i=*out_i_fromClient[rank] ; 
     365  
     366      for(StdSize n = 0; n < stored.numElements(); n++) 
     367         field(out_i(n)) = stored(n) ; 
    368368   } 
    369369 
     
    372372 
    373373   void CGrid::storeField_arr 
    374       (const double * const data, ARRAY(double, 1) stored) const 
    375    { 
    376       const StdSize size = (this->storeIndex_client)->num_elements() ; 
    377  
    378       stored->resize(boost::extents[size]) ; 
    379       for(StdSize i = 0; i < size; i++) 
    380          (*stored)[i] = data[(*storeIndex_client)[i]] ; 
     374      (const double * const data, CArray<double, 1>& stored) const 
     375   { 
     376      const StdSize size = storeIndex_client.numElements() ; 
     377 
     378      stored.resize(size) ; 
     379      for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)] ; 
    381380   } 
    382381    
    383382   //--------------------------------------------------------------- 
    384     
    385    void CGrid::toBinary  (StdOStream & os) const 
    386    { 
    387       SuperClass::toBinary(os); 
    388       
    389       os.write (reinterpret_cast<const char*>(&this->isChecked), sizeof(bool));  
    390       
    391       if (this->isChecked) 
    392       { 
    393          this->storeIndex [0]->toBinary(os); 
    394          this->out_i_index[0]->toBinary(os); 
    395          this->out_j_index[0]->toBinary(os); 
    396          this->out_l_index[0]->toBinary(os); 
    397       } 
    398    } 
    399  
    400    //--------------------------------------------------------------- 
    401     
    402    void CGrid::fromBinary(StdIStream & is) 
    403    { 
    404       bool hasIndex = false; 
    405       SuperClass::fromBinary(is);             
    406       is.read (reinterpret_cast<char*>(&hasIndex), sizeof(bool));  
    407        
    408       if (hasIndex) 
    409       { 
    410          ARRAY_CREATE(storeIndex_ , int, 1, [0]); 
    411          ARRAY_CREATE(out_l_index_, int, 1, [0]); 
    412          ARRAY_CREATE(out_i_index_, int, 1, [0]); 
    413          ARRAY_CREATE(out_j_index_, int, 1, [0]); 
    414           
    415          storeIndex_ ->fromBinary(is); 
    416          out_i_index_->fromBinary(is); 
    417          out_j_index_->fromBinary(is); 
    418          out_l_index_->fromBinary(is); 
    419           
    420          this->storeIndex .push_back(storeIndex_); 
    421          this->out_i_index.push_back(out_i_index_); 
    422          this->out_j_index.push_back(out_j_index_); 
    423          this->out_l_index.push_back(out_l_index_); 
    424       } 
    425    } 
    426     
    427    //--------------------------------------------------------------- 
     383 
    428384  void CGrid::sendIndex(void) 
    429385  { 
     
    434390    int rank ; 
    435391    list<shared_ptr<CMessage> > list_msg ; 
    436     list<ARRAY(int,1) > list_out_i,list_out_j,list_out_l ; 
     392    list< CArray<int,1>* > list_out_i,list_out_j,list_out_l ; 
    437393      
    438394    for(int ns=0;ns<domain->connectedServer.size();ns++) 
     
    446402       int i,j ; 
    447403       int nb=0 ; 
    448        for(int k=0;k<storeIndex_client->num_elements();k++) 
     404       for(int k=0;k<storeIndex_client.numElements();k++) 
    449405       { 
    450          i=(*out_i_client)[k] ; 
    451          j=(*out_j_client)[k] ; 
     406         i=out_i_client(k) ; 
     407         j=out_j_client(k) ; 
    452408         if (i>=ib-1 && i<=ie-1 && j>=jb-1 && j<=je-1) nb++ ;  
    453409       } 
    454410        
    455        ARRAY_CREATE(storeIndex,int,1,[nb]) ; 
    456        ARRAY_CREATE(out_i,int,1,[nb]) ; 
    457        ARRAY_CREATE(out_j,int,1,[nb]) ; 
    458        ARRAY_CREATE(out_l,int,1,[nb]) ; 
     411       CArray<int,1> storeIndex(nb) ; 
     412       CArray<int,1> out_i(nb) ; 
     413       CArray<int,1> out_j(nb) ; 
     414       CArray<int,1> out_l(nb) ; 
     415  
    459416        
    460417       nb=0 ; 
    461        for(int k=0;k<storeIndex_client->num_elements();k++) 
     418       for(int k=0;k<storeIndex_client.numElements();k++) 
    462419       { 
    463          i=(*out_i_client)[k] ; 
    464          j=(*out_j_client)[k] ; 
     420         i=out_i_client(k) ; 
     421         j=out_j_client(k) ; 
    465422         if (i>=ib-1 && i<=ie-1 && j>=jb-1 && j<=je-1)  
    466423         { 
    467             (*storeIndex)[nb]=k ; 
    468             (*out_i)[nb]=(*out_i_client)[k] ; 
    469             (*out_j)[nb]=(*out_j_client)[k] ; 
    470             (*out_l)[nb]=(*out_l_client)[k] ; 
     424            storeIndex(nb)=k ; 
     425            out_i(nb)=out_i_client(k) ; 
     426            out_j(nb)=out_j_client(k) ; 
     427            out_l(nb)=out_l_client(k) ; 
    471428            nb++ ; 
    472429         } 
    473430       } 
    474431        
    475        storeIndex_toSrv.insert(pair<int,ARRAY(int,1) >(rank,storeIndex)) ; 
     432       storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(storeIndex) )) ; 
    476433       nbSenders.insert(pair<int,int>(rank,domain->nbSenders[ns])) ; 
    477434       list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
    478        list_out_i.push_back(out_i) ; 
    479        list_out_j.push_back(out_j) ; 
    480        list_out_l.push_back(out_l) ; 
    481  
    482        *list_msg.back()<<getId()<<list_out_i.back()<<list_out_j.back()<<list_out_l.back() ; 
     435       list_out_i.push_back(new CArray<int,1>(out_i)) ; 
     436       list_out_j.push_back(new CArray<int,1>(out_j)) ; 
     437       list_out_l.push_back(new CArray<int,1>(out_l)) ; 
     438 
     439       *list_msg.back()<<getId()<<*list_out_i.back()<<*list_out_j.back()<<*list_out_l.back() ; 
    483440       event.push(rank,domain->nbSenders[ns],*list_msg.back()) ; 
    484441    } 
    485442    client->sendEvent(event) ; 
     443 
     444    for(list<CArray<int,1>* >::iterator it=list_out_i.begin();it!=list_out_i.end();it++) delete *it ; 
     445    for(list<CArray<int,1>* >::iterator it=list_out_j.begin();it!=list_out_j.end();it++) delete *it ; 
     446    for(list<CArray<int,1>* >::iterator it=list_out_l.begin();it!=list_out_l.end();it++) delete *it ; 
     447     
    486448  } 
    487449   
     
    501463  void CGrid::recvIndex(int rank, CBufferIn& buffer) 
    502464  { 
    503     ARRAY_CREATE(out_i,int,1,[0]) ; 
    504     ARRAY_CREATE(out_j,int,1,[0]) ; 
    505     ARRAY_CREATE(out_l,int,1,[0]) ; 
     465    CArray<int,1> out_i ; 
     466    CArray<int,1> out_j ; 
     467    CArray<int,1> out_l ; 
    506468     
    507469    buffer>>out_i>>out_j>>out_l ; 
    508     int offset ; 
    509470     
    510     offset=domain->zoom_ibegin_srv-1 ; 
    511     for(int k=0;k<out_i->num_elements();k++) (*out_i)[k]=(*out_i)[k]-offset ; 
     471    out_i -= domain->zoom_ibegin_srv-1 ; 
     472    out_j -= domain->zoom_jbegin_srv-1 ; 
    512473     
    513     offset=domain->zoom_jbegin_srv-1 ; 
    514     for(int k=0;k<out_i->num_elements();k++) (*out_j)[k]=(*out_j)[k]-offset ; 
    515      
    516     out_i_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_i)) ; 
    517     out_j_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_j)) ; 
    518     out_l_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_l)) ; 
     474    out_i_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_i) )) ; 
     475    out_j_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_j) )) ; 
     476    out_l_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_l) )) ; 
    519477  } 
    520478 
     
    540498  } 
    541499 
    542  
    543 /* 
    544    void CGrid::computeIndexServer(void) 
    545    { 
    546       ARRAY(int, 2) local_mask =  this->domain->getLocalMask(); 
    547        
    548       const std::vector<int> & ibegin = this->domain->getIBeginSub(); 
    549       const std::vector<int> & jbegin = this->domain->getJBeginSub(); 
    550       const std::vector<int> & iend = this->domain->getIEndSub(); 
    551       const std::vector<int> & jend = this->domain->getJEndSub(); 
    552       const std::vector<int> & ibegin_zoom = this->domain->getIBeginZoomSub(); 
    553       const std::vector<int> & jbegin_zoom = this->domain->getJBeginZoomSub(); 
    554       const std::vector<int> & ni_zoom = this->domain->getNiZoomSub(); 
    555       const std::vector<int> & nj_zoom = this->domain->getNjZoomSub(); 
    556        
    557       const int ibegin_srv  = this->domain->ibegin.getValue(); 
    558       const int jbegin_srv  = this->domain->jbegin.getValue(); 
    559       const int iend_srv  = this->domain->iend.getValue(); 
    560       const int jend_srv  = this->domain->jend.getValue(); 
    561       const int zoom_ni_srv = this->domain->zoom_ni_loc.getValue(); 
    562       const int zoom_nj_srv = this->domain->zoom_nj_loc.getValue(); 
    563        
    564       const int ibegin_zoom_srv = this->domain->zoom_ibegin_loc.getValue(); 
    565       const int jbegin_zoom_srv = this->domain->zoom_jbegin_loc.getValue(); 
    566        const int iend_zoom_srv = ibegin_zoom_srv + zoom_ni_srv-1 ; 
    567       const int  jend_zoom_srv = jbegin_zoom_srv + zoom_nj_srv-1 ; 
    568          
    569       StdSize dn = 0;       
    570       for (StdSize j = 1; j < this->out_i_index.size(); j++) 
    571          dn += this->out_i_index[j]->size(); 
    572           
    573       ARRAY_CREATE(storeIndex_srv , int, 1, [dn]); 
    574       ARRAY_CREATE(out_i_index_srv, int, 1, [dn]); 
    575       ARRAY_CREATE(out_j_index_srv, int, 1, [dn]); 
    576       ARRAY_CREATE(out_l_index_srv, int, 1, [dn]); 
    577        
    578       for (StdSize i = 0, dn = 0; i < ibegin.size(); i++) 
    579       { 
    580          ARRAY(int, 1) storeIndex_cl   =  this->storeIndex [i + 1]; 
    581          ARRAY(int, 1) out_i_index_cl  =  this->out_i_index[i + 1]; 
    582          ARRAY(int, 1) out_j_index_cl  =  this->out_j_index[i + 1]; 
    583          ARRAY(int, 1) out_l_index_cl  =  this->out_l_index[i + 1]; 
    584                   
    585          int ibegin_zoom_cl = ibegin[i]; //ibegin_zoom[i]; 
    586          int jbegin_zoom_cl = jbegin[i]; //jbegin_zoom[i]; 
    587          int iend_zoom_cl = iend[i]; //ibegin_zoom[i]; 
    588          int jend_zoom_cl = jend[i]; //jbegin_zoom[i]; 
    589  
    590          int ibegin_cl = ibegin[i]; //ibegin[i]; 
    591          int jbegin_cl = jbegin[i]; //jbegin[i]; 
    592          int iend_cl = iend[i]; //ibegin[i]; 
    593          int jend_cl = jend[i]; //jbegin[i]; 
    594           
    595          if (ibegin_zoom.size() != 0) 
    596          { 
    597             ibegin_zoom_cl = ibegin_zoom[i]; 
    598             jbegin_zoom_cl = jbegin_zoom[i]; 
    599             iend_zoom_cl = ibegin_zoom[i]+ni_zoom[i]-1; 
    600             jend_zoom_cl = jbegin_zoom[i]+nj_zoom[i]-1; 
    601          } 
    602           
    603  
    604          if (comm::CMPIManager::IsClient()) 
    605          { 
    606            for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++) 
    607            { 
    608               (*storeIndex_srv)[n]  = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. 
    609  
    610               (*out_i_index_srv)[n] = (*out_i_index_cl)[m] + ibegin_cl - 1 - (ibegin_srv + ibegin_zoom_srv - 1) + 1 ; 
    611               (*out_j_index_srv)[n] = (*out_j_index_cl)[m] + jbegin_cl - 1 - (jbegin_srv + jbegin_zoom_srv - 1) + 1 ; 
    612               (*out_l_index_srv)[n] = (*out_l_index_cl)[m]; 
    613            } 
    614          } 
    615          else 
    616          { 
    617            for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++) 
    618            { 
    619               (*storeIndex_srv)[n]  = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. 
    620             (*out_i_index_srv)[n] = (*out_i_index_cl)[m]  
    621                                    + (ibegin_cl - 1) - (ibegin_srv - 1) + (ibegin_zoom_cl - 1) - (ibegin_zoom_srv - 1); 
    622             (*out_j_index_srv)[n] = (*out_j_index_cl)[m] 
    623                                    + (jbegin_cl - 1) - (jbegin_srv - 1) + (jbegin_zoom_cl - 1) - (jbegin_zoom_srv - 1); 
    624             (*out_l_index_srv)[n] = (*out_l_index_cl)[m]; 
    625            }          
    626              
    627          } 
    628                    
    629          dn += storeIndex_cl->size();  
    630       } 
    631        
    632       if (storeIndex_srv->size() != 0) 
    633       { 
    634          const int ibegin_t =  
    635             *std::min_element(out_i_index_srv->begin(), out_i_index_srv->end()); 
    636          const int iend_t   = 
    637             *std::max_element(out_i_index_srv->begin(), out_i_index_srv->end()); 
    638          const int jbegin_t =    
    639             *std::min_element(out_j_index_srv->begin(), out_j_index_srv->end()); 
    640          const int jend_t   = 
    641             *std::max_element(out_j_index_srv->begin(), out_j_index_srv->end()); 
    642                 
    643                                   
    644          if ((ibegin_t < 0) || (jbegin_t < 0) || 
    645              (iend_t >= zoom_ni_srv) || (jend_t >= zoom_nj_srv)) 
    646          { 
    647             ERROR("CGrid::computeIndexServer(void)", 
    648                   << "[ grille = "      << this->getId() 
    649                   << ", ibegin_t = "    << ibegin_t 
    650                   << ", jbegin_t = "    << jbegin_t 
    651                   << ", iend_t = "      << iend_t 
    652                   << ", jend_t = "      << jend_t 
    653                   << ", zoom_ni_srv = " << zoom_ni_srv 
    654                   << ", zoom_nj_srv = " << zoom_nj_srv 
    655                   << ", nb subdomain = "   << out_i_index.size()-1 
    656                   <<" ] Erreur d'indexation de la grille au niveau du serveur") ; 
    657          } 
    658       } 
    659  
    660       if (storeIndex_srv->size() != 0) 
    661          for (StdSize u = 0; u < storeIndex_srv->size(); u++) 
    662             (*local_mask)[(*out_i_index_srv)[u]][(*out_j_index_srv)[u]] = 1; 
    663  
    664 //      StdOFStream ofs(("log_server_"+this->getId()).c_str()); 
    665 //      for (StdSize h = 0; h < storeIndex_srv->size(); h++) 
    666 //      { 
    667 //        ofs << "(" << (*storeIndex_srv)[h]  << ";" 
    668 //            << (*out_i_index_srv)[h] << "," 
    669 //            << (*out_j_index_srv)[h] << "," 
    670 //            << (*out_l_index_srv)[h] << ")" << std::endl; 
    671 //      } 
    672 //       ofs.close(); 
    673     
    674       this->storeIndex [0] = storeIndex_srv ; 
    675       this->out_i_index[0] = out_i_index_srv; 
    676       this->out_j_index[0] = out_j_index_srv; 
    677       this->out_l_index[0] = out_l_index_srv;       
    678    } 
    679 */ 
    680     
    681    void CGrid::inputFieldServer 
    682          (const std::deque<ARRAY(double, 1)> storedClient, 
    683                            ARRAY(double, 1)  storedServer) const 
     500   void CGrid::inputFieldServer(const std::deque< CArray<double, 1>* > storedClient, CArray<double, 1>&  storedServer) const 
    684501   { 
    685502      if ((this->storeIndex.size()-1 ) != storedClient.size()) 
    686          ERROR("CGrid::inputFieldServer(...)", 
     503         ERROR("void CGrid::inputFieldServer(const std::deque< CArray<double, 1>* > storedClient, CArray<double, 1>&  storedServer) const", 
    687504                << "[ Nombre de tableau attendu = " << (this->storeIndex.size()-1) << ", " 
    688505                << "[ Nombre de tableau reçu = "    << storedClient.size() << "] " 
    689506                << "Les données d'un client sont manquantes !") ; 
    690       if (storedServer.get() != NULL) 
    691          storedServer->resize(boost::extents[this->storeIndex[0]->num_elements()]); 
    692       else  
    693          ARRAY_ASSIGN(storedServer, double, 1, [this->storeIndex[0]->num_elements()]); 
     507      storedServer.resize(storeIndex[0]->numElements()); 
    694508          
    695509      for (StdSize i = 0, n = 0; i < storedClient.size(); i++) 
    696          for (StdSize j = 0; j < storedClient[i]->num_elements(); j++) 
    697             (*storedServer)[n++] = (*storedClient[i])[j]; 
    698    } 
    699  
    700    void CGrid::outputFieldToServer(ARRAY(double, 1) fieldIn, int rank, ARRAY(double, 1) fieldOut) 
    701    { 
    702      ARRAY(int,1) index=storeIndex_toSrv[rank] ; 
    703      int nb=index->num_elements() ; 
    704      fieldOut->resize(extents[nb]) ; 
     510         for (StdSize j = 0; j < storedClient[i]->numElements(); j++) 
     511            storedServer(n++) = (*storedClient[i])(j); 
     512   } 
     513 
     514   void CGrid::outputFieldToServer(CArray<double,1>& fieldIn, int rank, CArray<double,1>& fieldOut) 
     515   { 
     516     CArray<int,1>& index = *storeIndex_toSrv[rank] ; 
     517     int nb=index.numElements() ; 
     518     fieldOut.resize(nb) ; 
    705519      
    706      for(int k=0;k<nb;k++) (*fieldOut)[k]=(*fieldIn)[(*index)[k]] ; 
     520     for(int k=0;k<nb;k++) fieldOut(k)=fieldIn(index(k)) ; 
    707521    } 
    708522   ///--------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.