source: XIOS/dev/dev_trunk_omp/src/node/file.hpp @ 1646

Last change on this file since 1646 was 1646, checked in by yushan, 5 years ago

branch merged with trunk @1645. arch file (ep&mpi) added for ADA

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