source: XIOS3/trunk/src/node/file.hpp @ 2458

Last change on this file since 2458 was 2458, checked in by ymipsl, 17 months ago

Merge XIOS_FILE_SERVICE dev branch into trunk

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
File size: 8.2 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         {
[2326]54           EVENT_ID_COLLECTIVE=100,
[651]55           EVENT_ID_ADD_FIELD, EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE,
[2326]56           EVENT_ID_ADD_VARIABLE_GROUP, EVENT_ID_CREATE_ENABLED_FIELDS,
57           EVENT_ID_NO_COLLECTIVE=1000,
[651]58         };
[509]59
[219]60         typedef CFileAttributes RelAttributes;
61         typedef CFileGroup      RelGroup;
62
63         /// Constructeurs ///
64         CFile(void);
[651]65         explicit CFile(const StdString& id);
66         CFile(const CFile& file);       // Not implemented yet.
67         CFile(const CFile* const file); // Not implemented yet.
[219]68
[509]69         /// Destructeur ///
70         virtual ~CFile(void);
71
72      public:
[219]73         /// Accesseurs ///
[1158]74         const StdString getFileOutputName(void) const;
[1542]75         std::shared_ptr<CDataOutput> getDataOutput(void) const;
76         std::shared_ptr<CDataInput> getDataInput(void) const;
[347]77         CFieldGroup* getVirtualFieldGroup(void) const;
[472]78         CVariableGroup* getVirtualVariableGroup(void) const;
[347]79         std::vector<CField*> getAllFields(void) const;
[472]80         std::vector<CVariable*> getAllVariables(void) const;
[219]81
[347]82         std::vector<CField* > getEnabledFields(int default_outputlevel = 5,
83                                                int default_level = 1,
84                                                bool default_enabled = true);
[219]85
[1622]86         StdString dumpClassAttributes(void);
87
[219]88      public :
[509]89         // Some functions to verify state of file
[651]90         bool isSyncTime(void);
91         bool checkSplit(void);
92         bool checkSync(void);
[1136]93         void checkWriteFile(void);
94         void checkReadFile(void);
[1232]95         void initWrite(void);
96         void initRead(void);
97         bool isEmptyZone();
[219]98
99         /// Mutateurs ///
[509]100         // Set some root definitions in a file
[347]101         void setVirtualFieldGroup(CFieldGroup* newVFieldGroup);
[472]102         void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
[509]103
[300]104         void createHeader(void);
[1232]105         void openInReadMode(void);
[651]106         void close(void);
[775]107         void readAttributesOfEnabledFieldsInReadMode();
[1871]108         void readFieldAttributesMetaData(CField* field) ;
109         void readFieldAttributesValues(CField* field) ;
[509]110         // Some processing on file
[445]111         void solveFieldRefInheritance(bool apply);
[651]112         void processEnabledFile(void);
[1129]113         
[1358]114         void postProcessFilterGraph();
[598]115         void prefetchEnabledReadModeFields();
[1358]116         void doPreTimestepOperationsForEnabledReadModeFields();
[1318]117         void doPostTimestepOperationsForEnabledReadModeFields();
[219]118
[1025]119         void checkGridOfEnabledFields();
120         void sendGridOfEnabledFields();
[1494]121         void sendGridComponentOfEnabledFields();
[1025]122
[1494]123         void sortEnabledFieldsForUgrid();
124
[509]125         // Add component into file
[651]126         CField* addField(const string& id = "");
127         CFieldGroup* addFieldGroup(const string& id = "");
128         CVariable* addVariable(const string& id = "");
129         CVariableGroup* addVariableGroup(const string& id = "");
[2458]130         
131         
132         void getWriterServicesId(bool defaultUsingServer2_, const string& defaultPoolWriterId_, const string& defaultWriterId_, const string& defaultPoolGathererId_, const string& defaultGathererId_,
133                                  bool& usingServer2, string& poolWriterId, string& writerId, string& poolGathererId, string& gathererId) ;
134         void getReaderServicesId(const string& defaultPoolReaderId_, const string& defaultReaderId_, string& poolReaderId, string& readerId) ;
135 
136
137         void setContextClient(const string& defaultPoolId, const string& defaultServiceId, int partitionId) ;
[1021]138         void setContextClient(CContextClient* newContextClient);
139         CContextClient* getContextClient();
[509]140
[1144]141         // Send info to server         
142         void sendEnabledFields(CContextClient* client);         
143         void sendAddField(const string& id, CContextClient* client);         
144         void sendAddFieldGroup(const string& id, CContextClient* client);                           
[1021]145         void sendAddVariable(const string& id, CContextClient* client);
[1132]146         void sendAddVariableGroup(const string& id, CContextClient* client);
[1144]147         void sendAddAllVariables(CContextClient* client);
[1870]148      public:
149         void sendFileToFileServer(CContextClient* client) ;
150      private:
151         std::set<CContextClient*> sendFileToFileServer_done_ ;
152
153      public:
[509]154         // Receive info from client
[651]155         static void recvAddField(CEventServer& event);
156         void recvAddField(CBufferIn& buffer);
157         static void recvAddFieldGroup(CEventServer& event);
158         void recvAddFieldGroup(CBufferIn& buffer);
159         static void recvAddVariable(CEventServer& event);
160         void recvAddVariable(CBufferIn& buffer);
161         static void recvAddVariableGroup(CEventServer& event);
162         void recvAddVariableGroup(CBufferIn& buffer);
[509]163
164         // Dispatch event
[651]165         static bool dispatchEvent(CEventServer& event);
[509]166
167      public:
168         /// Accesseurs statiques ///
169         static StdString GetName(void);
170         static StdString GetDefName(void);
171
172         static ENodeType GetType(void);
173      public:
174         /// Traitements ///
[651]175         virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
[509]176
177          /// Autres ///
[651]178         virtual void parse(xml::CXMLNode& node);
[509]179         virtual StdString toString(void) const;
180      public:
181
[651]182         CDate lastSync;
183         CDate lastSplit;
[1961]184         
185         const CDate& getLastSplit(void) { return lastSplit ; }
186       
[609]187         int nbAxis, nbDomains;
[1232]188         bool isOpen;         
[1639]189         MPI_Comm fileComm;
[509]190
[1232]191      private:
192         void createSubComFile();
193         bool checkRead;
194         bool allZoneEmpty;
195         
[219]196      private :
197         /// Propriétés privées ///
[1054]198         CContextClient* client;
[347]199         CFieldGroup* vFieldGroup;
[651]200         CVariableGroup* vVariableGroup;
[1542]201         std::shared_ptr<CDataOutput> data_out;
202         std::shared_ptr<CDataInput> data_in;
[347]203         std::vector<CField*> enabledFields;
[219]204
[1871]205       private: 
206         bool isClientSide_ ; // the file is on client side or on server side ?
207       public:
208         bool isClientSide(void) { return isClientSide_ ;}
209         bool isServerSide(void) { return !isClientSide_ ;}
210         void setClientSide(void) { isClientSide_=true ;}
211         void setServerSide(void) { isClientSide_=false ;}
212       
213       private:
[1232]214
[1871]215
[509]216      public:
[651]217        //         virtual void toBinary  (StdOStream& os) const;
218        //         virtual void fromBinary(StdIStream& is);
[509]219
[219]220   }; // class CFile
221
222   ///--------------------------------------------------------------
223
224   // Declare/Define CFileGroup and CFileDefinition
225   DECLARE_GROUP(CFile);
226
227   ///--------------------------------------------------------------
228
[335]229} // namespace xios
[219]230
[591]231#endif // __XIOS_CFile__
Note: See TracBrowser for help on using the repository browser.