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

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

Some update on XIOS_COUPLING branch...

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.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   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      public:
148         void sendAxisToFileServer(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid) ;
149      private:
150         std::set<CContextClient*> sendAxisToFileServer_done_ ;
151     
152      private:
153         void sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
154                             CServerDistributionDescription::ServerDistributionType distType);
155         void sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
156                                        CServerDistributionDescription::ServerDistributionType distType);
157         
158
159         void sendNonDistributedAttributes(CContextClient* client);
160         void sendDistributedAttributes(CContextClient* client);
161
162         static void recvNonDistributedAttributes(CEventServer& event);
163         static void recvDistributedAttributes(CEventServer& event);
164         static void recvDistributionAttribute(CEventServer& event);
165         void recvNonDistributedAttributes(int rank, CBufferIn& buffer);
166         void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers);
167         void recvDistributionAttribute(CBufferIn& buffer);
168
169         void setTransformations(const TransMapTypes&);
170
171      private:
172
173/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
174         std::list<CContextClient*> clients;
175         std::set<CContextClient*> clientsSet;
176
177         /** define if the axis is completed or not ie all attributes have been received before in case
178             of grid reading from file or coupling */ 
179         bool isCompleted_=true ; 
180
181         bool isChecked;
182         bool areClientAttributesChecked_;
183         bool isClientAfterTransformationChecked;
184         std::set<StdString> relFiles, relFilesCompressed;
185         TransMapTypes transformationMap_;         
186         //! True if and only if the data defined on the axis can be outputted in a compressed way
187         bool isCompressible_;
188
189         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
190         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
191         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
192         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
193         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
194         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;
195         std::map<int, std::vector<int> > connectedServerRank_;
196         bool computedWrittenIndex_;                 
197
198       private:
199         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
200         static std::map<StdString, ETranformationType> transformationMapList_;
201         static bool dummyTransformationMapList_;
202
203         DECLARE_REF_FUNC(Axis,axis)
204   }; // class CAxis
205
206   ///--------------------------------------------------------------
207
208   // Declare/Define CAxisGroup and CAxisDefinition
209   DECLARE_GROUP(CAxis);
210} // namespace xios
211
212#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.