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

Last change on this file since 1460 was 1460, checked in by yushan, 6 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
RevLine 
[591]1#include "xios_spl.hpp"
[300]2#include "event_client.hpp"
3#include "buffer_out.hpp"
4#include "message.hpp"
5#include "type.hpp"
[382]6#include "mpi.hpp"
[1460]7#include "cxios.hpp"
[300]8
[335]9namespace xios
[300]10{
[814]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)
[731]12
[814]13
[731]14   CEventClient::CEventClient(int classId_, int typeId_)
[300]15   {
[731]16     classId = classId_;
17     typeId = typeId_;
[300]18   }
[731]19
20   void CEventClient::push(int rank, int nbSender, CMessage& msg)
[300]21   {
[731]22     nbSenders.push_back(nbSender);
23     ranks.push_back(rank);
24     messages.push_back(&msg);
[300]25   }
26
27   bool CEventClient::isEmpty(void)
28   {
[731]29     return ranks.empty();
[300]30   }
31
[731]32   std::list<int> CEventClient::getRanks(void)
[300]33   {
[731]34     return ranks;
[300]35   }
[731]36
37   std::list<int> CEventClient::getSizes(void)
[300]38   {
[731]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;
[300]44   }
[731]45
46   void CEventClient::send(size_t timeLine, const std::list<int>& sizes, std::list<CBufferOut*>& buffers)
[300]47   {
[731]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
[1460]52     if (CXios::checkEventSync)
53     {
54       #pragma omp critical(_output)
55       info(100)<<"Send event "<<timeLine<<" classId : "<<classId<<"  typeId : "<<typeId<<endl ;
56     }
[731]57     for (; itBuff != buffers.end(); ++itBuff, ++itSizes, ++itSenders, ++itMsg)
[300]58     {
[731]59       **itBuff << *itSizes << timeLine << *itSenders << classId << typeId << **itMsg;
[300]60     }
61   }
62}
Note: See TracBrowser for help on using the repository browser.