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

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

Making a minor change of info output

+) Use a more beautiful format for name of info output file
+) Do a same thing to error file

Test
+) On curie
+) Passed

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