source: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp @ 1853

Last change on this file since 1853 was 1853, checked in by ymipsl, 4 years ago

Coupling branch : replace hasServer and hasClient combination by the name of correct service : CLIENT, GATHERER or OUT_SERVER.

YM

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