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

Improve CF compliance: Add a new domain attribute "area".

Fixes ticket #68.

File:
1 edited

Legend:

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

    r610 r611  
    2121   CDomain::CDomain(void) 
    2222      : CObjectTemplate<CDomain>(), CDomainAttributes() 
    23       , isChecked(false), relFiles() 
     23      , isChecked(false), hasBounds(false), hasArea(false), relFiles() 
    2424   { /* Ne rien faire de plus */ } 
    2525 
    2626   CDomain::CDomain(const StdString & id) 
    2727      : CObjectTemplate<CDomain>(id), CDomainAttributes() 
    28       , isChecked(false), relFiles() 
     28      , isChecked(false), hasBounds(false), hasArea(false), relFiles() 
    2929         { /* Ne rien faire de plus */ } 
    3030 
     
    108108          for(int j=0;j<nj;j++) mask(0,j)=mask_tmp(j,0) ; 
    109109         } 
     110 
     111         if (!area.isEmpty()) 
     112           area.transposeSelf(1, 0); 
     113 
    110114         ni=1 ; 
    111115         ibegin=1 ; 
     
    533537   } 
    534538 
     539   void CDomain::checkArea(void) 
     540   { 
     541     hasArea = !area.isEmpty(); 
     542     if (hasArea) 
     543     { 
     544       if (area.extent(0) != ni || area.extent(1) != nj) 
     545       { 
     546         ERROR("void CDomain::checkArea(void)", 
     547               "The area attribute must be of size ni x nj."); 
     548       } 
     549     } 
     550   } 
     551 
    535552   //---------------------------------------------------------------- 
    536553 
     
    543560      this->checkZoom(); 
    544561      this->checkBounds(); 
     562      this->checkArea(); 
    545563 
    546564      if (context->hasClient) 
     
    561579        computeConnectedServer() ; 
    562580        sendServerAttribut() ; 
    563         sendLonLat() ; 
     581        sendLonLatArea(); 
    564582      } 
    565583 
     
    701719 
    702720 
    703   void CDomain::sendLonLat(void) 
     721  void CDomain::sendLonLatArea(void) 
    704722  { 
    705723    int ns,n,i,j,ind,nv; 
     
    709727    // send lon lat for each connected server 
    710728    CEventClient event(getType(), EVENT_ID_LON_LAT); 
     729    CEventClient eventArea(getType(), EVENT_ID_AREA); 
    711730 
    712731    list<CMessage> list_msg; 
     732    list<CMessage> list_msgArea; 
    713733    list<CArray<int,1> > list_indi,list_indj; 
    714734    list<CArray<double,1> >list_lon,list_lat; 
    715735    list<CArray<double,2> >list_boundslon,list_boundslat; 
     736    list<CArray<double,1> > list_area; 
    716737 
    717738    for (int ns = 0; ns < connectedServer.size(); ns++) 
     
    729750        list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
    730751      } 
     752      if (hasArea) 
     753        list_area.push_back(CArray<double,1>(nbData)); 
    731754 
    732755      CArray<int,1>& indi = list_indi.back(); 
     
    758781        indi(n) = ibegin + i_index(i - ibegin + 1, j - jbegin + 1) - 1; 
    759782        indj(n) = jbegin + j_index(i - ibegin + 1, j - jbegin + 1) - 1; 
     783 
     784        if (hasArea) 
     785          list_area.back()(n) = area(i - ibegin + 1, j - jbegin + 1); 
    760786      } 
    761787 
     
    768794         
    769795      event.push(connectedServer[ns], nbSenders[ns], list_msg.back()); 
     796 
     797      if (hasArea) 
     798      { 
     799        list_msgArea.push_back(CMessage()); 
     800        list_msgArea.back() << this->getId() << list_area.back(); 
     801        eventArea.push(connectedServer[ns], nbSenders[ns], list_msgArea.back()); 
     802      } 
    770803    } 
    771804 
    772805    client->sendEvent(event); 
     806    if (hasArea) 
     807      client->sendEvent(eventArea); 
    773808  } 
    774809 
     
    787822        case EVENT_ID_LON_LAT: 
    788823          recvLonLat(event); 
     824          return true; 
     825          break; 
     826        case EVENT_ID_AREA: 
     827          recvArea(event); 
    789828          return true; 
    790829          break; 
     
    837876      bounds_lat_srv = 0. ; 
    838877    } 
     878 
     879    if (hasArea) 
     880      area_srv.resize(zoom_ni_srv * zoom_nj_srv); 
    839881  } 
    840882 
     
    882924    } 
    883925  } 
    884    //---------------------------------------------------------------- 
    885  
    886  
    887  
    888    ///--------------------------------------------------------------- 
    889  
     926 
     927  void CDomain::recvArea(CEventServer& event) 
     928  { 
     929    list<CEventServer::SSubEvent>::iterator it; 
     930    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     931    { 
     932      CBufferIn* buffer = it->buffer; 
     933      string domainId; 
     934      *buffer >> domainId; 
     935      get(domainId)->recvArea(it->rank, *buffer); 
     936    } 
     937  } 
     938 
     939  void CDomain::recvArea(int rank, CBufferIn& buffer) 
     940  { 
     941    CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 
     942    CArray<double,1> clientArea; 
     943 
     944    buffer >> clientArea; 
     945 
     946    int i, j, ind_srv; 
     947    for (int ind = 0; ind < indi.numElements(); ind++) 
     948    { 
     949      i = indi(ind); j = indj(ind); 
     950      ind_srv = (i - (zoom_ibegin_srv - 1)) + (j - (zoom_jbegin_srv - 1)) * zoom_ni_srv; 
     951      area_srv(ind_srv) = clientArea(ind); 
     952    } 
     953  } 
    890954} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.