source: XIOS/trunk/src/node/field.hpp @ 583

Last change on this file since 583 was 569, checked in by mhnguyen, 9 years ago

Correct some bugs on discovering server index and do some code cleanings

+) Add some checking functions to make sure mpi_isend and mpi_irecv work correctly
+) Add comments to code
+) Remove some redundant code and comments

Test
+) On Curie
+) The new functions are tested in test_new_features.f90. Test_client and test_complete work like before
+) Test cases:

  • 3 dimension grid with: 1 domain, 1 axis
  • 3 dimension grid with: 3 axis
  • Attached and connected

+) All pass and results are correct

TODO:
+) Fix zoom bug with grid composed of only one axis

  • 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
File size: 7.3 KB
Line 
1#ifndef __XMLIO_CField__
2#define __XMLIO_CField__
3
4/// xios headers ///
5#include "xmlioserver_spl.hpp"
6#include "group_factory.hpp"
7#include "functor.hpp"
8#include "functor_type.hpp"
9#include "duration.hpp"
10#include "date.hpp"
11#include "declare_group.hpp"
12#include "calendar_util.hpp"
13#include "array_new.hpp"
14#include "attribute_array.hpp"
15#include "expr_node.hpp"
16#include "declare_ref_func.hpp"
17
18
19namespace xios {
20
21   /// ////////////////////// Déclarations ////////////////////// ///
22
23   class CFieldGroup;
24   class CFieldAttributes;
25   class CField;
26
27   class CFile;
28   class CGrid;
29   class CContext ;
30   ///--------------------------------------------------------------
31
32   // Declare/Define CFieldAttribute
33   BEGIN_DECLARE_ATTRIBUTE_MAP(CField)
34#  include "field_attribute.conf"
35   END_DECLARE_ATTRIBUTE_MAP(CField)
36
37   ///--------------------------------------------------------------
38   class CField
39      : public CObjectTemplate<CField>
40      , public CFieldAttributes
41   {
42         /// friend ///
43         friend class CFile;
44
45         /// typedef ///
46         typedef CObjectTemplate<CField>   SuperClass;
47         typedef CFieldAttributes SuperClassAttribute;
48
49      public :
50
51         typedef CFieldAttributes RelAttributes;
52         typedef CFieldGroup      RelGroup;
53
54         enum EEventId
55         {
56           EVENT_ID_UPDATE_DATA, EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP
57         } ;
58
59         /// Constructeurs ///
60         CField(void);
61         explicit CField(const StdString & id);
62         CField(const CField & field);       // Not implemented yet.
63         CField(const CField * const field); // Not implemented yet.
64
65         /// Accesseurs ///
66
67         CGrid* getRelGrid(void) const ;
68         CFile* getRelFile(void) const ;
69
70      public :
71
72         StdSize getNStep(void) const;
73
74         const CDuration & getFreqOperation(void) const;
75         const CDuration & getFreqWrite(void) const;
76
77         boost::shared_ptr<CDate> getLastWriteDate(void) const;
78         boost::shared_ptr<CDate> getLastOperationDate(void) const;
79
80         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
81
82         CArray<double, 1> getData(void) const;
83
84
85
86         /// Mutateur ///
87         void setRelFile(CFile* _file);
88         void incrementNStep(void);
89         void resetNStep() ;
90
91         template <int N> bool updateData(const CArray<double, N>&   data);
92         bool updateDataFromExpression(const CArray<double, 1>&   data);
93         void setDataFromExpression(const CArray<double, 1>& _data) ;
94
95         bool updateDataServer
96               (const CDate & currDate,
97                const std::deque< CArray<double, 1>* > storedClient);
98
99         std::map<int, StdSize> getGridDataSize();
100
101       public :
102         bool isActive(void) const;
103         bool active ;
104         bool hasOutputFile ;
105         bool hasFieldOut ;
106
107         /// Traitements ///
108         void processEnabledField(void) ;
109
110         void solveGridReference(void);
111         void solveOperation(void);
112         void solveCheckMaskIndex(bool doSendingIndex);
113         void solveAllReferenceEnabledField(bool doSending2Sever);
114         void buildAllExpressionEnabledField();
115         void solveGridDomainAxisRef(bool checkAtt);
116
117
118//         virtual void fromBinary(StdIStream & is);
119
120         /// Destructeur ///
121         virtual ~CField(void);
122
123         /// Accesseurs statiques ///
124         static StdString GetName(void);
125         static StdString GetDefName(void);
126
127         static ENodeType GetType(void);
128
129        template <int N> void setData(const CArray<double, N>& _data) ;
130        static bool dispatchEvent(CEventServer& event) ;
131        void sendUpdateData(void) ;
132        static void recvUpdateData(CEventServer& event) ;
133        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ;
134        void writeField(void) ;
135        void outputField(CArray<double,3>& fieldOut) ;
136        void outputField(CArray<double,2>& fieldOut) ;
137        void outputField(CArray<double,1>& fieldOut) ;
138        void scaleFactorAddOffset(double scaleFactor, double addOffset) ;
139        void parse(xml::CXMLNode & node) ;
140        CArray<double,1>* getInstantData(void)  ;
141
142        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
143        void setVirtualVariableGroup(void);
144        CVariableGroup* getVirtualVariableGroup(void) const;
145        vector<CVariable*> getAllVariables(void) const;
146        virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
147
148        CVariable* addVariable(const string& id="") ;
149        CVariableGroup* addVariableGroup(const string& id="") ;
150        void sendAddVariable(const string& id="") ;
151        void sendAddVariableGroup(const string& id="") ;
152        static void recvAddVariable(CEventServer& event) ;
153        void recvAddVariable(CBufferIn& buffer) ;
154        static void recvAddVariableGroup(CEventServer& event) ;
155        void recvAddVariableGroup(CBufferIn& buffer) ;
156        void sendAddAllVariables();
157
158
159        const std::pair<StdString, StdString>& getRefDomainAxisIds();
160      public :
161         /// Propriétés privées ///
162         CVariableGroup* vVariableGroup ;
163
164         CGrid*  grid ;
165         CFile*  file;
166         CField* fieldOut ;
167
168         CDuration freq_operation, freq_write;
169         CDuration freq_operation_srv, freq_write_srv;
170
171         StdSize nstep;
172         boost::shared_ptr<CDate>    last_Write, last_operation;
173         boost::shared_ptr<CDate>    lastlast_Write_srv,last_Write_srv, last_operation_srv;
174
175         boost::shared_ptr<func::CFunctor> foperation;
176         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
177
178         CArray<double, 1> data;
179         CArray<double, 1> instantData;
180         bool hasInstantData ;
181         map<int, CArray<double,1>* > data_srv ;
182         bool isOnceOperation ;
183         bool isFirstOperation ;
184         string content ;
185
186         list< pair<CField *,int> > fieldDependency ;
187         void buildExpression(void) ;
188         void addDependency(CField* field, int slotId) ;
189         void resetSlots(void) ;
190         vector<bool> slots ;
191         CDate* slotUpdateDate ;
192         CFieldNode * expression ;
193         bool hasExpression ;
194         bool slotsFull(void) ;
195         void setSlot(int slotId);
196         bool processed ;
197         bool areAllReferenceSolved;
198         bool areAllExpressionBuilt;
199         std::pair<StdString,StdString> domAxisIds_;
200         DECLARE_REF_FUNC(Field,field)
201//       public:
202//         bool hasDirectFieldReference(void) const;
203//         CField* getDirectFieldReference(void) const;
204//         CField* getBaseFieldReference(void) const;
205//         void addReference(CField* field);
206//         const std::vector<CField*> & getAllReference(void) const;
207//void solveRefInheritance(bool apply);
208//void solveBaseReference(void);
209//         void removeRefInheritance();
210//         const StdString & getBaseFieldId(void) const;
211//
212//         std::vector<CField*> refObject;
213//         CField* baseRefObject;
214
215
216   }; // class CField
217
218   ///--------------------------------------------------------------
219
220   // Declare/Define CFieldGroup and CFieldDefinition
221   DECLARE_GROUP(CField);
222
223   ///-----------------------------------------------------------------
224
225   template <>
226      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
227
228   ///-----------------------------------------------------------------
229} // namespace xios
230
231
232#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.