source: XIOS/dev/dev_olga/src/node/file.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
File size: 6.8 KB
RevLine 
[591]1#ifndef __XIOS_CFile__
2#define __XIOS_CFile__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]6#include "field.hpp"
[300]7#include "data_output.hpp"
[599]8#include "data_input.hpp"
[219]9#include "declare_group.hpp"
[318]10#include "date.hpp"
[369]11#include "attribute_enum.hpp"
12#include "attribute_enum_impl.hpp"
[1021]13#include "context_client.hpp"
[382]14#include "mpi.hpp"
[219]15
[335]16namespace xios {
[509]17
[219]18   /// ////////////////////// Déclarations ////////////////////// ///
19
20   class CFileGroup;
21   class CFileAttributes;
22   class CFile;
23
[640]24   class CGarbageCollector;
25
[219]26   ///--------------------------------------------------------------
27
28   // Declare/Define CFileAttribute
29   BEGIN_DECLARE_ATTRIBUTE_MAP(CFile)
30#  include "file_attribute.conf"
31   END_DECLARE_ATTRIBUTE_MAP(CFile)
32
33   ///--------------------------------------------------------------
34
[509]35   /*!
36   \class CFile
37   This class corresponds to file component of the xml.
38   The class contains all the nessceary information to write data into a netcdf file: The most important thing
39   is the field(s) which will be written into file. Besides, there are some options to write
40   data into file, e.g: writting into only one file or multiple file; splitting a running into several files.
41   Moreover, there are some other attributes of netcdf file which are also stored in this class
42   */
[219]43   class CFile
44      : public CObjectTemplate<CFile>
45      , public CFileAttributes
46   {
47         /// typedef ///
48         typedef CObjectTemplate<CFile>   SuperClass;
49         typedef CFileAttributes SuperClassAttribute;
[509]50
[219]51      public :
[300]52         enum EEventId
53         {
[651]54           EVENT_ID_ADD_FIELD, EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE,
[509]55           EVENT_ID_ADD_VARIABLE_GROUP, EVENT_ID_CREATE_ENABLED_FIELDS
[651]56         };
[509]57
[219]58         typedef CFileAttributes RelAttributes;
59         typedef CFileGroup      RelGroup;
60
61         /// Constructeurs ///
62         CFile(void);
[651]63         explicit CFile(const StdString& id);
64         CFile(const CFile& file);       // Not implemented yet.
65         CFile(const CFile* const file); // Not implemented yet.
[219]66
[509]67         /// Destructeur ///
68         virtual ~CFile(void);
69
70      public:
[219]71         /// Accesseurs ///
[773]72         const StdString& getFileOutputName(void) const;
[337]73         boost::shared_ptr<CDataOutput> getDataOutput(void) const;
[599]74         boost::shared_ptr<CDataInput> getDataInput(void) const;
[347]75         CFieldGroup* getVirtualFieldGroup(void) const;
[472]76         CVariableGroup* getVirtualVariableGroup(void) const;
[347]77         std::vector<CField*> getAllFields(void) const;
[472]78         std::vector<CVariable*> getAllVariables(void) const;
[219]79
[347]80         std::vector<CField* > getEnabledFields(int default_outputlevel = 5,
81                                                int default_level = 1,
82                                                bool default_enabled = true);
[219]83
84      public :
[509]85         // Some functions to verify state of file
[651]86         bool isSyncTime(void);
87         bool checkSplit(void);
88         bool checkSync(void);
89         void checkFile(void);
90         void initFile(void);
[219]91
92         /// Mutateurs ///
[509]93         // Set some root definitions in a file
[347]94         void setVirtualFieldGroup(CFieldGroup* newVFieldGroup);
[472]95         void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
[509]96
[300]97         void createHeader(void);
[599]98         void openInReadMode(void);
[651]99         void close(void);
[775]100         void readAttributesOfEnabledFieldsInReadMode();
[509]101
102         // Some processing on file
[445]103         void solveFieldRefInheritance(bool apply);
[651]104         void processEnabledFile(void);
[823]105         void solveOnlyRefOfEnabledFields(bool sendToServer);
106         void generateNewTransformationGridDest();
[1129]107         
[640]108         void buildFilterGraphOfEnabledFields(CGarbageCollector& gc);
[598]109         void prefetchEnabledReadModeFields();
110         void prefetchEnabledReadModeFieldsIfNeeded();
[219]111
[1129]112         void solveAllRefOfEnabledFieldsAndTransform(bool sendToServer);
[1025]113         void checkGridOfEnabledFields();
114         void sendGridOfEnabledFields();
115
[509]116         // Add component into file
[651]117         CField* addField(const string& id = "");
118         CFieldGroup* addFieldGroup(const string& id = "");
119         CVariable* addVariable(const string& id = "");
120         CVariableGroup* addVariableGroup(const string& id = "");
[1021]121         void setContextClient(CContextClient* newContextClient);
122         CContextClient* getContextClient();
[509]123
[992]124         // Send info to server
[1071]125         void sendEnabledFields();
[1021]126         void sendEnabledFields(CContextClient* client);
[651]127         void sendAddField(const string& id = "");
[1021]128         void sendAddField(const string& id, CContextClient* client);
[651]129         void sendAddFieldGroup(const string& id = "");
[1021]130         void sendAddAllVariables();                        // to be removed (?)
131         void sendAddAllVariables(CContextClient* client);
132         void sendAddVariable(const string& id = "");         // to be removed (?)
133         void sendAddVariable(const string& id, CContextClient* client);
[651]134         void sendAddVariableGroup(const string& id = "");
[509]135
136         // Receive info from client
[651]137         static void recvAddField(CEventServer& event);
138         void recvAddField(CBufferIn& buffer);
139         static void recvAddFieldGroup(CEventServer& event);
140         void recvAddFieldGroup(CBufferIn& buffer);
141         static void recvAddVariable(CEventServer& event);
142         void recvAddVariable(CBufferIn& buffer);
143         static void recvAddVariableGroup(CEventServer& event);
144         void recvAddVariableGroup(CBufferIn& buffer);
[509]145
146         // Dispatch event
[651]147         static bool dispatchEvent(CEventServer& event);
[509]148
149      public:
150         /// Accesseurs statiques ///
151         static StdString GetName(void);
152         static StdString GetDefName(void);
153
154         static ENodeType GetType(void);
155      public:
156         /// Traitements ///
[651]157         virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
[509]158
159          /// Autres ///
[651]160         virtual void parse(xml::CXMLNode& node);
[509]161         virtual StdString toString(void) const;
162      public:
163
[651]164         CDate lastSync;
165         CDate lastSplit;
[609]166         int nbAxis, nbDomains;
[651]167         bool isOpen;
168         bool allDomainEmpty;
169         MPI_Comm fileComm;
[509]170
[219]171      private :
172         /// Propriétés privées ///
[1054]173         CContextClient* client;
[347]174         CFieldGroup* vFieldGroup;
[651]175         CVariableGroup* vVariableGroup;
[337]176         boost::shared_ptr<CDataOutput> data_out;
[599]177         boost::shared_ptr<CDataInput> data_in;
[347]178         std::vector<CField*> enabledFields;
[219]179
[509]180      public:
[651]181        //         virtual void toBinary  (StdOStream& os) const;
182        //         virtual void fromBinary(StdIStream& is);
[509]183
[219]184   }; // class CFile
185
186   ///--------------------------------------------------------------
187
188   // Declare/Define CFileGroup and CFileDefinition
189   DECLARE_GROUP(CFile);
190
191   ///--------------------------------------------------------------
192
[335]193} // namespace xios
[219]194
[591]195#endif // __XIOS_CFile__
Note: See TracBrowser for help on using the repository browser.