source: XIOS/dev/branch_openmp/src/node/field.hpp @ 1328

Last change on this file since 1328 was 1328, checked in by yushan, 6 years ago

dev_omp

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