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