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

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

Seperating database of context on "client" side and "server" side

+) Add one more context in contex client in case of attached mode
+) Do some minor changements to make sure everything fine in case of attached mode
+) Replace buffer group with the new options

Test
+) On Curie
+) Connection mode: Attached and seperated
+) File mode: one and multiple
+) All tests passed

  • 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.5 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  bool CXios::isOptPerformance = true;
32
33  void CXios::initialize()
34  {
35    set_new_handler(noMemory);
36    parseFile(rootFile);
37    parseXiosConfig();
38  }
39
40  void CXios::parseXiosConfig()
41  {
42    usingOasis=getin<bool>("using_oasis",false) ;
43    usingServer=getin<bool>("using_server",false) ;
44    info.setLevel(getin<int>("info_level",0)) ;
45    report.setLevel(getin<int>("info_level",0));
46    printInfo2File=getin<bool>("print_file",false);
47    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
48    StdString bufMemory("memory");
49    StdString bufPerformance("performance");
50    StdString bufOpt = getin<StdString>("optimal_buffer_size", bufPerformance);
51    std::transform(bufOpt.begin(), bufOpt.end(), bufOpt.begin(), ::tolower);
52    if (0 == bufOpt.compare(bufMemory)) isOptPerformance = false;
53    else if (0 != bufOpt.compare(bufPerformance))
54    {
55      ERROR("CXios::parseXiosConfig()", << "optimal_buffer_size must be memory or performance "<< endl );
56    }
57
58//    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
59    bufferServerFactorSize=getin<double>("buffer_factor_size",defaultBufferServerFactorSize) ;
60    globalComm=MPI_COMM_WORLD ;
61  }
62
63  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
64  {
65    initialize() ;
66
67    isClient=true;
68
69    CClient::initialize(codeId,localComm,returnComm) ;
70
71    if (usingServer) isServerSide = isServer=false;
72    else isServerSide = isServer=true;
73
74    if (printInfo2File)
75      CClient::openInfoStream(clientFile);
76    else
77      CClient::openInfoStream();
78  }
79
80  void CXios::clientFinalize(void)
81  {
82     CClient::finalize() ;
83     CClient::closeInfoStream();
84
85#ifdef XIOS_MEMTRACK
86     MemTrack::TrackListMemoryUsage() ;
87     MemTrack::TrackDumpBlocks();
88#endif
89  }
90
91  void CXios::initServer()
92  {
93    set_new_handler(noMemory);
94    std::set<StdString> parseList;
95    parseList.insert("xios");
96    xml::CXMLParser::ParseFile(rootFile, parseList);
97    parseXiosConfig();
98  }
99
100  void CXios::initServerSide(void)
101  {
102//    initialize();
103    initServer();
104    isClient=true;
105    isServer=false ;
106
107    isServerSide = true;
108
109    // Initialize all aspects MPI
110    CServer::initialize();
111
112    if (printInfo2File)
113      CServer::openInfoStream(serverFile);
114    else
115      CServer::openInfoStream();
116
117    // Enter the loop to listen message from Client
118    CServer::eventLoop();
119
120    // Finalize
121    CServer::finalize();
122    CServer::closeInfoStream();
123  }
124
125  void CXios::parseFile(const string& filename)
126  {
127    xml::CXMLParser::ParseFile(filename);
128  }
129
130  void CXios::setUsingServer()
131  {
132    usingServer = true;
133  }
134
135  void CXios::setNotUsingServer()
136  {
137    usingServer = false;
138  }
139}
Note: See TracBrowser for help on using the repository browser.