Changeset 610 for XIOS/branchs/xios-1.0


Ignore:
Timestamp:
06/10/15 10:39:10 (9 years ago)
Author:
rlacroix
Message:

Domain initialization: Reduce communications and simplify the code.

Location:
XIOS/branchs/xios-1.0/src/node
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/src/node/domain.cpp

    r501 r610  
    1616 
    1717namespace xios { 
    18     
     18 
    1919   /// ////////////////////// Définitions ////////////////////// /// 
    2020 
     
    3030 
    3131   CDomain::~CDomain(void) 
    32    {  
     32   { 
    3333   } 
    3434 
     
    3737   const std::set<StdString> & CDomain::getRelFiles(void) const 
    3838   { 
    39       return (this->relFiles);  
    40    } 
    41  
    42    //---------------------------------------------------------------- 
    43     
     39      return (this->relFiles); 
     40   } 
     41 
     42   //---------------------------------------------------------------- 
     43 
    4444   bool CDomain::hasZoom(void) const 
    4545   { 
    46       return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) &&  
     46      return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && 
    4747              (this->zoom_nj.getValue() != this->nj_glo.getValue())); 
    4848   } 
    49     
    50    //---------------------------------------------------------------- 
    51     
     49 
     50   //---------------------------------------------------------------- 
     51 
    5252   bool CDomain::isEmpty(void) const 
    5353   { 
    54       return ((this->zoom_ni_srv == 0) ||  
     54      return ((this->zoom_ni_srv == 0) || 
    5555              (this->zoom_nj_srv == 0)); 
    5656   } 
     
    8686               << "[ Id = " << this->getId() << " ] " 
    8787               << "The global domain is badly defined," 
    88                << " check the \'ni_glo\'  value !")  
     88               << " check the \'ni_glo\'  value !") 
    8989         } 
    9090         nj_glo=ni_glo ; 
     
    111111         ibegin=1 ; 
    112112         iend=1 ; 
    113           
     113 
    114114      } 
    115115      else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 
     
    119119               << "[ Id = " << this->getId() << " ] " 
    120120               << "The global domain is badly defined," 
    121                << " check the \'ni_glo\' et \'nj_glo\' values !")  
     121               << " check the \'ni_glo\' et \'nj_glo\' values !") 
    122122      } 
    123123      checkLocalIDomain() ; 
    124124      checkLocalJDomain() ; 
    125        
     125 
    126126     if (i_index.isEmpty()) 
    127127     { 
    128128       i_index.resize(ni,nj) ; 
    129129       for(int j=0;j<nj;j++) 
    130          for(int i=0;i<ni;i++) i_index(i,j)=i ;    
     130         for(int i=0;i<ni;i++) i_index(i,j)=i ; 
    131131     } 
    132       
     132 
    133133     if (j_index.isEmpty()) 
    134134     { 
    135135        j_index.resize(ni,nj) ; 
    136136        for(int j=0;j<nj;j++) 
    137          for(int i=0;i<ni;i++) j_index(i,j)=j ;    
     137         for(int i=0;i<ni;i++) j_index(i,j)=j ; 
    138138     } 
    139   
     139 
    140140   } 
    141141 
     
    211211               << "Domain is wrong defined," 
    212212               << " Check the values : nj, nj_glo, jbegin, jend") ; 
    213                 
     213 
    214214     ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 
    215215     jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; 
     
    221221   { 
    222222      using namespace std; 
    223        
     223 
    224224      int ibegin_mask = 0, 
    225225          jbegin_mask = 0, 
    226226          iend_mask = iend.getValue() - ibegin.getValue(), 
    227227          jend_mask = jend.getValue() - jbegin.getValue(); 
    228        
     228 
    229229      if (!zoom_ibegin.isEmpty()) 
    230230      { 
    231231         int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; 
    232232         int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; 
    233           
     233 
    234234         ibegin_mask = max (ibegin.getValue(), zoom_ibegin.getValue()); 
    235235         jbegin_mask = max (jbegin.getValue(), zoom_jbegin.getValue()); 
    236236         iend_mask   = min (iend.getValue(), zoom_iend); 
    237237         jend_mask   = min (jend.getValue(), zoom_jend); 
    238                   
     238 
    239239         ibegin_mask -= ibegin.getValue(); 
    240240         jbegin_mask -= jbegin.getValue(); 
     
    242242         jend_mask   -= jbegin.getValue(); 
    243243      } 
    244        
     244 
    245245 
    246246      if (!mask.isEmpty()) 
     
    251251                  <<"the mask has not the same size than the local domain"<<endl 
    252252                   <<"Local size is "<<ni<<"x"<<nj<<endl 
    253                   <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1));                  
     253                  <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 
    254254         for (int i = 0; i < ni; i++) 
    255255         { 
     
    283283 
    284284   void CDomain::checkDomainData(void) 
    285    {      
     285   { 
    286286      if (!data_dim.isEmpty() && 
    287287         !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) 
     
    378378            data_i_index.resize(dni) ; 
    379379            data_j_index.resize(dni) ; 
    380              
     380 
    381381            data_n_index.setValue(dni); 
    382              
     382 
    383383            for(int count = 0, j = 0; j  < data_nj.getValue(); j++) 
    384384            { 
     
    394394 
    395395   //---------------------------------------------------------------- 
    396     
     396 
    397397   void CDomain::completeLonLatClient(void) 
    398398   { 
     
    402402      CArray<double,2> bounds_lon_temp(nvertex,ni*nj) ; 
    403403      CArray<double,2> bounds_lat_temp(nvertex,ni*nj) ; 
    404        
     404 
    405405      if (type.isEmpty()) 
    406406      { 
    407         if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj )  
     407        if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) 
    408408        { 
    409409          type.setValue(type_attr::curvilinear) ; 
    410410          isCurvilinear=true ; 
    411411        } 
    412         else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj )  
     412        else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) 
    413413        { 
    414414          type.setValue(type_attr::regular) ; 
     
    429429      { 
    430430        for(j=0;j<nj;j++) 
    431           for(i=0;i<ni;i++)  
     431          for(i=0;i<ni;i++) 
    432432          { 
    433433            k=j*ni+i ; 
     
    436436            if (hasBounds) 
    437437            { 
    438               for(int n=0;n<nvertex;n++)  
     438              for(int n=0;n<nvertex;n++) 
    439439              { 
    440440                bounds_lon_temp(n,k)=bounds_lon(n,i) ; 
     
    444444          } 
    445445      } 
    446           
     446 
    447447      StdSize dm = zoom_ni_client * zoom_nj_client; 
    448448 
    449449      lonvalue.resize(dm); 
    450450      latvalue.resize(dm); 
    451           
     451 
    452452      for (int i = 0; i < zoom_ni_client; i++) 
    453453      { 
    454454        for (int j = 0; j < zoom_nj_client; j++) 
    455455        { 
    456           lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni );  
     456          lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
    457457          latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); 
    458458          if (hasBounds) 
    459459          { 
    460             for(int n=0;n<nvertex;n++)  
     460            for(int n=0;n<nvertex;n++) 
    461461            { 
    462               bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni );  
     462              bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
    463463              bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); 
    464464            } 
     
    467467      } 
    468468    } 
    469   
     469 
    470470 
    471471   //---------------------------------------------------------------- 
     
    487487            int zoom_iend = zoom_ibegin + zoom_ni - 1; 
    488488            int zoom_jend = zoom_jbegin + zoom_nj - 1; 
    489                  
     489 
    490490            if (zoom_ibegin < 1  || zoom_jbegin < 1 || zoom_iend > ni_glo || zoom_jend > nj_glo) 
    491491               ERROR("CDomain::checkZoom(void)", 
     
    496496      else 
    497497      { 
    498          zoom_ni = ni_glo;  
     498         zoom_ni = ni_glo; 
    499499         zoom_nj = nj_glo; 
    500500         zoom_ibegin = 1; 
    501501         zoom_jbegin = 1; 
    502502      } 
    503        
     503 
    504504      // compute client zoom indices 
    505505 
     
    510510      if (zoom_ni_client<0) zoom_ni_client=0 ; 
    511511 
    512      
     512 
    513513      int zoom_jend=zoom_jbegin+zoom_nj-1 ; 
    514514      zoom_jbegin_client = jbegin_client > zoom_jbegin ? jbegin_client : zoom_jbegin ; 
     
    518518 
    519519   } 
    520     
     520 
    521521   void CDomain::checkBounds(void) 
    522522   { 
     
    524524     { 
    525525       hasBounds=true ; 
    526         
     526 
    527527     } 
    528      else  
     528     else 
    529529     { 
    530530       hasBounds=false; 
     
    532532     } 
    533533   } 
    534              
     534 
    535535   //---------------------------------------------------------------- 
    536536 
     
    543543      this->checkZoom(); 
    544544      this->checkBounds(); 
    545        
     545 
    546546      if (context->hasClient) 
    547547      { // CÃŽté client uniquement 
     
    556556// ne sert plus //   this->completeLonLatServer(); 
    557557      } 
    558      
     558 
    559559      if (context->hasClient) 
    560560      { 
     
    563563        sendLonLat() ; 
    564564      } 
    565        
     565 
    566566      this->isChecked = true; 
    567567   } 
    568     
     568 
    569569  void CDomain::sendServerAttribut(void) 
    570570  { 
     
    572572    int ibegin_srv=1 ; 
    573573    int iend_srv=ni_glo.getValue() ; 
    574       
     574 
    575575    int nj_srv ; 
    576576    int jbegin_srv ; 
    577577    int jend_srv ; 
    578      
     578 
    579579    CContext* context=CContext::getCurrent() ; 
    580580    CContextClient* client=context->client ; 
    581581    int nbServer=client->serverSize ; 
    582582    int serverRank=client->getServerLeader() ; 
    583      
     583 
    584584    jend_srv=0 ; 
    585585    for(int i=0;i<=serverRank;i++) 
     
    590590      jend_srv=jbegin_srv+nj_srv-1 ; 
    591591    } 
    592      
    593      CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ;    
     592 
     593     CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 
    594594     if (client->isServerLeader()) 
    595595     { 
     
    606606  { 
    607607    int i,j,i_ind,j_ind ; 
    608      
     608 
    609609    ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 
    610610    jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; 
    611       
     611 
    612612    CContext* context = CContext::getCurrent() ; 
    613613    CContextClient* client=context->client ; 
     
    617617    int zoom_iend=zoom_ibegin+zoom_ni-1 ; 
    618618    int zoom_jend=zoom_jbegin+zoom_nj-1 ; 
    619      
     619 
    620620    int blockSize=nj_glo/nbServer ; 
    621621    int ns=nj_glo%nbServer ; 
    622622    int pos=ns*(blockSize+1) ; 
    623623    int serverNum ; 
    624      
     624 
    625625    mapConnectedServer.resize(ni,nj) ; 
    626626    vector<int> nbData(nbServer,0) ; 
    627627    vector<int> indServer(nbServer,-1) ; 
    628628    vector<bool> IsConnected(nbServer,false) ; 
    629      
     629 
    630630    for(j=0;j<nj;j++) 
    631631      for(i=0;i<ni;i++) 
     
    633633        i_ind=ibegin+i_index(i,j)-1 ; 
    634634        j_ind=jbegin+j_index(i,j)-1 ; 
    635          
     635 
    636636        if (j_ind<pos) serverNum=j_ind/(blockSize+1) ; 
    637637        else serverNum=ns+(j_ind-pos)/blockSize ; 
    638638        IsConnected[serverNum]=true ; 
    639                  
     639 
    640640        if (i_ind >= zoom_ibegin-1 && i_ind <= zoom_iend-1 && j_ind >= zoom_jbegin-1 && j_ind <= zoom_jend-1) 
    641641        { 
     
    647647 
    648648 
    649     for(serverNum=0 ; serverNum<nbServer ; serverNum++)  
     649    for(serverNum=0 ; serverNum<nbServer ; serverNum++) 
    650650      if (IsConnected[serverNum]) 
    651651      { 
     
    655655        nbDataSrv.push_back(nbData[serverNum]) ; 
    656656      } 
    657       
     657 
    658658     i_indSrv.resize(connectedServer.size()) ; 
    659659     j_indSrv.resize(connectedServer.size()) ; 
    660660 
    661661     for(j=0;j<nj;j++) 
    662       for(i=0;i<ni;i++)  
     662      for(i=0;i<ni;i++) 
    663663      { 
    664664        if (mapConnectedServer(i,j)>=0) 
     
    670670        } 
    671671      } 
    672            
     672 
    673673    int nbConnectedServer=connectedServer.size() ; 
    674674 
     
    677677    int* sendBuff=new int[nbConnectedServer] ; 
    678678    valarray<int> nbClient(0,client->serverSize) ; 
    679      
     679 
    680680    for(int n=0;n<nbConnectedServer;n++) sendBuff[n]=connectedServer[n] ; 
    681      
     681 
    682682    // get connected server for everybody 
    683683    MPI_Allgather(&nbConnectedServer,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm) ; 
    684      
     684 
    685685    displ[0]=0 ; 
    686686    for(int n=1;n<client->clientSize;n++) displ[n]=displ[n-1]+recvCount[n-1] ; 
    687687    int recvSize=displ[client->clientSize-1]+recvCount[client->clientSize-1] ; 
    688688    int* recvBuff=new int[recvSize] ; 
    689   
    690      
     689 
     690 
    691691    MPI_Allgatherv(sendBuff,nbConnectedServer,MPI_INT,recvBuff,recvCount,displ,MPI_INT,client->intraComm) ; 
    692692    for(int n=0;n<recvSize;n++) nbClient[recvBuff[n]]++ ; 
    693      
     693 
    694694    for(int n=0;n<nbConnectedServer;n++) nbSenders.push_back(nbClient[connectedServer[n]]) ; 
    695     
     695 
    696696    delete [] recvCount ; 
    697697    delete [] displ ; 
     
    703703  void CDomain::sendLonLat(void) 
    704704  { 
    705     int ns,n,i,j,ind,nv ; 
    706     CContext* context = CContext::getCurrent() ; 
    707     CContextClient* client=context->client ; 
     705    int ns,n,i,j,ind,nv; 
     706    CContext* context = CContext::getCurrent(); 
     707    CContextClient* client = context->client; 
     708 
    708709    // send lon lat for each connected server 
    709     CEventClient event(getType(),EVENT_ID_LON_LAT) ; 
    710      
    711     list<shared_ptr<CMessage> > list_msg ;     
    712     list< CArray<int,1>* > list_indi,list_indj ; 
    713     list< CArray<double,1>* >list_lon,list_lat ; 
    714     list< CArray<double,2>* >list_boundslon,list_boundslat ; 
    715  
    716     for(int ns=0;ns<connectedServer.size();ns++) 
     710    CEventClient event(getType(), EVENT_ID_LON_LAT); 
     711 
     712    list<CMessage> list_msg; 
     713    list<CArray<int,1> > list_indi,list_indj; 
     714    list<CArray<double,1> >list_lon,list_lat; 
     715    list<CArray<double,2> >list_boundslon,list_boundslat; 
     716 
     717    for (int ns = 0; ns < connectedServer.size(); ns++) 
    717718    { 
    718       int nbData = nbDataSrv[ns] ; 
    719       CArray<int,1> indi(nbData) ; 
    720       CArray<int,1> indj(nbData) ; 
    721       CArray<double,1> lon(nbData) ; 
    722       CArray<double,1> lat(nbData) ; 
    723       CArray<double,2> boundslon(nvertex,nbData) ; 
    724       CArray<double,2> boundslat(nvertex,nbData) ; 
    725        
    726       for(n=0;n<nbData;n++)  
    727       { 
    728         i=i_indSrv[ns][n] ; 
    729         j=j_indSrv[ns][n] ; 
    730         ind=(i-(zoom_ibegin_client-1))+(j-(zoom_jbegin_client-1))*zoom_ni_client ; 
    731          
    732         lon(n)=lonvalue(ind) ; 
    733         lat(n)=latvalue(ind) ; 
     719      int nbData = nbDataSrv[ns]; 
     720 
     721      list_indi.push_back(CArray<int,1>(nbData)); 
     722      list_indj.push_back(CArray<int,1>(nbData)); 
     723      list_lon.push_back(CArray<double,1>(nbData)); 
     724      list_lat.push_back(CArray<double,1>(nbData)); 
     725 
     726      if (hasBounds) 
     727      { 
     728        list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 
     729        list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
     730      } 
     731 
     732      CArray<int,1>& indi = list_indi.back(); 
     733      CArray<int,1>& indj = list_indj.back(); 
     734      CArray<double,1>& lon = list_lon.back(); 
     735      CArray<double,1>& lat = list_lat.back(); 
     736 
     737      for (n = 0; n < nbData; n++) 
     738      { 
     739        i = i_indSrv[ns][n]; 
     740        j = j_indSrv[ns][n]; 
     741        ind = (i - (zoom_ibegin_client - 1)) + (j - (zoom_jbegin_client - 1)) * zoom_ni_client; 
     742 
     743        lon(n) = lonvalue(ind); 
     744        lat(n) = latvalue(ind); 
     745 
    734746        if (hasBounds) 
    735747        { 
    736           for(nv=0;nv<nvertex;nv++) 
     748          CArray<double,2>& boundslon = list_boundslon.back(); 
     749          CArray<double,2>& boundslat = list_boundslat.back(); 
     750 
     751          for(nv = 0; nv < nvertex; nv++) 
    737752          { 
    738             boundslon(nv,n)=bounds_lon(nv,ind); 
    739             boundslat(nv,n)=bounds_lat(nv,ind); 
     753            boundslon(nv,n) = bounds_lon(nv,ind); 
     754            boundslat(nv,n) = bounds_lat(nv,ind); 
    740755          } 
    741756        } 
    742         indi(n)=ibegin+i_index(i-ibegin+1,j-jbegin+1)-1  ; 
    743         indj(n)=jbegin+j_index(i-ibegin+1,j-jbegin+1)-1  ; 
    744       } 
    745      
    746       list_indi.push_back(new CArray<int,1>(indi.copy())) ; 
    747       list_indj.push_back(new CArray<int,1>(indj.copy())) ; 
    748       list_lon.push_back(new CArray<double,1>(lon.copy())) ; 
    749       list_lat.push_back(new CArray<double,1>(lat.copy())) ; 
    750       if (hasBounds) list_boundslon.push_back(new CArray<double,2>(boundslon.copy())) ; 
    751       if (hasBounds) list_boundslat.push_back(new CArray<double,2>(boundslat.copy())) ; 
    752  
    753       list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
    754  
    755       *list_msg.back()<<this->getId()<<(int)type ; // enum ne fonctionne pour les message => ToFix 
    756       *list_msg.back()<<isCurvilinear ; 
    757       *list_msg.back()<<*list_indi.back()<<*list_indj.back()<<*list_lon.back()<<*list_lat.back() ; 
    758       if (hasBounds) *list_msg.back()<<*list_boundslon.back()<<*list_boundslat.back(); 
    759       event.push(connectedServer[ns],nbSenders[ns],*list_msg.back()) ; 
     757 
     758        indi(n) = ibegin + i_index(i - ibegin + 1, j - jbegin + 1) - 1; 
     759        indj(n) = jbegin + j_index(i - ibegin + 1, j - jbegin + 1) - 1; 
     760      } 
     761 
     762      list_msg.push_back(CMessage()); 
     763 
     764      list_msg.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
     765      list_msg.back() << isCurvilinear; 
     766      list_msg.back() << list_indi.back() << list_indj.back() << list_lon.back() << list_lat.back(); 
     767      if (hasBounds) list_msg.back() << list_boundslon.back() << list_boundslat.back(); 
     768         
     769      event.push(connectedServer[ns], nbSenders[ns], list_msg.back()); 
    760770    } 
    761771 
    762     client->sendEvent(event) ; 
    763      
    764      
    765     for(list<CArray<int,1>* >::iterator it=list_indi.begin();it!=list_indi.end();it++) delete *it; 
    766     for(list<CArray<int,1>* >::iterator it=list_indj.begin();it!=list_indj.end();it++) delete *it; 
    767     for(list<CArray<double,1>* >::iterator it=list_lon.begin();it!=list_lon.end();it++)   delete *it; 
    768     for(list<CArray<double,1>* >::iterator it=list_lat.begin();it!=list_lat.end();it++)   delete *it; 
    769     if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslon.begin();it!=list_boundslon.end();it++)   delete *it; 
    770     if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++)   delete *it;     
    771      
     772    client->sendEvent(event); 
    772773  } 
    773    
    774    
     774 
     775 
    775776  bool CDomain::dispatchEvent(CEventServer& event) 
    776    { 
    777        
    778       if (SuperClass::dispatchEvent(event)) return true ; 
    779       else 
    780       { 
    781         switch(event.type) 
    782         { 
    783            case EVENT_ID_SERVER_ATTRIBUT : 
    784              recvServerAttribut(event) ; 
    785              return true ; 
    786              break ; 
    787            case EVENT_ID_LON_LAT : 
    788              recvLonLat(event) ; 
    789              return true ; 
    790              break ; 
    791            default : 
    792              ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
    793                     <<"Unknown Event") ; 
    794            return false ; 
    795          } 
    796       } 
    797    } 
    798     
     777  { 
     778    if (SuperClass::dispatchEvent(event)) return true; 
     779    else 
     780    { 
     781      switch(event.type) 
     782      { 
     783        case EVENT_ID_SERVER_ATTRIBUT: 
     784          recvServerAttribut(event); 
     785          return true; 
     786          break; 
     787        case EVENT_ID_LON_LAT: 
     788          recvLonLat(event); 
     789          return true; 
     790          break; 
     791        default: 
     792          ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
     793                << "Unknown Event"); 
     794          return false; 
     795      } 
     796    } 
     797  } 
     798 
    799799  void CDomain::recvServerAttribut(CEventServer& event) 
    800800  { 
     
    804804    get(domainId)->recvServerAttribut(*buffer) ; 
    805805  } 
    806    
     806 
    807807  void CDomain::recvServerAttribut(CBufferIn& buffer) 
    808808  { 
     
    811811 
    812812     buffer>>ni_srv>>ibegin_srv>>iend_srv>>nj_srv>>jbegin_srv>>jend_srv; 
    813       
    814      
     813 
     814 
    815815    zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; 
    816816    zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; 
    817817    zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; 
    818        
     818 
    819819    zoom_jbegin_srv = zoom_jbegin.getValue() > jbegin_srv ? zoom_jbegin.getValue() : jbegin_srv ; 
    820820    zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; 
    821821    zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; 
    822822 
    823     if (zoom_ni_srv<=0 || zoom_nj_srv<=0)  
     823    if (zoom_ni_srv<=0 || zoom_nj_srv<=0) 
    824824    { 
    825825      zoom_ibegin_srv=1 ; zoom_iend_srv=0 ; zoom_ni_srv=0 ; 
     
    830830    latvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 
    831831    latvalue_srv = 0. ; 
    832     if (hasBounds)  
     832    if (hasBounds) 
    833833    { 
    834834      bounds_lon_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; 
     
    838838    } 
    839839  } 
    840      
     840 
    841841  void CDomain::recvLonLat(CEventServer& event) 
    842842  { 
    843     list<CEventServer::SSubEvent>::iterator it ; 
    844     for (it=event.subEvents.begin();it!=event.subEvents.end();++it) 
     843    list<CEventServer::SSubEvent>::iterator it; 
     844    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    845845    { 
    846       CBufferIn* buffer=it->buffer; 
    847       string domainId ; 
    848       *buffer>>domainId ; 
    849       get(domainId)->recvLonLat(*buffer) ; 
     846      CBufferIn* buffer = it->buffer; 
     847      string domainId; 
     848      *buffer >> domainId; 
     849      get(domainId)->recvLonLat(it->rank, *buffer); 
    850850    } 
    851851  } 
    852    
    853   void CDomain::recvLonLat(CBufferIn& buffer) 
     852 
     853  void CDomain::recvLonLat(int rank, CBufferIn& buffer) 
    854854  { 
    855     CArray<int,1> indi ; 
    856     CArray<int,1> indj ; 
    857     CArray<double,1> lon ; 
    858     CArray<double,1> lat ; 
    859     CArray<double,2> boundslon ; 
    860     CArray<double,2> boundslat ; 
    861      
    862     int type_int ; 
    863     buffer>>type_int>>isCurvilinear>>indi>>indj>>lon>>lat ; 
    864     if (hasBounds) buffer>>boundslon>>boundslat ; 
    865     type.setValue((type_attr::t_enum)type_int) ; // probleme des type enum avec les buffers : ToFix 
    866  
    867     int i,j,ind_srv ; 
    868     for(int ind=0;ind<indi.numElements();ind++) 
     855    CArray<int,1>& indi = indiSrv[rank]; 
     856    CArray<int,1>& indj = indjSrv[rank]; 
     857    CArray<double,1> lon; 
     858    CArray<double,1> lat; 
     859    CArray<double,2> boundslon; 
     860    CArray<double,2> boundslat; 
     861 
     862    int type_int; 
     863    buffer >> type_int >> isCurvilinear >> indi >> indj >> lon >> lat; 
     864    if (hasBounds) buffer >> boundslon >> boundslat; 
     865    type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 
     866 
     867    int i, j, ind_srv; 
     868    for (int ind = 0; ind < indi.numElements(); ind++) 
    869869    { 
    870       i=indi(ind) ; j=indj(ind) ; 
    871       ind_srv=(i-(zoom_ibegin_srv-1))+(j-(zoom_jbegin_srv-1))*zoom_ni_srv ; 
    872       lonvalue_srv(ind_srv)=lon(ind) ; 
    873       latvalue_srv(ind_srv)=lat(ind) ; 
    874       if (hasBounds)  
    875       { 
    876         for(int nv=0;nv<nvertex;nv++)  
     870      i = indi(ind); j = indj(ind); 
     871      ind_srv = (i - (zoom_ibegin_srv - 1)) + (j - (zoom_jbegin_srv - 1)) * zoom_ni_srv; 
     872      lonvalue_srv(ind_srv) = lon(ind); 
     873      latvalue_srv(ind_srv) = lat(ind); 
     874      if (hasBounds) 
     875      { 
     876        for (int nv = 0; nv < nvertex; nv++) 
    877877        { 
    878           bounds_lon_srv(nv,ind_srv)=boundslon(nv,ind) ; 
    879           bounds_lat_srv(nv,ind_srv)=boundslat(nv,ind) ; 
     878          bounds_lon_srv(nv, ind_srv) = boundslon(nv, ind); 
     879          bounds_lat_srv(nv, ind_srv) = boundslat(nv, ind); 
    880880        } 
    881881      } 
     
    883883  } 
    884884   //---------------------------------------------------------------- 
    885     
    886     
    887     
     885 
     886 
     887 
    888888   ///--------------------------------------------------------------- 
    889889 
  • XIOS/branchs/xios-1.0/src/node/domain.hpp

    r501 r610  
    1515 
    1616namespace xios { 
    17     
     17 
    1818   /// ////////////////////// Déclarations ////////////////////// /// 
    1919 
     
    3939           EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_LON_LAT 
    4040         } ; 
    41           
     41 
    4242         /// typedef /// 
    4343         typedef CObjectTemplate<CDomain>   SuperClass; 
     
    6868         void checkDomainData(void); 
    6969         void checkCompression(void); 
    70           
     70 
    7171         void checkZoom(void); 
    7272         void checkBounds(void); 
     
    7474 
    7575      public : 
    76        
     76 
    7777         /// Autres /// 
    7878 
     
    8484         bool hasZoom(void) const; 
    8585         bool isEmpty(void) const; 
    86           
    87           
     86 
     87 
    8888         int ni_client,ibegin_client,iend_client ; 
    8989         int zoom_ni_client,zoom_ibegin_client,zoom_iend_client ; 
     
    100100         CArray<double, 1> lonvalue_srv, latvalue_srv ; 
    101101         CArray<double, 2> bounds_lon_srv, bounds_lat_srv ; 
    102           
    103           
    104         vector<int> connectedServer ; // list of connected server  
     102 
     103 
     104        vector<int> connectedServer ; // list of connected server 
    105105        vector<int> nbSenders ; // for each communication with a server, number of communicating client 
    106         vector<int> nbDataSrv ; // size of data to send to each server  
     106        vector<int> nbDataSrv ; // size of data to send to each server 
    107107        vector< vector<int> > i_indSrv ; // for each server, i global index to send 
    108108        vector< vector<int> > j_indSrv ; // for each server, j global index to send 
    109         
     109 
    110110        CArray<int,2> mapConnectedServer ;  // (ni,nj) => mapped to connected server number, -1 if no server is target 
    111                 
     111 
    112112//        vector<int> ib_srv, ie_srv, in_srv ; 
    113113//        vector<int> jb_srv, je_srv, jn_srv ; 
    114           
     114 
    115115      public : 
    116        
     116 
    117117         /// Mutateur /// 
    118118         void addRelFile(const StdString & filename); 
    119119         void completeLonLatClient(void); 
    120          void sendServerAttribut(void) ; 
    121          void sendLonLat(void) ; 
    122          void computeConnectedServer(void) ; 
    123          static bool dispatchEvent(CEventServer& event) ; 
    124          static void recvLonLat(CEventServer& event) ; 
    125          static void recvServerAttribut(CEventServer& event) ; 
    126          void recvLonLat(CBufferIn& buffer) ; 
    127          void recvServerAttribut(CBufferIn& buffer) ; 
    128           
     120         void sendServerAttribut(void); 
     121         void sendLonLat(void); 
     122         void computeConnectedServer(void); 
     123         static bool dispatchEvent(CEventServer& event); 
     124         static void recvServerAttribut(CEventServer& event); 
     125         static void recvLonLat(CEventServer& event); 
     126         void recvServerAttribut(CBufferIn& buffer); 
     127         void recvLonLat(int rank, CBufferIn& buffer); 
     128 
    129129         /// Destructeur /// 
    130130         virtual ~CDomain(void); 
     
    133133         static StdString GetName(void); 
    134134         static StdString GetDefName(void); 
    135           
     135 
    136136         static ENodeType GetType(void); 
    137137 
     
    144144         bool isChecked; 
    145145         std::set<StdString> relFiles; 
     146         std::map<int, CArray<int,1> > indiSrv, indjSrv; 
    146147 
    147148   }; // class CDomain 
Note: See TracChangeset for help on using the changeset viewer.