source: XIOS3/trunk/src/client.cpp @ 2535

Last change on this file since 2535 was 2535, checked in by jderouillat, 11 months ago

Backport [2448,2503,2516], ocean component in generic_testcase, memory_report option and nvertex name

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 21.7 KB
Line 
1#include "globalScopeData.hpp"
2#include "xios_spl.hpp"
3#include "cxios.hpp"
4#include "client.hpp"
5#include <boost/functional/hash.hpp>
6#include "type.hpp"
7#include "context.hpp"
8#include "context_client.hpp"
9#include "oasis_cinterface.hpp"
10#include "mpi.hpp"
11#include "timer.hpp"
12#include "buffer_client.hpp"
13#include "string_tools.hpp"
14#include "ressources_manager.hpp"
15#include "services_manager.hpp"
16#include <functional>
17#include <cstdio>
18#include "workflow_graph.hpp"
19#include "release_static_allocation.hpp"
20#include "mem_checker.hpp"
21
22namespace xios
23{
24
25    const double serverPublishDefaultTimeout=10;
26
27    MPI_Comm CClient::intraComm_ ;
28    MPI_Comm CClient::interComm_ ;
29    MPI_Comm CClient::clientsComm_ ;
30
31    std::list<MPI_Comm> CClient::contextInterComms;
32    int CClient::serverLeader ;
33    bool CClient::is_MPI_Initialized ;
34    int CClient::rank_ = INVALID_RANK;
35    StdOFStream CClient::m_infoStream;
36    StdOFStream CClient::m_errorStream;
37    CPoolRessource* CClient::poolRessource_=nullptr ;
38
39    MPI_Comm& CClient::getInterComm(void)   { return (interComm_); }
40     
41///---------------------------------------------------------------
42/*!
43 * \fn void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
44 * Function creates intraComm (CClient::intraComm) for client group with id=codeId and interComm (CClient::interComm) between client and server groups.
45 * \param [in] codeId identity of context.
46 * \param [in/out] localComm local communicator.
47 * \param [in/out] returnComm (intra)communicator of client group.
48 */
49
50    void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
51    {
52   
53       MPI_Comm clientComm ;
54      // initialize MPI if not initialized
55      int initialized ;
56      MPI_Initialized(&initialized) ;
57      if (initialized) is_MPI_Initialized=true ;
58      else is_MPI_Initialized=false ;
59     
60      MPI_Comm globalComm=CXios::getGlobalComm() ;
61
62      /////////////////////////////////////////
63      ///////////// PART 1 ////////////////////
64      /////////////////////////////////////////
65     
66
67      // localComm isn't given
68      if (localComm == MPI_COMM_NULL)
69      {
70         
71        // don't use OASIS
72        if (!CXios::usingOasis)
73        {
74
75          if (!is_MPI_Initialized)
76          {
77            MPI_Init(NULL, NULL);
78          }
79          CTimer::get("XIOS").resume() ;
80          CTimer::get("XIOS init/finalize",false).resume() ;
81         
82          // split the global communicator
83          // get hash from all model to attribute a unique color (int) and then split to get client communicator
84          // every mpi process of globalComm (MPI_COMM_WORLD) must participate
85
86          int commRank, commSize ;
87          MPI_Comm_rank(globalComm,&commRank) ;
88          MPI_Comm_size(globalComm,&commSize) ;
89
90          std::hash<string> hashString ;
91          size_t hashClient=hashString(codeId) ;
92         
93          size_t* hashAll = new size_t[commSize] ;
94          MPI_Allgather(&hashClient,1,MPI_SIZE_T,hashAll,1,MPI_SIZE_T,globalComm) ;
95         
96          int color=0 ;
97          map<size_t,int> listHash ;
98          for(int i=0 ; i<=commSize ; i++) 
99            if (listHash.count(hashAll[i])==0) 
100            {
101              listHash[hashAll[i]]=color ;
102              color=color+1 ;
103            }
104            color=listHash[hashClient] ;
105          delete[] hashAll ;
106
107          MPI_Comm_split(globalComm, color, commRank, &clientComm) ;
108        }
109        else
110        {
111          ERROR("void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)", <<"OASIS usage is set. In these conditions, XIOS initialization needs the local_comm created by OASIS."<<endl) ;
112        }
113      }
114      else // localComm is given
115      {
116        MPI_Comm_dup(localComm,&clientComm) ;
117        MPI_Comm_dup(localComm,&intraComm_) ;
118
119        if (CXios::usingServer)
120        {
121          MPI_Comm_rank(intraComm_,&rank_) ;
122        }
123
124      }
125     
126     
127      /////////////////////////////////////////
128      ///////////// PART 2 ////////////////////
129      /////////////////////////////////////////
130     
131
132      // Create the XIOS communicator for every process which is related
133      // to XIOS, as well on client side as on server side
134     
135      MPI_Comm xiosGlobalComm ;
136      string strIds=CXios::getin<string>("clients_code_id","") ;
137      vector<string> clientsCodeId=splitRegex(strIds,"\\s*,\\s*") ;
138      if (strIds.empty())
139      {
140         // no code Ids given, suppose XIOS initialisation is global           
141         int commRank, commGlobalRank, serverLeader, clientLeader,serverRemoteLeader,clientRemoteLeader ;
142         MPI_Comm splitComm,interComm ;
143         MPI_Comm_rank(globalComm,&commGlobalRank) ;
144         MPI_Comm_split(globalComm, 0, commGlobalRank, &splitComm) ;
145         int splitCommSize, globalCommSize ;
146       
147         MPI_Comm_size(splitComm,&splitCommSize) ;
148         MPI_Comm_size(globalComm,&globalCommSize) ;
149         if (splitCommSize==globalCommSize) // no server
150         {
151           MPI_Comm_dup(globalComm,&xiosGlobalComm) ;
152           CXios::setXiosComm(xiosGlobalComm) ;
153         }
154         else
155         {
156           MPI_Comm_rank(splitComm,&commRank) ;
157           if (commRank==0) clientLeader=commGlobalRank ;
158           else clientLeader=0 ;
159           serverLeader=0 ;
160           MPI_Allreduce(&clientLeader,&clientRemoteLeader,1,MPI_INT,MPI_SUM,globalComm) ;
161           MPI_Allreduce(&serverLeader,&serverRemoteLeader,1,MPI_INT,MPI_SUM,globalComm) ;
162           MPI_Intercomm_create(splitComm, 0, globalComm, serverRemoteLeader,1341,&interComm) ;
163           MPI_Intercomm_merge(interComm,true,&xiosGlobalComm) ;
164           CXios::setXiosComm(xiosGlobalComm) ;
165         }
166      }
167      else
168      {
169
170        xiosGlobalCommByFileExchange(clientComm, codeId) ;
171     
172      }
173
174      int commRank ;
175      MPI_Comm_rank(CXios::getXiosComm(), &commRank) ;
176      MPI_Comm_split(CXios::getXiosComm(),false,commRank, &clientsComm_) ;
177     
178      // is using server or not ?
179      int xiosCommSize, clientsCommSize ; 
180      MPI_Comm_size(CXios::getXiosComm(), &xiosCommSize) ;
181      MPI_Comm_size(clientsComm_, &clientsCommSize) ;
182      if (xiosCommSize==clientsCommSize) CXios::setUsingServer() ;
183      else CXios::setNotUsingServer() ;
184
185      /////////////////////////////////////////
186      ///////////// PART 3 ////////////////////
187      /////////////////////////////////////////
188     
189      CXios::launchDaemonsManager(false) ;
190      shared_ptr<CEventScheduler> eventScheduler ;
191      poolRessource_ = new CPoolRessource(clientComm, eventScheduler, codeId, false) ;
192
193      /////////////////////////////////////////
194      ///////////// PART 4 ////////////////////
195      /////////////////////////////////////////     
196/*
197      MPI_Request req ;
198      MPI_Status status ;
199      MPI_Ibarrier(CXios::getXiosComm(),&req) ; // be sure that all services are created now, could be remove later if more asynchronisity
200      int ok=false ;
201      while (!ok)
202      {
203        CXios::getDaemonsManager()->eventLoop() ;
204        MPI_Test(&req,&ok,&status) ;
205      }
206*/     
207      returnComm = clientComm ;
208    }
209
210
211    void CClient::xiosGlobalCommByFileExchange(MPI_Comm clientComm, const string& codeId)
212    {
213 
214      MPI_Comm globalComm=CXios::getGlobalComm() ;
215      MPI_Comm xiosGlobalComm ;
216
217      string strIds=CXios::getin<string>("clients_code_id","") ;
218      vector<string> clientsCodeId=splitRegex(strIds,"\\s*,\\s*") ;
219
220      int commRank, globalRank, clientRank, serverRank ;
221      MPI_Comm_rank(clientComm, &commRank) ;
222      MPI_Comm_rank(globalComm, &globalRank) ;
223      string clientFileName("__xios_publisher::"+codeId+"__to_remove__") ;
224           
225      int error ;
226
227      if (commRank==0) // if root process publish name
228      { 
229        std::ofstream ofs (clientFileName, std::ofstream::out);
230        ofs<<globalRank ;
231        ofs.close();
232       
233  // get server root rank
234
235        std::ifstream ifs ;
236        string fileName=("__xios_publisher::"+CXios::xiosCodeId+"__to_remove__") ;
237     
238        double timeout = CXios::getin<double>("server_puplish_timeout",serverPublishDefaultTimeout) ;
239        double time ;
240         
241        do
242        {
243          CTimer::get("server_publish_timeout").resume() ; 
244          ifs.clear() ;
245          ifs.open(fileName, std::ifstream::in) ;
246          CTimer::get("server_publish_timeout").suspend() ;
247        } while (ifs.fail() && CTimer::get("server_publish_timeout").getCumulatedTime()<timeout) ;
248       
249        if (CTimer::get("server_publish_timeout").getCumulatedTime()>=timeout || ifs.fail())
250        {
251          ifs.clear() ;
252          ifs.close() ;
253          ifs.clear() ;
254          error=true ;           
255        }
256        else 
257        {
258          ifs>>serverRank ;
259          ifs.close() ;
260          error=false ;
261        } 
262
263      } 
264      MPI_Bcast(&error,1,MPI_INT,0,clientComm) ;
265     
266      if (error==false)  // you have a server
267      {
268        MPI_Comm intraComm ;
269        MPI_Comm_dup(clientComm,&intraComm) ;
270        MPI_Comm interComm ;
271       
272        int pos=0 ;
273        for(int i=0 ; codeId!=clientsCodeId[i]; i++) pos=pos+1 ;
274
275        bool high=true ;
276        for(int i=pos ; i<clientsCodeId.size(); i++)
277        { 
278          MPI_Intercomm_create(intraComm, 0, globalComm, serverRank, 3141, &interComm);
279          MPI_Comm_free(&intraComm) ;
280          MPI_Intercomm_merge(interComm,high, &intraComm ) ;
281          high=false ;
282          if (i==pos) {
283            interComm_=interComm ;
284          }
285        }
286        xiosGlobalComm=intraComm ;
287      }
288      else  // no server detected
289      {
290        vector<int> clientsRank(clientsCodeId.size()) ;
291       
292        if (commRank==0)
293        { 
294          for(int i=0;i<clientsRank.size();i++)
295          {
296            std::ifstream ifs ;
297            string fileName=("__xios_publisher::"+clientsCodeId[i]+"__to_remove__") ;
298            do
299            {
300              ifs.clear() ;
301              ifs.open(fileName, std::ifstream::in) ;
302            } while (ifs.fail()) ;
303            ifs>>clientsRank[i] ;
304            ifs.close() ;
305          }
306        }
307         
308        int client ;
309        MPI_Comm intraComm ;
310        MPI_Comm_dup(clientComm,&intraComm) ;
311        MPI_Comm interComm ;
312       
313        int pos=0 ;
314        for(int i=0 ; codeId!=clientsCodeId[i]; i++) pos=pos+1 ;
315       
316        bool high=true ;
317        for(int i=pos+1 ; i<clientsCodeId.size(); i++)
318        { 
319          if (codeId==clientsCodeId[0])   // first model play the server rule
320          {         
321            MPI_Intercomm_create(intraComm, 0, globalComm, clientsRank[i], 3141, &interComm);
322            MPI_Intercomm_merge(interComm,false, &intraComm ) ;
323          }
324          else
325          {         
326            MPI_Intercomm_create(intraComm, 0, globalComm, clientsRank[0], 3141, &interComm);
327            MPI_Intercomm_merge(interComm,high, &intraComm ) ;
328            high=false ;
329          }
330          if (i==pos) {
331            interComm_=interComm ; // NOT TESTED !
332          }
333        }
334        xiosGlobalComm=intraComm ;
335      }
336
337      MPI_Barrier(xiosGlobalComm);
338      if (commRank==0) std::remove(clientFileName.c_str()) ;         
339      MPI_Barrier(xiosGlobalComm);
340 
341      CXios::setXiosComm(xiosGlobalComm) ;
342
343      MPI_Comm commUnfree ;
344      MPI_Comm_dup(clientComm, &commUnfree ) ;
345 
346    }
347
348// to check on other architecture
349    void CClient::xiosGlobalCommByPublishing(MPI_Comm clientComm, const string& codeId)
350    {
351
352      // untested. need to be developped an a true MPI compliant library
353
354/*
355        // try to discover other client/server
356        // do you have a xios server ?
357        char portName[MPI_MAX_PORT_NAME];
358        int ierr ;
359        int commRank ;
360        MPI_Comm_rank(clientComm,&commRank) ;
361
362        MPI_Barrier(globalComm) ;
363        if (commRank==0)
364        {
365             
366          MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN );
367          const char* serviceName=CXios::xiosCodeId.c_str() ;
368          ierr=MPI_Lookup_name(CXios::xiosCodeId.c_str(), MPI_INFO_NULL, portName);
369          MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
370        }
371        ierr=MPI_SUCCESS ;
372        MPI_Bcast(&ierr,1,MPI_INT,0,clientComm) ;
373
374        if (ierr==MPI_SUCCESS) // you have a server
375        { 
376          MPI_Comm intraComm=clientComm ;
377          MPI_Comm interComm ;
378          for(int i=0 ; i<clientsCodeId.size(); i++)
379          { 
380            MPI_Comm_connect(portName, MPI_INFO_NULL, 0, intraComm, &interComm);
381            MPI_Intercomm_merge(interComm, true, &intraComm ) ;
382          }
383          xiosGlobalComm=intraComm ;
384        }
385        else  // you don't have any server
386        {
387          if (codeId==clientsCodeId[0]) // first code will publish his name
388          {
389
390            if (commRank==0) // if root process publish name
391            { 
392              MPI_Open_port(MPI_INFO_NULL, portName);
393              MPI_Publish_name(CXios::xiosCodeId.c_str(), MPI_INFO_NULL, portName);
394            }
395
396            MPI_Comm intraComm=clientComm ;
397            MPI_Comm interComm ;
398            for(int i=0 ; i<clientsCodeId.size()-1; i++)
399            { 
400              MPI_Comm_accept(portName, MPI_INFO_NULL, 0, intraComm, &interComm);
401              MPI_Intercomm_merge(interComm,false, &intraComm ) ;
402            }
403          }
404          else  // other clients are connecting to the first one
405          {
406            if (commRank==0)
407            {
408
409              MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN );
410              ierr=MPI_Lookup_name(CXios::xiosCodeId.c_str(), MPI_INFO_NULL, portName);
411              MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
412             }
413
414            MPI_Bcast(&ierr,1,MPI_INT,0,clientComm) ;
415
416            if (ierr==MPI_SUCCESS) // you can connect
417            { 
418              MPI_Comm intraComm=clientComm ;
419              MPI_Comm interComm ;
420              for(int i=0 ; i<clientsCodeId.size()-1; i++)
421              { 
422                MPI_Comm_connect(portName, MPI_INFO_NULL, 0, intraComm, &interComm);
423                MPI_Intercomm_merge(interComm, true, &intraComm ) ;
424              }
425              xiosGlobalComm=intraComm ;
426            }
427          }
428        } 
429      */
430    }
431
432
433///---------------------------------------------------------------
434/*!
435 * \fn void CClient::registerContext(const string& id, MPI_Comm contextComm)
436 * \brief Sends a request to create a context to server. Creates client/server contexts.
437 * \param [in] id id of context.
438 * \param [in] contextComm.
439 * Function is only called by client.
440 */
441    void CClient::registerContext(const string& id, MPI_Comm contextComm)
442    {
443      int commRank, commSize ;
444      MPI_Comm_rank(contextComm,&commRank) ;
445      MPI_Comm_size(contextComm,&commSize) ;
446     
447      shared_ptr<CEventScheduler> eventScheduler ;
448     
449      getPoolRessource()->createService(contextComm, eventScheduler, id, 0, CServicesManager::CLIENT, 1) ;
450//      getPoolRessource()->createService(contextComm, eventScheduler, id+"_"+CXios::defaultWriterId, 0, CServicesManager::WRITER, 1) ;
451      getPoolRessource()->createNewServiceOnto(id+"_"+CXios::defaultWriterId, CServicesManager::WRITER, id) ;
452//      getPoolRessource()->createService(contextComm, eventScheduler, id+"_"+CXios::defaultReaderId, 0, CServicesManager::READER, 1) ;
453      getPoolRessource()->createNewServiceOnto(id+"_"+CXios::defaultReaderId, CServicesManager::READER, id) ;
454
455      if (commRank==0) while (!CXios::getServicesManager()->hasService(getPoolRessource()->getId(), id, 0)) { CXios::getDaemonsManager()->eventLoop();}
456
457      if (commRank==0) CXios::getContextsManager()->createServerContext(getPoolRessource()->getId(), id, 0, id) ;
458      int type=CServicesManager::CLIENT ;
459      string name = CXios::getContextsManager()->getServerContextName(getPoolRessource()->getId(), id, 0, type, id) ;
460      double time ;
461      double lastTime=0 ;
462      double latency=0 ;
463      bool out=false ;
464      while (!out)
465      {
466        time=MPI_Wtime() ;
467        if (time-lastTime > latency) 
468        {
469          out=CXios::getContextsManager()->hasContext(name, contextComm);
470          lastTime=time ;
471        }
472        if (!out) CXios::getDaemonsManager()->eventLoop() ;
473      }
474
475    }
476
477
478
479/*!
480 * \fn void CClient::callOasisEnddef(void)
481 * \brief Send the order to the servers to call "oasis_enddef". It must be done by each compound of models before calling oasis_enddef on client side
482 * Function is only called by client.
483 */
484    void CClient::callOasisEnddef(void)
485    {
486      bool oasisEnddef=CXios::getin<bool>("call_oasis_enddef",true) ;
487      if (!oasisEnddef) ERROR("void CClient::callOasisEnddef(void)", <<"Function xios_oasis_enddef called but variable <call_oasis_enddef> is set to false."<<endl
488                                                                     <<"Variable <call_oasis_enddef> must be set to true"<<endl) ;
489      if (!CXios::isClient) // != isServer (change recently )
490      // Attached mode
491      {
492        // nothing to do   
493      }
494      else
495      {
496        int rank ;
497        int msg=0 ;
498
499        MPI_Comm_rank(intraComm_,&rank) ;
500        if (rank==0) 
501        {
502          MPI_Send(&msg,1,MPI_INT,0,5,interComm_) ; // tags oasis_endded = 5
503        }
504
505      }
506    }
507
508    void CClient::finalize(void)
509    {
510     
511      MPI_Barrier(clientsComm_) ;
512      int commRank ;
513      MPI_Comm_rank(clientsComm_, &commRank) ;
514      if (commRank==0) CXios::getRessourcesManager()->finalize() ;
515     
516      CTimer::get("XIOS init/finalize",false).suspend() ;
517      CTimer::get("XIOS").suspend() ;
518      CXios::finalizeDaemonsManager() ;
519      finalizePoolRessource() ;
520      CContext::removeAllContexts() ; // free memory for related context
521
522      CXios::getMpiGarbageCollector().release() ; // release unfree MPI ressources
523      if (!is_MPI_Initialized)
524      {
525        if (!CXios::usingOasis) MPI_Finalize() ;
526      }
527     
528      info(20) << "Client side context is finalized"<<endl ;
529      report(0) <<" Performance report : Whole time from XIOS init and finalize: "<< CTimer::get("XIOS init/finalize").getCumulatedTime()<<" s"<<endl ;
530      report(0) <<" Performance report : total time spent for XIOS : "<< CTimer::get("XIOS").getCumulatedTime()<<" s"<<endl ;
531      report(0)<< " Performance report : time spent for waiting free buffer : "<< CTimer::get("Blocking time").getCumulatedTime()<<" s"<<endl ;
532      report(0)<< " Performance report : Ratio : "<< CTimer::get("Blocking time").getCumulatedTime()/CTimer::get("XIOS init/finalize").getCumulatedTime()*100.<<" %"<<endl ;
533      report(0)<< " Performance report : This ratio must be close to zero. Otherwise it may be usefull to increase buffer size or numbers of server"<<endl ;
534//      report(0)<< " Memory report : Current buffer_size : "<<CXios::bufferSize<<endl ;
535      report(0)<< " Memory report : Minimum buffer size required : " << CClientBuffer::maxRequestSize << " bytes" << endl ;
536      report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ;
537      report(100)<<CTimer::getAllCumulatedTime()<<endl ;
538      if (CXios::reportMemory)
539      {
540        report(100)<<CMemChecker::getAllCumulatedMem()<<endl ;
541      }
542      CWorkflowGraph::drawWorkFlowGraph_client();
543
544      xios::releaseStaticAllocation() ;
545
546    }
547   
548    void CClient::finalizePoolRessource() 
549    { 
550      delete poolRessource_ ; poolRessource_=nullptr ;
551    }
552
553    /*!
554    * Return global rank without oasis and current rank in model intraComm in case of oasis
555    */
556   int CClient::getRank()
557   {
558     return rank_;
559   }
560
561    /*!
562    * Open a file specified by a suffix and an extension and use it for the given file buffer.
563    * The file name will be suffix+rank+extension.
564    *
565    * \param fileName[in] protype file name
566    * \param ext [in] extension of the file
567    * \param fb [in/out] the file buffer
568    */
569    void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)
570    {
571      StdStringStream fileNameClient;
572      int numDigit = 0;
573      int size = 0;
574      int rank;
575      MPI_Comm_size(CXios::getGlobalComm(), &size);
576      MPI_Comm_rank(CXios::getGlobalComm(),&rank);
577      while (size)
578      {
579        size /= 10;
580        ++numDigit;
581      }
582
583      fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << rank << ext;
584
585      fb->open(fileNameClient.str().c_str(), std::ios::out);
586      if (!fb->is_open())
587        ERROR("void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)",
588              << std::endl << "Can not open <" << fileNameClient.str() << "> file to write the client log(s).");
589    }
590
591    /*!
592    * \brief Open a file stream to write the info logs
593    * Open a file stream with a specific file name suffix+rank
594    * to write the info logs.
595    * \param fileName [in] protype file name
596    */
597    void CClient::openInfoStream(const StdString& fileName)
598    {
599      std::filebuf* fb = m_infoStream.rdbuf();
600      openStream(fileName, ".out", fb);
601
602      info.write2File(fb);
603      report.write2File(fb);
604    }
605
606    //! Write the info logs to standard output
607    void CClient::openInfoStream()
608    {
609      info.write2StdOut();
610      report.write2StdOut();
611    }
612
613    //! Close the info logs file if it opens
614    void CClient::closeInfoStream()
615    {
616      if (m_infoStream.is_open()) m_infoStream.close();
617    }
618
619    /*!
620    * \brief Open a file stream to write the error log
621    * Open a file stream with a specific file name suffix+rank
622    * to write the error log.
623    * \param fileName [in] protype file name
624    */
625    void CClient::openErrorStream(const StdString& fileName)
626    {
627      std::filebuf* fb = m_errorStream.rdbuf();
628      openStream(fileName, ".err", fb);
629
630      error.write2File(fb);
631    }
632
633    //! Write the error log to standard error output
634    void CClient::openErrorStream()
635    {
636      error.write2StdErr();
637    }
638
639    //! Close the error log file if it opens
640    void CClient::closeErrorStream()
641    {
642      if (m_errorStream.is_open()) m_errorStream.close();
643    }
644}
Note: See TracBrowser for help on using the repository browser.