Changeset 983


Ignore:
Timestamp:
11/07/16 17:55:55 (7 years ago)
Author:
oabramkina
Message:

My branch

Location:
XIOS/dev/dev_olga
Files:
29 edited
1 copied

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/arch/arch-GCC_LINUX.env

    r395 r983  
    1 export HDF5_INC_DIR=$HOME/hdf5/include 
    2 export HDF5_LIB_DIR=$HOME/hdf5/lib 
     1export HDF5_INC_DIR=$HOME/hdf5/hdf5/include 
     2export HDF5_LIB_DIR=$HOME/hdf5/hdf5/lib 
    33 
    44export NETCDF_INC_DIR=$HOME/netcdf4/include 
  • XIOS/dev/dev_olga/arch/arch-GCC_LINUX.fcm

    r591 r983  
    1212%DEBUG_CFLAGS   -g  
    1313 
    14 %BASE_FFLAGS    -D__NONE__  
     14%BASE_FFLAGS    -D__NONE__ -ffree-line-length-none  
    1515%PROD_FFLAGS    -O3 
    1616%DEV_FFLAGS     -g -O2 
  • XIOS/dev/dev_olga/arch/arch-GCC_LINUX.path

    r475 r983  
    55MPI_INCDIR="" 
    66MPI_LIBDIR="" 
    7 MPI_LIB="" 
     7MPI_LIB="-lcurl" 
    88 
    99HDF5_INCDIR="-I $HDF5_INC_DIR" 
  • XIOS/dev/dev_olga/arch/arch-X64_CURIE.fcm

    r591 r983  
    1414%BASE_FFLAGS    -D__NONE__  
    1515%PROD_FFLAGS    -O3 
    16 %DEV_FFLAGS     -g -O2 -traceback 
     16%DEV_FFLAGS     -g -traceback 
    1717%DEBUG_FFLAGS   -g -traceback 
    1818 
  • XIOS/dev/dev_olga/bld.cfg

    r709 r983  
    3232bld::target libxios.a  
    3333#bld::target generate_fortran_interface.exe  
    34 bld::target xios_server.exe test_remap.exe 
    35 bld::target test_new_features.exe test_unstruct_complete.exe  
    36 bld::target test_client.exe test_complete.exe 
     34#bld::target xios_server.exe #test_remap.exe 
     35bld::target xios_server.exe  
     36bld::target xios_server1.exe xios_server2.exe 
     37#bld::target test_new_features.exe test_unstruct_complete.exe  
     38#bld::target test_client.exe test_complete.exe 
     39bld::target test_client.exe 
    3740bld::exe_dep 
    3841 
  • XIOS/dev/dev_olga/inputs/iodef.xml

    r787 r983  
    1414   <file_definition type="multiple_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
    1515     <file id="output" name="output"> 
    16         <field field_ref="field_A_zoom" name="field_A" /> 
     16        <field field_ref="field_A" name="field_A" /> 
    1717     </file> 
    1818   </file_definition> 
  • XIOS/dev/dev_olga/src/buffer_client.cpp

    r917 r983  
    8686      if (count > 0) 
    8787      { 
    88         MPI_Issend(buffer[current], count, MPI_CHAR, serverRank, 20, interComm, &request); 
     88        MPI_Comm_test_inter(interComm, &flag); 
     89//        if (flag) 
     90          MPI_Issend(buffer[current], count, MPI_CHAR, serverRank, 20, interComm, &request); 
     91//        else 
     92//          ERROR("bool CClientBuffer::checkBuffer(void)", 
     93//                << "Invalid intercommunicator"); 
    8994        pending = true; 
    9095        if (current == 1) current = 0; 
  • XIOS/dev/dev_olga/src/client.cpp

    r925 r983  
    1818    MPI_Comm CClient::interComm ; 
    1919    std::list<MPI_Comm> CClient::contextInterComms; 
    20     int CClient::serverLeader ; 
     20    int CClient::serverLeader; 
    2121    bool CClient::is_MPI_Initialized ; 
    2222    int CClient::rank = INVALID_RANK; 
     
    2424    StdOFStream CClient::m_errorStream; 
    2525 
    26     void CClient::initialize(const string& codeId,MPI_Comm& localComm,MPI_Comm& returnComm) 
     26///--------------------------------------------------------------- 
     27/*! 
     28 * \fn void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
     29 * Function creates intraComm (CClient::intraComm) for client group with id=codeId and interComm (CClient::interComm) between client and server groups. 
     30 * \param [in] codeId identity of context. 
     31 * \param [in/out] localComm local communicator. 
     32 * \param [in/out] returnComm (intra)communicator of client group. 
     33 */ 
     34 
     35    void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
    2736    { 
    2837      int initialized ; 
     
    3443      if (!CXios::usingOasis) 
    3544      { 
    36 // localComm doesn't given 
     45// localComm isn't given 
    3746        if (localComm == MPI_COMM_NULL) 
    3847        { 
     
    4554          boost::hash<string> hashString ; 
    4655 
    47           unsigned long hashClient=hashString(codeId) ; 
    48           unsigned long hashServer=hashString(CXios::xiosCodeId) ; 
     56          unsigned long hashClient = hashString(codeId) ; 
     57          unsigned long hashServer = hashString(CXios::xiosCodeIdPrm); 
    4958          unsigned long* hashAll ; 
    5059          int size ; 
     
    5867          hashAll=new unsigned long[size] ; 
    5968 
    60           MPI_Allgather(&hashClient,1,MPI_LONG,hashAll,1,MPI_LONG,CXios::globalComm) ; 
     69          MPI_Allgather(&hashClient, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ; 
    6170 
    6271          map<unsigned long, int> colors ; 
     
    7786          for (i=0; i < size; ++i) 
    7887          { 
    79             if (hashServer == hashAll[i]) 
     88            if ((hashAll[i] == hashString(CXios::xiosCodeId)) 
     89                || (hashAll[i] == hashString(CXios::xiosCodeIdPrm)) 
     90                || (hashAll[i] == hashString(CXios::xiosCodeIdSnd))) 
    8091            { 
    8192              CXios::setUsingServer(); 
     
    8596 
    8697          myColor=colors[hashClient] ; 
    87  
    8898          MPI_Comm_split(CXios::globalComm,myColor,rank,&intraComm) ; 
    8999 
     
    92102            int clientLeader=leaders[hashClient] ; 
    93103            serverLeader=leaders[hashServer] ; 
    94  
    95104            int intraCommSize, intraCommRank ; 
    96105            MPI_Comm_size(intraComm,&intraCommSize) ; 
    97106            MPI_Comm_rank(intraComm,&intraCommRank) ; 
    98107            info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 
    99                  <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ; 
    100             MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 
     108                   <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ; 
     109             MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 
    101110          } 
    102111          else 
     
    123132      else 
    124133      { 
    125         // localComm doesn't given 
     134        // localComm isn't given 
    126135        if (localComm == MPI_COMM_NULL) 
    127136        { 
     
    150159    } 
    151160 
    152  
    153     void CClient::registerContext(const string& id,MPI_Comm contextComm) 
     161    void CClient::initializeClientOnServer(const int rank, MPI_Comm& intraCommPrmSrv, const int srvSndLeader) 
     162    { 
     163      MPI_Comm_dup(intraCommPrmSrv, &intraComm) ; 
     164      serverLeader = srvSndLeader; 
     165      int intraCommSize, intraCommRank ; 
     166      MPI_Comm_size(intraComm,&intraCommSize) ; 
     167      MPI_Comm_rank(intraComm,&intraCommRank) ; 
     168      info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 
     169          <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ; 
     170      MPI_Intercomm_create(intraComm, 0, CXios::globalComm, serverLeader, 0, &interComm) ; 
     171    } 
     172 
     173///--------------------------------------------------------------- 
     174/*! 
     175 * \fn void CClient::registerContext(const string& id, MPI_Comm contextComm) 
     176 * Function creates intraComm (CClient::intraComm) for client group with id=codeId and interComm (CClient::interComm) between client and server groups. 
     177 * \param [in] id id of context. 
     178 * \param [in] contextComm. 
     179 */ 
     180    void CClient::registerContext(const string& id, MPI_Comm contextComm) 
    154181    { 
    155182      CContext::setCurrent(id) ; 
     
    158185      idServer += "_server"; 
    159186 
    160       if (!CXios::isServer) 
     187      if (CXios::isServer && !context->hasServer) 
     188      // Attached mode 
     189      { 
     190        MPI_Comm contextInterComm ; 
     191        MPI_Comm_dup(contextComm,&contextInterComm) ; 
     192        CContext* contextServer = CContext::create(idServer); 
     193 
     194        // Firstly, initialize context on client side 
     195        context->initClient(contextComm,contextInterComm, contextServer); 
     196 
     197        // Secondly, initialize context on server side 
     198        contextServer->initServer(contextComm,contextInterComm, context); 
     199 
     200        // Finally, we should return current context to context client 
     201        CContext::setCurrent(id); 
     202 
     203        contextInterComms.push_back(contextInterComm); 
     204      } 
     205      else 
    161206      { 
    162207        int size,rank,globalRank ; 
     
    170215        if (rank!=0) globalRank=0 ; 
    171216 
    172  
    173217        CMessage msg ; 
    174218        msg<<idServer<<size<<globalRank ; 
     
    180224        buffer<<msg ; 
    181225 
    182         MPI_Send(buff,buffer.count(),MPI_CHAR,serverLeader,1,CXios::globalComm) ; 
     226        MPI_Send(buff, buffer.count(), MPI_CHAR, serverLeader, 1, CXios::globalComm) ; 
    183227        delete [] buff ; 
    184228 
    185         MPI_Intercomm_create(contextComm,0,CXios::globalComm,serverLeader,10+globalRank,&contextInterComm) ; 
     229        MPI_Intercomm_create(contextComm, 0, CXios::globalComm, serverLeader, 10+globalRank, &contextInterComm) ; 
    186230        info(10)<<"Register new Context : "<<id<<endl ; 
    187231 
     
    195239        MPI_Comm_free(&inter); 
    196240      } 
    197       else 
    198       { 
    199         MPI_Comm contextInterComm ; 
    200         MPI_Comm_dup(contextComm,&contextInterComm) ; 
    201         CContext* contextServer = CContext::create(idServer); 
    202  
    203         // Firstly, initialize context on client side 
    204         context->initClient(contextComm,contextInterComm, contextServer); 
    205  
    206         // Secondly, initialize context on server side 
    207         contextServer->initServer(contextComm,contextInterComm, context); 
    208  
    209         // Finally, we should return current context to context client 
    210         CContext::setCurrent(id); 
    211  
    212         contextInterComms.push_back(contextInterComm); 
    213       } 
    214241    } 
    215242 
     
    221248      MPI_Comm_rank(intraComm,&rank) ; 
    222249  
    223       if (!CXios::isServer) 
     250      if ((!CXios::isServer) || (CXios::serverLevel == 1)) 
    224251      { 
    225252        MPI_Comm_rank(intraComm,&rank) ; 
     
    252279      report(0)<< " Memory report : Minimum buffer size required : " << CClientBuffer::maxRequestSize << " bytes" << endl ; 
    253280      report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ; 
     281 
    254282   } 
    255283 
  • XIOS/dev/dev_olga/src/client.hpp

    r655 r983  
    1111      public: 
    1212        static void initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm); 
     13        static void initializeClientOnServer(const int rank, MPI_Comm& localComm, const int srvSndLeader); 
    1314        static void finalize(void); 
    1415        static void registerContext(const string& id, MPI_Comm contextComm); 
  • XIOS/dev/dev_olga/src/config/file_attribute.conf

    r878 r983  
    2020DECLARE_ATTRIBUTE(StdString, time_counter_name) 
    2121DECLARE_ATTRIBUTE(int,       record_offset) 
    22 DECLARE_ATTRIBUTE(bool,       cyclic) 
     22DECLARE_ATTRIBUTE(bool,      cyclic) 
    2323 
    2424DECLARE_ATTRIBUTE(int,       compression_level) 
     25DECLARE_ATTRIBUTE(bool,      coupler) 
    2526 
    2627DECLARE_ENUM4(timeseries,    none, only, both, exclusive) 
  • XIOS/dev/dev_olga/src/context_client.cpp

    r917 r983  
    1818    \param [in] intraComm_ communicator of group client 
    1919    \param [in] interComm_ communicator of group server 
    20     \cxtSer [in] cxtSer Pointer to context of server side. (It is only used on case of attached mode) 
     20    \cxtSer [in] cxtSer Pointer to context of server side. (It is only used in case of attached mode). 
    2121    */ 
    2222    CContextClient::CContextClient(CContext* parent, MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer) 
  • XIOS/dev/dev_olga/src/context_server.cpp

    r887 r983  
    3434    if (flag) MPI_Comm_remote_size(interComm,&commSize); 
    3535    else  MPI_Comm_size(interComm,&commSize); 
     36 
    3637    currentTimeLine=0; 
    3738    scheduled=false; 
     
    159160      count=buffer.remain(); 
    160161    } 
    161  
    162162  } 
    163163 
     
    220220      info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl; 
    221221      std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 
    222                                              iteMap = mapBufferSize_.end(), itMap; 
     222                           iteMap = mapBufferSize_.end(), itMap; 
    223223      StdSize totalBuf = 0; 
    224224      for (itMap = itbMap; itMap != iteMap; ++itMap) 
    225225      { 
    226226        report(10)<< " Memory report : Context <"<<context->getId()<<"> : server side : memory used for buffer of each connection to client" << endl 
    227                   << "  +) With client of rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
     227            << "  +) With client of rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
    228228        totalBuf += itMap->second; 
    229229      } 
  • XIOS/dev/dev_olga/src/context_server.hpp

    r697 r983  
    4848    private: 
    4949      std::map<int, StdSize> mapBufferSize_; 
     50 
    5051  } ; 
    5152 
  • XIOS/dev/dev_olga/src/cxios.cpp

    r956 r983  
    1616  string CXios::rootFile="./iodef.xml" ; 
    1717  string CXios::xiosCodeId="xios.x" ; 
     18  string CXios::xiosCodeIdPrm="xios.x.1" ; 
     19  string CXios::xiosCodeIdSnd="xios.x.2" ; 
    1820  string CXios::clientFile="./xios_client"; 
    1921  string CXios::serverFile="./xios_server"; 
     22  string CXios::serverPrimFile="./xios_server1"; 
     23  string CXios::serverScndFile="./xios_server2"; 
    2024 
    2125  bool CXios::isClient ; 
    2226  bool CXios::isServer ; 
     27  int CXios::serverLevel = 0 ; 
    2328  MPI_Comm CXios::globalComm ; 
    2429  bool CXios::usingOasis ; 
     
    127132 
    128133  //! Initialize server then put it into listening state 
    129   void CXios::initServerSide(void) 
     134  void CXios::initServerSide(int serverLvl) 
    130135  { 
    131136    initServer(); 
    132     isClient = false; 
     137    if (serverLvl == 1) 
     138      isClient = true; 
     139    else 
     140      isClient = false; 
     141 
    133142    isServer = true; 
     143    serverLevel = serverLvl; 
    134144 
    135145    // Initialize all aspects MPI 
     
    139149    if (printLogs2Files) 
    140150    { 
    141       CServer::openInfoStream(serverFile); 
    142       CServer::openErrorStream(serverFile); 
     151      if (CXios::serverLevel == 0) 
     152      { 
     153        CServer::openInfoStream(serverFile); 
     154        CServer::openErrorStream(serverFile); 
     155      } 
     156      else if (CXios::serverLevel == 1) 
     157      { 
     158        CServer::openInfoStream(serverPrimFile); 
     159        CServer::openErrorStream(serverPrimFile); 
     160      } 
     161      else 
     162      { 
     163        CServer::openInfoStream(serverScndFile); 
     164        CServer::openErrorStream(serverScndFile); 
     165      } 
    143166    } 
    144167    else 
     
    174197  } 
    175198 
     199  //! Set using secondary server 
     200//  void CXios::setUsingSecondaryServer() 
     201//  { 
     202//    usingSecondaryServer = true; 
     203//  } 
     204 
    176205  //! Unset using server 
    177206  void CXios::setNotUsingServer() 
  • XIOS/dev/dev_olga/src/cxios.hpp

    r719 r983  
    1616     static void initialize(void) ; 
    1717     static void initClientSide(const string & codeId, MPI_Comm& localComm, MPI_Comm& returnComm) ; 
    18      static void initServerSide(void) ; 
     18     static void initServerSide(int serverLevel) ; 
    1919     static void clientFinalize(void) ; 
    2020     static void parseFile(const string& filename) ; 
     
    2929     static string rootFile ; //!< Configuration filename 
    3030     static string xiosCodeId ; //!< Identity for XIOS 
    31      static string clientFile; //!< Filename template for client 
    32      static string serverFile; //!< Filename template for server 
     31     static string xiosCodeIdPrm ; //!< Identity for XIOS primary server 
     32     static string xiosCodeIdSnd ; //!< Identity for XIOS secondary server 
     33     static string clientFile;        //!< Filename template for client 
     34     static string serverFile;        //!< Filename template for server 
     35     static string serverPrimFile;  //!< Filename template for primary server in case of two server groups 
     36     static string serverScndFile;  //!< Filename template for secondary server in case of two server groups 
    3337 
    3438     static bool isClient ; //!< Check if xios is client 
    35      static bool isServer ; //!< Check if xios is server 
     39     static bool isServer ; //!< Check if xios is primary server 
     40 
     41     static int serverLevel ; // 
    3642 
    3743     static MPI_Comm globalComm ; //!< Global communicator 
     
    5056     static void setUsingServer(); 
    5157 
     58     //! Setting xios to use secondary server mode 
     59//     static void setUsingSecondaryServer(); 
     60 
    5261     //! Setting xios NOT to use server mode 
    5362     static void setNotUsingServer(); 
  • XIOS/dev/dev_olga/src/distribution_client.cpp

    r932 r983  
    1010 
    1111namespace xios { 
     12 
     13CDistributionClient::CDistributionClient(int rank, const GlobalLocalDataMap& globalLocalIndex) 
     14  : CDistribution(rank, 0) 
     15   , axisDomainOrder_() 
     16   , nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_() 
     17   , dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_() 
     18   , gridMask_(), indexMap_() 
     19   , isDataDistributed_(true), axisNum_(0), domainNum_(0) 
     20   , localDataIndex_(), localMaskIndex_() 
     21   , globalLocalDataSendToServerMap_(globalLocalIndex) 
     22   , infoIndex_(), isComputed_(false) 
     23   , elementLocalIndex_(), elementGlobalIndex_(), elementIndexData_() 
     24   , elementZoomMask_(), elementNLocal_(), elementNGlobal_() 
     25{ 
     26//  numElement_ = globalLocalIndex.size();    !!! numElement_ should be calculated !!!! 
     27  isComputed_ = true;  // my changes 
     28 
     29 
     30  localDataIndex_.resize(globalLocalIndex.size()); 
     31  localMaskIndex_.resize(globalLocalIndex.size()); 
     32  GlobalLocalDataMap::const_iterator it = globalLocalIndex.begin(), ite = globalLocalIndex.end(); 
     33  int idx = 0; 
     34  for (; it!=ite; ++it) 
     35  { 
     36    localMaskIndex_[idx] = localDataIndex_[idx] = it->second; 
     37    ++idx; 
     38  } 
     39} 
    1240 
    1341CDistributionClient::CDistributionClient(int rank, int dims, const CArray<size_t,1>& globalIndex) 
  • XIOS/dev/dev_olga/src/distribution_client.hpp

    r930 r983  
    3434  public: 
    3535    /** Default constructor */ 
     36    CDistributionClient(int rank, const GlobalLocalDataMap& globalLocalIndex); 
    3637    CDistributionClient(int rank, int dims, const CArray<size_t,1>& globalIndex = CArray<size_t,1>()); 
    3738    CDistributionClient(int rank, CGrid* grid); 
  • XIOS/dev/dev_olga/src/distribution_server.hpp

    r930 r983  
    3737    const std::vector<int>& getZoomBeginServer() const; 
    3838    const std::vector<int>& getZoomSizeServer() const; 
     39    const GlobalLocalMap& getGlobalLocalIndex() const { return globalLocalIndexMap_; } 
    3940 
    4041    virtual CArray<size_t,1> computeLocalIndex(const CArray<size_t,1>& globalIndex); 
  • XIOS/dev/dev_olga/src/interface/c/icdata.cpp

    r961 r983  
    4747   } 
    4848 
    49    void cxios_init_server(void) 
    50    { 
    51      CXios::initServerSide(); 
     49   void cxios_init_server(int server_level) 
     50   { 
     51     CXios::initServerSide(server_level); 
    5252   } 
    5353 
  • XIOS/dev/dev_olga/src/interface/fortran/idata.F90

    r965 r983  
    77   INTERFACE ! Ne pas appeler directement/Interface FORTRAN 2003 <-> C99 
    88 
    9       SUBROUTINE  cxios_init_server() BIND(C) 
     9      SUBROUTINE  cxios_init_server(server_level) BIND(C) 
     10         USE ISO_C_BINDING 
     11         INTEGER  (kind = C_INT)    , VALUE         :: server_level 
    1012      END SUBROUTINE cxios_init_server 
    1113 
     
    451453   CONTAINS ! Fonctions disponibles pour les utilisateurs. 
    452454 
    453    SUBROUTINE  xios(init_server)() 
    454    IMPLICIT NONE 
    455      CALL cxios_init_server() 
     455   SUBROUTINE  xios(init_server)(server_level) 
     456   IMPLICIT NONE 
     457       INTEGER  (kind = C_INT), INTENT(IN)         :: server_level 
     458       CALL cxios_init_server(server_level) 
    456459   END SUBROUTINE xios(init_server) 
    457460 
  • XIOS/dev/dev_olga/src/node/calendar_wrapper.cpp

    r550 r983  
    77namespace xios { 
    88 
    9   /// ////////////////////// Définitions ////////////////////// /// 
     9  /// ////////////////////// Dfinitions ////////////////////// /// 
    1010 
    1111  CCalendarWrapper::CCalendarWrapper(void) 
     
    8383  { 
    8484    // Create the calendar if possible 
    85     if (calendar) 
     85    if (0 != calendar) 
    8686    { 
    8787      ERROR("CCalendarWrapper::createCalendar(void)", 
  • XIOS/dev/dev_olga/src/node/context.cpp

    r958 r983  
    2424   CContext::CContext(void) 
    2525      : CObjectTemplate<CContext>(), CContextAttributes() 
    26       , calendar(), hasClient(false), hasServer(false), isPostProcessed(false), finalized(false) 
    27       , idServer_(), client(0), server(0) 
     26      , calendar(), hasClient(false), hasServer(false) 
     27      , isPostProcessed(false), finalized(false) 
     28      , idServer_(), client(0), server(0), clientPrimServer(0), serverPrimServer(0) 
    2829   { /* Ne rien faire de plus */ } 
    2930 
    3031   CContext::CContext(const StdString & id) 
    3132      : CObjectTemplate<CContext>(id), CContextAttributes() 
    32       , calendar(), hasClient(false), hasServer(false), isPostProcessed(false), finalized(false) 
    33       , idServer_(), client(0), server(0) 
     33      , calendar(), hasClient(false), hasServer(false) 
     34      , isPostProcessed(false), finalized(false) 
     35      , idServer_(), client(0), server(0), clientPrimServer(0), serverPrimServer(0) 
    3436   { /* Ne rien faire de plus */ } 
    3537 
     
    3840     delete client; 
    3941     delete server; 
     42     delete clientPrimServer; 
     43     delete serverPrimServer; 
    4044   } 
    4145 
     
    238242   void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer /*= 0*/) 
    239243   { 
    240      hasClient=true; 
    241      client = new CContextClient(this,intraComm, interComm, cxtServer); 
     244 
     245     hasClient = true; 
     246     if (CXios::serverLevel != 1)  // initClient is called by client pool 
     247     { 
     248       client = new CContextClient(this, intraComm, interComm, cxtServer); 
     249       server = new CContextServer(this, intraComm, interComm); 
     250     } 
     251     else                         // initClient is called by primary server pool 
     252     { 
     253       clientPrimServer = new CContextClient(this, intraComm, interComm); 
     254       serverPrimServer = new CContextServer(this, intraComm, interComm); 
     255     } 
     256 
    242257     registryIn=new CRegistry(intraComm); 
    243258     registryIn->setPath(getId()) ; 
     
    261276       comms.push_back(interCommServer); 
    262277     } 
    263      server = new CContextServer(this,intraCommServer,interCommServer); 
    264278   } 
    265279 
     
    300314         if (!bufferSize.count(*itRank)) bufferSize[*itRank] = maxEventSize[*itRank] = minBufferSize; 
    301315     } 
    302  
    303316     client->setBufferSize(bufferSize, maxEventSize); 
     317 
     318     // If it is primary server pool, also set buffer for clientPrimServer. 
     319     if (hasClient && hasServer) 
     320     { 
     321       if (clientPrimServer->isServerLeader()) 
     322       { 
     323         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
     324         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     325           if (!bufferSize.count(*itRank)) bufferSize[*itRank] = maxEventSize[*itRank] = minBufferSize; 
     326       } 
     327       clientPrimServer->setBufferSize(bufferSize, maxEventSize); 
     328     } 
     329 
    304330   } 
    305331 
     
    310336   } 
    311337 
    312    //! Initialize server 
    313    void CContext::initServer(MPI_Comm intraComm,MPI_Comm interComm, CContext* cxtClient /*= 0*/) 
     338   void CContext::initServer(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtClient /*= 0*/) 
    314339   { 
    315340     hasServer=true; 
    316341     server = new CContextServer(this,intraComm,interComm); 
     342     client = new CContextClient(this,intraComm,interComm); 
     343//     client = new CContextClient(this,intraComm,interComm, cxtClient); 
    317344 
    318345     registryIn=new CRegistry(intraComm); 
     
    336363       comms.push_back(interCommClient); 
    337364     } 
    338      client = new CContextClient(this,intraCommClient,interCommClient, cxtClient); 
     365 
    339366   } 
    340367 
     
    342369   bool CContext::eventLoop(void) 
    343370   { 
    344      return server->eventLoop(); 
     371     if (CXios::serverLevel == 0) 
     372     { 
     373       return server->eventLoop(); 
     374     } 
     375     else if (CXios::serverLevel == 1) 
     376     { 
     377       bool serverFinished = server->eventLoop(); 
     378       bool serverPrimFinished = serverPrimServer->eventLoop(); 
     379       return ( serverFinished && serverPrimFinished); 
     380     } 
     381     else 
     382     { 
     383       return server->eventLoop(); 
     384     } 
    345385   } 
    346386 
     
    348388   bool CContext::checkBuffersAndListen(void) 
    349389   { 
    350      client->checkBuffers(); 
    351      return server->eventLoop(); 
     390     if (CXios::serverLevel == 0) 
     391     { 
     392       client->checkBuffers(); 
     393       return server->eventLoop(); 
     394     } 
     395     else if (CXios::serverLevel == 1) 
     396     { 
     397       client->checkBuffers(); 
     398       clientPrimServer->checkBuffers(); 
     399       bool serverFinished = server->eventLoop(); 
     400       bool serverPrimFinished = serverPrimServer->eventLoop(); 
     401       return ( serverFinished && serverPrimFinished); 
     402     } 
     403     else if (CXios::serverLevel == 2) 
     404     { 
     405       client->checkBuffers(); 
     406       return server->eventLoop(); 
     407     } 
    352408   } 
    353409 
     
    359415        finalized = true; 
    360416        if (hasClient) sendRegistry() ; 
     417 
     418/*        if (CXios::serverLevel == 0) 
     419        { 
     420          client->finalize(); 
     421          while (!server->hasFinished()) 
     422          { 
     423            server->eventLoop(); 
     424          } 
     425        } 
     426        else if (CXios::serverLevel == 1) 
     427        { 
     428          clientPrimServer->finalize(); 
     429          while (!serverPrimServer->hasFinished()) 
     430          { 
     431            serverPrimServer->eventLoop(); 
     432          } 
     433          client->finalize(); 
     434          while (!server->hasFinished()) 
     435          { 
     436            server->eventLoop(); 
     437          } 
     438        } 
     439        else if (CXios::serverLevel == 2) 
     440        { 
     441          client->finalize(); 
     442          while (!server->hasFinished()) 
     443          { 
     444            server->eventLoop(); 
     445          } 
     446        }*/ 
     447 
    361448        client->finalize(); 
    362449        while (!server->hasFinished()) 
    363450        { 
    364451          server->eventLoop(); 
     452        } 
     453 
     454        if ((hasClient) && (hasServer)) 
     455        { 
     456          clientPrimServer->finalize(); 
     457          while (!serverPrimServer->hasFinished()) 
     458          { 
     459            serverPrimServer->eventLoop(); 
     460          } 
    365461        } 
    366462 
     
    391487     // There is nothing client need to send to server 
    392488     if (hasClient) 
     489//     if (hasClient && !hasServer) 
    393490     { 
    394491       // After xml is parsed, there are some more works with post processing 
    395492       postProcessing(); 
    396493     } 
     494 
    397495     setClientServerBuffer(); 
    398496 
    399      if (hasClient && !hasServer) 
     497//     if (hasClient && !hasServer) 
     498     if (hasClient) 
    400499     { 
    401500      // Send all attributes of current context to server 
     
    417516      // After that, send all grid (if any) 
    418517       sendRefGrid(); 
    419     } 
     518 
     519       // We have a xml tree on the server side and now, it should be also processed 
     520       sendPostProcessing(); 
     521     } 
     522 
     523//     // Now tell server that it can process all messages from client 
     524// //    if (hasClient && !hasServer) this->sendCloseDefinition(); 
     525     if (hasClient) this->sendCloseDefinition(); 
    420526 
    421527    // We have a xml tree on the server side and now, it should be also processed 
    422     if (hasClient && !hasServer) sendPostProcessing(); 
     528//    if (hasClient && !hasServer) sendPostProcessing(); 
    423529 
    424530    // There are some processings that should be done after all of above. For example: check mask or index 
    425     if (hasClient) 
     531     if (hasClient && !hasServer) 
     532//    if (hasClient) 
    426533    { 
    427       this->buildFilterGraphOfEnabledFields(); 
     534      this->buildFilterGraphOfEnabledFields();  // references are resolved here (access xml file) 
    428535      buildFilterGraphOfFieldsWithReadAccess(); 
    429536      this->solveAllRefOfEnabledFields(true); 
    430537    } 
    431538 
    432     // Now tell server that it can process all messages from client 
    433     if (hasClient && !hasServer) this->sendCloseDefinition(); 
     539//    // Now tell server that it can process all messages from client 
     540////    if (hasClient && !hasServer) this->sendCloseDefinition(); 
     541//    if (hasClient) this->sendCloseDefinition(); 
    434542 
    435543    // Nettoyage de l'arborescence 
    436     if (hasClient && !hasServer) CleanTree(); // Only on client side?? 
     544//    if (hasClient && !hasServer) CleanTree(); // Only on client side?? 
     545    if (hasClient) CleanTree(); // Only on client side?? 
    437546 
    438547    if (hasClient) 
    439548    { 
    440549      sendCreateFileHeader(); 
    441  
    442       startPrefetchingOfEnabledReadModeFiles(); 
     550      if (!hasServer) startPrefetchingOfEnabledReadModeFiles(); 
    443551    } 
    444552   } 
     
    549657      const vector<CGrid*> allGrids= CGrid::getAll(); 
    550658 
    551      //if (hasClient && !hasServer) 
    552       if (hasClient) 
     659      if (hasClient && !hasServer) 
     660      //if (hasClient) 
    553661      { 
    554662        for (unsigned int i = 0; i < allFiles.size(); i++) 
     
    646754   } 
    647755 
     756//   // Only send close definition from process having hasClient 
     757//   void CContext::sendCloseDefinitionToServer(void) 
     758//   { 
     759//     CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION); 
     760//   } 
     761 
    648762   //! Client side: Send a message to server to make it close 
    649763   void CContext::sendCloseDefinition(void) 
    650764   { 
    651765     CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION); 
    652      if (client->isServerLeader()) 
    653      { 
    654        CMessage msg; 
    655        msg<<this->getIdServer(); 
    656        const std::list<int>& ranks = client->getRanksServerLeader(); 
    657        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    658          event.push(*itRank,1,msg); 
    659        client->sendEvent(event); 
    660      } 
    661      else client->sendEvent(event); 
     766     if (!hasServer) 
     767     { 
     768       if (client->isServerLeader()) 
     769       { 
     770         CMessage msg; 
     771         msg<<this->getIdServer(); 
     772         const std::list<int>& ranks = client->getRanksServerLeader(); 
     773         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     774           event.push(*itRank,1,msg); 
     775         client->sendEvent(event); 
     776       } 
     777       else client->sendEvent(event); 
     778     } 
     779     else 
     780     { 
     781       if (clientPrimServer->isServerLeader()) 
     782       { 
     783         CMessage msg; 
     784         msg<<this->getIdServer(); 
     785         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
     786         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     787           event.push(*itRank,1,msg); 
     788         clientPrimServer->sendEvent(event); 
     789       } 
     790       else clientPrimServer->sendEvent(event); 
     791 
     792     } 
    662793   } 
    663794 
     
    675806   void CContext::sendUpdateCalendar(int step) 
    676807   { 
     808     CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR); 
    677809     if (!hasServer) 
    678810     { 
    679        CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR); 
    680811       if (client->isServerLeader()) 
    681812       { 
     
    689820       else client->sendEvent(event); 
    690821     } 
     822     else 
     823     { 
     824       if (clientPrimServer->isServerLeader()) 
     825       { 
     826         CMessage msg; 
     827         msg<<this->getIdServer()<<step; 
     828         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
     829         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     830           event.push(*itRank,1,msg); 
     831         clientPrimServer->sendEvent(event); 
     832       } 
     833       else clientPrimServer->sendEvent(event); 
     834     } 
    691835   } 
    692836 
     
    712856   { 
    713857     CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER); 
    714      if (client->isServerLeader()) 
    715      { 
    716        CMessage msg; 
    717        msg<<this->getIdServer(); 
    718        const std::list<int>& ranks = client->getRanksServerLeader(); 
    719        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    720          event.push(*itRank,1,msg) ; 
    721        client->sendEvent(event); 
    722      } 
    723      else client->sendEvent(event); 
     858 
     859     if (!hasServer) 
     860     { 
     861       if (client->isServerLeader()) 
     862       { 
     863         CMessage msg; 
     864         msg<<this->getIdServer(); 
     865         const std::list<int>& ranks = client->getRanksServerLeader(); 
     866         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     867           event.push(*itRank,1,msg) ; 
     868         client->sendEvent(event); 
     869       } 
     870       else client->sendEvent(event); 
     871     } 
     872     else 
     873     { 
     874       if (clientPrimServer->isServerLeader()) 
     875       { 
     876         CMessage msg; 
     877         msg<<this->getIdServer(); 
     878         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
     879         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     880           event.push(*itRank,1,msg) ; 
     881         clientPrimServer->sendEvent(event); 
     882       } 
     883       else clientPrimServer->sendEvent(event); 
     884     } 
    724885   } 
    725886 
     
    742903   void CContext::sendPostProcessing() 
    743904   { 
    744      if (!hasServer) 
    745      { 
    746        CEventClient event(getType(),EVENT_ID_POST_PROCESS); 
    747        if (client->isServerLeader()) 
    748        { 
    749          CMessage msg; 
    750          msg<<this->getIdServer(); 
    751          const std::list<int>& ranks = client->getRanksServerLeader(); 
    752          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    753            event.push(*itRank,1,msg); 
    754          client->sendEvent(event); 
    755        } 
    756        else client->sendEvent(event); 
     905     if (hasClient) 
     906     { 
     907       if (!hasServer) 
     908       { 
     909         CEventClient event(getType(),EVENT_ID_POST_PROCESS); 
     910         if (client->isServerLeader()) 
     911         { 
     912           CMessage msg; 
     913           msg<<this->getIdServer(); 
     914           const std::list<int>& ranks = client->getRanksServerLeader(); 
     915           for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     916             event.push(*itRank,1,msg); 
     917           client->sendEvent(event); 
     918         } 
     919         else client->sendEvent(event); 
     920       } 
     921       else 
     922       { 
     923         CEventClient event(getType(),EVENT_ID_POST_PROCESS); 
     924         if (clientPrimServer->isServerLeader()) 
     925         { 
     926           CMessage msg; 
     927           msg<<this->getIdServer(); 
     928           const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
     929           for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     930             event.push(*itRank,1,msg); 
     931           clientPrimServer->sendEvent(event); 
     932         } 
     933         else clientPrimServer->sendEvent(event); 
     934       } 
    757935     } 
    758936   } 
     
    806984      this->solveAllInheritance(); 
    807985 
     986      ShowTree(info(10)); 
     987 
    808988      // Check if some axis, domains or grids are eligible to for compressed indexed output. 
    809989      // Warning: This must be done after solving the inheritance and before the rest of post-processing 
     
    8221002      this->findAllEnabledFieldsInReadModeFiles(); 
    8231003 
     1004//     if (hasClient) 
    8241005     if (hasClient && !hasServer) 
    8251006     { 
     
    11871368 
    11881369 
    1189  
    11901370     //! Server side: Receive a message to do some post processing 
    11911371  void CContext::recvRegistry(CEventServer& event) 
     
    12121392 
    12131393    CEventClient event(CContext::GetType(), CContext::EVENT_ID_SEND_REGISTRY); 
    1214     if (client->isServerLeader()) 
     1394    if (!hasServer) 
    12151395    { 
    1216        CMessage msg ; 
    1217        msg<<this->getIdServer(); 
    1218        if (client->clientRank==0) msg<<*registryOut ; 
    1219        const std::list<int>& ranks = client->getRanksServerLeader(); 
    1220        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1221          event.push(*itRank,1,msg); 
    1222        client->sendEvent(event); 
    1223      } 
    1224      else client->sendEvent(event); 
     1396      if (client->isServerLeader()) 
     1397      { 
     1398         CMessage msg ; 
     1399         msg<<this->getIdServer(); 
     1400         if (client->clientRank==0) msg<<*registryOut ; 
     1401         const std::list<int>& ranks = client->getRanksServerLeader(); 
     1402         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1403           event.push(*itRank,1,msg); 
     1404         client->sendEvent(event); 
     1405       } 
     1406       else client->sendEvent(event); 
     1407    } 
     1408    else 
     1409    { 
     1410      if (clientPrimServer->isServerLeader()) 
     1411      { 
     1412         CMessage msg ; 
     1413         msg<<this->getIdServer(); 
     1414         if (clientPrimServer->clientRank==0) msg<<*registryOut ; 
     1415         const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
     1416         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1417           event.push(*itRank,1,msg); 
     1418         clientPrimServer->sendEvent(event); 
     1419       } 
     1420       else clientPrimServer->sendEvent(event); 
     1421 
     1422    } 
    12251423  } 
    12261424 
  • XIOS/dev/dev_olga/src/node/context.hpp

    r917 r983  
    8888      public : 
    8989         // Initialize server or client 
     90         void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer = 0); 
    9091         void initServer(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtClient = 0); 
    91          void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer = 0); 
    9292         bool isInitialized(void); 
    9393 
     
    137137         void sendRefGrid(); 
    138138         void sendPostProcessing(); 
    139          void sendRegistry(void) ; //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 
     139         //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 
     140         void sendRegistry(void) ; 
     141 
    140142         const StdString& getIdServer(); 
    141143 
     
    151153         void recvPostProcessing(CBufferIn& buffer); 
    152154         static void recvRegistry(CEventServer& event) ; 
    153          void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the root process of the servers 
     155         void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the servers 
    154156 
    155157         // dispatch event 
     
    216218         bool hasServer; 
    217219 
    218          // Concrete context server 
    219          CContextServer* server; 
    220  
    221220         // Concrete contex client 
    222221         CContextClient* client; 
    223222         CRegistry* registryIn ;  //!< input registry which is read from file 
    224223         CRegistry* registryOut ; //!< output registry which will be wrote on file at the finalize 
     224 
     225         // Concrete context server 
     226         CContextServer* server; 
     227 
     228         // Client-server pair in case of secondary server pool 
     229         CContextClient* clientPrimServer; 
     230         CContextServer* serverPrimServer; 
    225231 
    226232      private: 
  • XIOS/dev/dev_olga/src/node/field.cpp

    r967 r983  
    122122 
    123123    CContext* context = CContext::getCurrent(); 
    124     CContextClient* client = context->client; 
     124//    CContextClient* client = context->client; 
     125    CContextClient* client = (!context->hasServer) ? context->client : context->clientPrimServer; 
    125126 
    126127    CEventClient event(getType(), EVENT_ID_UPDATE_DATA); 
     
    195196  void  CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 
    196197  { 
     198    CContext* context = CContext::getCurrent(); 
     199 
    197200    if (data_srv.empty()) 
    198201    { 
     
    205208    } 
    206209 
    207     CContext* context = CContext::getCurrent(); 
    208210    const CDate& currDate = context->getCalendar()->getCurrentDate(); 
    209211    const CDate opeDate      = last_operation_srv +freq_op + freq_operation_srv - freq_op; 
     
    229231 
    230232      last_Write_srv = writeDate; 
     233    } 
     234 
     235    if (context->hasClient && context->hasServer) 
     236    { 
     237      size_t writtenSize; 
     238//      if (field->getUseCompressedOutput()) 
     239//        writtenSize = grid->getNumberWrittenIndexes(); 
     240//      else 
     241        writtenSize = grid->getWrittenDataSize(); 
     242 
     243      CArray<double,1> fieldData(writtenSize); 
     244//      if (!field->default_value.isEmpty()) fieldData = field->default_value; 
     245 
     246//      if (field->getUseCompressedOutput()) 
     247//        field->outputCompressedField(fieldData); 
     248//      else 
     249        this->outputField(fieldData); 
     250      sendUpdateData(fieldData); 
     251    } 
     252    if (!context->hasClient && context->hasServer) 
     253    { 
    231254      writeField(); 
    232       lastlast_Write_srv = last_Write_srv; 
    233     } 
     255    } 
     256 
     257    lastlast_Write_srv = last_Write_srv; 
     258 
    234259  } 
    235260 
     
    503528        isReferenceSolved = true; 
    504529 
    505         if (context->hasClient) 
     530        if (context->hasClient && !context->hasServer) 
     531//        if (context->hasClient) 
    506532        { 
    507533          solveRefInheritance(true); 
    508534          if (hasDirectFieldReference()) getDirectFieldReference()->solveOnlyReferenceEnabledField(false); 
    509535        } 
    510         else if (context->hasServer) 
     536//        else if (context->hasServer) 
     537        if (context->hasServer) 
    511538          solveServerOperation(); 
    512539 
    513540        solveGridReference(); 
    514541 
    515        if (context->hasClient) 
     542        if (context->hasClient && !context->hasServer) 
     543//       if (context->hasClient) 
    516544       { 
    517545         solveGenerateGrid(); 
     
    528556   { 
    529557     CContext* context = CContext::getCurrent(); 
    530      if (context->hasClient) 
     558     if (context->hasClient && !context->hasServer) 
     559//     if (context->hasClient) 
    531560     { 
    532561       if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) 
     
    543572   { 
    544573     CContext* context = CContext::getCurrent(); 
    545      if (context->hasClient) 
     574     if (context->hasClient && !context->hasServer) 
     575//     if (context->hasClient) 
    546576     { 
    547577       std::map<CGrid*,std::pair<bool,StdString> >& gridSrcMap = grid->getTransGridSource(); 
     
    628658        areAllReferenceSolved = true; 
    629659 
    630         if (context->hasClient) 
     660//        if (context->hasClient) 
     661        if (context->hasClient && !context->hasServer) 
    631662        { 
    632663          solveRefInheritance(true); 
    633664          if (hasDirectFieldReference()) getDirectFieldReference()->solveAllReferenceEnabledField(false); 
    634665        } 
    635         else if (context->hasServer) 
     666//        else if (context->hasServer) 
     667        if (context->hasServer && !context->hasClient) 
    636668          solveServerOperation(); 
    637669 
     
    641673     solveGridDomainAxisRef(doSending2Server); 
    642674 
    643      if (context->hasClient) 
     675     if (context->hasClient && !context->hasClient) 
    644676     { 
    645677       solveTransformedGrid(); 
  • XIOS/dev/dev_olga/src/node/grid.cpp

    r968 r983  
    273273   { 
    274274     CContext* context = CContext::getCurrent(); 
    275      CContextClient* client=context->client; 
     275     CContextClient* client= context->hasServer ? context->clientPrimServer : context->client; 
    276276 
    277277     if (isScalarGrid()) 
    278278     { 
    279        if (context->hasClient) 
     279       if (context->hasClient && !context->hasServer) 
     280//         if (context->hasClient) 
    280281          if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndexScalarGrid(); this->isIndexSent = true; } 
    281282 
    282283       if (this->isChecked) return; 
    283        if (context->hasClient) 
     284       if (context->hasClient && !context->hasServer) 
     285//       if (context->hasClient) 
    284286       { 
    285287          this->computeIndexScalarGrid(); 
     
    290292     } 
    291293 
    292      if (context->hasClient) 
     294     if (context->hasClient && !context->hasServer) 
     295//     if (context->hasClient) 
    293296      if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndex(); this->isIndexSent = true; } 
    294297 
    295298     if (this->isChecked) return; 
    296299 
    297      if (context->hasClient) 
     300     if (context->hasClient && !context->hasServer) 
     301//     if (context->hasClient) 
    298302     { 
    299303        this->checkAttributesAfterTransformation(); 
     
    497501   { 
    498502     CContext* context = CContext::getCurrent(); 
    499      CContextClient* client = context->client; 
     503//     CContextClient* client = context->client; 
     504     CContextClient* client = (context->hasServer) ? context->clientPrimServer : context->client; 
     505 
    500506 
    501507     // First of all, compute distribution on client side 
    502      clientDistribution_ = new CDistributionClient(client->clientRank, this); 
     508     if (0 != serverDistribution_) 
     509       clientDistribution_ = new CDistributionClient(client->clientRank, serverDistribution_->getGlobalLocalIndex()); 
     510     else 
     511       clientDistribution_ = new CDistributionClient(client->clientRank, this); 
     512 
    503513     // Get local data index on client 
     514     int tmp = clientDistribution_->getLocalDataIndexOnClient().size(); 
    504515     storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
    505516     int nbStoreIndex = storeIndex_client.numElements(); 
     
    577588   { 
    578589     CContext* context = CContext::getCurrent(); 
    579      CContextClient* client = context->client; 
     590     CContextClient* client = context->hasServer ? context->clientPrimServer : context->client; 
    580591     int serverSize = client->serverSize; 
    581592     std::vector<CDomain*> domList = getDomains(); 
     
    975986  { 
    976987    CContext* context = CContext::getCurrent(); 
    977     CContextClient* client=context->client; 
     988    CContextClient* client = context->hasServer ? context->clientPrimServer : context->client; 
    978989 
    979990    storeIndex_client.resize(1); 
     
    10311042  { 
    10321043    CContext* context = CContext::getCurrent(); 
    1033     CContextClient* client = context->client; 
     1044    CContextClient* client = context->hasServer ? context->clientPrimServer : context->client; 
    10341045 
    10351046    CEventClient event(getType(), EVENT_ID_INDEX); 
     
    10701081  { 
    10711082    CContext* context = CContext::getCurrent(); 
    1072     CContextClient* client = context->client; 
     1083//    CContextClient* client = context->client; 
     1084    CContextClient* client = context->hasServer ? context->clientPrimServer : context->client ; 
    10731085 
    10741086    CEventClient event(getType(), EVENT_ID_INDEX); 
     
    11781190    } 
    11791191    get(gridId)->recvIndex(ranks, buffers); 
     1192 
     1193    CContext* context = CContext::getCurrent(); 
     1194    if (context->hasClient && context->hasServer) 
     1195    { 
     1196      get(gridId)->computeIndex(); 
     1197      get(gridId)->sendIndex(); 
     1198    } 
    11801199  } 
    11811200 
     
    11831202  { 
    11841203    CContext* context = CContext::getCurrent(); 
    1185     CContextServer* server = context->server; 
     1204    CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer; 
     1205    CContextClient* client = (context->hasServer) ? context->client : context->clientPrimServer; 
    11861206    numberWrittenIndexes_ = totalNumberWrittenIndexes_ = offsetWrittenIndexes_ = 0; 
    11871207    connectedServerRank_ = ranks; 
     
    12831303      totalNumberWrittenIndexes_ = numberWrittenIndexes_; 
    12841304 
    1285     nbSenders = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); 
     1305    nbSenders = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, ranks); 
    12861306  } 
    12871307 
     
    16571677    { 
    16581678      CDomain* pDom = CDomain::get(*it); 
    1659       if (context->hasClient) 
     1679      if (context->hasClient && !context->hasServer) 
     1680//      if (context->hasClient) 
    16601681      { 
    16611682        pDom->solveRefInheritance(apply); 
     
    16691690    { 
    16701691      CAxis* pAxis = CAxis::get(*it); 
    1671       if (context->hasClient) 
     1692      if (context->hasClient && !context->hasServer) 
     1693//      if (context->hasClient) 
    16721694      { 
    16731695        pAxis->solveRefInheritance(apply); 
     
    16811703    { 
    16821704      CScalar* pScalar = CScalar::get(*it); 
    1683       if (context->hasClient) 
     1705      if (context->hasClient && !context->hasServer) 
     1706//      if (context->hasClient) 
    16841707      { 
    16851708        pScalar->solveRefInheritance(apply); 
  • XIOS/dev/dev_olga/src/server.cpp

    r956 r983  
    33#include "cxios.hpp" 
    44#include "server.hpp" 
     5#include "client.hpp" 
    56#include "type.hpp" 
    67#include "context.hpp" 
     
    1920    list<MPI_Comm> CServer::interComm ; 
    2021    std::list<MPI_Comm> CServer::contextInterComms; 
    21     bool CServer::isRoot ; 
     22    bool CServer::isRoot = false ; 
    2223    int CServer::rank = INVALID_RANK; 
    2324    StdOFStream CServer::m_infoStream; 
     
    2728    bool CServer::is_MPI_Initialized ; 
    2829    CEventScheduler* CServer::eventScheduler = 0; 
    29     
     30 
     31//--------------------------------------------------------------- 
     32/*! 
     33 * \fn void CServer::initialize(void) 
     34 * Function creates intra and inter comm for each initialized server pool 
     35 */ 
    3036    void CServer::initialize(void) 
    3137    { 
     
    4551        CTimer::get("XIOS").resume() ; 
    4652 
     53        int nbSrvLevels = 2; 
     54 
    4755        boost::hash<string> hashString ; 
    48  
    49         unsigned long hashServer=hashString(CXios::xiosCodeId) ; 
     56        unsigned long hashServer1 = hashString(CXios::xiosCodeIdPrm); 
     57        unsigned long hashServer2 = hashString(CXios::xiosCodeIdSnd); 
     58        unsigned long hashServer = (CXios::serverLevel < 2)  ? hashServer1 : hashServer2; 
     59 
    5060        unsigned long* hashAll ; 
    5161 
     
    5666        MPI_Comm newComm ; 
    5767 
    58         MPI_Comm_size(CXios::globalComm,&size) ; 
    59         MPI_Comm_rank(CXios::globalComm,&rank); 
     68        MPI_Comm_size(CXios::globalComm, &size) ; 
     69        MPI_Comm_rank(CXios::globalComm, &rank); 
    6070        hashAll=new unsigned long[size] ; 
    61  
    62         MPI_Allgather(&hashServer,1,MPI_LONG,hashAll,1,MPI_LONG,CXios::globalComm) ; 
     71        MPI_Allgather(&hashServer, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ; 
    6372 
    6473        map<unsigned long, int> colors ; 
     
    7786 
    7887        myColor=colors[hashServer] ; 
    79         MPI_Comm_split(MPI_COMM_WORLD,myColor,rank,&intraComm) ; 
    80  
    81         int serverLeader=leaders[hashServer] ; 
    82         int clientLeader; 
    83  
    84          serverLeader=leaders[hashServer] ; 
    85          for(it=leaders.begin();it!=leaders.end();it++) 
    86          { 
    87            if (it->first!=hashServer) 
    88            { 
    89              clientLeader=it->second ; 
    90              int intraCommSize, intraCommRank ; 
    91              MPI_Comm_size(intraComm,&intraCommSize) ; 
    92              MPI_Comm_rank(intraComm,&intraCommRank) ; 
    93              info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize 
    94                      <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ; 
    95  
    96              MPI_Intercomm_create(intraComm,0,CXios::globalComm,clientLeader,0,&newComm) ; 
    97              interComm.push_back(newComm) ; 
    98            } 
    99          } 
    100  
    101          delete [] hashAll ; 
     88        MPI_Comm_split(MPI_COMM_WORLD, myColor, rank, &intraComm) ; 
     89 
     90        if (CXios::serverLevel == 0) 
     91        { 
     92          int clientLeader; 
     93          for(it=leaders.begin();it!=leaders.end();it++) 
     94          { 
     95            if (it->first!=hashServer) 
     96            { 
     97              clientLeader=it->second ; 
     98              int intraCommSize, intraCommRank ; 
     99              MPI_Comm_size(intraComm,&intraCommSize) ; 
     100              MPI_Comm_rank(intraComm,&intraCommRank) ; 
     101              info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize 
     102                       <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ; 
     103 
     104               MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 
     105               interComm.push_back(newComm) ; 
     106            } 
     107          } 
     108        } 
     109 
     110        else if ((CXios::serverLevel == 1)) 
     111        { 
     112          int clientLeader; 
     113          int srvSndLeader; 
     114          for(it=leaders.begin();it!=leaders.end();it++) 
     115          { 
     116            if (it->first != hashServer2) 
     117            { 
     118              if (it->first != hashServer1) 
     119              { 
     120                clientLeader=it->second ; 
     121                int intraCommSize, intraCommRank ; 
     122                MPI_Comm_size(intraComm,&intraCommSize) ; 
     123                MPI_Comm_rank(intraComm,&intraCommRank) ; 
     124                info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize 
     125                         <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ; 
     126                MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 
     127                interComm.push_back(newComm) ; 
     128              } 
     129            } 
     130            else 
     131            { 
     132              srvSndLeader = it->second; 
     133            } 
     134          } 
     135 
     136        CClient::initializeClientOnServer(rank, intraComm, srvSndLeader); 
     137        } 
     138 
     139        else // secondary server pool 
     140        { 
     141          int clientLeader; 
     142          for(it=leaders.begin();it!=leaders.end();it++) 
     143          { 
     144            if (it->first == hashServer1) 
     145            { 
     146              // no changes needed here to create one context per process of the secondary server pool 
     147              clientLeader=it->second ; 
     148              int intraCommSize, intraCommRank ; 
     149              MPI_Comm_size(intraComm,&intraCommSize) ; 
     150              MPI_Comm_rank(intraComm,&intraCommRank) ; 
     151              info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize 
     152                       <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ; 
     153 
     154              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 
     155              interComm.push_back(newComm) ; 
     156 
     157              break; 
     158            } 
     159          } 
     160        } 
     161 
     162        delete [] hashAll ; 
     163 
    102164      } 
    103165      // using OASIS 
     
    145207    void CServer::finalize(void) 
    146208    { 
     209      if (CXios::serverLevel == 1) 
     210      { 
     211        CClient::finalize(); 
     212      } 
     213 
    147214      CTimer::get("XIOS").suspend() ; 
    148215      
     
    151218      for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 
    152219        MPI_Comm_free(&(*it)); 
     220 
    153221      for (std::list<MPI_Comm>::iterator it = interComm.begin(); it != interComm.end(); it++) 
    154222        MPI_Comm_free(&(*it)); 
     223 
    155224      MPI_Comm_free(&intraComm); 
    156225 
     
    172241       while(!stop) 
    173242       { 
     243 
    174244         if (isRoot) 
    175245         { 
     
    186256         if (finished && contextList.empty()) stop=true ; 
    187257         eventScheduler->checkEvent() ; 
     258 
    188259       } 
    189260       CTimer::get("XIOS server").suspend() ; 
     
    288359     void CServer::recvContextMessage(void* buff,int count) 
    289360     { 
    290        static map<string,contextMessage> recvContextId ; 
     361       static map<string,contextMessage> recvContextId; 
     362 
    291363       map<string,contextMessage>::iterator it ; 
    292364 
     
    362434           MPI_Get_count(&status,MPI_CHAR,&count) ; 
    363435           registerContext(buffer,count) ; 
     436 
    364437           delete [] buffer ; 
    365438           recept=false ; 
     
    373446       CBufferIn buffer(buff, count); 
    374447       buffer >> contextId; 
     448       CContext* context; 
    375449 
    376450       info(20) << "CServer : Register new Context : " << contextId << endl; 
     
    380454               << "Context '" << contextId << "' has already been registred"); 
    381455 
    382        MPI_Comm contextIntercomm; 
    383        MPI_Intercomm_create(intraComm,0,CXios::globalComm,leaderRank,10+leaderRank,&contextIntercomm); 
     456       MPI_Comm contextInterComm; 
     457       MPI_Intercomm_create(intraComm,0,CXios::globalComm,leaderRank,10+leaderRank,&contextInterComm); 
    384458 
    385459       MPI_Comm inter; 
    386        MPI_Intercomm_merge(contextIntercomm,1,&inter); 
     460       MPI_Intercomm_merge(contextInterComm,1,&inter); 
    387461       MPI_Barrier(inter); 
    388462 
    389        CContext* context=CContext::create(contextId); 
     463       context=CContext::create(contextId); 
    390464       contextList[contextId]=context; 
    391        context->initServer(intraComm,contextIntercomm); 
    392  
    393        contextInterComms.push_back(contextIntercomm); 
     465       context->initServer(intraComm,contextInterComm); 
     466       contextInterComms.push_back(contextInterComm); 
     467 
     468       if (CXios::serverLevel == 1) 
     469       { 
     470         CClient::registerContext(contextId, intraComm); 
     471       } 
     472 
    394473       MPI_Comm_free(&inter); 
     474 
    395475     } 
    396476 
     
    399479       bool finished ; 
    400480       map<string,CContext*>::iterator it ; 
     481 
    401482       for(it=contextList.begin();it!=contextList.end();it++) 
    402483       { 
     
    408489         } 
    409490       } 
    410  
    411491     } 
    412492 
  • XIOS/dev/dev_olga/src/server.hpp

    r697 r983  
    2222        static void listenRootContext(void); 
    2323        static void listenRootFinalize(void); 
    24         static void registerContext(void* buff,int count, int leaderRank=0); 
     24        static void registerContext(void* buff,int count, int leaderRank=0);        // context registered by the primary server 
    2525 
     26        // Communicators for the primary group of servers 
    2627        static MPI_Comm intraComm; 
    2728        static list<MPI_Comm> interComm; 
    2829        static std::list<MPI_Comm> contextInterComms; 
    2930        static CEventScheduler* eventScheduler; 
    30          
     31 
    3132        struct contextMessage 
    3233        { 
     
    3738        static bool isRoot; 
    3839 
    39         static map<string,CContext*> contextList; 
     40        static map<string,CContext*> contextList;       // contexts on the primary server 
    4041        static bool finished; 
    4142        static bool is_MPI_Initialized; 
  • XIOS/dev/dev_olga/src/test/test_client.f90

    r794 r983  
    1717  CHARACTER(len=15) :: calendar_type 
    1818  TYPE(xios_context) :: ctx_hdl 
    19   INTEGER,PARAMETER :: ni_glo=100 
    20   INTEGER,PARAMETER :: nj_glo=100 
    21   INTEGER,PARAMETER :: llm=5 
     19  INTEGER,PARAMETER :: ni_glo=2 
     20  INTEGER,PARAMETER :: nj_glo=2 
     21  INTEGER,PARAMETER :: llm=1 
    2222  DOUBLE PRECISION  :: lval(llm)=1 
    2323  TYPE(xios_field) :: field_hdl 
     
    8484  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
    8585 
    86   CALL xios_get_handle("field_definition",fieldgroup_hdl) 
    87   CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 
    88   CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 
     86  !CALL xios_get_handle("field_definition",fieldgroup_hdl) 
     87  !CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 
     88  !CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 
    8989 
    90   CALL xios_get_handle("output",file_hdl) 
    91   CALL xios_add_child(file_hdl,field_hdl) 
    92   CALL xios_set_attr(field_hdl,field_ref="field_A_zoom",name="field_C") 
     90  !CALL xios_get_handle("output",file_hdl) 
     91  !CALL xios_add_child(file_hdl,field_hdl) 
     92  !CALL xios_set_attr(field_hdl,field_ref="field_A_zoom",name="field_C") 
    9393 
    9494  dtime%second = 3600 
  • XIOS/dev/dev_olga/src/xios_server.f90

    r501 r983  
    44  INCLUDE "mpif.h" 
    55  INTEGER :: ierr 
    6    
    7     CALL xios_init_server 
     6  INTEGER            :: server_level = 0   
     7  ! 0 in case of a single server pool  
     8  ! 1 for primary server in case of two server pools 
     9  ! 2 for secondary server in case of two server pools 
    810 
    9   END PROGRAM server_main 
     11  CALL xios_init_server(server_level) 
     12 
     13END PROGRAM server_main 
Note: See TracChangeset for help on using the changeset viewer.