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

Last change on this file since 1294 was 1294, checked in by oabramkina, 7 years ago

Improvements for the secondary server: each grid is only sent to secondary-server pools that need it.

  • 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: 10.0 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
[1232]60         enum EReadField
61         {
62           RF_NODATA, RF_EOF, RF_DATA
63         };
64         
[707]65      public:
[219]66
67         typedef CFieldAttributes RelAttributes;
68         typedef CFieldGroup      RelGroup;
69
[300]70         enum EEventId
71         {
[598]72           EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY,
73           EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP
[651]74         };
[509]75
[219]76         /// Constructeurs ///
77         CField(void);
[651]78         explicit CField(const StdString& id);
79         CField(const CField& field);       // Not implemented yet.
80         CField(const CField* const field); // Not implemented yet.
[219]81
82         /// Accesseurs ///
83
[651]84         CGrid* getRelGrid(void) const;
85         CFile* getRelFile(void) const;
[219]86
[645]87         func::CFunctor::ETimeType getOperationTimeType() const;
88
[707]89      public:
[952]90         int getNStep(void) const;
[266]91
[593]92         template <int N> void getData(CArray<double, N>& _data) const;
[219]93
[641]94         boost::shared_ptr<COutputPin> getInstantDataFilter();
[219]95
96         /// Mutateur ///
[347]97         void setRelFile(CFile* _file);
[266]98         void incrementNStep(void);
[952]99         void resetNStep(int nstep = 0);
[599]100         void resetNStepMax();
[219]101
[1236]102         std::map<int, StdSize> getGridAttributesBufferSize(CContextClient* client);
103         std::map<int, StdSize> getGridDataBufferSize(CContextClient* client); // Grid data buffer size for each connection of contextclient
[509]104
[1294]105         void setContextClient(CContextClient* newContextClient);
106         CContextClient* getContextClient();
107
[707]108       public:
[1158]109         bool isActive(bool atCurrentTimestep = false) const;
[651]110         bool hasOutputFile;
[219]111
[707]112         bool wasWritten() const;
113         void setWritten();
114
[676]115         bool getUseCompressedOutput() const;
116         void setUseCompressedOutput();
117
[219]118         /// Traitements ///
119         void solveGridReference(void);
[645]120         void solveServerOperation(void);
[509]121         void solveCheckMaskIndex(bool doSendingIndex);
[823]122         void solveAllReferenceEnabledField(bool doSending2Server);
123         void solveOnlyReferenceEnabledField(bool doSending2Server);
124         void generateNewTransformationGridDest();
125         void updateRef(CGrid* grid);
126         void buildGridTransformationGraph();
[509]127         void solveGridDomainAxisRef(bool checkAtt);
[619]128         void solveTransformedGrid();
[687]129         void solveGenerateGrid();
[775]130         void solveGridDomainAxisBaseRef();
[219]131
[1129]132         void solveAllEnabledFieldsAndTransform();
[1024]133         void checkGridOfEnabledFields();
134         void sendGridOfEnabledFields();
[1278]135         void sendGridComponentOfEnabledFields();
[1024]136
[1278]137         /// Vérifications ///
138         void checkAttributes(void);
139
[640]140         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput);
[1215]141         size_t getGlobalWrittenSize(void) ;
142         
143         
[737]144         boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc);
[642]145         boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc);
[643]146         boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
[1021]147         boost::shared_ptr<COutputPin> getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq);
[640]148
[651]149//         virtual void fromBinary(StdIStream& is);
[219]150
151         /// Destructeur ///
152         virtual ~CField(void);
153
154         /// Accesseurs statiques ///
155         static StdString GetName(void);
156         static StdString GetDefName(void);
[509]157
[219]158         static ENodeType GetType(void);
[509]159
[651]160        template <int N> void setData(const CArray<double, N>& _data);
161        static bool dispatchEvent(CEventServer& event);
[638]162        void sendUpdateData(const CArray<double,1>& data);
[1099]163        void sendUpdateData(const CArray<double,1>& data, CContextClient* client);
[651]164        static void recvUpdateData(CEventServer& event);
[1024]165        void recvUpdateData(std::map<int,CBufferIn*>& rankBuffers);
[651]166        void writeField(void);
[1158]167        bool sendReadDataRequest(const CDate& tsDataRequested);
[598]168        bool sendReadDataRequestIfNeeded(void);
169        static void recvReadDataRequest(CEventServer& event);
170        void recvReadDataRequest(void);
[1232]171        EReadField readField(void);
[598]172        static void recvReadDataReady(CEventServer& event);
173        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers);
[1158]174        void outputField(CArray<double,3>& fieldOut);
175        void outputField(CArray<double,2>& fieldOut);
[651]176        void outputField(CArray<double,1>& fieldOut);
[1158]177        void inputField(CArray<double,3>& fieldOut);
178        void inputField(CArray<double,2>& fieldOut);
[599]179        void inputField(CArray<double,1>& fieldOut);
[676]180        void outputCompressedField(CArray<double, 1>& fieldOut);
[651]181        void scaleFactorAddOffset(double scaleFactor, double addOffset);
[599]182        void invertScaleFactorAddOffset(double scaleFactor, double addOffset);
[651]183        void parse(xml::CXMLNode& node);
[509]184
[472]185        void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
186        CVariableGroup* getVirtualVariableGroup(void) const;
187        vector<CVariable*> getAllVariables(void) const;
[651]188        virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
[509]189
[651]190        CVariable* addVariable(const string& id = "");
[1144]191        CVariableGroup* addVariableGroup(const string& id = "");       
[1021]192        void sendAddVariable(const string& id, CContextClient* client);
[1144]193        void sendAddVariableGroup(const string& id, CContextClient* client);
[651]194        static void recvAddVariable(CEventServer& event);
195        void recvAddVariable(CBufferIn& buffer);
196        static void recvAddVariableGroup(CEventServer& event);
[1144]197        void recvAddVariableGroup(CBufferIn& buffer);       
[1021]198        void sendAddAllVariables(CContextClient* client);
[1024]199        void writeUpdateData(const CArray<double,1>& data);
[509]200
[887]201        const std::vector<StdString>& getRefDomainAxisIds();
[619]202
[1021]203        const string& getExpression(void);
204        bool hasExpression(void) const;
205
[707]206      public:
[219]207         /// Propriétés privées ///
[651]208         CVariableGroup* vVariableGroup;
[509]209
[651]210         CGrid*  grid;
[347]211         CFile*  file;
[219]212
[343]213         CDuration freq_operation_srv, freq_write_srv;
[219]214
[707]215         bool written; //<! Was the field written at least once
[952]216         int nstep, nstepMax;
[599]217         bool isEOF;
[651]218         CDate lastlast_Write_srv, last_Write_srv, last_operation_srv;
[1021]219         CDate lastDataRequestedFromServer, lastDataReceivedFromServer;
220         bool wasDataAlreadyReceivedFromServer;
[509]221
[300]222         map<int,boost::shared_ptr<func::CFunctor> > foperation_srv;
[509]223
[1144]224         // map<int, CArray<double,1> > data_srv;
[1024]225         CArray<double,1> recvDataSrv;
226         
227         boost::shared_ptr<func::CFunctor> recvFoperationSrv;
[651]228         string content;
[509]229
[887]230         std::vector<StdString> domAxisScalarIds_;
[676]231         bool useCompressedOutput;
[645]232
[1021]233         // Two variables to identify the time_counter meta data written in file, which has no time_counter
234         bool hasTimeInstant;
235         bool hasTimeCentered;
236
[1129]237
[540]238         DECLARE_REF_FUNC(Field,field)
[219]239
[640]240      private:
[1294]241         CContextClient* client;
242
[1129]243         bool areAllReferenceSolved;
244         bool isReferenceSolved;
245         bool isReferenceSolvedAndTransformed;
[1232]246         bool nstepMaxRead;
[1129]247
248      private:
[645]249         //! The type of operation attached to the field
250         func::CFunctor::ETimeType operationTimeType;
251
[640]252         //! The output pin of the filter providing the instant data for the field
253         boost::shared_ptr<COutputPin> instantDataFilter;
[643]254         //! The output pin of the filters providing the result of the field's temporal operation
255         std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters;
[737]256         //! The output pin of the filter providing the instant data for self references
257         boost::shared_ptr<COutputPin> selfReferenceFilter;
[640]258         //! The source filter for data provided by the client
259         boost::shared_ptr<CSourceFilter> clientSourceFilter;
260         //! The source filter for data provided by the server
261         boost::shared_ptr<CSourceFilter> serverSourceFilter;
262         //! The terminal filter which stores the instant data
263         boost::shared_ptr<CStoreFilter> storeFilter;
[1158]264         //! The terminal filter which writes the data to file
[640]265         boost::shared_ptr<CFileWriterFilter> fileWriterFilter;
[1024]266         //! The terminal filter which writes data to file
267         boost::shared_ptr<CFileServerWriterFilter> fileServerWriterFilter;
[219]268   }; // class CField
269
270   ///--------------------------------------------------------------
271
272   // Declare/Define CFieldGroup and CFieldDefinition
273   DECLARE_GROUP(CField);
274
275   ///-----------------------------------------------------------------
276
277   template <>
278      void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void);
279
280   ///-----------------------------------------------------------------
[335]281} // namespace xios
[219]282
283
[591]284#endif // __XIOS_CField__
Note: See TracBrowser for help on using the repository browser.