source: XIOS/dev/dev_olga/src/node/field.hpp @ 1024

Last change on this file since 1024 was 1024, checked in by mhnguyen, 7 years ago

Try committing with rapidSvn. Attempt No2.

  • 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.4 KB
Line 
1#ifndef __XIOS_CField__
2#define __XIOS_CField__
3
4/// XIOS headers ///
5#include "xios_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 "declare_ref_func.hpp"
16#include "transformation_enum.hpp"
17#include "variable.hpp"
18#include "context_client.hpp"
19
20
21namespace xios {
22
23   /// ////////////////////// Déclarations ////////////////////// ///
24
25   class CFieldGroup;
26   class CFieldAttributes;
27   class CField;
28
29   class CFile;
30   class CGrid;
31   class CContext;
32   class CGenericFilter;
33
34   class CGarbageCollector;
35   class COutputPin;
36   class CSourceFilter;
37   class CStoreFilter;
38   class CFileWriterFilter;
39   class CFileServerWriterFilter;
40
41   ///--------------------------------------------------------------
42
43   // Declare/Define CFieldAttribute
44   BEGIN_DECLARE_ATTRIBUTE_MAP(CField)
45#  include "field_attribute.conf"
46   END_DECLARE_ATTRIBUTE_MAP(CField)
47
48   ///--------------------------------------------------------------
49   class CField
50      : public CObjectTemplate<CField>
51      , public CFieldAttributes
52   {
53         /// friend ///
54         friend class CFile;
55
56         /// typedef ///
57         typedef CObjectTemplate<CField>   SuperClass;
58         typedef CFieldAttributes SuperClassAttribute;
59
60      public:
61
62         typedef CFieldAttributes RelAttributes;
63         typedef CFieldGroup      RelGroup;
64
65         enum EEventId
66         {
67           EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY,
68           EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP
69         };
70
71         /// Constructeurs ///
72         CField(void);
73         explicit CField(const StdString& id);
74         CField(const CField& field);       // Not implemented yet.
75         CField(const CField* const field); // Not implemented yet.
76
77         /// Accesseurs ///
78
79         CGrid* getRelGrid(void) const;
80         CFile* getRelFile(void) const;
81
82         func::CFunctor::ETimeType getOperationTimeType() const;
83
84      public:
85         int getNStep(void) const;
86
87         template <int N> void getData(CArray<double, N>& _data) const;
88
89         boost::shared_ptr<COutputPin> getInstantDataFilter();
90
91         /// Mutateur ///
92         void setRelFile(CFile* _file);
93         void incrementNStep(void);
94         void resetNStep(int nstep = 0);
95         void resetNStepMax();
96
97         std::map<int, StdSize> getGridAttributesBufferSize();
98         std::map<int, StdSize> getGridDataBufferSize();
99
100       public:
101         bool isActive(void) const;
102         bool hasOutputFile;
103
104         bool wasWritten() const;
105         void setWritten();
106
107         bool getUseCompressedOutput() const;
108         void setUseCompressedOutput();
109
110         /// Traitements ///
111         void solveGridReference(void);
112         void solveServerOperation(void);
113         void solveCheckMaskIndex(bool doSendingIndex);
114         void solveAllReferenceEnabledField(bool doSending2Server);
115         void solveOnlyReferenceEnabledField(bool doSending2Server);
116         void generateNewTransformationGridDest();
117         void updateRef(CGrid* grid);
118         void buildGridTransformationGraph();
119         void solveGridDomainAxisRef(bool checkAtt);
120         void solveTransformedGrid();
121         void solveGenerateGrid();
122         void solveGridDomainAxisBaseRef();
123
124         void solveAllEnabledFields();
125         void checkGridOfEnabledFields();
126         void sendGridOfEnabledFields();
127
128         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput);
129         boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc);
130         boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc);
131         boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
132         boost::shared_ptr<COutputPin> getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
133
134//         virtual void fromBinary(StdIStream& is);
135
136         /// Destructeur ///
137         virtual ~CField(void);
138
139         /// Accesseurs statiques ///
140         static StdString GetName(void);
141         static StdString GetDefName(void);
142
143         static ENodeType GetType(void);
144
145        template <int N> void setData(const CArray<double, N>& _data);
146        static bool dispatchEvent(CEventServer& event);
147        void sendUpdateData(const CArray<double,1>& data);
148        void sendUpdateData(const CArray<double,1>& data, CContextClient* client);
149        static void recvUpdateData(CEventServer& event);
150        void recvUpdateData(std::map<int,CBufferIn*>& rankBuffers);
151        void writeField(void);
152        void sendReadDataRequest(const CDate& tsDataRequested);
153        bool sendReadDataRequestIfNeeded(void);
154        static void recvReadDataRequest(CEventServer& event);
155        void recvReadDataRequest(void);
156        bool readField(void);
157        static void recvReadDataReady(CEventServer& event);
158        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers);
159        void outputField(CArray<double,3>& fieldOut);
160        void outputField(CArray<double,2>& fieldOut);
161        void outputField(CArray<double,1>& fieldOut);
162        void inputField(CArray<double,3>& fieldOut);
163        void inputField(CArray<double,2>& fieldOut);
164        void inputField(CArray<double,1>& fieldOut);
165        void outputCompressedField(CArray<double, 1>& fieldOut);
166        void scaleFactorAddOffset(double scaleFactor, double addOffset);
167        void invertScaleFactorAddOffset(double scaleFactor, double addOffset);
168        void parse(xml::CXMLNode& node);
169
170        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
171        CVariableGroup* getVirtualVariableGroup(void) const;
172        vector<CVariable*> getAllVariables(void) const;
173        virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
174
175        CVariable* addVariable(const string& id = "");
176        CVariableGroup* addVariableGroup(const string& id = "");
177        void sendAddVariable(const string& id = "");
178        void sendAddVariable(const string& id, CContextClient* client);
179        void sendAddVariableGroup(const string& id = "");
180        static void recvAddVariable(CEventServer& event);
181        void recvAddVariable(CBufferIn& buffer);
182        static void recvAddVariableGroup(CEventServer& event);
183        void recvAddVariableGroup(CBufferIn& buffer);
184        void sendAddAllVariables();
185        void sendAddAllVariables(CContextClient* client);
186        void writeUpdateData(const CArray<double,1>& data);
187
188
189        const std::vector<StdString>& getRefDomainAxisIds();
190
191        const string& getExpression(void);
192        bool hasExpression(void) const;
193
194      public:
195         /// Propriétés privées ///
196         CVariableGroup* vVariableGroup;
197
198         CGrid*  grid;
199         CFile*  file;
200
201         CDuration freq_operation_srv, freq_write_srv;
202
203         bool written; //<! Was the field written at least once
204         int nstep, nstepMax;
205         bool isEOF;
206         CDate lastlast_Write_srv, last_Write_srv, last_operation_srv;
207         CDate lastDataRequestedFromServer, lastDataReceivedFromServer;
208         bool wasDataAlreadyReceivedFromServer;
209
210         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
211
212         map<int, CArray<double,1> > data_srv;
213         CArray<double,1> recvDataSrv;
214         
215         boost::shared_ptr<func::CFunctor> recvFoperationSrv;
216         string content;
217
218         bool areAllReferenceSolved;
219         bool isReferenceSolved;
220         std::vector<StdString> domAxisScalarIds_;
221         bool useCompressedOutput;
222
223         // Two variables to identify the time_counter meta data written in file, which has no time_counter
224         bool hasTimeInstant;
225         bool hasTimeCentered;
226
227         DECLARE_REF_FUNC(Field,field)
228
229      private:
230         //! The type of operation attached to the field
231         func::CFunctor::ETimeType operationTimeType;
232
233         //! The output pin of the filter providing the instant data for the field
234         boost::shared_ptr<COutputPin> instantDataFilter;
235         //! The output pin of the filters providing the result of the field's temporal operation
236         std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters;
237         //! The output pin of the filter providing the instant data for self references
238         boost::shared_ptr<COutputPin> selfReferenceFilter;
239         //! The source filter for data provided by the client
240         boost::shared_ptr<CSourceFilter> clientSourceFilter;
241         //! The source filter for data provided by the server
242         boost::shared_ptr<CSourceFilter> serverSourceFilter;
243         //! The terminal filter which stores the instant data
244         boost::shared_ptr<CStoreFilter> storeFilter;
245         //! The terminal filter which sends the data to file
246         boost::shared_ptr<CFileWriterFilter> fileWriterFilter;
247         //! The terminal filter which writes data to file
248         boost::shared_ptr<CFileServerWriterFilter> fileServerWriterFilter;
249   }; // class CField
250
251   ///--------------------------------------------------------------
252
253   // Declare/Define CFieldGroup and CFieldDefinition
254   DECLARE_GROUP(CField);
255
256   ///-----------------------------------------------------------------
257
258   template <>
259      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
260
261   ///-----------------------------------------------------------------
262} // namespace xios
263
264
265#endif // __XIOS_CField__
Note: See TracBrowser for help on using the repository browser.