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

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

Updating two-level server.
Each client now can play the role of server: It can forward data to other clients or write data like a server.
Each client must combine all data received from other client(s) before forward them or write them on files

+) Correct some bugs of exchange data_index in domain and axis
+) Reorder some functions in context.cpp to make sure that all necessary attributes are available before computing index
+) Add the mapping index for client to write data.

Test
+) On Curie
+) test_client and test_complete
+) Mode:

  • Only one level: Correct
  • Two levels: Work if using ddt (bug)

+) Only zoom is tested but other transformations should work
+) No reading test

  • 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
RevLine 
[591]1#ifndef __XIOS_CField__
2#define __XIOS_CField__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]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"
[540]15#include "declare_ref_func.hpp"
[619]16#include "transformation_enum.hpp"
[646]17#include "variable.hpp"
[1021]18#include "context_client.hpp"
[219]19
[300]20
[335]21namespace xios {
[509]22
[219]23   /// ////////////////////// Déclarations ////////////////////// ///
24
25   class CFieldGroup;
26   class CFieldAttributes;
27   class CField;
28
29   class CFile;
30   class CGrid;
[640]31   class CContext;
[619]32   class CGenericFilter;
33
[640]34   class CGarbageCollector;
35   class COutputPin;
36   class CSourceFilter;
37   class CStoreFilter;
38   class CFileWriterFilter;
[1024]39   class CFileServerWriterFilter;
[640]40
[219]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
[707]60      public:
[219]61
62         typedef CFieldAttributes RelAttributes;
63         typedef CFieldGroup      RelGroup;
64
[300]65         enum EEventId
66         {
[598]67           EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY,
68           EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP
[651]69         };
[509]70
[219]71         /// Constructeurs ///
72         CField(void);
[651]73         explicit CField(const StdString& id);
74         CField(const CField& field);       // Not implemented yet.
75         CField(const CField* const field); // Not implemented yet.
[219]76
77         /// Accesseurs ///
78
[651]79         CGrid* getRelGrid(void) const;
80         CFile* getRelFile(void) const;
[219]81
[645]82         func::CFunctor::ETimeType getOperationTimeType() const;
83
[707]84      public:
[952]85         int getNStep(void) const;
[266]86
[593]87         template <int N> void getData(CArray<double, N>& _data) const;
[219]88
[641]89         boost::shared_ptr<COutputPin> getInstantDataFilter();
[219]90
91         /// Mutateur ///
[347]92         void setRelFile(CFile* _file);
[266]93         void incrementNStep(void);
[952]94         void resetNStep(int nstep = 0);
[599]95         void resetNStepMax();
[219]96
[731]97         std::map<int, StdSize> getGridAttributesBufferSize();
[1099]98         std::vector<std::map<int, StdSize> > getGridDataBufferSize(); // Grid data buffer size for each connection of contextclient
[509]99
[707]100       public:
[310]101         bool isActive(void) const;
[651]102         bool hasOutputFile;
[219]103
[707]104         bool wasWritten() const;
105         void setWritten();
106
[676]107         bool getUseCompressedOutput() const;
108         void setUseCompressedOutput();
109
[219]110         /// Traitements ///
111         void solveGridReference(void);
[645]112         void solveServerOperation(void);
[509]113         void solveCheckMaskIndex(bool doSendingIndex);
[823]114         void solveAllReferenceEnabledField(bool doSending2Server);
115         void solveOnlyReferenceEnabledField(bool doSending2Server);
116         void generateNewTransformationGridDest();
117         void updateRef(CGrid* grid);
118         void buildGridTransformationGraph();
[509]119         void solveGridDomainAxisRef(bool checkAtt);
[619]120         void solveTransformedGrid();
[687]121         void solveGenerateGrid();
[775]122         void solveGridDomainAxisBaseRef();
[219]123
[1129]124         void solveAllEnabledFieldsAndTransform();
[1024]125         void checkGridOfEnabledFields();
126         void sendGridOfEnabledFields();
127
[640]128         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput);
[737]129         boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc);
[642]130         boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc);
[643]131         boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
[1021]132         boost::shared_ptr<COutputPin> getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
[640]133
[651]134//         virtual void fromBinary(StdIStream& is);
[219]135
136         /// Destructeur ///
137         virtual ~CField(void);
138
139         /// Accesseurs statiques ///
140         static StdString GetName(void);
141         static StdString GetDefName(void);
[509]142
[219]143         static ENodeType GetType(void);
[509]144
[651]145        template <int N> void setData(const CArray<double, N>& _data);
146        static bool dispatchEvent(CEventServer& event);
[638]147        void sendUpdateData(const CArray<double,1>& data);
[1099]148        void sendUpdateData(const CArray<double,1>& data, CContextClient* client);
[651]149        static void recvUpdateData(CEventServer& event);
[1024]150        void recvUpdateData(std::map<int,CBufferIn*>& rankBuffers);
[651]151        void writeField(void);
[1021]152        void sendReadDataRequest(const CDate& tsDataRequested);
[598]153        bool sendReadDataRequestIfNeeded(void);
154        static void recvReadDataRequest(CEventServer& event);
155        void recvReadDataRequest(void);
[599]156        bool readField(void);
[598]157        static void recvReadDataReady(CEventServer& event);
158        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers);
[651]159        void outputField(CArray<double,3>& fieldOut);
160        void outputField(CArray<double,2>& fieldOut);
161        void outputField(CArray<double,1>& fieldOut);
[599]162        void inputField(CArray<double,3>& fieldOut);
163        void inputField(CArray<double,2>& fieldOut);
164        void inputField(CArray<double,1>& fieldOut);
[676]165        void outputCompressedField(CArray<double, 1>& fieldOut);
[651]166        void scaleFactorAddOffset(double scaleFactor, double addOffset);
[599]167        void invertScaleFactorAddOffset(double scaleFactor, double addOffset);
[651]168        void parse(xml::CXMLNode& node);
[509]169
[472]170        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
171        CVariableGroup* getVirtualVariableGroup(void) const;
172        vector<CVariable*> getAllVariables(void) const;
[651]173        virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
[509]174
[651]175        CVariable* addVariable(const string& id = "");
176        CVariableGroup* addVariableGroup(const string& id = "");
177        void sendAddVariable(const string& id = "");
[1021]178        void sendAddVariable(const string& id, CContextClient* client);
[651]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);
[509]184        void sendAddAllVariables();
[1021]185        void sendAddAllVariables(CContextClient* client);
[1024]186        void writeUpdateData(const CArray<double,1>& data);
[509]187
[1024]188
[887]189        const std::vector<StdString>& getRefDomainAxisIds();
[619]190
[1021]191        const string& getExpression(void);
192        bool hasExpression(void) const;
193
[707]194      public:
[219]195         /// Propriétés privées ///
[651]196         CVariableGroup* vVariableGroup;
[509]197
[651]198         CGrid*  grid;
[347]199         CFile*  file;
[219]200
[343]201         CDuration freq_operation_srv, freq_write_srv;
[219]202
[707]203         bool written; //<! Was the field written at least once
[952]204         int nstep, nstepMax;
[599]205         bool isEOF;
[651]206         CDate lastlast_Write_srv, last_Write_srv, last_operation_srv;
[1021]207         CDate lastDataRequestedFromServer, lastDataReceivedFromServer;
208         bool wasDataAlreadyReceivedFromServer;
[509]209
[300]210         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
[509]211
[651]212         map<int, CArray<double,1> > data_srv;
[1024]213         CArray<double,1> recvDataSrv;
214         
215         boost::shared_ptr<func::CFunctor> recvFoperationSrv;
[651]216         string content;
[509]217
[887]218         std::vector<StdString> domAxisScalarIds_;
[676]219         bool useCompressedOutput;
[645]220
[1021]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
[1129]225
[540]226         DECLARE_REF_FUNC(Field,field)
[219]227
[640]228      private:
[1129]229         bool areAllReferenceSolved;
230         bool isReferenceSolved;
231         bool isReferenceSolvedAndTransformed;
232
233      private:
[645]234         //! The type of operation attached to the field
235         func::CFunctor::ETimeType operationTimeType;
236
[640]237         //! The output pin of the filter providing the instant data for the field
238         boost::shared_ptr<COutputPin> instantDataFilter;
[643]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;
[737]241         //! The output pin of the filter providing the instant data for self references
242         boost::shared_ptr<COutputPin> selfReferenceFilter;
[640]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;
[1024]249         //! The terminal filter which sends the data to file
[640]250         boost::shared_ptr<CFileWriterFilter> fileWriterFilter;
[1024]251         //! The terminal filter which writes data to file
252         boost::shared_ptr<CFileServerWriterFilter> fileServerWriterFilter;
[219]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   ///-----------------------------------------------------------------
[335]266} // namespace xios
[219]267
268
[591]269#endif // __XIOS_CField__
Note: See TracBrowser for help on using the repository browser.