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

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

XIOS coupling branch
Some updates.

First coupling test is beginning to work...

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: 9.6 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      public: 
127        bool hasValue;       
128        bool hasBounds;
129        bool hasLabel;
130
131        CArray<int,1> localIndexToWriteOnServer;
132         
133         void computeConnectedClients(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid);
134         private: std::set<CContextClient*> computeConnectedClients_done_ ; public :
135         /** The number of server of a context client. Avoid to re-compute indice computed in a previous computeConnectedClient */
136         private: std::set<int> listNbServer_ ; public:
137
138      private:
139         void checkData();
140         void checkMask();
141         void checkBounds();
142         void checkLabel();
143      public:
144         void sendAxisToFileServer(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid) ;
145      private:
146         std::set<CContextClient*> sendAxisToFileServer_done_ ;
147     
148      public:
149         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
150      private:
151         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
152   
153      public:
154         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
155
156      private:
157         void sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
158                             CServerDistributionDescription::ServerDistributionType distType, const string& axisId="");
159         void sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
160                                        CServerDistributionDescription::ServerDistributionType distType, const string& axisId="");
161         
162
163         void sendNonDistributedAttributes(CContextClient* client, const string& axisId="");
164         void sendDistributedAttributes(CContextClient* client, const string& axisId="");
165
166         static void recvNonDistributedAttributes(CEventServer& event);
167         static void recvDistributedAttributes(CEventServer& event);
168         static void recvDistributionAttribute(CEventServer& event);
169         void recvNonDistributedAttributes(int rank, CBufferIn& buffer);
170         void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers);
171         void recvDistributionAttribute(CBufferIn& buffer);
172
173         void setTransformations(const TransMapTypes&);
174
175      private:
176
177/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
178         std::list<CContextClient*> clients;
179         std::set<CContextClient*> clientsSet;
180
181      private:
182         /** define if the axis is completed or not ie all attributes have been received before in case
183             of grid reading from file or coupling */ 
184         bool isCompleted_=true ; 
185      public:     
186         /*!
187           \brief Check if a axis is completed
188           Before make any axis processing, we must be sure that all axis informations have
189           been sent, for exemple when reading a grid in a file or when grid elements are sent by an
190           other context (coupling). So all direct reference of the axis (axis_ref) must be also completed
191           \return true if axis and axis reference are completed
192          */
193         bool isCompleted(void)
194         {
195           if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false;
196           else return isCompleted_ ;
197         }
198         void setCompleted(void) { isCompleted_=true ; }
199         void unsetCompleted(void) { isCompleted_=false ; }
200     
201      private:
202         bool isChecked;
203         bool areClientAttributesChecked_;
204         bool isClientAfterTransformationChecked;
205         std::set<StdString> relFiles, relFilesCompressed;
206         TransMapTypes transformationMap_;         
207         //! True if and only if the data defined on the axis can be outputted in a compressed way
208         bool isCompressible_;
209
210         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
211         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
212         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
213         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
214         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
215         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;
216         std::map<int, std::vector<int> > connectedServerRank_;
217         bool computedWrittenIndex_;                 
218
219       private:
220         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
221         static std::map<StdString, ETranformationType> transformationMapList_;
222         static bool dummyTransformationMapList_;
223
224         DECLARE_REF_FUNC(Axis,axis)
225   }; // class CAxis
226
227   ///--------------------------------------------------------------
228
229   // Declare/Define CAxisGroup and CAxisDefinition
230   DECLARE_GROUP(CAxis);
231} // namespace xios
232
233#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.