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

Last change on this file since 504 was 501, checked in by ymipsl, 10 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
RevLine 
[300]1
2#include "xmlioserver_spl.hpp"
3#include "cxios.hpp"
[342]4#include "client.hpp"
5#include "server.hpp"
[346]6#include "xml_parser.hpp"
[300]7#include <boost/functional/hash.hpp>
[382]8#include "mpi.hpp"
[400]9#include "memory.hpp"
10#include <new>
[401]11#include "memtrack.hpp"
[300]12
[335]13namespace xios
[300]14{
15  string CXios::rootFile="./iodef.xml" ;
16  string CXios::xiosCodeId="xios.x" ;
[499]17  string CXios::clientFile="./xios_client";
18  string CXios::serverFile="./xios_server";
[490]19
[300]20  bool CXios::isClient ;
21  bool CXios::isServer ;
22  MPI_Comm CXios::globalComm ;
23  bool CXios::usingOasis ;
[491]24  bool CXios::usingServer = false;
[317]25  size_t CXios::bufferSize ;
26  double CXios::bufferServerFactorSize=2 ;
27  size_t CXios::defaultBufferSize=1024*1024*100 ; // 100Mo
28  double CXios::defaultBufferServerFactorSize=2 ;
[490]29  bool CXios::printInfo2File;
[499]30  bool CXios::isServerSide;
[490]31
32
[300]33  void CXios::initialize()
34  {
[400]35    set_new_handler(noMemory);
[346]36    parseFile(rootFile);
[311]37    usingOasis=getin<bool>("using_oasis",false) ;
38    info.setLevel(getin<int>("info_level",0)) ;
[491]39    printInfo2File=getin<bool>("print_file",false);
[317]40    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
41    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
[300]42    globalComm=MPI_COMM_WORLD ;
43  }
44
45
46  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
47  {
[490]48
[300]49    initialize() ;
[490]50
[300]51    isClient=true;
[491]52
53    CClient::initialize(codeId,localComm,returnComm) ;
54
[499]55    if (usingServer) isServerSide = isServer=false;
56    else isServerSide = isServer=true;
[490]57
58    if (printInfo2File)
[499]59      CClient::openInfoStream(clientFile);
[490]60    else
61      CClient::openInfoStream();
62  }
[300]63
64  void CXios::clientFinalize(void)
65  {
[490]66     CClient::finalize() ;
67     CClient::closeInfoStream();
68
[401]69#ifdef XIOS_MEMTRACK
70     MemTrack::TrackListMemoryUsage() ;
[490]71     MemTrack::TrackDumpBlocks();
[401]72#endif
[490]73  }
74
75
[300]76  void CXios::initServerSide(void)
77  {
78    initialize();
[499]79
[300]80    isClient=true;
81    isServer=false ;
82
[499]83    isServerSide = true;
84
[491]85    // Initialize all aspects MPI
[490]86    CServer::initialize();
87
88    if (printInfo2File)
[499]89      CServer::openInfoStream(serverFile);
[490]90    else
91      CServer::openInfoStream();
92
[491]93    // Enter the loop to listen message from Client
[490]94    CServer::eventLoop();
95
[491]96    // Finalize
[490]97    CServer::finalize();
98    CServer::closeInfoStream();
99  }
100
[346]101  void CXios::parseFile(const string& filename)
102  {
[490]103    xml::CXMLParser::ParseFile(filename);
[346]104  }
[491]105
106  void CXios::setUsingServer()
107  {
108    usingServer = true;
109  }
110
111  void CXios::setNotUsingServer()
112  {
113    usingServer = false;
114  }
[300]115}
Note: See TracBrowser for help on using the repository browser.