source: XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp @ 1227

Last change on this file since 1227 was 1215, checked in by ymipsl, 7 years ago

Distribute files on servers 2 -> Ok test_dcmip2

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_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::vector<std::map<int, StdSize> > getGridDataBufferSize(); // Grid data buffer size for each connection of contextclient
99
100       public:
101         bool isActive(bool atCurrentTimestep = false) 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 solveAllEnabledFieldsAndTransform();
125         void checkGridOfEnabledFields();
126         void sendGridOfEnabledFields();
127
128         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput);
129         size_t getGlobalWrittenSize(void) ;
130         
131         
132         boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc);
133         boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc);
134         boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
135         boost::shared_ptr<COutputPin> getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
136
137//         virtual void fromBinary(StdIStream& is);
138
139         /// Destructeur ///
140         virtual ~CField(void);
141
142         /// Accesseurs statiques ///
143         static StdString GetName(void);
144         static StdString GetDefName(void);
145
146         static ENodeType GetType(void);
147
148        template <int N> void setData(const CArray<double, N>& _data);
149        static bool dispatchEvent(CEventServer& event);
150        void sendUpdateData(const CArray<double,1>& data);
151        void sendUpdateData(const CArray<double,1>& data, CContextClient* client);
152        static void recvUpdateData(CEventServer& event);
153        void recvUpdateData(std::map<int,CBufferIn*>& rankBuffers);
154        void writeField(void);
155        bool sendReadDataRequest(const CDate& tsDataRequested);
156        bool sendReadDataRequestIfNeeded(void);
157        static void recvReadDataRequest(CEventServer& event);
158        void recvReadDataRequest(void);
159        bool readField(void);
160        static void recvReadDataReady(CEventServer& event);
161        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers);
162        void outputField(CArray<double,3>& fieldOut);
163        void outputField(CArray<double,2>& fieldOut);
164        void outputField(CArray<double,1>& fieldOut);
165        void inputField(CArray<double,3>& fieldOut);
166        void inputField(CArray<double,2>& fieldOut);
167        void inputField(CArray<double,1>& fieldOut);
168        void outputCompressedField(CArray<double, 1>& fieldOut);
169        void scaleFactorAddOffset(double scaleFactor, double addOffset);
170        void invertScaleFactorAddOffset(double scaleFactor, double addOffset);
171        void parse(xml::CXMLNode& node);
172
173        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
174        CVariableGroup* getVirtualVariableGroup(void) const;
175        vector<CVariable*> getAllVariables(void) const;
176        virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
177
178        CVariable* addVariable(const string& id = "");
179        CVariableGroup* addVariableGroup(const string& id = "");       
180        void sendAddVariable(const string& id, CContextClient* client);
181        void sendAddVariableGroup(const string& id, CContextClient* client);
182        static void recvAddVariable(CEventServer& event);
183        void recvAddVariable(CBufferIn& buffer);
184        static void recvAddVariableGroup(CEventServer& event);
185        void recvAddVariableGroup(CBufferIn& buffer);       
186        void sendAddAllVariables(CContextClient* client);
187        void writeUpdateData(const CArray<double,1>& data);
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         std::vector<StdString> domAxisScalarIds_;
219         bool useCompressedOutput;
220
221         // Two variables to identify the time_counter meta data written in file, which has no time_counter
222         bool hasTimeInstant;
223         bool hasTimeCentered;
224
225
226         DECLARE_REF_FUNC(Field,field)
227
228      private:
229         bool areAllReferenceSolved;
230         bool isReferenceSolved;
231         bool isReferenceSolvedAndTransformed;
232
233      private:
234         //! The type of operation attached to the field
235         func::CFunctor::ETimeType operationTimeType;
236
237         //! The output pin of the filter providing the instant data for the field
238         boost::shared_ptr<COutputPin> instantDataFilter;
239         //! The output pin of the filters providing the result of the field's temporal operation
240         std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters;
241         //! The output pin of the filter providing the instant data for self references
242         boost::shared_ptr<COutputPin> selfReferenceFilter;
243         //! The source filter for data provided by the client
244         boost::shared_ptr<CSourceFilter> clientSourceFilter;
245         //! The source filter for data provided by the server
246         boost::shared_ptr<CSourceFilter> serverSourceFilter;
247         //! The terminal filter which stores the instant data
248         boost::shared_ptr<CStoreFilter> storeFilter;
249         //! The terminal filter which writes the data to file
250         boost::shared_ptr<CFileWriterFilter> fileWriterFilter;
251         //! The terminal filter which writes data to file
252         boost::shared_ptr<CFileServerWriterFilter> fileServerWriterFilter;
253   }; // class CField
254
255   ///--------------------------------------------------------------
256
257   // Declare/Define CFieldGroup and CFieldDefinition
258   DECLARE_GROUP(CField);
259
260   ///-----------------------------------------------------------------
261
262   template <>
263      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
264
265   ///-----------------------------------------------------------------
266} // namespace xios
267
268
269#endif // __XIOS_CField__
Note: See TracBrowser for help on using the repository browser.