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

Last change on this file since 401 was 401, checked in by ymipsl, 9 years ago
  • Implement mechanism for tracking memory leak
  • Correct important memory leaks
  • Add complementary report on memory consumption

YM

  • Property svn:eol-style set to native
File size: 1.9 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 
18  bool CXios::isClient ;
19  bool CXios::isServer ;
20  MPI_Comm CXios::globalComm ;
21  bool CXios::usingOasis ;
22  bool CXios::usingServer ;   
23  size_t CXios::bufferSize ;
24  double CXios::bufferServerFactorSize=2 ;
25  size_t CXios::defaultBufferSize=1024*1024*100 ; // 100Mo
26  double CXios::defaultBufferServerFactorSize=2 ;
27 
28  void CXios::initialize()
29  {
30    set_new_handler(noMemory);
31    parseFile(rootFile);
32    usingServer=getin<bool>("using_server",false) ;
33    usingOasis=getin<bool>("using_oasis",false) ;
34    info.setLevel(getin<int>("info_level",0)) ;
35    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ;
36    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ;
37    globalComm=MPI_COMM_WORLD ;
38  }
39
40
41  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
42  {
43     
44    initialize() ;
45   
46    isClient=true;
47    if (usingServer) isServer=false;
48    else isServer=true ;
49   
50    CClient::initialize(codeId,localComm,returnComm) ;
51
52  }   
53
54  void CXios::clientFinalize(void)
55  {
56     CClient::finalize() ; 
57#ifdef XIOS_MEMTRACK
58     MemTrack::TrackListMemoryUsage() ;
59     MemTrack::TrackDumpBlocks(); 
60#endif
61  }   
62 
63 
64  void CXios::initServerSide(void)
65  {
66    initialize();
67
68    if (!usingServer) ERROR("void CXios::initServerSide(void)",<<"using_server is set to <false> and server initialization is called") ;
69    isClient=true;
70    isServer=false ;
71
72    CServer::initialize() ;
73  } 
74 
75  void CXios::parseFile(const string& filename)
76  {
77    xml::CXMLParser::ParseFile(filename); 
78  }
79 
80
81}
Note: See TracBrowser for help on using the repository browser.