source: XIOS/trunk/src/node/axis.hpp @ 775

Last change on this file since 775 was 775, checked in by mhnguyen, 8 years ago

Implementing the reading of attributes of an axis from a file

+) 3d grid can be read directly from a file
+) Clean some redundant codes
+) Add new attribute declaration that allows to output only desired attributes

Test
+) On Curie
+) test_remap passes and result is correct

  • 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: 6.0 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         enum EEventId
40         {
41           EVENT_ID_SERVER_ATTRIBUT,
42           EVENT_ID_INDEX,
43           EVENT_ID_DISTRIBUTED_VALUE,
44           EVENT_ID_NON_DISTRIBUTED_VALUE
45         } ;
46
47         /// typedef ///
48         typedef CObjectTemplate<CAxis>   SuperClass;
49         typedef CAxisAttributes SuperClassAttribute;
50
51      public :
52
53         typedef CAxisAttributes RelAttributes;
54         typedef CAxisGroup      RelGroup;
55         typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes;
56
57      public:
58         /// Constructeurs ///
59         CAxis(void);
60         explicit CAxis(const StdString & id);
61         CAxis(const CAxis & axis);       // Not implemented yet.
62         CAxis(const CAxis * const axis); // Not implemented yet.
63
64         static CAxis* createAxis();
65
66         /// Accesseurs ///
67         const std::set<StdString> & getRelFiles(void) const;
68
69         const std::vector<int>& getIndexesToWrite(void) const;
70         int getNumberWrittenIndexes() const;
71         int getTotalNumberWrittenIndexes() const;
72         int getOffsetWrittenIndexes() const;
73
74         std::map<int, StdSize> getAttributesBufferSize();
75
76         /// Test ///
77         bool IsWritten(const StdString & filename) const;
78         bool isWrittenCompressed(const StdString& filename) const;
79         bool isDistributed(void) const;
80         bool isCompressible(void) const;
81
82         /// Mutateur ///
83         void addRelFile(const StdString & filename);
84         void addRelFileCompressed(const StdString& filename);
85
86         /// Vérifications ///
87         void checkAttributes(void);
88
89         /// Destructeur ///
90         virtual ~CAxis(void);
91
92         virtual void parse(xml::CXMLNode & node);
93
94         /// Accesseurs statiques ///
95         static StdString GetName(void);
96         static StdString GetDefName(void);
97         static ENodeType GetType(void);
98
99         void sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid,
100                                 CServerDistributionDescription::ServerDistributionType distType);
101         static bool dispatchEvent(CEventServer& event);
102         static void recvServerAttribut(CEventServer& event);
103         void recvServerAttribut(CBufferIn& buffer) ;
104         void checkAttributesOnClient();
105         void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
106                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
107
108         void checkEligibilityForCompressedOutput();
109
110         bool hasTransformation();
111         void solveInheritanceTransformation();
112         TransMapTypes getAllTransformations();
113         void fillInValues(const CArray<double,1>& values);
114
115      public:
116        int zoom_begin_srv, zoom_end_srv, zoom_size_srv;
117        int ni_srv, begin_srv, end_srv;
118        int global_zoom_begin, global_zoom_size;  // The real global zoom begin and zoom size after axis is transformed (zoomed)
119        CArray<double,1> value_srv;
120        CArray<double,2> bound_srv;
121
122      private:
123         void checkData();
124         void checkMask();
125         void checkZoom();
126         void checkBounds();
127         void checkTransformations();
128         void computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid,
129                                 CServerDistributionDescription::ServerDistributionType disType);
130         void sendValue();
131         void computeConnectedServer(void);
132         void sendDistributedValue();
133         void sendNonDistributedValue();
134
135         static void recvIndex(CEventServer& event);
136         static void recvDistributedValue(CEventServer& event);
137         static void recvNonDistributedValue(CEventServer& event);
138         void recvIndex(int rank, CBufferIn& buffer);
139         void recvDistributedValue(int rank, CBufferIn& buffer);
140         void recvNonDistributedValue(int rank, CBufferIn& buffer);
141
142         void setTransformations(const TransMapTypes&);
143
144      private:
145         bool isChecked;
146         bool areClientAttributesChecked_;
147         std::set<StdString> relFiles, relFilesCompressed;
148         TransMapTypes transformationMap_;
149         bool isDistributed_;
150         //! True if and only if the data defined on the axis can be outputted in a compressed way
151         bool isCompressible_;
152         std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server
153         std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server
154         std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
155         std::vector<int> indexesToWrite;
156         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
157         std::vector<int> connectedServerRank_;
158         std::map<int, CArray<int,1> > indiSrv_;
159         bool hasBounds_;
160         DECLARE_REF_FUNC(Axis,axis)
161   }; // class CAxis
162
163   ///--------------------------------------------------------------
164
165   // Declare/Define CAxisGroup and CAxisDefinition
166   DECLARE_GROUP(CAxis);
167} // namespace xios
168
169#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.