[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] | 13 | namespace xios |
---|
[300] | 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 ; |
---|
[317] | 23 | size_t CXios::bufferSize ; |
---|
| 24 | double CXios::bufferServerFactorSize=2 ; |
---|
| 25 | size_t CXios::defaultBufferSize=1024*1024*100 ; // 100Mo |
---|
| 26 | double CXios::defaultBufferServerFactorSize=2 ; |
---|
[300] | 27 | |
---|
| 28 | void CXios::initialize() |
---|
| 29 | { |
---|
[400] | 30 | set_new_handler(noMemory); |
---|
[346] | 31 | parseFile(rootFile); |
---|
[311] | 32 | usingServer=getin<bool>("using_server",false) ; |
---|
| 33 | usingOasis=getin<bool>("using_oasis",false) ; |
---|
| 34 | info.setLevel(getin<int>("info_level",0)) ; |
---|
[317] | 35 | bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ; |
---|
| 36 | bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ; |
---|
[300] | 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 | |
---|
[342] | 50 | CClient::initialize(codeId,localComm,returnComm) ; |
---|
[300] | 51 | |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | void CXios::clientFinalize(void) |
---|
| 55 | { |
---|
[401] | 56 | CClient::finalize() ; |
---|
| 57 | #ifdef XIOS_MEMTRACK |
---|
| 58 | MemTrack::TrackListMemoryUsage() ; |
---|
| 59 | MemTrack::TrackDumpBlocks(); |
---|
| 60 | #endif |
---|
[300] | 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 | |
---|
[342] | 72 | CServer::initialize() ; |
---|
[300] | 73 | } |
---|
| 74 | |
---|
[346] | 75 | void CXios::parseFile(const string& filename) |
---|
| 76 | { |
---|
| 77 | xml::CXMLParser::ParseFile(filename); |
---|
| 78 | } |
---|
| 79 | |
---|
[300] | 80 | |
---|
| 81 | } |
---|