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

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

Adding a check on field attributes. For now it only concerns freq_op and freq_offset.
It is done so to avoid changing its values on client after the attributes have already been sent to servers.

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