Ignore:
Timestamp:
05/12/20 11:52:13 (4 years ago)
Author:
ymipsl
Message:

XIOS coupling branch
Some updates.

First coupling test is beginning to work...

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp

    r1871 r1875  
    21012101  } 
    21022102 
     2103  void CDomain::sendDomainToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) 
     2104  { 
     2105    if (sendDomainToFileServer_done_.count(client)!=0) return ; 
     2106    else sendDomainToFileServer_done_.insert(client) ; 
     2107     
     2108    const string domainId = "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     2109     
     2110    if (!domain_ref.isEmpty()) 
     2111    { 
     2112      auto domain_ref_tmp=domain_ref.getValue() ; 
     2113      domain_ref.reset() ; // remove the reference, find an other way to do that more cleanly 
     2114      this->sendAllAttributesToServer(client, domainId)  ; 
     2115      domain_ref = domain_ref_tmp ; 
     2116    } 
     2117    else this->sendAllAttributesToServer(client, domainId)  ; 
     2118 
     2119    this->sendDistributionAttributes(client, domainId);    
     2120    this->sendIndex(client, domainId);        
     2121    this->sendLonLat(client, domainId); 
     2122    this->sendArea(client, domainId);     
     2123    this->sendDataIndex(client, domainId); 
     2124  } 
     2125 
     2126  void CDomain::makeAliasForCoupling(const string& fieldId, int posInGrid) 
     2127  { 
     2128    const string domainId = "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     2129    this->createAlias(domainId) ; 
     2130  } 
     2131 
    21032132  /*! 
    21042133    Send all attributes from client to connected clients 
     
    21192148    Send global index from client to connected client(s) 
    21202149  */ 
    2121   void CDomain::sendIndex(CContextClient* client) 
     2150  void CDomain::sendIndex(CContextClient* client, const string& domainId) 
    21222151  TRY 
    21232152  { 
     2153    string serverDomainId = domainId.empty() ? this->getId() : domainId ; 
     2154     
    21242155    int ns, n, i, j, ind, nv, idx; 
    2125     
    21262156    int serverSize = client->serverSize; 
    21272157    CEventClient eventIndex(getType(), EVENT_ID_INDEX); 
     
    21462176 
    21472177      list_msgsIndex.push_back(CMessage()); 
    2148       list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
     2178      list_msgsIndex.back() << serverDomainId << (int)type; // enum ne fonctionne pour les message => ToFix 
    21492179      list_msgsIndex.back() << isCurvilinear; 
    21502180      list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); 
     
    21612191    it calculates this distribution then sends it to the corresponding clients on the next level 
    21622192  */ 
    2163   void CDomain::sendDistributionAttributes(CContextClient* client) 
     2193  void CDomain::sendDistributionAttributes(CContextClient* client, const string& domainId) 
    21642194  TRY 
    21652195  { 
     2196    string serverDomainId = domainId.empty() ? this->getId() : domainId ; 
     2197 
    21662198    int nbServer = client->serverSize; 
    21672199    std::vector<int> nGlobDomain(2); 
     
    21922224        msgs.push_back(CMessage()); 
    21932225        CMessage& msg = msgs.back(); 
    2194         msg << this->getId() ; 
     2226        msg << serverDomainId ; 
    21952227        msg << isUnstructed_; 
    21962228        msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; 
     
    22092241    Send area from client to connected client(s) 
    22102242  */ 
    2211   void CDomain::sendArea(CContextClient* client) 
     2243  void CDomain::sendArea(CContextClient* client, const string& domainId) 
    22122244  TRY 
    22132245  { 
    22142246    if (!hasArea) return; 
    2215  
     2247    string serverDomainId = domainId.empty() ? this->getId() : domainId ; 
     2248     
    22162249    int ns, n, i, j, ind, nv, idx; 
    22172250    int serverSize = client->serverSize; 
     
    22422275 
    22432276      list_msgsArea.push_back(CMessage()); 
    2244       list_msgsArea.back() << this->getId() << hasArea; 
     2277      list_msgsArea.back() <<serverDomainId << hasArea; 
    22452278      list_msgsArea.back() << list_area.back(); 
    22462279      eventArea.push(rank, nbSenders[serverSize][rank], list_msgsArea.back()); 
     
    22552288    Because longitude and latitude are optional, this function only called if latitude and longitude exist 
    22562289  */ 
    2257   void CDomain::sendLonLat(CContextClient* client) 
     2290  void CDomain::sendLonLat(CContextClient* client, const string& domainId) 
    22582291  TRY 
    22592292  { 
    22602293    if (!hasLonLat) return; 
    2261  
     2294    string serverDomainId = domainId.empty() ? this->getId() : domainId ; 
     2295     
    22622296    int ns, n, i, j, ind, nv, idx; 
    22632297    int serverSize = client->serverSize; 
     
    23162350      list_msgsLat.push_back(CMessage()); 
    23172351 
    2318       list_msgsLon.back() << this->getId() << hasLonLat; 
     2352      list_msgsLon.back() << serverDomainId << hasLonLat; 
    23192353      if (hasLonLat)  
    23202354        list_msgsLon.back() << list_lon.back(); 
     
    23252359      } 
    23262360 
    2327       list_msgsLat.back() << this->getId() << hasLonLat; 
     2361      list_msgsLat.back() << serverDomainId << hasLonLat; 
    23282362      if (hasLonLat) 
    23292363        list_msgsLat.back() << list_lat.back(); 
     
    23482382    The compressed index are represented with 1 and others are represented with -1 
    23492383  */ 
    2350   void CDomain::sendDataIndex(CContextClient* client) 
     2384  void CDomain::sendDataIndex(CContextClient* client, const string& domainId) 
    23512385  TRY 
    23522386  { 
     2387    string serverDomainId = domainId.empty() ? this->getId() : domainId ; 
     2388     
    23532389    int ns, n, i, j, ind, nv, idx; 
    23542390    int serverSize = client->serverSize; 
     
    24062442 
    24072443      list_msgsDataIndex.push_back(CMessage()); 
    2408       list_msgsDataIndex.back() << this->getId(); 
     2444      list_msgsDataIndex.back() << serverDomainId ; 
    24092445      list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 
    24102446      eventDataIndex.push(rank, nbSenders[serverSize][rank], list_msgsDataIndex.back()); 
     
    26142650           << "The number of sending clients is not correct." 
    26152651           << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
    2616  
     2652     
     2653    int nbLonInd = 0; 
    26172654    vector<CArray<double,1> > recvLonValue(nbReceived); 
    26182655    vector<CArray<double,2> > recvBoundsLonValue(nbReceived);     
     
    26312668    if (hasLonLat) 
    26322669    { 
    2633       int nbLonInd = 0; 
    26342670      for (i = 0; i < nbReceived; ++i) 
    26352671      { 
     
    26652701        } 
    26662702      }        
     2703    } 
     2704 
     2705   // setup attribute depending the type of domain 
     2706    if (hasLonLat) 
     2707    { 
     2708      nbLonInd = globalLocalIndexMap_.size(); 
     2709      if (ni*nj != nbLonInd) 
     2710        ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", 
     2711             << "The number of index received is not coherent with the given resolution" 
     2712             << "nbLonInd=" << nbLonInd << ", ni=" << ni <<", nj"<<ni<<" ni*nj="<<ni*nj); 
     2713 
     2714      if (type == type_attr::rectilinear || type == type_attr::curvilinear) 
     2715      { 
     2716        lonvalue_2d.resize(ni,nj); 
     2717          for(int ij=0, j=0 ; j<nj ; j++) 
     2718            for(int i=0 ; i<ni; i++, ij++) lonvalue_2d(i,j) = lonvalue(ij) ; 
     2719         
     2720        if (hasBounds) 
     2721        { 
     2722          bounds_lon_2d.resize(nvertex, ni, nj) ; 
     2723          for(int ij=0, j=0 ; j<nj ; j++) 
     2724            for(int i=0 ; i<ni; i++, ij++)  
     2725              for(int nv=0; nv<nvertex; nv++) bounds_lon_2d(nv,i,j) = bounds_lonvalue(nv,ij) ; 
     2726        } 
     2727      } 
     2728    } 
     2729    else if (type == type_attr::unstructured || type == type_attr::gaussian) 
     2730    { 
     2731      lonvalue_1d.resize(nbLonInd); 
     2732      lonvalue_1d = lonvalue ; 
     2733      if (hasBounds) 
     2734      { 
     2735        bounds_lon_1d.resize(nvertex, nbLonInd) ; 
     2736        bounds_lon_1d = bounds_lonvalue ; 
     2737      } 
    26672738    } 
    26682739  } 
     
    27172788    } 
    27182789 
     2790    int nbLatInd = 0; 
    27192791    if (hasLonLat) 
    27202792    { 
    2721       int nbLatInd = 0; 
    27222793      for (i = 0; i < nbReceived; ++i) 
    27232794      { 
     
    27562827      }        
    27572828    } 
     2829      // setup attribute depending the type of domain 
     2830    if (hasLonLat) 
     2831    { 
     2832      nbLatInd = globalLocalIndexMap_.size(); 
     2833       
     2834      if (ni*nj != nbLatInd) 
     2835        ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 
     2836             << "The number of index received is not coherent with the given resolution" 
     2837            << "nbLonInd=" << nbLatInd << ", ni=" << ni <<", nj"<<ni<<" ni*nj="<<ni*nj); 
     2838 
     2839      if (type == type_attr::rectilinear || type == type_attr::curvilinear) 
     2840      { 
     2841        { 
     2842          latvalue_2d.resize(ni,nj); 
     2843          for(int ij=0, j=0 ; j<nj ; j++) 
     2844            for(int i=0 ; i<ni; i++, ij++) latvalue_2d(i,j) = latvalue(ij) ; 
     2845         
     2846          if (hasBounds) 
     2847          { 
     2848            bounds_lat_2d.resize(nvertex, ni, nj) ; 
     2849            for(int ij=0, j=0 ; j<nj ; j++) 
     2850              for(int i=0 ; i<ni; i++, ij++)  
     2851                for(int nv=0; nv<nvertex; nv++) bounds_lat_2d(nv,i,j) = bounds_latvalue(nv,ij) ; 
     2852          } 
     2853        } 
     2854      } 
     2855      else if (type == type_attr::unstructured || type == type_attr::gaussian) 
     2856      { 
     2857        if (hasLonLat) 
     2858        { 
     2859          latvalue_1d.resize(nbLatInd); 
     2860          latvalue_1d = latvalue ; 
     2861          if (hasBounds) 
     2862          { 
     2863            bounds_lat_1d.resize(nvertex, nbLatInd) ; 
     2864            bounds_lon_1d = bounds_lonvalue ; 
     2865          } 
     2866        } 
     2867      } 
     2868    }  
    27582869  } 
    27592870  CATCH_DUMP_ATTR 
     
    30163127  } 
    30173128  CATCH_DUMP_ATTR 
    3018  
    3019   /*! 
    3020   \brief Check if a domain is completed 
    3021   Before make any domain processing, we must be sure that all domain informations have 
    3022   been sent, for exemple when reading a grid in a file or when grid elements are sent by an 
    3023   other context (coupling). So all direct reference of the domain (domain_ref) must be also completed 
    3024   \return true if domain and domain reference are completed 
    3025   */ 
    3026   bool CDomain::checkIfCompleted(void) 
    3027   { 
    3028     if (hasDirectDomainReference()) if (!getDirectDomainReference()->checkIfCompleted()) return false; 
    3029     return isCompleted_ ; 
    3030   } 
    3031  
    3032   /*! 
    3033   \brief Set a domain as completed 
    3034    When all information about a domain have been received, the domain is tagged as completed and is 
    3035    suitable for processing 
    3036   */ 
    3037   void CDomain::setCompleted(void) 
    3038   { 
    3039     if (hasDirectDomainReference()) getDirectDomainReference()->setCompleted() ; 
    3040     isCompleted_=true ; 
    3041   } 
    3042  
    3043   /*! 
    3044   \brief Set a domain as uncompleted 
    3045    When informations about a domain are expected from a grid reading from file or coupling, the domain is  
    3046    tagged as uncompleted and is not suitable for processing 
    3047   */ 
    3048   void CDomain::setUncompleted(void) 
    3049   { 
    3050     if (hasDirectDomainReference()) getDirectDomainReference()->setUncompleted() ; 
    3051     isCompleted_=false ; 
    3052   } 
    3053    
     3129     
    30543130  /*! 
    30553131   * Go through the hierarchy to find the domain from which the transformations must be inherited 
Note: See TracChangeset for help on using the changeset viewer.