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

Last change on this file since 492 was 491, checked in by mhnguyen, 10 years ago

Removing using_server from iodef.xml file. From now on, XIOS is capable of dectectin automatically server mode

+) Check whether server is in the MPI global group
+) Add some more methods to set/unset using_server
+) Do some cleaning stuff

Test
+) On Curie
+) All test passed correctly without using_server id

  • 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" ;
[490]17  string CXios::infoFile="./info_output";
18
[300]19  bool CXios::isClient ;
20  bool CXios::isServer ;
21  MPI_Comm CXios::globalComm ;
22  bool CXios::usingOasis ;
[491]23  bool CXios::usingServer = false;
[317]24  size_t CXios::bufferSize ;
25  double CXios::bufferServerFactorSize=2 ;
26  size_t CXios::defaultBufferSize=1024*1024*100 ; // 100Mo
27  double CXios::defaultBufferServerFactorSize=2 ;
[490]28  bool CXios::printInfo2File;
29
30
[300]31  void CXios::initialize()
32  {
[400]33    set_new_handler(noMemory);
[346]34    parseFile(rootFile);
[311]35    usingOasis=getin<bool>("using_oasis",false) ;
36    info.setLevel(getin<int>("info_level",0)) ;
[491]37    printInfo2File=getin<bool>("print_file",false);
[317]38    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
39    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
[300]40    globalComm=MPI_COMM_WORLD ;
41  }
42
43
44  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
45  {
[490]46
[300]47    initialize() ;
[490]48
[300]49    isClient=true;
[491]50
51    CClient::initialize(codeId,localComm,returnComm) ;
52
[300]53    if (usingServer) isServer=false;
54    else isServer=true ;
[490]55
56    if (printInfo2File)
57      CClient::openInfoStream(infoFile);
58    else
59      CClient::openInfoStream();
60  }
[300]61
62  void CXios::clientFinalize(void)
63  {
[490]64     CClient::finalize() ;
65     CClient::closeInfoStream();
66
[401]67#ifdef XIOS_MEMTRACK
68     MemTrack::TrackListMemoryUsage() ;
[490]69     MemTrack::TrackDumpBlocks();
[401]70#endif
[490]71  }
72
73
[300]74  void CXios::initServerSide(void)
75  {
76    initialize();
77
[491]78//    if (!usingServer) ERROR("void CXios::initServerSide(void)",<<"using_server is set to <false> and server initialization is called") ;
[300]79    isClient=true;
80    isServer=false ;
81
[491]82    // Initialize all aspects MPI
[490]83    CServer::initialize();
84
85    if (printInfo2File)
86      CServer::openInfoStream(infoFile);
87    else
88      CServer::openInfoStream();
89
[491]90    // Enter the loop to listen message from Client
[490]91    CServer::eventLoop();
92
[491]93    // Finalize
[490]94    CServer::finalize();
95    CServer::closeInfoStream();
96  }
97
[346]98  void CXios::parseFile(const string& filename)
99  {
[490]100    xml::CXMLParser::ParseFile(filename);
[346]101  }
[491]102
103  void CXios::setUsingServer()
104  {
105    usingServer = true;
106  }
107
108  void CXios::setNotUsingServer()
109  {
110    usingServer = false;
111  }
[300]112}
Note: See TracBrowser for help on using the repository browser.