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

Last change on this file since 589 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
RevLine 
[219]1#ifndef __XMLIO_CField__
2#define __XMLIO_CField__
3
[335]4/// xios headers ///
[219]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"
[231]12#include "calendar_util.hpp"
[369]13#include "array_new.hpp"
14#include "attribute_array.hpp"
[459]15#include "expr_node.hpp"
[540]16#include "declare_ref_func.hpp"
[219]17
[300]18
[335]19namespace xios {
[509]20
[219]21   /// ////////////////////// Déclarations ////////////////////// ///
22
23   class CFieldGroup;
24   class CFieldAttributes;
25   class CField;
26
27   class CFile;
28   class CGrid;
[300]29   class CContext ;
[219]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
[300]54         enum EEventId
55         {
[472]56           EVENT_ID_UPDATE_DATA, EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP
[300]57         } ;
[509]58
[219]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
[347]67         CGrid* getRelGrid(void) const ;
68         CFile* getRelFile(void) const ;
[219]69
70      public :
71
[266]72         StdSize getNStep(void) const;
73
[343]74         const CDuration & getFreqOperation(void) const;
75         const CDuration & getFreqWrite(void) const;
[219]76
[343]77         boost::shared_ptr<CDate> getLastWriteDate(void) const;
78         boost::shared_ptr<CDate> getLastOperationDate(void) const;
[219]79
80         boost::shared_ptr<func::CFunctor> getFieldOperation(void) const;
[509]81
[369]82         CArray<double, 1> getData(void) const;
[219]83
84
[540]85
[219]86         /// Mutateur ///
[347]87         void setRelFile(CFile* _file);
[266]88         void incrementNStep(void);
[321]89         void resetNStep() ;
[219]90
[369]91         template <int N> bool updateData(const CArray<double, N>&   data);
[459]92         bool updateDataFromExpression(const CArray<double, 1>&   data);
[509]93         void setDataFromExpression(const CArray<double, 1>& _data) ;
94
[219]95         bool updateDataServer
[343]96               (const CDate & currDate,
[369]97                const std::deque< CArray<double, 1>* > storedClient);
[509]98
99         std::map<int, StdSize> getGridDataSize();
100
[300]101       public :
[310]102         bool isActive(void) const;
[459]103         bool active ;
104         bool hasOutputFile ;
[460]105         bool hasFieldOut ;
[219]106
107         /// Traitements ///
[459]108         void processEnabledField(void) ;
[540]109
[219]110         void solveGridReference(void);
111         void solveOperation(void);
[509]112         void solveCheckMaskIndex(bool doSendingIndex);
113         void solveAllReferenceEnabledField(bool doSending2Sever);
114         void buildAllExpressionEnabledField();
115         void solveGridDomainAxisRef(bool checkAtt);
[219]116
[540]117
[369]118//         virtual void fromBinary(StdIStream & is);
[219]119
120         /// Destructeur ///
121         virtual ~CField(void);
122
123         /// Accesseurs statiques ///
124         static StdString GetName(void);
125         static StdString GetDefName(void);
[509]126
[219]127         static ENodeType GetType(void);
[509]128
[369]129        template <int N> void setData(const CArray<double, N>& _data) ;
[300]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) ;
[369]135        void outputField(CArray<double,3>& fieldOut) ;
136        void outputField(CArray<double,2>& fieldOut) ;
[567]137        void outputField(CArray<double,1>& fieldOut) ;
[464]138        void scaleFactorAddOffset(double scaleFactor, double addOffset) ;
[459]139        void parse(xml::CXMLNode & node) ;
140        CArray<double,1>* getInstantData(void)  ;
[509]141
[472]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);
[509]147
[472]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) ;
[509]156        void sendAddAllVariables();
157
158
[569]159        const std::pair<StdString, StdString>& getRefDomainAxisIds();
[300]160      public :
[219]161         /// Propriétés privées ///
[472]162         CVariableGroup* vVariableGroup ;
[509]163
[347]164         CGrid*  grid ;
165         CFile*  file;
[460]166         CField* fieldOut ;
[219]167
[343]168         CDuration freq_operation, freq_write;
169         CDuration freq_operation_srv, freq_write_srv;
[219]170
[266]171         StdSize nstep;
[343]172         boost::shared_ptr<CDate>    last_Write, last_operation;
173         boost::shared_ptr<CDate>    lastlast_Write_srv,last_Write_srv, last_operation_srv;
[509]174
[219]175         boost::shared_ptr<func::CFunctor> foperation;
[300]176         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
[509]177
[369]178         CArray<double, 1> data;
[459]179         CArray<double, 1> instantData;
180         bool hasInstantData ;
[369]181         map<int, CArray<double,1>* > data_srv ;
[436]182         bool isOnceOperation ;
183         bool isFirstOperation ;
[459]184         string content ;
[509]185
[459]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 ;
[509]197         bool areAllReferenceSolved;
198         bool areAllExpressionBuilt;
199         std::pair<StdString,StdString> domAxisIds_;
[540]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;
[219]214
[540]215
[219]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   ///-----------------------------------------------------------------
[335]229} // namespace xios
[219]230
231
232#endif // __XMLIO_CField__
Note: See TracBrowser for help on using the repository browser.