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

Last change on this file since 1678 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
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, 
[1646]52           EVENT_ID_AREA,
[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
[1646]145         CArray<int,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();
[665]178         void sendArea();
[1236]179         void sendLonLat();         
[1025]180         void sendDataIndex();
[1129]181         void convertLonLatValue();
[1158]182         void fillInRectilinearLonLat();
183         void fillInCurvilinearLonLat();
184         void fillInUnstructuredLonLat();
[1236]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
[1025]202       private:         
[1345]203
204/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
[1353]205         std::list<CContextClient*> clients;
206         std::set<CContextClient*> clientsSet;
[1345]207
[1129]208         bool isChecked, computedWrittenIndex_;
[676]209         std::set<StdString> relFiles, relFilesCompressed;
[551]210         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
[657]211         bool isClientAfterTransformationChecked;
[1236]212         std::map<int, CArray<int,1> > indGlob_;
[1337]213         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
[1025]214
[1337]215/** Global index of each client sent to server: map<serverSize, map<serverRank, indexes>> */
[1542]216         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_;
[1236]217         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
[676]218         std::vector<int> indexesToWrite;
[1236]219         std::vector<int> recvClientRanks_;
[1249]220         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
221         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;     
[1337]222         std::map<int, std::map<int,size_t> > connectedDataSize_;
223         std::map<int, std::vector<int> > connectedServerRank_;
[1236]224
[676]225         //! True if and only if the data defined on the domain can be outputted in a compressed way
226         bool isCompressible_;
[715]227         bool isRedistributed_;
[1025]228         TransMapTypes transformationMap_;         
[657]229         bool isUnstructed_;
[1542]230         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
[953]231       
[836]232       private:
233         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
[1601]234         static bool initializeTransformationMap();
235         static std::map<StdString, ETranformationType> *transformationMapList_ptr;
236         #pragma omp threadprivate(transformationMapList_ptr)
[836]237
[1646]238
[540]239         DECLARE_REF_FUNC(Domain,domain)
240
[219]241   }; // class CDomain
242
243   ///--------------------------------------------------------------
244
245   // Declare/Define CDomainGroup and CDomainDefinition
246   DECLARE_GROUP(CDomain);
247
248   ///--------------------------------------------------------------
249
[335]250} // namespace xios
[219]251
[878]252#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.