source: XIOS/trunk/src/node/context.hpp @ 689

Last change on this file since 689 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
File size: 7.8 KB
RevLine 
[591]1#ifndef __XIOS_CContext__
2#define __XIOS_CContext__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[352]6//#include "node_type.hpp"
[549]7#include "calendar_wrapper.hpp"
[219]8
9#include "declare_group.hpp"
[300]10//#include "context_client.hpp"
11//#include "context_server.hpp"
12#include "data_output.hpp"
[639]13#include "garbage_collector.hpp"
[219]14
[382]15#include "mpi.hpp"
[300]16
[219]17
[335]18namespace xios {
[549]19   class CContextClient;
20   class CContextServer;
[509]21
22
[219]23   /// ////////////////////// Déclarations ////////////////////// ///
24   class CContextGroup;
25   class CContextAttributes;
26   class CContext;
[352]27   class CFile;
[219]28   ///--------------------------------------------------------------
29
30   // Declare/Define CFileAttribute
31   BEGIN_DECLARE_ATTRIBUTE_MAP(CContext)
32#  include "context_attribute.conf"
33   END_DECLARE_ATTRIBUTE_MAP(CContext)
34
35   ///--------------------------------------------------------------
[509]36  /*!
37  \class CContext
38   This class corresponds to the concrete presentation of context in xml file and in play an essential role in XIOS
39   Each object of this class contains all root definition of elements: files, fiels, domains, axis, etc, ... from which
40   we can have access to each element.
41   In fact, every thing must a be inside a particuliar context. After the xml file (iodef.xml) is parsed,
42   object of the class is created and its contains all information of other elements in the xml file.
43  */
[219]44   class CContext
45      : public CObjectTemplate<CContext>
46      , public CContextAttributes
47   {
[300]48         public :
49         enum EEventId
50         {
51           EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR,
[509]52           EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE,
53           EVENT_ID_POST_PROCESS
[549]54         };
[509]55
[219]56         /// typedef ///
57         typedef CObjectTemplate<CContext>   SuperClass;
58         typedef CContextAttributes SuperClassAttribute;
59
60      public :
61
62         typedef CContextAttributes RelAttributes;
63         typedef CContext           RelGroup;
64
65         //---------------------------------------------------------
66
67      public :
68
69         /// Constructeurs ///
70         CContext(void);
71         explicit CContext(const StdString & id);
72         CContext(const CContext & context);       // Not implemented yet.
73         CContext(const CContext * const context); // Not implemented yet.
74
75         /// Destructeur ///
76         virtual ~CContext(void);
77
78         //---------------------------------------------------------
79
80      public :
[509]81
[219]82         /// Mutateurs ///
[343]83         void setCalendar(boost::shared_ptr<CCalendar> newCalendar);
[509]84
[219]85         /// Accesseurs ///
[343]86         boost::shared_ptr<CCalendar>      getCalendar(void) const;
[219]87
88      public :
[509]89         // Initialize server or client
[597]90         void initServer(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtClient = 0);
91         void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer = 0);
[549]92         bool isInitialized(void);
[219]93
[509]94         // Put sever or client into loop state
[549]95         bool eventLoop(void);
[509]96
[597]97         bool checkBuffersAndListen(void);
98
[509]99         // Finalize a context
[549]100         void finalize(void);
101         void closeDefinition(void);
[509]102
103         // Some functions to process context
[300]104         void findAllEnabledFields(void);
[549]105         void solveAllInheritance(bool apply=true);
[300]106         void findEnabledFiles(void);
[598]107         void findEnabledReadModeFiles(void);
[549]108         void closeAllFile(void);
109         void updateCalendar(int step);
110         void createFileHeader(void );
[676]111         void checkAxisDomainsGridsEligibilityForCompressedOutput();
[509]112         void solveAllRefOfEnabledFields(bool sendToServer);
[640]113         void buildFilterGraphOfEnabledFields();
[598]114         void startPrefetchingOfEnabledReadModeFiles();
115         void checkPrefetchingOfEnabledReadModeFiles();
[593]116         void findFieldsWithReadAccess(void);
117         void solveAllRefOfFieldsWithReadAccess();
[640]118         void buildFilterGraphOfFieldsWithReadAccess();
[509]119         void postProcessing();
120
121         std::map<int, StdSize>& getDataSize();
122         void setClientServerBuffer();
123
124         // Send context close definition
[549]125         void sendCloseDefinition(void);
[509]126         // There are something to send on closing context defintion
[549]127         void sendUpdateCalendar(int step);
128         void sendCreateFileHeader(void);
[509]129         void sendEnabledFiles();
130         void sendEnabledFields();
131         void sendRefDomainsAxis();
132         void sendRefGrid();
133         void sendPostProcessing();
134
[511]135         const StdString& getIdServer();
136
[509]137         // Client side: Receive and process messages
[549]138         static void recvUpdateCalendar(CEventServer& event);
139         void recvUpdateCalendar(CBufferIn& buffer);
140         static void recvCloseDefinition(CEventServer& event);
141         static void recvCreateFileHeader(CEventServer& event);
142         void recvCreateFileHeader(CBufferIn& buffer);
[509]143         static void recvSolveInheritanceContext(CEventServer& event);
144         void recvSolveInheritanceContext(CBufferIn& buffer);
145         static void recvPostProcessing(CEventServer& event);
146         void recvPostProcessing(CBufferIn& buffer);
147
148         // dispatch event
[549]149         static bool dispatchEvent(CEventServer& event);
[509]150
151      public:
152        // Get current context
153        static CContext* getCurrent(void);
154
155        // Get context root
156        static CContextGroup* getRoot(void);
157
158        // Set current context
159        static void setCurrent(const string& id);
160
161        // Create new context
162        static CContext* create(const string& id = "");
163
164        /// Accesseurs statiques ///
165        static StdString GetName(void);
166        static StdString GetDefName(void);
167        static ENodeType GetType(void);
168
169        static CContextGroup* GetContextGroup(void);
170
171        // Some functions to visualize structure of current context
172        static void ShowTree(StdOStream & out = std::clog);
173        static void CleanTree(void);
174
[219]175      public :
[509]176         // Parse xml node and write all info into context
[219]177         virtual void parse(xml::CXMLNode & node);
178
[509]179         // Visualize a context
[219]180         virtual StdString toString(void) const;
[509]181
182
183         // Solve all inheritance relation in current context
184         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0);
185
186         // Verify if all root definition in a context have children
187         virtual bool hasChild(void) const;
188
[300]189      public :
[509]190         // Calendar of context
191         boost::shared_ptr<CCalendar>   calendar;
192
[598]193         // List of all enabled files (files on which fields are written or read)
[347]194         std::vector<CFile*> enabledFiles;
[598]195         // List of all enabled files in read mode (files on which fields are read)
196         std::vector<CFile*> enabledReadModeFiles;
[509]197
[593]198         // List of all fields whose instant data is accessible from the public API
199         std::vector<CField*> fieldsWithReadAccess;
200
[509]201         // Context root
[549]202         static shared_ptr<CContextGroup> root;
[219]203
[509]204         // Determine context on client or not
[549]205         bool hasClient;
[300]206
[509]207         // Determine context on server or not
[549]208         bool hasServer;
[509]209
210         // Concrete context server
[549]211         CContextServer* server;
[509]212
213         // Concrete contex client
[549]214         CContextClient* client;
[509]215
216      private:
217         bool isPostProcessed;
[597]218         bool finalized;
[509]219         std::map<int, StdSize> dataSize_;
[511]220         StdString idServer_;
[639]221         CGarbageCollector garbageCollector;
[655]222         std::list<MPI_Comm> comms; //!< Communicators allocated internally
[509]223
224      public: // Some function maybe removed in the near future
225        // virtual void toBinary  (StdOStream & os) const;
226        // virtual void fromBinary(StdIStream & is);
[219]227   }; // class CContext
228
229   ///--------------------------------------------------------------
230
231   // Declare/Define CContextGroup and CContextDefinition
232   DECLARE_GROUP(CContext);
233
234   ///--------------------------------------------------------------
235
[335]236} // namespace xios
[219]237
[591]238#endif // __XIOS_CContext__
Note: See TracBrowser for help on using the repository browser.