source: XIOS/trunk/src/cxios.cpp @ 509

Last change on this file since 509 was 509, checked in by mhnguyen, 9 years ago

Implementing buffer size auto-detection for mode client -server

+) Process xml tree in client side then send all the information to server
+) Only information enabled fields in enabled files are sent to server
+) Some important change in structure of code which must be refactored

Test
+) On Curie
+) Only mode client-server
+) Passed for all tests

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1
2#include "xmlioserver_spl.hpp"
3#include "cxios.hpp"
4#include "client.hpp"
5#include "server.hpp"
6#include "xml_parser.hpp"
7#include <boost/functional/hash.hpp>
8#include "mpi.hpp"
9#include "memory.hpp"
10#include <new>
11#include "memtrack.hpp"
12
13namespace xios
14{
15  string CXios::rootFile="./iodef.xml" ;
16  string CXios::xiosCodeId="xios.x" ;
17  string CXios::clientFile="./xios_client";
18  string CXios::serverFile="./xios_server";
19
20  bool CXios::isClient ;
21  bool CXios::isServer ;
22  MPI_Comm CXios::globalComm ;
23  bool CXios::usingOasis ;
24  bool CXios::usingServer = false;
25  size_t CXios::bufferSize ;
26  double CXios::bufferServerFactorSize=2 ;
27  size_t CXios::defaultBufferSize=1024*1024*100 ; // 100Mo
28  double CXios::defaultBufferServerFactorSize=2 ;
29  bool CXios::printInfo2File;
30  bool CXios::isServerSide;
31
32
33  void CXios::initialize()
34  {
35    set_new_handler(noMemory);
36    parseFile(rootFile);
37    usingOasis=getin<bool>("using_oasis",false) ;
38    usingServer=getin<bool>("using_server",false) ;
39    info.setLevel(getin<int>("info_level",0)) ;
40    printInfo2File=getin<bool>("print_file",false);
41    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
42    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
43    globalComm=MPI_COMM_WORLD ;
44  }
45
46
47  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
48  {
49    initialize() ;
50
51    isClient=true;
52
53    CClient::initialize(codeId,localComm,returnComm) ;
54
55    if (usingServer) isServerSide = isServer=false;
56    else isServerSide = isServer=true;
57
58    if (printInfo2File)
59      CClient::openInfoStream(clientFile);
60    else
61      CClient::openInfoStream();
62  }
63
64  void CXios::clientFinalize(void)
65  {
66     CClient::finalize() ;
67     CClient::closeInfoStream();
68
69#ifdef XIOS_MEMTRACK
70     MemTrack::TrackListMemoryUsage() ;
71     MemTrack::TrackDumpBlocks();
72#endif
73  }
74
75  void CXios::initServer()
76  {
77    set_new_handler(noMemory);
78    std::set<StdString> parseList;
79    parseList.insert("xios");
80    xml::CXMLParser::ParseFile(rootFile, parseList);
81//    parseFile(rootFile);
82    usingOasis=getin<bool>("using_oasis",false) ;
83    info.setLevel(getin<int>("info_level",0)) ;
84    printInfo2File=getin<bool>("print_file",false);
85    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
86    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
87    globalComm=MPI_COMM_WORLD ;
88
89  }
90
91  void CXios::initServerSide(void)
92  {
93//    initialize();
94    initServer();
95    isClient=true;
96    isServer=false ;
97
98    isServerSide = true;
99
100    // Initialize all aspects MPI
101    CServer::initialize();
102
103    if (printInfo2File)
104      CServer::openInfoStream(serverFile);
105    else
106      CServer::openInfoStream();
107
108    // Enter the loop to listen message from Client
109    CServer::eventLoop();
110
111    // Finalize
112    CServer::finalize();
113    CServer::closeInfoStream();
114  }
115
116  void CXios::parseFile(const string& filename)
117  {
118    xml::CXMLParser::ParseFile(filename);
119  }
120
121  void CXios::setUsingServer()
122  {
123    usingServer = true;
124  }
125
126  void CXios::setNotUsingServer()
127  {
128    usingServer = false;
129  }
130}
Note: See TracBrowser for help on using the repository browser.