source: XIOS/dev/dev_olga/src/server.cpp @ 1139

Last change on this file since 1139 was 1139, checked in by oabramkina, 7 years ago

Fixing a bug in context finalization. Now context finalization is done in two stages.
Tested on Cure with test_regular and test_xios2_cmip6.

  • 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.8 KB
Line 
1#include "globalScopeData.hpp"
2#include "xios_spl.hpp"
3#include "cxios.hpp"
4#include "server.hpp"
5#include "client.hpp"
6#include "type.hpp"
7#include "context.hpp"
8#include "object_template.hpp"
9#include "oasis_cinterface.hpp"
10#include <boost/functional/hash.hpp>
11#include <boost/algorithm/string.hpp>
12#include "mpi.hpp"
13#include "tracer.hpp"
14#include "timer.hpp"
15#include "event_scheduler.hpp"
16
17namespace xios
18{
19    MPI_Comm CServer::intraComm ;
20    list<MPI_Comm> CServer::interCommLeft ;
21    list<MPI_Comm> CServer::interCommRight ;
22//    list<MPI_Comm> CServer::interComm ;
23    std::list<MPI_Comm> CServer::contextInterComms;
24    std::list<MPI_Comm> CServer::contextIntraComms;
25    int CServer::serverLevel = 0 ;
26    int CServer::serverLeader_ = 0;
27    int CServer::serverSize_ = 0;
28    int CServer::nbPools = 0;
29    int CServer::poolId = 0;
30    int CServer::nbContexts_ = 0;
31    bool CServer::isRoot = false ;
32    int CServer::rank_ = INVALID_RANK;
33    StdOFStream CServer::m_infoStream;
34    StdOFStream CServer::m_errorStream;
35    map<string,CContext*> CServer::contextList ;
36    bool CServer::finished=false ;
37    bool CServer::is_MPI_Initialized ;
38    CEventScheduler* CServer::eventScheduler = 0;
39
40//---------------------------------------------------------------
41/*!
42 * \fn void CServer::initialize(void)
43 * Creates intraComm for each possible type of servers (classical, primary or secondary).
44 * In case of secondary servers intraComm is created for each secondary server pool.
45 * (For now the assumption is that there is one proc per pool.)
46 * Creates the following lists of interComms:
47 *   classical server -- interCommLeft
48 *   primary server -- interCommLeft and interCommRight
49 *   secondary server -- interComm for each pool.
50 */
51    void CServer::initialize(void)
52    {
53      int initialized ;
54      MPI_Initialized(&initialized) ;
55      if (initialized) is_MPI_Initialized=true ;
56      else is_MPI_Initialized=false ;
57
58      // Not using OASIS
59      if (!CXios::usingOasis)
60      {
61
62        if (!is_MPI_Initialized)
63        {
64          MPI_Init(NULL, NULL);
65        }
66        CTimer::get("XIOS").resume() ;
67
68        boost::hash<string> hashString ;
69        unsigned long hashServer = hashString(CXios::xiosCodeId);
70
71        unsigned long* hashAll ;
72
73//        int rank ;
74        int size ;
75        int myColor ;
76        int i,c ;
77        MPI_Comm newComm, serversComm;
78
79        MPI_Comm_size(CXios::globalComm, &size) ;
80        MPI_Comm_rank(CXios::globalComm, &rank_);
81
82        hashAll=new unsigned long[size] ;
83        MPI_Allgather(&hashServer, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ;
84
85        map<unsigned long, int> colors ;
86        map<unsigned long, int> leaders ;
87        map<unsigned long, int> lastProcesses ;  // needed in case of two server levels
88        map<unsigned long, int>::iterator it ;
89
90        for(i=0,c=0;i<size;i++)
91        {
92          if (colors.find(hashAll[i])==colors.end())
93          {
94            colors[hashAll[i]]=c ;
95            leaders[hashAll[i]]=i ;
96            c++ ;
97          }
98          if (hashAll[i+1] != hashAll[i])
99            lastProcesses[hashAll[i]]=i ;
100        }
101
102        // Setting the number of secondary pools
103        myColor = colors[hashServer];
104        if (CXios::usingServer2)
105        {
106          int serverRank = rank_ - leaders[hashServer]; // server proc rank starting 0
107          serverSize_ = lastProcesses[hashServer] - leaders[hashServer] + 1;
108//          serverSize_ = lastProcesses - leaders[hashServer];
109          nbPools = serverSize_ * CXios::ratioServer2 / 100;
110          if ( serverRank < (serverSize_ - nbPools) )
111          {
112            serverLevel = 1;
113          }
114          else
115          {
116            serverLevel = 2;
117            poolId = serverRank - serverSize_ + nbPools;
118            myColor = rank_;
119          }
120        }
121
122        MPI_Comm_split(CXios::globalComm, myColor, rank_, &intraComm) ;
123
124        if (serverLevel == 0)
125        {
126          int clientLeader;
127          for(it=leaders.begin();it!=leaders.end();it++)
128          {
129            if (it->first!=hashServer)
130            {
131              clientLeader=it->second ;
132              int intraCommSize, intraCommRank ;
133              MPI_Comm_size(intraComm,&intraCommSize) ;
134              MPI_Comm_rank(intraComm,&intraCommRank) ;
135              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
136                       <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
137
138              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ;
139               interCommLeft.push_back(newComm) ;
140            }
141          }
142        }
143        else if (serverLevel == 1)
144        {
145          int clientLeader, srvSndLeader;
146          int srvPrmLeader ;
147          for (it=leaders.begin();it!=leaders.end();it++)
148          {
149            if (it->first != hashServer)
150            {
151              clientLeader=it->second ;
152              int intraCommSize, intraCommRank ;
153              MPI_Comm_size(intraComm, &intraCommSize) ;
154              MPI_Comm_rank(intraComm, &intraCommRank) ;
155              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
156                       <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
157              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ;
158              interCommLeft.push_back(newComm) ;
159            }
160            else
161              serverLeader_ = it->second;
162          }
163
164          for (int i = 0; i < nbPools; ++i)
165          {
166            srvSndLeader = serverLeader_ + serverSize_ - nbPools + i;
167            int intraCommSize, intraCommRank ;
168            MPI_Comm_size(intraComm, &intraCommSize) ;
169            MPI_Comm_rank(intraComm, &intraCommRank) ;
170            info(50)<<"intercommCreate::client "<<rank_<<" intraCommSize : "<<intraCommSize
171                <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< srvSndLeader<<endl ;
172            MPI_Intercomm_create(intraComm, 0, CXios::globalComm, srvSndLeader, 0, &newComm) ;
173            interCommRight.push_back(newComm) ;
174          }
175        } // primary server
176        else
177        {
178          int clientLeader;
179          clientLeader = leaders[hashString(CXios::xiosCodeId)];
180          int intraCommSize, intraCommRank ;
181          MPI_Comm_size(intraComm, &intraCommSize) ;
182          MPI_Comm_rank(intraComm, &intraCommRank) ;
183          info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
184                   <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
185
186          MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ;
187          interCommLeft.push_back(newComm) ;
188        } // secondary server
189
190        delete [] hashAll ;
191
192      }
193      // using OASIS
194      else
195      {
196        int size, rank;
197        int myColor;
198        if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId);
199
200        CTimer::get("XIOS").resume() ;
201        MPI_Comm localComm;
202        oasis_get_localcomm(localComm);
203
204        // Create server intraComm
205        if (!CXios::usingServer2)
206          MPI_Comm_dup(localComm, &intraComm);
207        else
208        {
209          MPI_Comm_rank(localComm,&rank) ;
210          MPI_Comm_size(localComm,&serverSize_) ;
211          nbPools = serverSize_ * CXios::ratioServer2 / 100;
212          if ( rank < (serverSize_ - nbPools) )
213          {
214            serverLevel = 1;
215            myColor = 0;
216          }
217          else
218          {
219            serverLevel = 2;
220            poolId = rank - serverSize_ + nbPools;
221            myColor = rank;
222          }
223          MPI_Comm_split(localComm, myColor, rank, &intraComm) ;
224
225        }
226        MPI_Comm_rank(intraComm,&rank_) ;
227        MPI_Comm_size(intraComm,&size) ;
228
229        string codesId=CXios::getin<string>("oasis_codes_id") ;
230
231        vector<string> splitted ;
232        boost::split( splitted, codesId, boost::is_any_of(","), boost::token_compress_on ) ;
233        vector<string>::iterator it ;
234
235        MPI_Comm newComm ;
236        int globalRank ;
237        MPI_Comm_rank(CXios::globalComm,&globalRank);
238
239        for(it=splitted.begin();it!=splitted.end();it++)
240        {
241          oasis_get_intercomm(newComm,*it) ;
242//        interComm.push_back(newComm) ;
243          if ( !CXios::usingServer2)
244            interCommLeft.push_back(newComm) ;
245          else
246          {
247            if (serverLevel == 1)
248            {
249              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<size
250                       <<" intraCommRank :"<<rank_<<"  clientLeader "<< rank<<endl ;
251              MPI_Intercomm_create(intraComm, 0, localComm, rank, 0, &newComm) ;
252              interCommRight.push_back(newComm) ;
253
254            }
255            else if (serverLevel == 2)
256            {
257              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<size
258                       <<" intraCommRank :"<<rank_<<"  clientLeader "<< 0<<endl ;
259              MPI_Intercomm_create(intraComm, 0, localComm, 0, 0, &newComm) ;
260              interCommLeft.push_back(newComm) ;
261
262            }
263
264          }
265//          if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ;
266//          MPI_Comm_remote_size(newComm,&size);
267          // Send serverLeader to client
268          if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,interCommLeft.back()) ;
269        }
270              oasis_enddef() ;
271      }
272
273      MPI_Comm_rank(intraComm, &rank_) ;
274      if (rank_==0) isRoot=true;
275      else isRoot=false;
276     
277      eventScheduler = new CEventScheduler(intraComm) ;
278    }
279
280    void CServer::finalize(void)
281    {
282
283      CTimer::get("XIOS").suspend() ;
284     
285      delete eventScheduler ;
286
287      for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++)
288        MPI_Comm_free(&(*it));
289
290      for (std::list<MPI_Comm>::iterator it = contextIntraComms.begin(); it != contextIntraComms.end(); it++)
291        MPI_Comm_free(&(*it));
292
293//      for (std::list<MPI_Comm>::iterator it = interComm.begin(); it != interComm.end(); it++)
294//        MPI_Comm_free(&(*it));
295
296//        for (std::list<MPI_Comm>::iterator it = interCommLeft.begin(); it != interCommLeft.end(); it++)
297//          MPI_Comm_free(&(*it));
298
299        for (std::list<MPI_Comm>::iterator it = interCommRight.begin(); it != interCommRight.end(); it++)
300          MPI_Comm_free(&(*it));
301
302      MPI_Comm_free(&intraComm);
303
304      if (!is_MPI_Initialized)
305      {
306        if (CXios::usingOasis) oasis_finalize();
307        else MPI_Finalize() ;
308      }
309      report(0)<<"Performance report : Time spent for XIOS : "<<CTimer::get("XIOS server").getCumulatedTime()<<endl  ;
310      report(0)<<"Performance report : Time spent in processing events : "<<CTimer::get("Process events").getCumulatedTime()<<endl  ;
311      report(0)<<"Performance report : Ratio : "<<CTimer::get("Process events").getCumulatedTime()/CTimer::get("XIOS server").getCumulatedTime()*100.<<"%"<<endl  ;
312    }
313
314     void CServer::eventLoop(void)
315     {
316       bool stop=false ;
317
318       CTimer::get("XIOS server").resume() ;
319       while(!stop)
320       {
321         if (isRoot)
322         {
323           listenContext();
324           if (!finished) listenFinalize() ;
325         }
326         else
327         {
328           listenRootContext();
329           if (!finished) listenRootFinalize() ;
330         }
331
332         contextEventLoop() ;
333         if (finished && contextList.empty()) stop=true ;
334         eventScheduler->checkEvent() ;
335
336       }
337       CTimer::get("XIOS server").suspend() ;
338     }
339
340     void CServer::listenFinalize(void)
341     {
342        list<MPI_Comm>::iterator it, itr;
343        int msg ;
344        int flag ;
345
346        for(it=interCommLeft.begin();it!=interCommLeft.end();it++)
347        {
348           MPI_Status status ;
349           traceOff() ;
350           MPI_Iprobe(0,0,*it,&flag,&status) ;
351           traceOn() ;
352           if (flag==true)
353           {
354              MPI_Recv(&msg,1,MPI_INT,0,0,*it,&status) ;
355              info(20)<<" CServer : Receive client finalize"<<endl ;
356              // Sending server finalize message to secondary servers (if any)
357              for(itr=interCommRight.begin();itr!=interCommRight.end();itr++)
358              {
359                MPI_Send(&msg,1,MPI_INT,0,0,*itr) ;
360              }
361              MPI_Comm_free(&(*it));
362              interCommLeft.erase(it) ;
363              break ;
364            }
365         }
366
367         if (interCommLeft.empty())
368         {
369           int i,size ;
370           MPI_Comm_size(intraComm,&size) ;
371           MPI_Request* requests= new MPI_Request[size-1] ;
372           MPI_Status* status= new MPI_Status[size-1] ;
373
374           for(int i=1;i<size;i++) MPI_Isend(&msg,1,MPI_INT,i,4,intraComm,&requests[i-1]) ;
375           MPI_Waitall(size-1,requests,status) ;
376
377           finished=true ;
378           delete [] requests ;
379           delete [] status ;
380         }
381     }
382
383
384     void CServer::listenRootFinalize()
385     {
386        int flag ;
387        MPI_Status status ;
388        int msg ;
389
390        traceOff() ;
391        MPI_Iprobe(0,4,intraComm, &flag, &status) ;
392        traceOn() ;
393        if (flag==true)
394        {
395           MPI_Recv(&msg,1,MPI_INT,0,4,intraComm,&status) ;
396           finished=true ;
397        }
398      }
399
400     void CServer::listenContext(void)
401     {
402
403       MPI_Status status ;
404       int flag ;
405       static void* buffer ;
406       static MPI_Request request ;
407       static bool recept=false ;
408       int rank ;
409       int count ;
410
411       if (recept==false)
412       {
413         traceOff() ;
414         MPI_Iprobe(MPI_ANY_SOURCE,1,CXios::globalComm, &flag, &status) ;
415         traceOn() ;
416         if (flag==true)
417         {
418           rank=status.MPI_SOURCE ;
419           MPI_Get_count(&status,MPI_CHAR,&count) ;
420           buffer=new char[count] ;
421           MPI_Irecv(buffer,count,MPI_CHAR,rank,1,CXios::globalComm,&request) ;
422           recept=true ;
423         }
424       }
425       else
426       {
427         traceOff() ;
428         MPI_Test(&request,&flag,&status) ;
429         traceOn() ;
430         if (flag==true)
431         {
432           rank=status.MPI_SOURCE ;
433           MPI_Get_count(&status,MPI_CHAR,&count) ;
434           recvContextMessage(buffer,count) ;
435           delete [] buffer;
436           recept=false ;
437         }
438       }
439     }
440
441     void CServer::recvContextMessage(void* buff,int count)
442     {
443       static map<string,contextMessage> recvContextId;
444       map<string,contextMessage>::iterator it ;
445       CBufferIn buffer(buff,count) ;
446       string id ;
447       int clientLeader ;
448       int nbMessage ;
449
450       buffer>>id>>nbMessage>>clientLeader ;
451
452       it=recvContextId.find(id) ;
453       if (it==recvContextId.end())
454       {
455         contextMessage msg={0,0} ;
456         pair<map<string,contextMessage>::iterator,bool> ret ;
457         ret=recvContextId.insert(pair<string,contextMessage>(id,msg)) ;
458         it=ret.first ;
459       }
460       it->second.nbRecv+=1 ;
461       it->second.leaderRank+=clientLeader ;
462
463       if (it->second.nbRecv==nbMessage)
464       {
465         int size ;
466         MPI_Comm_size(intraComm,&size) ;
467         MPI_Request* requests= new MPI_Request[size-1] ;
468         MPI_Status* status= new MPI_Status[size-1] ;
469
470         for(int i=1;i<size;i++)
471         {
472            MPI_Isend(buff,count,MPI_CHAR,i,2,intraComm,&requests[i-1]) ;
473         }
474         MPI_Waitall(size-1,requests,status) ;
475         registerContext(buff,count,it->second.leaderRank) ;
476
477         recvContextId.erase(it) ;
478         delete [] requests ;
479         delete [] status ;
480
481       }
482     }
483
484     void CServer::listenRootContext(void)
485     {
486       MPI_Status status ;
487       int flag ;
488       static void* buffer ;
489       static MPI_Request request ;
490       static bool recept=false ;
491       int rank ;
492       int count ;
493       const int root=0 ;
494
495       if (recept==false)
496       {
497         traceOff() ;
498         MPI_Iprobe(root,2,intraComm, &flag, &status) ;
499         traceOn() ;
500         if (flag==true)
501         {
502           MPI_Get_count(&status,MPI_CHAR,&count) ;
503           buffer=new char[count] ;
504           MPI_Irecv(buffer,count,MPI_CHAR,root,2,intraComm,&request) ;
505           recept=true ;
506         }
507       }
508       else
509       {
510         MPI_Test(&request,&flag,&status) ;
511         if (flag==true)
512         {
513           MPI_Get_count(&status,MPI_CHAR,&count) ;
514           registerContext(buffer,count) ;
515           delete [] buffer ;
516           recept=false ;
517         }
518       }
519     }
520
521     void CServer::registerContext(void* buff, int count, int leaderRank)
522     {
523       string contextId;
524       CBufferIn buffer(buff, count);
525       buffer >> contextId;
526       CContext* context;
527
528       info(20) << "CServer : Register new Context : " << contextId << endl;
529
530       if (contextList.find(contextId) != contextList.end())
531         ERROR("void CServer::registerContext(void* buff, int count, int leaderRank)",
532               << "Context '" << contextId << "' has already been registred");
533
534       context=CContext::create(contextId);
535       contextList[contextId]=context;
536
537       // Primary or classical server: initialize its own server (CContextServer)
538       MPI_Comm inter;
539       if (serverLevel < 2)
540       {
541         MPI_Comm contextInterComm;
542         MPI_Intercomm_create(intraComm, 0, CXios::globalComm, leaderRank, 10+leaderRank, &contextInterComm);
543         MPI_Intercomm_merge(contextInterComm,1,&inter);
544         MPI_Barrier(inter);
545         MPI_Comm_free(&inter);
546         context->initServer(intraComm,contextInterComm);
547         contextInterComms.push_back(contextInterComm);
548
549       }
550       // Secondary server: initialize its own server (CContextServer)
551       else if (serverLevel == 2)
552       {
553         MPI_Comm_dup(interCommLeft.front(), &inter);
554         contextInterComms.push_back(inter);
555         context->initServer(intraComm, contextInterComms.back());
556       }
557
558       // Primary server: send create context message to secondary servers and initialize its own client (CContextClient)
559       if (serverLevel == 1)
560       {
561         int i = 0, size;
562         CMessage msg;
563         int messageSize;
564         MPI_Comm_size(intraComm, &size) ;
565         for (std::list<MPI_Comm>::iterator it = interCommRight.begin(); it != interCommRight.end(); it++, ++i)
566         {
567           StdString str = contextId +"_server_" + boost::lexical_cast<string>(i);
568           msg<<str<<size<<rank_ ;
569           messageSize = msg.size() ;
570           buff = new char[messageSize] ;
571           CBufferOut buffer(buff,messageSize) ;
572           buffer<<msg ;
573           int sndServerGloRanks = serverSize_-nbPools+serverLeader_ +i;  // the assumption is that there is only one proc per secondary server pool
574           MPI_Send(buff, buffer.count(), MPI_CHAR, sndServerGloRanks, 1, CXios::globalComm) ;
575           MPI_Comm_dup(*it, &inter);
576           contextInterComms.push_back(inter);
577           MPI_Comm_dup(intraComm, &inter);
578           contextIntraComms.push_back(inter);
579           context->initClient(contextIntraComms.back(), contextInterComms.back()) ;
580           delete [] buff ;
581         }
582         ++nbContexts_;
583       }
584     }
585
586     void CServer::contextEventLoop(void)
587     {
588       bool isFinalized ;
589       map<string,CContext*>::iterator it ;
590
591       for(it=contextList.begin();it!=contextList.end();it++)
592       {
593         isFinalized=it->second->isFinalized();
594         if (isFinalized)
595         {
596//           it->second->postFinalize();
597           contextList.erase(it) ;
598           break ;
599         }
600         else
601           it->second->checkBuffersAndListen();
602       }
603     }
604
605     //! Get rank of the current process
606     int CServer::getRank()
607     {
608       return rank_;
609     }
610
611    /*!
612    * Open a file specified by a suffix and an extension and use it for the given file buffer.
613    * The file name will be suffix+rank+extension.
614    *
615    * \param fileName[in] protype file name
616    * \param ext [in] extension of the file
617    * \param fb [in/out] the file buffer
618    */
619    void CServer::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)
620    {
621      StdStringStream fileNameClient;
622      int numDigit = 0;
623      int size = 0;
624      int id;
625      MPI_Comm_size(CXios::globalComm, &size);
626      while (size)
627      {
628        size /= 10;
629        ++numDigit;
630      }
631
632      if (!CXios::usingServer2)
633        id = getRank();
634      else
635      {
636        if (serverLevel == 1)
637          id = rank_;
638        else
639          id = poolId;
640      }
641      fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << id << ext;
642      fb->open(fileNameClient.str().c_str(), std::ios::out);
643      if (!fb->is_open())
644        ERROR("void CServer::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)",
645              << std::endl << "Can not open <" << fileNameClient << "> file to write the server log(s).");
646    }
647
648    /*!
649    * \brief Open a file stream to write the info logs
650    * Open a file stream with a specific file name suffix+rank
651    * to write the info logs.
652    * \param fileName [in] protype file name
653    */
654    void CServer::openInfoStream(const StdString& fileName)
655    {
656      std::filebuf* fb = m_infoStream.rdbuf();
657      openStream(fileName, ".out", fb);
658
659      info.write2File(fb);
660      report.write2File(fb);
661    }
662
663    //! Write the info logs to standard output
664    void CServer::openInfoStream()
665    {
666      info.write2StdOut();
667      report.write2StdOut();
668    }
669
670    //! Close the info logs file if it opens
671    void CServer::closeInfoStream()
672    {
673      if (m_infoStream.is_open()) m_infoStream.close();
674    }
675
676    /*!
677    * \brief Open a file stream to write the error log
678    * Open a file stream with a specific file name suffix+rank
679    * to write the error log.
680    * \param fileName [in] protype file name
681    */
682    void CServer::openErrorStream(const StdString& fileName)
683    {
684      std::filebuf* fb = m_errorStream.rdbuf();
685      openStream(fileName, ".err", fb);
686
687      error.write2File(fb);
688    }
689
690    //! Write the error log to standard error output
691    void CServer::openErrorStream()
692    {
693      error.write2StdErr();
694    }
695
696    //! Close the error log file if it opens
697    void CServer::closeErrorStream()
698    {
699      if (m_errorStream.is_open()) m_errorStream.close();
700    }
701}
Note: See TracBrowser for help on using the repository browser.