source: XIOS/dev/dev_olga/src/node/file.hpp @ 1136

Last change on this file since 1136 was 1136, checked in by mhnguyen, 7 years ago

Reading for two-level server

+) Update reading with the changes of grid distribution
+) Correct a minor bug on modification grid mask
+) Do some code cleaning

Test
+) On Curie
+) Work in both mode: classical and two-level
+) Push some *.nc for test_remap

  • 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.0 KB
Line 
1#ifndef __XIOS_CFile__
2#define __XIOS_CFile__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "field.hpp"
7#include "data_output.hpp"
8#include "data_input.hpp"
9#include "declare_group.hpp"
10#include "date.hpp"
11#include "attribute_enum.hpp"
12#include "attribute_enum_impl.hpp"
13#include "context_client.hpp"
14#include "mpi.hpp"
15
16namespace xios {
17
18   /// ////////////////////// Déclarations ////////////////////// ///
19
20   class CFileGroup;
21   class CFileAttributes;
22   class CFile;
23
24   class CGarbageCollector;
25
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
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   */
43   class CFile
44      : public CObjectTemplate<CFile>
45      , public CFileAttributes
46   {
47         /// typedef ///
48         typedef CObjectTemplate<CFile>   SuperClass;
49         typedef CFileAttributes SuperClassAttribute;
50
51      public :
52         enum EEventId
53         {
54           EVENT_ID_ADD_FIELD, EVENT_ID_ADD_FIELD_GROUP, EVENT_ID_ADD_VARIABLE,
55           EVENT_ID_ADD_VARIABLE_GROUP, EVENT_ID_CREATE_ENABLED_FIELDS
56         };
57
58         typedef CFileAttributes RelAttributes;
59         typedef CFileGroup      RelGroup;
60
61         /// Constructeurs ///
62         CFile(void);
63         explicit CFile(const StdString& id);
64         CFile(const CFile& file);       // Not implemented yet.
65         CFile(const CFile* const file); // Not implemented yet.
66
67         /// Destructeur ///
68         virtual ~CFile(void);
69
70      public:
71         /// Accesseurs ///
72         const StdString& getFileOutputName(void) const;
73         boost::shared_ptr<CDataOutput> getDataOutput(void) const;
74         boost::shared_ptr<CDataInput> getDataInput(void) const;
75         CFieldGroup* getVirtualFieldGroup(void) const;
76         CVariableGroup* getVirtualVariableGroup(void) const;
77         std::vector<CField*> getAllFields(void) const;
78         std::vector<CVariable*> getAllVariables(void) const;
79
80         std::vector<CField* > getEnabledFields(int default_outputlevel = 5,
81                                                int default_level = 1,
82                                                bool default_enabled = true);
83
84      public :
85         // Some functions to verify state of file
86         bool isSyncTime(void);
87         bool checkSplit(void);
88         bool checkSync(void);
89         void checkWriteFile(void);
90         void checkReadFile(void);
91         void initFile(void);
92
93         /// Mutateurs ///
94         // Set some root definitions in a file
95         void setVirtualFieldGroup(CFieldGroup* newVFieldGroup);
96         void setVirtualVariableGroup(CVariableGroup* newVVariableGroup);
97
98         void createHeader(void);
99         void openInReadMode(MPI_Comm* readComm = NULL);
100         void close(void);
101         void readAttributesOfEnabledFieldsInReadMode();
102
103         // Some processing on file
104         void solveFieldRefInheritance(bool apply);
105         void processEnabledFile(void);
106         void solveOnlyRefOfEnabledFields(bool sendToServer);
107         void generateNewTransformationGridDest();
108         
109         void buildFilterGraphOfEnabledFields(CGarbageCollector& gc);
110         void prefetchEnabledReadModeFields();
111         void prefetchEnabledReadModeFieldsIfNeeded();
112
113         void solveAllRefOfEnabledFieldsAndTransform(bool sendToServer);
114         void checkGridOfEnabledFields();
115         void sendGridOfEnabledFields();
116
117         // Add component into file
118         CField* addField(const string& id = "");
119         CFieldGroup* addFieldGroup(const string& id = "");
120         CVariable* addVariable(const string& id = "");
121         CVariableGroup* addVariableGroup(const string& id = "");
122         void setContextClient(CContextClient* newContextClient);
123         CContextClient* getContextClient();
124
125         // Send info to server
126         void sendEnabledFields();
127         void sendEnabledFields(CContextClient* client);
128         void sendAddField(const string& id = "");
129         void sendAddField(const string& id, CContextClient* client);
130         void sendAddFieldGroup(const string& id = "");
131         void sendAddFieldGroup(const string& id, CContextClient* client);
132         void sendAddAllVariables();                        // to be removed (?)
133         void sendAddAllVariables(CContextClient* client);
134         void sendAddVariable(const string& id = "");         // to be removed (?)
135         void sendAddVariable(const string& id, CContextClient* client);
136         void sendAddVariableGroup(const string& id = "");
137         void sendAddVariableGroup(const string& id, CContextClient* client);
138
139         // Receive info from client
140         static void recvAddField(CEventServer& event);
141         void recvAddField(CBufferIn& buffer);
142         static void recvAddFieldGroup(CEventServer& event);
143         void recvAddFieldGroup(CBufferIn& buffer);
144         static void recvAddVariable(CEventServer& event);
145         void recvAddVariable(CBufferIn& buffer);
146         static void recvAddVariableGroup(CEventServer& event);
147         void recvAddVariableGroup(CBufferIn& buffer);
148
149         // Dispatch event
150         static bool dispatchEvent(CEventServer& event);
151
152      public:
153         /// Accesseurs statiques ///
154         static StdString GetName(void);
155         static StdString GetDefName(void);
156
157         static ENodeType GetType(void);
158      public:
159         /// Traitements ///
160         virtual void solveDescInheritance(bool apply, const CAttributeMap* const parent = 0);
161
162          /// Autres ///
163         virtual void parse(xml::CXMLNode& node);
164         virtual StdString toString(void) const;
165      public:
166
167         CDate lastSync;
168         CDate lastSplit;
169         int nbAxis, nbDomains;
170         bool isOpen;
171         bool allDomainEmpty;
172         MPI_Comm fileComm;
173
174      private :
175         /// Propriétés privées ///
176         CContextClient* client;
177         CFieldGroup* vFieldGroup;
178         CVariableGroup* vVariableGroup;
179         boost::shared_ptr<CDataOutput> data_out;
180         boost::shared_ptr<CDataInput> data_in;
181         std::vector<CField*> enabledFields;
182
183      public:
184        //         virtual void toBinary  (StdOStream& os) const;
185        //         virtual void fromBinary(StdIStream& is);
186
187   }; // class CFile
188
189   ///--------------------------------------------------------------
190
191   // Declare/Define CFileGroup and CFileDefinition
192   DECLARE_GROUP(CFile);
193
194   ///--------------------------------------------------------------
195
196} // namespace xios
197
198#endif // __XIOS_CFile__
Note: See TracBrowser for help on using the repository browser.