source: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp @ 1869

Last change on this file since 1869 was 1869, checked in by ymipsl, 4 years ago

Some update...

YM

  • 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: 8.2 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   END_DECLARE_ATTRIBUTE_MAP(CAxis)
32
33   ///--------------------------------------------------------------
34
35   class CAxis
36      : public CObjectTemplate<CAxis>
37      , public CAxisAttributes
38   {
39               /// typedef ///
40         typedef CObjectTemplate<CAxis>   SuperClass;
41         typedef CAxisAttributes SuperClassAttribute;
42         
43      public:
44         enum EEventId
45         {
46           EVENT_ID_DISTRIBUTION_ATTRIBUTE,           
47           EVENT_ID_DISTRIBUTED_VALUE,
48           EVENT_ID_NON_DISTRIBUTED_VALUE,
49           EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES,
50           EVENT_ID_DISTRIBUTED_ATTRIBUTES
51         } ;
52
53      public:
54         typedef CAxisAttributes RelAttributes;
55         typedef CAxisGroup      RelGroup;
56         typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes;
57
58      public:
59         /// Constructeurs ///
60         CAxis(void);
61         explicit CAxis(const StdString & id);
62         CAxis(const CAxis & axis);       // Not implemented yet.
63         CAxis(const CAxis * const axis); // Not implemented yet.
64
65         static CAxis* createAxis();
66
67         /// Accesseurs ///
68         const std::set<StdString> & getRelFiles(void) const;
69
70         int getNumberWrittenIndexes(MPI_Comm writtenCom);
71         int getTotalNumberWrittenIndexes(MPI_Comm writtenCom);
72         int getOffsetWrittenIndexes(MPI_Comm writtenCom);
73         CArray<int, 1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);
74
75         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
76                                                        CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
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         
89
90         /// Destructeur ///
91         virtual ~CAxis(void);
92
93         virtual void parse(xml::CXMLNode & node);
94
95         void setContextClient(CContextClient* contextClient);
96
97         /// Accesseurs statiques ///
98         static StdString GetName(void);
99         static StdString GetDefName(void);
100         static ENodeType GetType(void);
101
102         static bool dispatchEvent(CEventServer& event);         
103       
104         /// Vérifications ///
105         void checkAttributes(void);
106         bool checkAttributes_done_ = false ;
107         
108         void checkAttributesOnClient();
109         void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid,
110                                                         CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION);
111         void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
112                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
113
114         void checkEligibilityForCompressedOutput();
115         size_t getGlobalWrittenSize(void) ;
116
117         void computeWrittenIndex();
118         void computeWrittenCompressedIndex(MPI_Comm);
119         bool hasTransformation();
120         void solveInheritanceTransformation();
121         TransMapTypes getAllTransformations();         
122         void duplicateTransformation(CAxis*);
123         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id="");
124         bool isEqual(CAxis* axis);
125
126         bool checkIfCompleted(void) ;
127         void setCompleted(void) ;
128         void setUncompleted(void) ;
129
130      public: 
131        bool hasValue;       
132        bool hasBounds;
133        bool hasLabel;
134
135        CArray<int,1> localIndexToWriteOnServer;
136         
137         void computeConnectedClients(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid);
138         private: std::set<CContextClient*> computeConnectedClients_done_ ; public :
139         /** The number of server of a context client. Avoid to re-compute indice computed in a previous computeConnectedClient */
140         private: std::set<int> listNbServer_ ; public:
141
142      private:
143         void checkData();
144         void checkMask();
145         void checkBounds();
146         void checkLabel();
147         void sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
148                             CServerDistributionDescription::ServerDistributionType distType);
149         void sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid,
150                                        CServerDistributionDescription::ServerDistributionType distType);
151         
152
153         void sendNonDistributedAttributes(void);
154         void sendDistributedAttributes(void);
155
156         static void recvNonDistributedAttributes(CEventServer& event);
157         static void recvDistributedAttributes(CEventServer& event);
158         static void recvDistributionAttribute(CEventServer& event);
159         void recvNonDistributedAttributes(int rank, CBufferIn& buffer);
160         void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers);
161         void recvDistributionAttribute(CBufferIn& buffer);
162
163         void setTransformations(const TransMapTypes&);
164
165      private:
166
167/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
168         std::list<CContextClient*> clients;
169         std::set<CContextClient*> clientsSet;
170
171         /** define if the axis is completed or not ie all attributes have been received before in case
172             of grid reading from file or coupling */ 
173         bool isCompleted_=true ; 
174
175         bool isChecked;
176         bool areClientAttributesChecked_;
177         bool isClientAfterTransformationChecked;
178         std::set<StdString> relFiles, relFilesCompressed;
179         TransMapTypes transformationMap_;         
180         //! True if and only if the data defined on the axis can be outputted in a compressed way
181         bool isCompressible_;
182
183         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
184         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
185         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
186         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
187         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
188         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;
189         std::map<int, std::vector<int> > connectedServerRank_;
190         bool computedWrittenIndex_;                 
191
192       private:
193         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
194         static std::map<StdString, ETranformationType> transformationMapList_;
195         static bool dummyTransformationMapList_;
196
197         DECLARE_REF_FUNC(Axis,axis)
198   }; // class CAxis
199
200   ///--------------------------------------------------------------
201
202   // Declare/Define CAxisGroup and CAxisDefinition
203   DECLARE_GROUP(CAxis);
204} // namespace xios
205
206#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.