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

Last change on this file since 490 was 490, checked in by mhnguyen, 7 years ago

Implementing print output in seperate files

+) Add an option to write information into standard output or into files,
each of which is created by a process
+) Add a new file for global data (constant, value macro, etc)
+) Do a minor change in how to generate doxygen

Test
+) On Curie, with two modes: only client (connected) and client-server
+) All tests passed, each client prints out its info in a seperate file

  • 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
19  bool CXios::isClient ;
20  bool CXios::isServer ;
21  MPI_Comm CXios::globalComm ;
22  bool CXios::usingOasis ;
23  bool CXios::usingServer ;
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    usingServer=getin<bool>("using_server",false) ;
36    usingOasis=getin<bool>("using_oasis",false) ;
37    info.setLevel(getin<int>("info_level",0)) ;
38    printInfo2File=getin<bool>("info_output_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    if (usingServer) isServer=false;
52    else isServer=true ;
53
54    CClient::initialize(codeId,localComm,returnComm) ;
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 aspect 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}
Note: See TracBrowser for help on using the repository browser.