source: XIOS/dev/dev_trunk_omp/src/node/domain.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: 9.5 KB
Line 
1#ifndef __XIOS_CDomain__
2#define __XIOS_CDomain__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "group_factory.hpp"
7
8#include "declare_group.hpp"
9#include "declare_ref_func.hpp"
10#include "event_client.hpp"
11#include "event_server.hpp"
12#include "buffer_in.hpp"
13#include "array_new.hpp"
14#include "attribute_array.hpp"
15#include "attribute_enum.hpp"
16#include "transformation.hpp"
17#include "transformation_enum.hpp"
18#include "server_distribution_description.hpp"
19#include "mpi_std.hpp"
20#include "mesh.hpp"
21
22namespace xios {
23
24   /// ////////////////////// Déclarations ////////////////////// ///
25
26   class CDomainGroup;
27   class CDomainAttributes;
28   class CDomain;
29   class CFile;
30
31   ///--------------------------------------------------------------
32
33   // Declare/Define CDomainAttribute
34   BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain)
35#  include "domain_attribute.conf"
36#  include "domain_attribute_private.conf"
37   END_DECLARE_ATTRIBUTE_MAP(CDomain)
38
39   ///--------------------------------------------------------------
40
41   class CDomain
42      : public CObjectTemplate<CDomain>
43      , public CDomainAttributes
44   {
45     /// typedef ///
46     typedef CObjectTemplate<CDomain>   SuperClass;
47     typedef CDomainAttributes SuperClassAttribute;
48     public:
49         enum EEventId
50         {
51           EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 
52           EVENT_ID_AREA,
53           EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT
54         } ;
55
56      public:
57
58         typedef CDomainAttributes RelAttributes;
59         typedef CDomainGroup      RelGroup;
60         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
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
68         static CDomain* createDomain();
69         
70         CMesh* mesh;
71         void assignMesh(const StdString, const int);
72       
73         virtual void parse(xml::CXMLNode & node);
74
75         void setContextClient(CContextClient* contextClient);
76
77         /// Vérifications ///
78         void checkAttributes(void);
79         void checkAttributesOnClient();
80         void checkAttributesOnClientAfterTransformation();
81         void checkEligibilityForCompressedOutput(void);
82
83         void sendCheckedAttributes();
84
85         bool hasTransformation();
86         void solveInheritanceTransformation();
87         TransMapTypes getAllTransformations();
88         void redistribute(int nbLocalDomain);
89         void duplicateTransformation(CDomain*);
90         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
91
92      public:
93         const std::set<StdString> & getRelFiles(void) const;
94         bool IsWritten(const StdString & filename) const;
95         bool isWrittenCompressed(const StdString& filename) const;
96         
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);
101
102         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
103
104         bool isEmpty(void) const;
105         bool isDistributed(void) const;
106         bool isCompressible(void) const; 
107 
108         std::vector<int> getNbGlob();
109         bool isEqual(CDomain* domain);
110
111         static bool dispatchEvent(CEventServer& event);
112
113      public:
114         /// Mutateur ///
115         void addRelFile(const StdString & filename);
116         void addRelFileCompressed(const StdString& filename);           
117         
118         void computeWrittenIndex();
119         void computeWrittenCompressedIndex(ep_lib::MPI_Comm);
120
121         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
122                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
123
124         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
125                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
126         
127         void fillInLonLat();
128         bool distributionAttributesHaveValue() const;
129
130         size_t getGlobalWrittenSize() ;
131         /// Destructeur ///
132         virtual ~CDomain(void);
133
134         /// Accesseurs statiques ///
135         static StdString GetName(void);
136         static StdString GetDefName(void);
137
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
145         CArray<int,1> localIndexToWriteOnServer;
146
147         CArray<bool, 1> domainMask; // mask_1d, mask_2d -> domainMask
148         CArray<bool, 1> localMask; // domainMask + indexing
149         bool isCurvilinear ;
150         bool hasBounds ;
151         bool hasArea;
152         bool hasLonLat;
153         bool hasPole ;
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
158
159         void computeLocalMask(void) ;
160      private:
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
173         void setTransformations(const TransMapTypes&);         
174         void computeNGlobDomain();
175         void sendAttributes();
176         void sendIndex();
177         void sendDistributionAttributes();
178         void sendArea();
179         void sendLonLat();         
180         void sendDataIndex();
181         void convertLonLatValue();
182         void fillInRectilinearLonLat();
183         void fillInCurvilinearLonLat();
184         void fillInUnstructuredLonLat();
185         
186         static void recvDistributionAttributes(CEventServer& event);
187         static void recvIndex(CEventServer& event);
188         static void recvLon(CEventServer& event);
189         static void recvLat(CEventServer& event);
190         static void recvArea(CEventServer& event);
191         static void recvDataIndex(CEventServer& event);
192         void recvDistributionAttributes(CBufferIn& buffer);                 
193         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);         
194         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
195         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
196         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
197         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
198
199         void completeLonLatClient(void); 
200         void computeConnectedClients();   
201
202       private:         
203
204/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
205         std::list<CContextClient*> clients;
206         std::set<CContextClient*> clientsSet;
207
208         bool isChecked, computedWrittenIndex_;
209         std::set<StdString> relFiles, relFilesCompressed;
210         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
211         bool isClientAfterTransformationChecked;
212         std::map<int, CArray<int,1> > indGlob_;
213         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
214
215/** Global index of each client sent to server: map<serverSize, map<serverRank, indexes>> */
216         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_;
217         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
218         std::vector<int> indexesToWrite;
219         std::vector<int> recvClientRanks_;
220         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
221         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;     
222         std::map<int, std::map<int,size_t> > connectedDataSize_;
223         std::map<int, std::vector<int> > connectedServerRank_;
224
225         //! True if and only if the data defined on the domain can be outputted in a compressed way
226         bool isCompressible_;
227         bool isRedistributed_;
228         TransMapTypes transformationMap_;         
229         bool isUnstructed_;
230         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
231       
232       private:
233         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
234         static bool initializeTransformationMap();
235         static std::map<StdString, ETranformationType> *transformationMapList_ptr;
236         #pragma omp threadprivate(transformationMapList_ptr)
237
238
239         DECLARE_REF_FUNC(Domain,domain)
240
241   }; // class CDomain
242
243   ///--------------------------------------------------------------
244
245   // Declare/Define CDomainGroup and CDomainDefinition
246   DECLARE_GROUP(CDomain);
247
248   ///--------------------------------------------------------------
249
250} // namespace xios
251
252#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.