source: XIOS/dev/dev_trunk_omp/src/node/domain.hpp @ 1610

Last change on this file since 1610 was 1601, checked in by yushan, 6 years ago

branch_openmp merged with trunk r1597

  • 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: 9.8 KB
RevLine 
[591]1#ifndef __XIOS_CDomain__
2#define __XIOS_CDomain__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]6#include "group_factory.hpp"
7
8#include "declare_group.hpp"
[540]9#include "declare_ref_func.hpp"
[300]10#include "event_client.hpp"
11#include "event_server.hpp"
12#include "buffer_in.hpp"
[369]13#include "array_new.hpp"
14#include "attribute_array.hpp"
[449]15#include "attribute_enum.hpp"
[631]16#include "transformation.hpp"
17#include "transformation_enum.hpp"
[1025]18#include "server_distribution_description.hpp"
[1601]19#include "mpi_std.hpp"
[878]20#include "mesh.hpp"
21
[335]22namespace xios {
[509]23
[219]24   /// ////////////////////// Déclarations ////////////////////// ///
25
26   class CDomainGroup;
27   class CDomainAttributes;
28   class CDomain;
[878]29   class CFile;
[219]30
31   ///--------------------------------------------------------------
32
33   // Declare/Define CDomainAttribute
34   BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain)
35#  include "domain_attribute.conf"
[775]36#  include "domain_attribute_private.conf"
[219]37   END_DECLARE_ATTRIBUTE_MAP(CDomain)
38
39   ///--------------------------------------------------------------
40
41   class CDomain
42      : public CObjectTemplate<CDomain>
43      , public CDomainAttributes
44   {
[1158]45     /// typedef ///
46     typedef CObjectTemplate<CDomain>   SuperClass;
47     typedef CDomainAttributes SuperClassAttribute;
48     public:
[300]49         enum EEventId
50         {
[1025]51           EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 
52           EVENT_ID_AREA, EVENT_ID_MASK,
[1236]53           EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT
[300]54         } ;
[509]55
[676]56      public:
[219]57
58         typedef CDomainAttributes RelAttributes;
59         typedef CDomainGroup      RelGroup;
[631]60         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
[219]61
62         /// Constructeurs ///
63         CDomain(void);
64         explicit CDomain(const StdString & id);
65         CDomain(const CDomain & domain);       // Not implemented yet.
66         CDomain(const CDomain * const domain); // Not implemented yet.
67
[622]68         static CDomain* createDomain();
[878]69         
70         CMesh* mesh;
[924]71         void assignMesh(const StdString, const int);
[878]72       
[631]73         virtual void parse(xml::CXMLNode & node);
74
[1345]75         void setContextClient(CContextClient* contextClient);
76
[219]77         /// Vérifications ///
78         void checkAttributes(void);
[509]79         void checkAttributesOnClient();
[657]80         void checkAttributesOnClientAfterTransformation();
[676]81         void checkEligibilityForCompressedOutput(void);
82
[509]83         void sendCheckedAttributes();
84
[631]85         bool hasTransformation();
86         void solveInheritanceTransformation();
87         TransMapTypes getAllTransformations();
[687]88         void redistribute(int nbLocalDomain);
[823]89         void duplicateTransformation(CDomain*);
[836]90         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
[631]91
[1158]92      public:
93         const std::set<StdString> & getRelFiles(void) const;
[219]94         bool IsWritten(const StdString & filename) const;
[676]95         bool isWrittenCompressed(const StdString& filename) const;
[1144]96         
[1601]97         int getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom);
98         int getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom);
99         int getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom);
100         CArray<int,1>& getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom);
[676]101
[1330]102         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
[731]103
[219]104         bool isEmpty(void) const;
[594]105         bool isDistributed(void) const;
[1025]106         bool isCompressible(void) const; 
107 
[1158]108         std::vector<int> getNbGlob();
109         bool isEqual(CDomain* domain);
[1236]110
111         static bool dispatchEvent(CEventServer& event);
112
[676]113      public:
[219]114         /// Mutateur ///
115         void addRelFile(const StdString & filename);
[1236]116         void addRelFileCompressed(const StdString& filename);           
117         
[1129]118         void computeWrittenIndex();
[1601]119         void computeWrittenCompressedIndex(ep_lib::MPI_Comm);
[821]120
121         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
[809]122                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
[821]123
124         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
[809]125                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
[1158]126         
127         void fillInLonLat();
128         bool distributionAttributesHaveValue() const;
[611]129
[1215]130         size_t getGlobalWrittenSize() ;
[219]131         /// Destructeur ///
132         virtual ~CDomain(void);
133
134         /// Accesseurs statiques ///
135         static StdString GetName(void);
136         static StdString GetDefName(void);
[509]137
[1236]138         static ENodeType GetType(void);       
139
140      public:
141         CArray<double, 1> lonvalue, latvalue;
142         CArray<double, 2> bounds_lonvalue, bounds_latvalue;
143         CArray<double, 1> areavalue;
144
[1249]145         CArray<size_t,1> localIndexToWriteOnServer;         
[1236]146
[1311]147         CArray<bool, 1> domainMask; // mask_1d, mask_2d -> domainMask
148         CArray<bool, 1> localMask; // domainMask + indexing
[384]149         bool isCurvilinear ;
[449]150         bool hasBounds ;
[611]151         bool hasArea;
[665]152         bool hasLonLat;
[953]153         bool hasPole ;
[1578]154         bool hasLatInReadFile_ ; // specify if latitude is defined on read file, so it can be read later when grid distribution will be defined
155         bool hasBoundsLatInReadFile_ ; // specify if latitude boundarues are defined on read file, so it can be read later when grid distribution will be defined
156         bool hasLonInReadFile_ ; // specify if longitude is defined on read file, so it can be read later when grid distribution will be defined
157         bool hasBoundsLonInReadFile_ ; // specify if longitude boundaries are defined on read file, so it can be read later when grid distribution will be defined
[953]158
[1291]159         void computeLocalMask(void) ;
[631]160      private:
[667]161         void checkDomain(void);
162         void checkLocalIDomain(void);
163         void checkLocalJDomain(void);
164
165         void checkMask(void);
166         void checkDomainData(void);
167         void checkCompression(void);
168
169         void checkBounds(void);
170         void checkArea(void);
171         void checkLonLat();
172
[1025]173         void setTransformations(const TransMapTypes&);         
[1158]174         void computeNGlobDomain();
[1025]175         void sendAttributes();
[665]176         void sendIndex();
[1025]177         void sendDistributionAttributes();
178         void sendMask();
[665]179         void sendArea();
[1236]180         void sendLonLat();         
[1025]181         void sendDataIndex();
[1129]182         void convertLonLatValue();
[1158]183         void fillInRectilinearLonLat();
184         void fillInCurvilinearLonLat();
185         void fillInUnstructuredLonLat();
[1236]186         
187         static void recvDistributionAttributes(CEventServer& event);
188         static void recvIndex(CEventServer& event);
189         static void recvMask(CEventServer& event);         
190         static void recvLon(CEventServer& event);
191         static void recvLat(CEventServer& event);
192         static void recvArea(CEventServer& event);
193         static void recvDataIndex(CEventServer& event);
194         void recvDistributionAttributes(CBufferIn& buffer);                 
195         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);         
196         void recvMask(std::map<int, CBufferIn*>& rankBuffers);
197         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
198         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
199         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
200         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
201
202         void completeLonLatClient(void); 
203         void computeConnectedClients();   
204
[1025]205       private:         
[1345]206
207/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
[1353]208         std::list<CContextClient*> clients;
209         std::set<CContextClient*> clientsSet;
[1345]210
[1129]211         bool isChecked, computedWrittenIndex_;
[676]212         std::set<StdString> relFiles, relFilesCompressed;
[551]213         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
[657]214         bool isClientAfterTransformationChecked;
[1236]215         std::map<int, CArray<int,1> > indGlob_;
[1337]216         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
[1025]217
[1337]218/** Global index of each client sent to server: map<serverSize, map<serverRank, indexes>> */
[1542]219         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_;
[1236]220         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
[676]221         std::vector<int> indexesToWrite;
[1236]222         std::vector<int> recvClientRanks_;
[1249]223         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
224         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;     
[1337]225         std::map<int, std::map<int,size_t> > connectedDataSize_;
226         std::map<int, std::vector<int> > connectedServerRank_;
[1236]227
[676]228         //! True if and only if the data defined on the domain can be outputted in a compressed way
229         bool isCompressible_;
[715]230         bool isRedistributed_;
[1025]231         TransMapTypes transformationMap_;         
[657]232         bool isUnstructed_;
[1542]233         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
[953]234       
[836]235       private:
236         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
[1601]237         static bool initializeTransformationMap();
238         static std::map<StdString, ETranformationType> *transformationMapList_ptr;
239         #pragma omp threadprivate(transformationMapList_ptr)
[836]240         static bool _dummyTransformationMapList;
[1601]241         #pragma omp threadprivate(_dummyTransformationMapList)
[836]242
[540]243         DECLARE_REF_FUNC(Domain,domain)
244
[219]245   }; // class CDomain
246
247   ///--------------------------------------------------------------
248
249   // Declare/Define CDomainGroup and CDomainDefinition
250   DECLARE_GROUP(CDomain);
251
252   ///--------------------------------------------------------------
253
[335]254} // namespace xios
[219]255
[878]256#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.