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/trunk/src/node/domain.cpp

    r610 r611  
    2424      : CObjectTemplate<CDomain>(), CDomainAttributes() 
    2525      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    26       , isDistributed_(false) 
     26      , hasBounds(false), hasArea(false), isDistributed_(false) 
    2727   { /* Ne rien faire de plus */ } 
    2828 
     
    3030      : CObjectTemplate<CDomain>(id), CDomainAttributes() 
    3131      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    32       , isDistributed_(false) 
     32      , hasBounds(false), hasArea(false), isDistributed_(false) 
    3333         { /* Ne rien faire de plus */ } 
    3434 
     
    119119          for(int j=0;j<nj;j++) mask(0,j)=mask_tmp(j,0) ; 
    120120         } 
     121 
     122         if (!area.isEmpty()) 
     123           area.transposeSelf(1, 0); 
     124 
    121125         ni=1 ; 
    122126         ibegin=0 ; 
     
    553557     { 
    554558       hasBounds=true ; 
    555  
    556559     } 
    557560     else 
     
    562565   } 
    563566 
     567   void CDomain::checkArea(void) 
     568   { 
     569     hasArea = !area.isEmpty(); 
     570     if (hasArea) 
     571     { 
     572       if (area.extent(0) != ni || area.extent(1) != nj) 
     573       { 
     574         ERROR("void CDomain::checkArea(void)", 
     575               "The area attribute must be of size ni x nj."); 
     576       } 
     577     } 
     578   } 
     579 
    564580   //---------------------------------------------------------------- 
    565581   // Divide function checkAttributes into 2 seperate ones 
     
    573589      this->checkZoom(); 
    574590      this->checkBounds(); 
     591      this->checkArea(); 
    575592 
    576593      if (context->hasClient) 
     
    601618     { 
    602619       sendServerAttribut() ; 
    603        sendLonLat() ; 
     620       sendLonLatArea() ; 
    604621     } 
    605622 
     
    615632      this->checkZoom(); 
    616633      this->checkBounds(); 
     634      this->checkArea(); 
    617635 
    618636      if (context->hasClient) 
     
    633651        computeConnectedServer() ; 
    634652        sendServerAttribut() ; 
    635         sendLonLat() ; 
     653        sendLonLatArea() ; 
    636654      } 
    637655 
     
    790808  } 
    791809 
    792   void CDomain::sendLonLat(void) 
     810  void CDomain::sendLonLatArea(void) 
    793811  { 
    794812    int ns, n, i, j, ind, nv, idx; 
     
    800818    CEventClient eventLon(getType(), EVENT_ID_LON); 
    801819    CEventClient eventLat(getType(), EVENT_ID_LAT); 
    802  
    803     list<CMessage> list_msgsIndex, list_msgsLon, list_msgsLat; 
     820    CEventClient eventArea(getType(), EVENT_ID_AREA); 
     821 
     822    list<CMessage> list_msgsIndex, list_msgsLon, list_msgsLat, list_msgsArea; 
    804823    list<CArray<int,1> > list_indi, list_indj; 
    805824    list<CArray<double,1> > list_lon, list_lat; 
    806825    list<CArray<double,2> > list_boundslon, list_boundslat; 
     826    list<CArray<double,1> > list_area; 
    807827 
    808828    std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     
    826846        list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
    827847      } 
     848      if (hasArea) 
     849        list_area.push_back(CArray<double,1>(nbData)); 
    828850 
    829851      CArray<int,1>& indi = list_indi.back(); 
     
    856878        indi(n) = ibegin + i_index(i - ibegin, j - jbegin); 
    857879        indj(n) = jbegin + j_index(i - ibegin, j - jbegin); 
     880 
     881        if (hasArea) 
     882          list_area.back()(n) = area(i - ibegin, j - jbegin); 
    858883      } 
    859884 
     
    879904      eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); 
    880905      eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); 
     906 
     907      if (hasArea) 
     908      { 
     909        list_msgsArea.push_back(CMessage()); 
     910        list_msgsArea.back() << this->getId() << list_area.back(); 
     911        eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 
     912      } 
    881913    } 
    882914 
     
    884916    client->sendEvent(eventLon); 
    885917    client->sendEvent(eventLat); 
     918    if (hasArea) 
     919      client->sendEvent(eventArea); 
    886920  } 
    887921 
     
    909943          return true; 
    910944          break; 
     945        case EVENT_ID_AREA: 
     946          recvArea(event); 
     947          return true; 
     948          break; 
    911949        default: 
    912950          ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
     
    956994      bounds_lat_srv = 0. ; 
    957995    } 
     996 
     997    if (hasArea) 
     998      area_srv.resize(zoom_ni_srv * zoom_nj_srv); 
    958999  } 
    9591000 
     
    10471088  } 
    10481089 
     1090  void CDomain::recvArea(CEventServer& event) 
     1091  { 
     1092    list<CEventServer::SSubEvent>::iterator it; 
     1093    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     1094    { 
     1095      CBufferIn* buffer = it->buffer; 
     1096      string domainId; 
     1097      *buffer >> domainId; 
     1098      get(domainId)->recvArea(it->rank, *buffer); 
     1099    } 
     1100  } 
     1101 
     1102  void CDomain::recvArea(int rank, CBufferIn& buffer) 
     1103  { 
     1104    CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 
     1105    CArray<double,1> clientArea; 
     1106 
     1107    buffer >> clientArea; 
     1108 
     1109    int i, j, ind_srv; 
     1110    for (int ind = 0; ind < indi.numElements(); ind++) 
     1111    { 
     1112      i = indi(ind); j = indj(ind); 
     1113      ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 
     1114      area_srv(ind_srv) = clientArea(ind); 
     1115    } 
     1116  } 
     1117 
    10491118   //---------------------------------------------------------------- 
    10501119 
Note: See TracChangeset for help on using the changeset viewer.