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

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

dev on ADA. add flag switch _usingEP/_usingMPI

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