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

Last change on this file since 681 was 676, checked in by rlacroix, 9 years ago

Add support for indexed output.

If the new field attribute "indexed_output" is set to true and a mask is defined (either at grid, domain or axis level), the indexed data will be outputed instead of the full data with missing values.

See http://cfconventions.org/Data/cf-conventions/cf-conventions-1.5/build/cf-conventions.html#compression-by-gathering for more information.

  • 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: 7.7 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
84         StdSize getNStep(void) const;
85
86         template <int N> void getData(CArray<double, N>& _data) const;
87
88         boost::shared_ptr<COutputPin> getInstantDataFilter();
89
90         /// Mutateur ///
91         void setRelFile(CFile* _file);
92         void incrementNStep(void);
93         void resetNStep();
94         void resetNStepMax();
95
96         std::map<int, StdSize> getGridDataSize();
97
98       public :
99         bool isActive(void) const;
100         bool hasOutputFile;
101
102         bool getUseCompressedOutput() const;
103         void setUseCompressedOutput();
104
105         /// Traitements ///
106         void solveGridReference(void);
107         void solveServerOperation(void);
108         void solveCheckMaskIndex(bool doSendingIndex);
109         void solveAllReferenceEnabledField(bool doSending2Sever);
110         void solveGridDomainAxisRef(bool checkAtt);
111         void solveTransformedGrid();
112
113         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput);
114         boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc);
115         boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
116
117//         virtual void fromBinary(StdIStream& is);
118
119         /// Destructeur ///
120         virtual ~CField(void);
121
122         /// Accesseurs statiques ///
123         static StdString GetName(void);
124         static StdString GetDefName(void);
125
126         static ENodeType GetType(void);
127
128        template <int N> void setData(const CArray<double, N>& _data);
129        static bool dispatchEvent(CEventServer& event);
130        void sendUpdateData(const CArray<double,1>& data);
131        static void recvUpdateData(CEventServer& event);
132        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers);
133        void writeField(void);
134        void sendReadDataRequest(void);
135        bool sendReadDataRequestIfNeeded(void);
136        static void recvReadDataRequest(CEventServer& event);
137        void recvReadDataRequest(void);
138        bool readField(void);
139        static void recvReadDataReady(CEventServer& event);
140        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers);
141        void outputField(CArray<double,3>& fieldOut);
142        void outputField(CArray<double,2>& fieldOut);
143        void outputField(CArray<double,1>& fieldOut);
144        void inputField(CArray<double,3>& fieldOut);
145        void inputField(CArray<double,2>& fieldOut);
146        void inputField(CArray<double,1>& fieldOut);
147        void outputCompressedField(CArray<double, 1>& fieldOut);
148        void scaleFactorAddOffset(double scaleFactor, double addOffset);
149        void invertScaleFactorAddOffset(double scaleFactor, double addOffset);
150        void parse(xml::CXMLNode& node);
151
152        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
153        void setVirtualVariableGroup(void);
154        CVariableGroup* getVirtualVariableGroup(void) const;
155        vector<CVariable*> getAllVariables(void) const;
156        virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
157
158        CVariable* addVariable(const string& id = "");
159        CVariableGroup* addVariableGroup(const string& id = "");
160        void sendAddVariable(const string& id = "");
161        void sendAddVariableGroup(const string& id = "");
162        static void recvAddVariable(CEventServer& event);
163        void recvAddVariable(CBufferIn& buffer);
164        static void recvAddVariableGroup(CEventServer& event);
165        void recvAddVariableGroup(CBufferIn& buffer);
166        void sendAddAllVariables();
167
168
169        const std::pair<StdString, StdString>& getRefDomainAxisIds();
170
171      public :
172         /// Propriétés privées ///
173         CVariableGroup* vVariableGroup;
174
175         CGrid*  grid;
176         CFile*  file;
177
178         CDuration freq_operation_srv, freq_write_srv;
179
180         StdSize nstep, nstepMax;
181         bool isEOF;
182         CDate lastlast_Write_srv, last_Write_srv, last_operation_srv;
183         CDate lastDataRequestedFromServer;
184
185         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
186
187         map<int, CArray<double,1> > data_srv;
188         string content;
189
190         bool areAllReferenceSolved;
191         std::pair<StdString,StdString> domAxisIds_;
192         bool isReadDataRequestPending;
193         bool useCompressedOutput;
194
195         DECLARE_REF_FUNC(Field,field)
196
197      private:
198         //! The type of operation attached to the field
199         func::CFunctor::ETimeType operationTimeType;
200
201         //! The output pin of the filter providing the instant data for the field
202         boost::shared_ptr<COutputPin> instantDataFilter;
203         //! The output pin of the filters providing the result of the field's temporal operation
204         std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters;
205         //! The source filter for data provided by the client
206         boost::shared_ptr<CSourceFilter> clientSourceFilter;
207         //! The source filter for data provided by the server
208         boost::shared_ptr<CSourceFilter> serverSourceFilter;
209         //! The terminal filter which stores the instant data
210         boost::shared_ptr<CStoreFilter> storeFilter;
211         //! The terminal filter which writes the data to file
212         boost::shared_ptr<CFileWriterFilter> fileWriterFilter;
213   }; // class CField
214
215   ///--------------------------------------------------------------
216
217   // Declare/Define CFieldGroup and CFieldDefinition
218   DECLARE_GROUP(CField);
219
220   ///-----------------------------------------------------------------
221
222   template <>
223      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
224
225   ///-----------------------------------------------------------------
226} // namespace xios
227
228
229#endif // __XIOS_CField__
Note: See TracBrowser for help on using the repository browser.