source: XIOS/dev/branch_openmp/src/node/domain.hpp @ 1463

Last change on this file since 1463 was 1460, checked in by yushan, 6 years ago

branch_openmp merged with XIOS_DEV_CMIP6@1459

  • 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.3 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"
[1460]18#include "server_distribution_description.hpp"
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   {
[1460]45     /// typedef ///
46     typedef CObjectTemplate<CDomain>   SuperClass;
47     typedef CDomainAttributes SuperClassAttribute;
48     public:
[300]49         enum EEventId
50         {
[1460]51           EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 
52           EVENT_ID_AREA, EVENT_ID_MASK,
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
[1460]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
[676]92      public:
[219]93         const std::set<StdString> & getRelFiles(void) const;
94         bool IsWritten(const StdString & filename) const;
[676]95         bool isWrittenCompressed(const StdString& filename) const;
[1460]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);
[676]101
[1460]102         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
[676]103
[219]104         bool isEmpty(void) const;
[594]105         bool isDistributed(void) const;
[1460]106         bool isCompressible(void) const; 
107 
108         std::vector<int> getNbGlob();
109         bool isEqual(CDomain* domain);
[509]110
[1460]111         static bool dispatchEvent(CEventServer& event);
[300]112
[676]113      public:
[219]114         /// Mutateur ///
115         void addRelFile(const StdString & filename);
[1460]116         void addRelFileCompressed(const StdString& filename);           
[1106]117         
[1460]118         void computeWrittenIndex();
119         void computeWrittenCompressedIndex(ep_lib::MPI_Comm);
120
[821]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);
[1064]126         
127         void fillInLonLat();
[1460]128         bool distributionAttributesHaveValue() const;
[611]129
[1460]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
[1460]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<size_t,1> localIndexToWriteOnServer;         
146
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 ;
154
[1460]155         void computeLocalMask(void) ;
[631]156      private:
[667]157         void checkDomain(void);
158         void checkLocalIDomain(void);
159         void checkLocalJDomain(void);
160
161         void checkMask(void);
162         void checkDomainData(void);
163         void checkCompression(void);
164
165         void checkBounds(void);
166         void checkArea(void);
167         void checkLonLat();
[1460]168         void checkZoom(void);
169
170         void setTransformations(const TransMapTypes&);         
[657]171         void computeNGlobDomain();
[1460]172         void sendAttributes();
[665]173         void sendIndex();
[1460]174         void sendDistributionAttributes();
175         void sendMask();
[665]176         void sendArea();
[1460]177         void sendLonLat();         
178         void sendDataIndex();
179         void convertLonLatValue();
[1064]180         void fillInRectilinearLonLat();
181         void fillInCurvilinearLonLat();
182         void fillInUnstructuredLonLat();
[1460]183         
184         static void recvDistributionAttributes(CEventServer& event);
185         static void recvIndex(CEventServer& event);
186         static void recvIndexZoom(CEventServer& event);
187         static void recvMask(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 recvMask(std::map<int, CBufferIn*>& rankBuffers);
195         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
196         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
197         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
198         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
199
200         void completeLonLatClient(void); 
201         void computeConnectedClients();   
202
[676]203       private:
[1460]204
205/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
206         std::list<CContextClient*> clients;
207         std::set<CContextClient*> clientsSet;
208
209         bool doZoomByIndex_;
210         bool isChecked, computedWrittenIndex_;
[676]211         std::set<StdString> relFiles, relFilesCompressed;
[551]212         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
[657]213         bool isClientAfterTransformationChecked;
[1460]214         std::map<int, CArray<int,1> > indGlob_;
215         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
216
217/** Global index of each client sent to server: map<serverSize, map<serverRank, indexes>> */
218         std::map<int, boost::unordered_map<int, vector<size_t> > > indSrv_;
219         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
[676]220         std::vector<int> indexesToWrite;
[1460]221         std::vector<int> recvClientRanks_;
222         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
223         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;     
224         std::map<int, std::map<int,size_t> > connectedDataSize_;
225         std::map<int, std::vector<int> > connectedServerRank_;
226
[676]227         //! True if and only if the data defined on the domain can be outputted in a compressed way
228         bool isCompressible_;
[715]229         bool isRedistributed_;
[1078]230         TransMapTypes transformationMap_;         
[657]231         bool isUnstructed_;
[1460]232         boost::unordered_map<size_t,size_t> globalLocalIndexMap_;
[953]233       
[836]234       private:
235         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
[1134]236         static bool initializeTransformationMap();
237         static std::map<StdString, ETranformationType> *transformationMapList_ptr;
[1331]238         #pragma omp threadprivate(transformationMapList_ptr)
[1328]239         static bool _dummyTransformationMapList;
[1331]240         #pragma omp threadprivate(_dummyTransformationMapList)
[836]241
[540]242         DECLARE_REF_FUNC(Domain,domain)
243
[219]244   }; // class CDomain
245
246   ///--------------------------------------------------------------
247
248   // Declare/Define CDomainGroup and CDomainDefinition
249   DECLARE_GROUP(CDomain);
250
251   ///--------------------------------------------------------------
252
[335]253} // namespace xios
[219]254
[878]255#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.