Ignore:
Timestamp:
08/24/15 14:53:23 (9 years ago)
Author:
mhnguyen
Message:

Changing longitude and latitude (as well as their bounds) be optional

+) Seperate sendIndex, sendLonLat and sendArea

Test
+) On Curie
+) test_client and test_complete are correct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/domain.cpp

    r664 r665  
    2828      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) 
    2929      , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 
    30       , isClientAfterTransformationChecked(false) 
     30      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    3131      , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
    3232   { /* Ne rien faire de plus */ } 
     
    3737      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) 
    3838      , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 
    39       , isClientAfterTransformationChecked(false) 
     39      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    4040      , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
    4141   { /* Ne rien faire de plus */ } 
     
    574574 
    575575   //---------------------------------------------------------------- 
    576  
    577576   void CDomain::completeLonLatClient(void) 
    578577   { 
    579578     completeLonClient(); 
    580579     completeLatClient(); 
    581 //      int i,j,k ; 
    582 //      CArray<double,1> lonvalue_temp(ni*nj) ; 
    583 //      CArray<double,1> latvalue_temp(ni*nj) ; 
    584 //      CArray<double,2> bounds_lon_temp(nvertex,ni*nj); 
    585 //      CArray<double,2> bounds_lat_temp(nvertex,ni*nj); 
    586 // 
    587 //      if (type.isEmpty()) 
    588 //      { 
    589 //        if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) 
    590 //        { 
    591 //          type.setValue(type_attr::curvilinear) ; 
    592 //          isCurvilinear=true ; 
    593 //        } 
    594 //        else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) 
    595 //        { 
    596 //          type.setValue(type_attr::regular) ; 
    597 //          isCurvilinear=false ; 
    598 //        } 
    599 //        else ERROR("void CDomain::completeLonLatClient(void)",<<"the grid is nor curvilinear, nor cartesian, because the size of longitude and latitude array is not coherent with the domain size"<<endl 
    600 //                                                              <<"lonvalue size = " << lonvalue.numElements() << "different of ni or ni*nj"<<endl 
    601 //                                                              <<"latvalue size = " << latvalue.numElements() << "different of nj or ni*nj" ) ; 
    602 //      } 
    603 //      if (type==type_attr::curvilinear || type==type_attr::unstructured) 
    604 //      { 
    605 //        lonvalue_temp=lonvalue ; 
    606 //        latvalue_temp=latvalue ; 
    607 //        if (hasBounds) bounds_lon_temp=bounds_lon ; 
    608 //        if (hasBounds) bounds_lat_temp=bounds_lat ; 
    609 //      }checkBounds 
    610 //      else 
    611 //      { 
    612 //        for(j=0;j<nj;j++) 
    613 //          for(i=0;i<ni;i++) 
    614 //          { 
    615 //            k=j*ni+i ; 
    616 //            lonvalue_temp(k)=lonvalue(i) ; 
    617 //            latvalue_temp(k)=latvalue(j) ; 
    618 //            if (hasBounds) 
    619 //            { 
    620 //              for(int n=0;n<nvertex;n++) 
    621 //              { 
    622 //                bounds_lon_temp(n,k)=bounds_lon(n,i) ; 
    623 //                bounds_lat_temp(n,k)=bounds_lat(n,j) ; 
    624 //              } 
    625 //            } 
    626 //          } 
    627 //      } 
    628 // 
    629 //      StdSize dm = zoom_ni_client * zoom_nj_client; 
    630 // 
    631 //      // Make sure that this attribute is non-empty for every client. 
    632 //      if (0 != dm) 
    633 //      { 
    634 //        lonvalue.resize(dm); 
    635 //        latvalue.resize(dm); 
    636 //      } 
    637 // 
    638 // 
    639 //      for (int i = 0; i < zoom_ni_client; i++) 
    640 //      { 
    641 //        for (int j = 0; j < zoom_nj_client; j++) 
    642 //        { 
    643 //          lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
    644 //          latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); 
    645 //          if (hasBounds) 
    646 //          { 
    647 //            for(int n=0;n<nvertex;n++) 
    648 //            { 
    649 //              bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
    650 //              bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); 
    651 //            } 
    652 //          } 
    653 //        } 
    654 //      } 
    655     } 
     580   } 
    656581 
    657582 
    658583   //---------------------------------------------------------------- 
    659  
    660584   void CDomain::checkZoom(void) 
    661585   { 
     
    763687   } 
    764688 
     689   void CDomain::checkLonLat() 
     690   { 
     691     hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || 
     692                 (!latvalue_2d.isEmpty() && !lonvalue_2d.isEmpty()); 
     693   } 
     694 
    765695   void CDomain::checkAttributesOnClientAfterTransformation() 
    766696   { 
     
    772702     { 
    773703       this->checkMask(); 
    774        this->computeConnectedServer(); 
    775        this->completeLonLatClient(); 
     704       if (hasLonLat || hasArea) this->computeConnectedServer(); 
     705       if (hasLonLat) this->completeLonLatClient(); 
    776706     } 
    777707 
     
    790720      this->checkBounds(); 
    791721      this->checkArea(); 
     722      this->checkLonLat(); 
    792723 
    793724      if (context->hasClient) 
     
    815746     if (context->hasClient) 
    816747     { 
    817        sendServerAttribut() ; 
    818        sendLonLatArea() ; 
     748       sendServerAttribut(); 
     749       if (hasLonLat || hasArea) sendLonLatArea(); 
    819750     } 
    820751 
     
    829760      this->checkDomain(); 
    830761      this->checkZoom(); 
     762      this->checkLonLat(); 
    831763      this->checkBounds(); 
    832764      this->checkArea(); 
     
    1015947  } 
    1016948 
    1017   void CDomain::sendLonLatArea(void) 
     949  void CDomain::sendIndex() 
    1018950  { 
    1019951    int ns, n, i, j, ind, nv, idx; 
     
    1021953    CContextClient* client=context->client; 
    1022954 
    1023     // send lon lat for each connected server 
    1024955    CEventClient eventIndex(getType(), EVENT_ID_INDEX); 
    1025     CEventClient eventLon(getType(), EVENT_ID_LON); 
    1026     CEventClient eventLat(getType(), EVENT_ID_LAT); 
    1027     CEventClient eventArea(getType(), EVENT_ID_AREA); 
    1028  
    1029     list<CMessage> list_msgsIndex, list_msgsLon, list_msgsLat, list_msgsArea; 
     956 
     957    list<CMessage> list_msgsIndex; 
    1030958    list<CArray<int,1> > list_indi, list_indj; 
    1031     list<CArray<double,1> > list_lon, list_lat; 
    1032     list<CArray<double,2> > list_boundslon, list_boundslat; 
    1033     list<CArray<double,1> > list_area; 
    1034959 
    1035960    std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     
    1045970      list_indi.push_back(CArray<int,1>(nbData)); 
    1046971      list_indj.push_back(CArray<int,1>(nbData)); 
     972 
     973      CArray<int,1>& indi = list_indi.back(); 
     974      CArray<int,1>& indj = list_indj.back(); 
     975      const std::vector<size_t>& temp = it->second; 
     976      for (n = 0; n < nbData; ++n) 
     977      { 
     978        idx = static_cast<int>(it->second[n]); 
     979        indi(n) = i_index(idx); 
     980        indj(n) = j_index(idx); 
     981      } 
     982 
     983      list_msgsIndex.push_back(CMessage()); 
     984 
     985      list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
     986      list_msgsIndex.back() << isCurvilinear; 
     987      list_msgsIndex.back() << list_indi.back() << list_indj.back(); 
     988 
     989      eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
     990    } 
     991 
     992    client->sendEvent(eventIndex); 
     993  } 
     994 
     995  void CDomain::sendArea() 
     996  { 
     997    if (!hasArea) return; 
     998 
     999    int ns, n, i, j, ind, nv, idx; 
     1000    CContext* context = CContext::getCurrent(); 
     1001    CContextClient* client=context->client; 
     1002 
     1003    // send area for each connected server 
     1004    CEventClient eventArea(getType(), EVENT_ID_AREA); 
     1005 
     1006    list<CMessage> list_msgsArea; 
     1007    list<CArray<double,1> > list_area; 
     1008 
     1009    std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     1010    iteMap = indSrv_.end(); 
     1011    for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1012    { 
     1013      int nbData = 0; 
     1014      int rank = connectedServerRank_[k]; 
     1015      it = indSrv_.find(rank); 
     1016      if (iteMap != it) 
     1017        nbData = it->second.size(); 
     1018      list_area.push_back(CArray<double,1>(nbData)); 
     1019 
     1020      const std::vector<size_t>& temp = it->second; 
     1021      for (n = 0; n < nbData; ++n) 
     1022      { 
     1023        idx = static_cast<int>(it->second[n]); 
     1024        i = i_index(idx); 
     1025        j = j_index(idx); 
     1026        if (hasArea) 
     1027          list_area.back()(n) = area(i - ibegin, j - jbegin); 
     1028      } 
     1029 
     1030      list_msgsArea.push_back(CMessage()); 
     1031      list_msgsArea.back() << this->getId() << list_area.back(); 
     1032      eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 
     1033    } 
     1034    client->sendEvent(eventArea); 
     1035  } 
     1036 
     1037  void CDomain::sendLonLat() 
     1038  { 
     1039    if (!hasLonLat) return; 
     1040 
     1041    int ns, n, i, j, ind, nv, idx; 
     1042    CContext* context = CContext::getCurrent(); 
     1043    CContextClient* client=context->client; 
     1044 
     1045    // send lon lat for each connected server 
     1046    CEventClient eventLon(getType(), EVENT_ID_LON); 
     1047    CEventClient eventLat(getType(), EVENT_ID_LAT); 
     1048 
     1049    list<CMessage> list_msgsLon, list_msgsLat; 
     1050    list<CArray<double,1> > list_lon, list_lat; 
     1051    list<CArray<double,2> > list_boundslon, list_boundslat; 
     1052 
     1053    std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     1054    iteMap = indSrv_.end(); 
     1055    for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1056    { 
     1057      int nbData = 0; 
     1058      int rank = connectedServerRank_[k]; 
     1059      it = indSrv_.find(rank); 
     1060      if (iteMap != it) 
     1061        nbData = it->second.size(); 
     1062 
    10471063      list_lon.push_back(CArray<double,1>(nbData)); 
    10481064      list_lat.push_back(CArray<double,1>(nbData)); 
     
    10531069        list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
    10541070      } 
    1055       if (hasArea) 
    1056         list_area.push_back(CArray<double,1>(nbData)); 
    1057  
    1058       CArray<int,1>& indi = list_indi.back(); 
    1059       CArray<int,1>& indj = list_indj.back(); 
     1071 
    10601072      CArray<double,1>& lon = list_lon.back(); 
    10611073      CArray<double,1>& lat = list_lat.back(); 
     
    10821094          } 
    10831095        } 
    1084  
    1085         indi(n) = i; 
    1086         indj(n) = j; 
    1087  
    1088         if (hasArea) 
    1089           list_area.back()(n) = area(i - ibegin, j - jbegin); 
    1090       } 
    1091  
    1092       list_msgsIndex.push_back(CMessage()); 
    1093  
    1094       list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
    1095       list_msgsIndex.back() << isCurvilinear; 
    1096       list_msgsIndex.back() << list_indi.back() << list_indj.back(); 
     1096      } 
    10971097 
    10981098      list_msgsLon.push_back(CMessage()); 
     
    11081108      } 
    11091109 
    1110       eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
    11111110      eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); 
    11121111      eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); 
    1113  
    1114       if (hasArea) 
    1115       { 
    1116         list_msgsArea.push_back(CMessage()); 
    1117         list_msgsArea.back() << this->getId() << list_area.back(); 
    1118         eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 
    1119       } 
    1120     } 
    1121  
    1122     client->sendEvent(eventIndex); 
     1112    } 
     1113 
    11231114    client->sendEvent(eventLon); 
    11241115    client->sendEvent(eventLat); 
    1125     if (hasArea) 
    1126       client->sendEvent(eventArea); 
     1116  } 
     1117 
     1118 
     1119  void CDomain::sendLonLatArea(void) 
     1120  { 
     1121    sendIndex(); 
     1122    sendLonLat(); 
     1123    sendArea(); 
    11271124  } 
    11281125 
Note: See TracChangeset for help on using the changeset viewer.