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