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

Last change on this file since 501 was 501, checked in by ymipsl, 7 years ago

Add licence copyright to all file ond directory src using the command :
svn propset -R copyright -F header_licence src

XIOS is now officialy under CeCILL licence

YM

  • 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: 2.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
32
33  void CXios::initialize()
34  {
35    set_new_handler(noMemory);
36    parseFile(rootFile);
37    usingOasis=getin<bool>("using_oasis",false) ;
38    info.setLevel(getin<int>("info_level",0)) ;
39    printInfo2File=getin<bool>("print_file",false);
40    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
41    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
42    globalComm=MPI_COMM_WORLD ;
43  }
44
45
46  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
47  {
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
76  void CXios::initServerSide(void)
77  {
78    initialize();
79
80    isClient=true;
81    isServer=false ;
82
83    isServerSide = true;
84
85    // Initialize all aspects MPI
86    CServer::initialize();
87
88    if (printInfo2File)
89      CServer::openInfoStream(serverFile);
90    else
91      CServer::openInfoStream();
92
93    // Enter the loop to listen message from Client
94    CServer::eventLoop();
95
96    // Finalize
97    CServer::finalize();
98    CServer::closeInfoStream();
99  }
100
101  void CXios::parseFile(const string& filename)
102  {
103    xml::CXMLParser::ParseFile(filename);
104  }
105
106  void CXios::setUsingServer()
107  {
108    usingServer = true;
109  }
110
111  void CXios::setNotUsingServer()
112  {
113    usingServer = false;
114  }
115}
Note: See TracBrowser for help on using the repository browser.