Ignore:
Timestamp:
06/01/23 10:58:08 (13 months ago)
Author:
ymipsl
Message:

Merging XIOS3_ATTACHED branch into XIOS3 trunk.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/src/node/context.cpp

    r2498 r2507  
    77#include "duration.hpp" 
    88 
     9#include "online_context_client.hpp" 
    910#include "legacy_context_client.hpp" 
    1011#include "legacy_context_server.hpp" 
     
    662663       
    663664      int serviceType ; 
    664       //if (intraCommRank_==0) CXios::getServicesManager()->getServiceType(poolId, serviceId, 0, serviceType, true) ; 
    665       if (intraCommRank_==0) CXios::getServicesManager()->getServiceType(poolId, serviceId, 0, serviceType) ; 
     665      if (intraCommRank_==0) CXios::getServicesManager()->getServiceType(poolId, serviceId, 0, serviceType, true) ; 
    666666      MPI_Bcast(&serviceType,1,MPI_INT,0,intraComm_) ; 
    667667       
     
    679679  vector<CContextClient*> CContext::getContextClient(const string& poolId, const string& serviceId) 
    680680  { 
    681     vector<pair<CContextClient*,CContextServer*>> clientServers ; 
    682     getServerInterComm(poolId, serviceId, clientServers ) ; 
    683     vector<CContextClient*> ret ; 
    684     for(auto& clientServer : clientServers) ret.push_back(clientServer.first) ; 
     681     vector<CContextClient*> ret ; 
     682     
     683    if (serviceId=="attached") ret.push_back(onlineContextClient_) ; 
     684    else 
     685    { 
     686      vector<pair<CContextClient*,CContextServer*>> clientServers ; 
     687      getServerInterComm(poolId, serviceId, clientServers ) ; 
     688      for(auto& clientServer : clientServers) ret.push_back(clientServer.first) ; 
     689    } 
    685690    return ret ; 
    686691  } 
     
    808813      if (serviceType_==CServicesManager::CLIENT) 
    809814      { 
    810 //ym        doPreTimestepOperationsForEnabledReadModeFiles(); // For now we only use server level 1 to read data 
    811815        triggerLateFields() ; 
    812816 
     
    986990 
    987991     CTimer::get("Context : close definition").resume() ; 
     992 
     993     onlineContextClient_=CContextClient::getNew<CContextClient::online>(this,intraComm_, intraComm_); 
    988994           
    989995     // create intercommunicator with servers.  
     
    11461152    { 
    11471153      for(auto field : fileInField)  
    1148       { 
    1149         field->sendFieldToInputFileServer() ; 
    1150         field->connectToServerInput(garbageCollector) ; // connect the field to server filter 
     1154        if (field->getContextClient()->getType() != CContextClient::online) field->sendFieldToInputFileServer() ; 
     1155 
     1156      for(auto field : fileInField)  
     1157      { 
     1158        if (field->getContextClient()->getType() == CContextClient::online) field->connectToOnlineReader(garbageCollector) ; 
     1159        else field->connectToServerInput(garbageCollector) ; // connect the field to server filter 
    11511160        fileInFields_.push_back(field) ; 
    11521161      } 
     
    11581167      for(auto field : fileOutField)  
    11591168      { 
    1160         field->connectToFileServer(garbageCollector) ; // connect the field to server filter 
    1161       } 
    1162       for(auto field : fileOutField) field->sendFieldToFileServer() ; 
     1169        if (field->getContextClient()->getType() == CContextClient::online)  field->connectToOnlineWriter(garbageCollector) ; 
     1170        else  field->connectToFileServer(garbageCollector) ; // connect the field to server filter 
     1171      } 
     1172      for(auto field : fileOutField)  
     1173        if (field->getContextClient()->getType() != CContextClient::online) field->sendFieldToFileServer() ; 
    11631174    } 
    11641175 
     
    11771188      for(auto field : fileInField)  
    11781189      { 
    1179         field->connectToServerToClient(garbageCollector) ; 
     1190        if (field->getContextClient()->getType() == CContextClient::online) field->connectToOnlineReader(garbageCollector) ; 
     1191        else field->connectToServerToClient(garbageCollector) ; 
    11801192      } 
    11811193    } 
     
    12321244    if (serviceType_==CServicesManager::CLIENT)  
    12331245    { 
    1234       for(auto field : fileOutField) slaves[clientsId_[field->getContextClient()]] = field->getContextClient() ;  
    1235       for(auto field : fileInField) slaves[clientsId_[field->getContextClient()]] = field->getContextClient() ;  
     1246      for(auto field : fileOutField) 
     1247        if (field->getContextClient()->getType()!=CContextClient::online)  slaves[clientsId_[field->getContextClient()]] = field->getContextClient() ;  
     1248      for(auto field : fileInField)  
     1249        if (field->getContextClient()->getType()!=CContextClient::online)  slaves[clientsId_[field->getContextClient()]] = field->getContextClient() ;  
    12361250    } 
    12371251    else if (serviceType_==CServicesManager::GATHERER)  
     
    12421256    for(auto& slaveServer : slaveServers_) sendCloseDefinition(slaveServer) ; 
    12431257 
    1244     if (serviceType_==CServicesManager::WRITER)   
    1245     { 
    1246       createFileHeader(); 
    1247     } 
    1248  
    1249     if (serviceType_==CServicesManager::CLIENT) startPrefetchingOfEnabledReadModeFiles(); 
     1258    createFileHeader(); 
     1259    
     1260    //if (serviceType_==CServicesManager::CLIENT) startPrefetchingOfEnabledReadModeFiles(); 
     1261    if (serviceType_==CServicesManager::CLIENT)  
     1262       for(auto field : fileInField) field->sendReadDataRequest(getCalendar()->getCurrentDate());   
    12501263    
    12511264    // send signal to couplerIn context that definition phasis is done 
     
    13561369   CATCH_DUMP_ATTR 
    13571370 
    1358  
    1359    void CContext::postProcessFilterGraph() 
    1360    TRY 
    1361    { 
    1362      int size = enabledFiles.size(); 
    1363      for (int i = 0; i < size; ++i) 
    1364      { 
    1365         enabledFiles[i]->postProcessFilterGraph(); 
    1366      } 
    1367    } 
    1368    CATCH_DUMP_ATTR 
    1369  
    13701371   void CContext::startPrefetchingOfEnabledReadModeFiles() 
    13711372   TRY 
     
    13751376     { 
    13761377        enabledReadModeFiles[i]->prefetchEnabledReadModeFields(); 
    1377      } 
    1378    } 
    1379    CATCH_DUMP_ATTR 
    1380  
    1381    void CContext::doPreTimestepOperationsForEnabledReadModeFiles() 
    1382    TRY 
    1383    { 
    1384      int size = enabledReadModeFiles.size(); 
    1385      for (int i = 0; i < size; ++i) 
    1386      { 
    1387         enabledReadModeFiles[i]->doPreTimestepOperationsForEnabledReadModeFields(); 
    13881378     } 
    13891379   } 
     
    21772167        if (serviceType_==CServicesManager::CLIENT) // For now we only use server level 1 to read data 
    21782168        { 
    2179           doPostTimestepOperationsForEnabledReadModeFiles(); 
     2169         // doPostTimestepOperationsForEnabledReadModeFiles(); 
     2170          for(auto& field : fileInFields_) field->sendReadDataRequestIfNeeded() ; 
    21802171          garbageCollector.invalidate(calendar->getCurrentDate()); 
    21812172        } 
     
    22022193   CATCH_DUMP_ATTR 
    22032194 
    2204    //! Server side: Create header of netcdf file 
     2195   //! Create header of netcdf file 
    22052196   void CContext::createFileHeader(void) 
    22062197   TRY 
    22072198   { 
    2208       vector<CFile*>::const_iterator it; 
    2209  
    2210       //for (it=enabledFiles.begin(); it != enabledFiles.end(); it++) 
    2211       for (it=enabledWriteModeFiles.begin(); it != enabledWriteModeFiles.end(); it++) 
    2212       { 
    2213          (*it)->initWrite(); 
    2214       } 
     2199      for(auto& file : filesToWrite_) file->initWrite(); 
    22152200   } 
    22162201   CATCH_DUMP_ATTR 
Note: See TracChangeset for help on using the changeset viewer.