Changeset 1878


Ignore:
Timestamp:
05/13/20 23:15:06 (3 months ago)
Author:
ymipsl
Message:

Coupling Branch.
Implementing a coupler scheduler, to impose order for intercommunicator creation between several coupling context.
Two way coupling is now working.

YM

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src
Files:
2 added
6 edited

Legend:

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

    r1765 r1878  
    5555  CServicesManager*   CXios::servicesManager_=nullptr ; 
    5656  CContextsManager*   CXios::contextsManager_=nullptr ; 
     57  CCouplerManager*    CXios::couplerManager_=nullptr ; 
    5758 
    5859  //! Parse configuration file and create some objects from it 
     
    221222  } 
    222223 
     224  void CXios::launchCouplerManager(bool isXiosServer) 
     225  { 
     226    couplerManager_ = new CCouplerManager(isXiosServer) ; 
     227  } 
     228 
    223229  void CXios::launchServicesManager(bool isXiosServer) 
    224230  { 
     
    240246  { 
    241247    delete ressourcesManager_; 
     248  } 
     249 
     250  void CXios::finalizeCouplerManager() 
     251  { 
     252    delete couplerManager_; 
    242253  } 
    243254 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.hpp

    r1764 r1878  
    99#include "contexts_manager.hpp" 
    1010#include "daemons_manager.hpp" 
     11#include "coupler_manager.hpp" 
    1112 
    1213namespace xios 
     
    6869 
    6970     static CRessourcesManager* ressourcesManager_ ; 
     71     static CCouplerManager* couplerManager_ ; 
    7072     static CServicesManager* servicesManager_ ; 
    7173     static CContextsManager* contextsManager_ ; 
     
    9092     static void launchDaemonsManager(bool isXiosServer) ; 
    9193     static void launchRessourcesManager(bool isXiosServer) ; 
    92       
     94     static void launchCouplerManager(bool isXiosServer) ; 
     95     
    9396     static void finalizeServicesManager() ; 
    9497     static void finalizeContextsManager() ; 
    9598     static void finalizeDaemonsManager() ; 
    9699     static void finalizeRessourcesManager() ; 
     100     static void finalizeCouplerManager() ; 
    97101 
    98102     static CRessourcesManager* getRessourcesManager(void) { return ressourcesManager_ ;} 
     103     static CCouplerManager*    getCouplerManager(void) { return couplerManager_ ;} 
    99104     static CServicesManager*   getServicesManager(void) { return servicesManager_ ;} 
    100105     static CContextsManager*   getContextsManager(void) { return contextsManager_ ;} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/manager/daemons_manager.cpp

    r1764 r1878  
    2222    CXios::launchServicesManager(isXiosServer) ; 
    2323    CXios::launchContextsManager(isXiosServer) ; 
     24    CXios::launchCouplerManager(isXiosServer) ; 
     25 
    2426    if (isXiosServer) CServer::launchServersRessource(splitComm) ; 
    2527    MPI_Comm_free(&splitComm) ; 
     
    2931  { 
    3032    CXios::finalizeContextsManager() ; 
     33    CXios::finalizeCouplerManager() ; 
    3134    CXios::finalizeServicesManager() ; 
    3235    CXios::finalizeRessourcesManager() ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp

    r1875 r1878  
    24462446   TRY 
    24472447   { 
    2448       // juste for test now, in future need an scheduler to avoid dead-lock 
    2449       for(auto it=enabledCouplerOut.begin();it!=enabledCouplerOut.end();++it) 
    2450       { 
    2451         (*it)->createInterCommunicator() ; 
    2452       } 
    2453  
    2454       for(auto it=enabledCouplerIn.begin();it!=enabledCouplerIn.end();++it) 
    2455       { 
    2456         (*it)->createInterCommunicator() ; 
    2457       } 
     2448      int rank=this->getIntraCommRank() ; 
     2449      map<string,list<CCouplerOut*>> listCouplerOut ;   
     2450      map<string,list<CCouplerIn*>> listCouplerIn ;   
     2451 
     2452      for(auto couplerOut : enabledCouplerOut) listCouplerOut[couplerOut->getCouplingContextId()].push_back(couplerOut) ; 
     2453      for(auto couplerIn : enabledCouplerIn) listCouplerIn[couplerIn->getCouplingContextId()].push_back(couplerIn) ; 
     2454 
     2455      CCouplerManager* couplerManager = CXios::getCouplerManager() ; 
     2456      if (rank==0) 
     2457      { 
     2458        for(auto couplerOut : listCouplerOut) couplerManager->registerCoupling(this->getContextId(),couplerOut.first) ; 
     2459        for(auto couplerIn : listCouplerIn) couplerManager->registerCoupling(couplerIn.first,this->getContextId()) ; 
     2460      } 
     2461 
     2462      do 
     2463      { 
     2464        for(auto couplerOut : listCouplerOut)  
     2465        { 
     2466          bool isNextCoupling ; 
     2467          if (rank==0) isNextCoupling = couplerManager->isNextCoupling(this->getContextId(),couplerOut.first) ; 
     2468          MPI_Bcast(&isNextCoupling,1,MPI_C_BOOL, 0, getIntraComm()) ;  
     2469          if (isNextCoupling)  
     2470          { 
     2471            addCouplingChanel(couplerOut.first, true) ; 
     2472            listCouplerOut.erase(couplerOut.first) ; 
     2473            break ; 
     2474          }             
     2475        } 
     2476        for(auto couplerIn : listCouplerIn)  
     2477        { 
     2478          bool isNextCoupling ; 
     2479          if (rank==0) isNextCoupling = couplerManager->isNextCoupling(couplerIn.first,this->getContextId()); 
     2480          MPI_Bcast(&isNextCoupling,1,MPI_C_BOOL, 0, getIntraComm()) ;  
     2481          if (isNextCoupling)  
     2482          { 
     2483            addCouplingChanel(couplerIn.first, false) ; 
     2484            listCouplerIn.erase(couplerIn.first) ; 
     2485            break ; 
     2486          }            
     2487        } 
     2488 
     2489      } while (!listCouplerOut.empty() || !listCouplerIn.empty()) ; 
     2490 
    24582491   } 
    24592492   CATCH_DUMP_ATTR 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp

    r1875 r1878  
    28622862          { 
    28632863            bounds_lat_1d.resize(nvertex, nbLatInd) ; 
    2864             bounds_lon_1d = bounds_lonvalue ; 
     2864            bounds_lat_1d = bounds_latvalue ; 
    28652865          } 
    28662866        } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r1875 r1878  
    580580      // for coupling, it would be after the first freq_op, because for now we don't have 
    581581      // restart mecanism to send the value at ts=0. It mus be changed in future 
    582       lastDataReceivedFromServer = context->getCalendar()->getInitDate()+freq_op; 
     582      lastDataReceivedFromServer = context->getCalendar()->getInitDate(); 
    583583      wasDataAlreadyReceivedFromServer = true; 
    584584    } 
     
    659659    do 
    660660    { 
    661       const CDate nextDataDue = wasDataAlreadyReceivedFromServer ? (lastDataReceivedFromServer + freq_op) : context->getCalendar()->getInitDate(); 
     661      const CDate nextDataDue = (wasDataAlreadyReceivedFromServer ? (lastDataReceivedFromServer + freq_op) : context->getCalendar()->getInitDate()) + freq_offset; 
    662662      isDataLate = (nextDataDue <= currentDate); 
    663663 
Note: See TracChangeset for help on using the changeset viewer.