source: XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp @ 1346

Last change on this file since 1346 was 1345, checked in by oabramkina, 6 years ago

In addition to r1294: all domain/axis attributes are only sent to secondary-server pools that need them (and not to all pools).

  • 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:executable set to *
File size: 7.5 KB
Line 
1#ifndef __XIOS_CAxis__
2#define __XIOS_CAxis__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "group_factory.hpp"
7#include "virtual_node.hpp"
8
9#include "declare_group.hpp"
10#include "declare_ref_func.hpp"
11#include "declare_virtual_node.hpp"
12#include "attribute_array.hpp"
13#include "attribute_enum.hpp"
14#include "attribute_enum_impl.hpp"
15#include "server_distribution_description.hpp"
16#include "transformation.hpp"
17#include "transformation_enum.hpp"
18
19namespace xios {
20   /// ////////////////////// Déclarations ////////////////////// ///
21
22   class CAxisGroup;
23   class CAxisAttributes;
24   class CAxis;
25
26   ///--------------------------------------------------------------
27
28   // Declare/Define CAxisAttribute
29   BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis)
30#  include "axis_attribute.conf"
31#  include "axis_attribute_private.conf"
32   END_DECLARE_ATTRIBUTE_MAP(CAxis)
33
34   ///--------------------------------------------------------------
35
36   class CAxis
37      : public CObjectTemplate<CAxis>
38      , public CAxisAttributes
39   {
40               /// typedef ///
41         typedef CObjectTemplate<CAxis>   SuperClass;
42         typedef CAxisAttributes SuperClassAttribute;
43         
44      public:
45         enum EEventId
46         {
47           EVENT_ID_DISTRIBUTION_ATTRIBUTE,           
48           EVENT_ID_DISTRIBUTED_VALUE,
49           EVENT_ID_NON_DISTRIBUTED_VALUE,
50           EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES,
51           EVENT_ID_DISTRIBUTED_ATTRIBUTES
52         } ;
53
54      public:
55         typedef CAxisAttributes RelAttributes;
56         typedef CAxisGroup      RelGroup;
57         typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes;
58
59      public:
60         /// Constructeurs ///
61         CAxis(void);
62         explicit CAxis(const StdString & id);
63         CAxis(const CAxis & axis);       // Not implemented yet.
64         CAxis(const CAxis * const axis); // Not implemented yet.
65
66         static CAxis* createAxis();
67
68         /// Accesseurs ///
69         const std::set<StdString> & getRelFiles(void) const;
70
71         int getNumberWrittenIndexes(MPI_Comm writtenCom);
72         int getTotalNumberWrittenIndexes(MPI_Comm writtenCom);
73         int getOffsetWrittenIndexes(MPI_Comm writtenCom);
74         CArray<int, 1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);
75
76         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
77
78         /// Test ///
79         bool IsWritten(const StdString & filename) const;
80         bool isWrittenCompressed(const StdString& filename) const;
81         bool isDistributed(void) const;
82         bool isCompressible(void) const;
83
84         /// Mutateur ///
85         void addRelFile(const StdString & filename);
86         void addRelFileCompressed(const StdString& filename);
87
88         /// Vérifications ///
89         void checkAttributes(void);
90
91         /// Destructeur ///
92         virtual ~CAxis(void);
93
94         virtual void parse(xml::CXMLNode & node);
95
96         void setContextClient(CContextClient* contextClient);
97
98         /// Accesseurs statiques ///
99         static StdString GetName(void);
100         static StdString GetDefName(void);
101         static ENodeType GetType(void);
102
103         static bool dispatchEvent(CEventServer& event);         
104         
105         void checkAttributesOnClient();
106         void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid,
107                                                         CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION);
108         void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
109                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
110
111         void checkEligibilityForCompressedOutput();
112         size_t getGlobalWrittenSize(void) ;
113
114         void computeWrittenIndex();
115         void computeWrittenCompressedIndex(MPI_Comm);
116         bool hasTransformation();
117         void solveInheritanceTransformation();
118         TransMapTypes getAllTransformations();         
119         void duplicateTransformation(CAxis*);
120         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id="");
121         bool isEqual(CAxis* axis);
122         bool zoomByIndex();
123
124      public: 
125        bool hasValue;       
126        CArray<size_t,1> localIndexToWriteOnServer;       
127
128      private:
129         void checkData();
130         void checkMask();
131         void checkZoom();
132         void checkBounds();
133         void checkLabel();
134         void sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
135                             CServerDistributionDescription::ServerDistributionType distType);
136         void sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid,
137                                        CServerDistributionDescription::ServerDistributionType distType);
138         void computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid,
139                                     CServerDistributionDescription::ServerDistributionType distType);
140
141         void sendNonDistributedAttributes(void);
142         void sendDistributedAttributes(void);
143
144         static void recvNonDistributedAttributes(CEventServer& event);
145         static void recvDistributedAttributes(CEventServer& event);
146         static void recvDistributionAttribute(CEventServer& event);
147         void recvNonDistributedAttributes(int rank, CBufferIn& buffer);
148         void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers);
149         void recvDistributionAttribute(CBufferIn& buffer);
150
151         void setTransformations(const TransMapTypes&);
152
153      private:
154
155/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
156         std::set<CContextClient*> clients;
157
158         bool isChecked;
159         bool areClientAttributesChecked_;
160         bool isClientAfterTransformationChecked;
161         std::set<StdString> relFiles, relFilesCompressed;
162         TransMapTypes transformationMap_;         
163         //! True if and only if the data defined on the axis can be outputted in a compressed way
164         bool isCompressible_;
165         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
166         std::map<int, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
167         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
168         boost::unordered_map<size_t,size_t> globalLocalIndexMap_;
169         std::vector<int> indexesToWrite;
170         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
171         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;
172         std::map<int, std::vector<int> > connectedServerRank_;
173         bool hasBounds;
174         bool hasLabel;         
175         bool computedWrittenIndex_;                 
176
177       private:
178         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
179         static std::map<StdString, ETranformationType> transformationMapList_;
180         static bool dummyTransformationMapList_;
181
182         DECLARE_REF_FUNC(Axis,axis)
183   }; // class CAxis
184
185   ///--------------------------------------------------------------
186
187   // Declare/Define CAxisGroup and CAxisDefinition
188   DECLARE_GROUP(CAxis);
189} // namespace xios
190
191#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.