source: XIOS/dev/branch_openmp/src/event_client.cpp @ 1460

Last change on this file since 1460 was 1460, checked in by yushan, 3 years ago

branch_openmp merged with XIOS_DEV_CMIP6@1459

  • 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: 1.7 KB
Line 
1#include "xios_spl.hpp"
2#include "event_client.hpp"
3#include "buffer_out.hpp"
4#include "message.hpp"
5#include "type.hpp"
6#include "mpi.hpp"
7#include "cxios.hpp"
8
9namespace xios
10{
11   const size_t CEventClient::headerSize = sizeof(int) + sizeof(size_t) + sizeof(int) + sizeof(int) + sizeof(int); // The two last one signify sizeof(classId) and sizeof(typeId)
12
13
14   CEventClient::CEventClient(int classId_, int typeId_)
15   {
16     classId = classId_;
17     typeId = typeId_;
18   }
19
20   void CEventClient::push(int rank, int nbSender, CMessage& msg)
21   {
22     nbSenders.push_back(nbSender);
23     ranks.push_back(rank);
24     messages.push_back(&msg);
25   }
26
27   bool CEventClient::isEmpty(void)
28   {
29     return ranks.empty();
30   }
31
32   std::list<int> CEventClient::getRanks(void)
33   {
34     return ranks;
35   }
36
37   std::list<int> CEventClient::getSizes(void)
38   {
39     std::list<CMessage*>::iterator it;
40     std::list<int> sizes;
41
42     for (it = messages.begin(); it != messages.end(); ++it) sizes.push_back((*it)->size() + headerSize);
43     return sizes;
44   }
45
46   void CEventClient::send(size_t timeLine, const std::list<int>& sizes, std::list<CBufferOut*>& buffers)
47   {
48     std::list<CBufferOut*>::iterator itBuff = buffers.begin();
49     std::list<int>::const_iterator itSizes = sizes.begin(), itSenders = nbSenders.begin();
50     std::list<CMessage*>::iterator itMsg = messages.begin();
51
52     if (CXios::checkEventSync)
53     {
54       #pragma omp critical(_output)
55       info(100)<<"Send event "<<timeLine<<" classId : "<<classId<<"  typeId : "<<typeId<<endl ;
56     }
57     for (; itBuff != buffers.end(); ++itBuff, ++itSizes, ++itSenders, ++itMsg)
58     {
59       **itBuff << *itSizes << timeLine << *itSenders << classId << typeId << **itMsg;
60     }
61   }
62}
Note: See TracBrowser for help on using the repository browser.