source: XIOS/trunk/src/node/grid.hpp @ 520

Last change on this file since 520 was 509, checked in by mhnguyen, 10 years ago

Implementing buffer size auto-detection for mode client -server

+) Process xml tree in client side then send all the information to server
+) Only information enabled fields in enabled files are sent to server
+) Some important change in structure of code which must be refactored

Test
+) On Curie
+) Only mode client-server
+) Passed for all tests

  • 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: 6.3 KB
Line 
1#ifndef __XMLIO_CGrid__
2#define __XMLIO_CGrid__
3
4/// xios headers ///
5#include "xmlioserver_spl.hpp"
6#include "group_factory.hpp"
7
8#include "declare_group.hpp"
9#include "domain.hpp"
10#include "axis.hpp"
11#include "array_new.hpp"
12#include "attribute_array.hpp"
13
14namespace xios {
15
16   /// ////////////////////// Déclarations ////////////////////// ///
17
18   class CGridGroup;
19   class CGridAttributes;
20   class CGrid;
21
22   ///--------------------------------------------------------------
23
24   // Declare/Define CGridAttribute
25   BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid)
26#  include "grid_attribute.conf"
27   END_DECLARE_ATTRIBUTE_MAP(CGrid)
28
29   ///--------------------------------------------------------------
30
31   class CGrid
32      : public CObjectTemplate<CGrid>
33      , public CGridAttributes
34   {
35         /// typedef ///
36         typedef CObjectTemplate<CGrid>   SuperClass;
37         typedef CGridAttributes SuperClassAttribute;
38
39      public :
40
41         typedef CGridAttributes RelAttributes;
42         typedef CGridGroup      RelGroup;
43
44         enum EEventId
45         {
46           EVENT_ID_INDEX
47         } ;
48
49         /// Constructeurs ///
50         CGrid(void);
51         explicit CGrid(const StdString & id);
52         CGrid(const CGrid & grid);       // Not implemented yet.
53         CGrid(const CGrid * const grid); // Not implemented yet.
54
55         /// Traitements ///
56//         void solveReference(void);
57
58         void solveDomainAxisRef(bool areAttributesChecked);
59
60         void checkMaskIndex(bool doCalculateIndex);
61
62 //        virtual void toBinary  (StdOStream & os) const;
63//         virtual void fromBinary(StdIStream & is);
64
65         /// Tests ///
66         bool hasAxis(void) const;
67
68      public :
69
70         /// Accesseurs ///
71         const std::deque< CArray<int, 1>* > & getStoreIndex(void) const;
72         const std::deque< CArray<int, 1>* > & getOutIIndex(void)  const;
73         const std::deque< CArray<int, 1>* > & getOutJIndex(void)  const;
74         const std::deque< CArray<int, 1>* > & getOutLIndex(void)  const;
75
76         const CAxis*   getRelAxis  (void) const;
77         const CDomain* getRelDomain(void) const;
78
79         StdSize getDimension(void) const;
80
81//         StdSize getLocalSize(void) const;
82//         StdSize getGlobalSize(void) const;
83         StdSize  getDataSize(void) const;
84//         std::vector<StdSize> getLocalShape(void) const;
85//         std::vector<StdSize> getGlobalShape(void) const;
86
87         /// Entrées-sorties de champs ///
88         template <int n>
89            void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const;
90
91         void inputFieldServer(const std::deque< CArray<double, 1>* > storedClient,
92                               CArray<double, 1>&  storedServer) const;
93
94         void outputField(int rank, const CArray<double,1>& stored,  CArray<double,3>& field)  ;
95         void outputField(int rank, const CArray<double,1>& stored,  CArray<double,2>& field)  ;
96         void outputField(int rank, const CArray<double,1>& stored,  CArray<double,1>& field)  ;
97
98         /// Destructeur ///
99         virtual ~CGrid(void);
100
101      public :
102
103         /// Accesseurs statiques ///
104         static StdString GetName(void);
105         static StdString GetDefName(void);
106
107         static ENodeType GetType(void);
108
109         /// Instanciateurs Statiques ///
110         static CGrid* createGrid(CDomain* domain);
111         static CGrid* createGrid(CDomain* domain, CAxis* axis);
112
113      public :
114
115         /// Entrées-sorties de champs (interne) ///
116         void storeField_arr(const double * const data, CArray<double,1>& stored) const;
117
118         /// Traitements protégés ///
119         void computeIndexServer(void);
120         void computeIndex(void);
121//         void solveDomainRef(void);  //TODO temporarily comment
122//         void solveAxisRef(void);   // TODO: temporarily comment
123
124         void solveDomainRef(bool checkAtt);
125         void solveAxisRef(bool checkAtt);
126
127         static bool dispatchEvent(CEventServer& event) ;
128         void outputFieldToServer(CArray<double,1>& fieldIn, int rank, CArray<double,1>& fieldOut) ;
129         static void recvIndex(CEventServer& event) ;
130         void recvIndex(int rank, CBufferIn& buffer) ;
131         void sendIndex(void) ;
132
133         void computeDomConServer();
134         std::map<int, int> getDomConServerSide();
135         std::map<int, StdSize> getConnectedServerDataSize();
136      public:
137
138         /// Propriétés privées ///
139         bool withAxis ;
140         bool isChecked;
141         bool isDomainAxisChecked;
142
143         CAxis*   axis ;
144         CDomain* domain ;
145
146         std::deque< CArray<int, 1>* > storeIndex ;
147         std::deque< CArray<int, 1>* > out_i_index ;
148         std::deque< CArray<int, 1>* > out_j_index ;
149         std::deque< CArray<int, 1>* > out_l_index ;
150
151        CArray<int, 1>  storeIndex_client ;
152        CArray<int, 1>  out_i_client ;
153        CArray<int, 1>  out_j_client ;
154        CArray<int, 1>  out_l_client ;
155
156         map<int, CArray<int, 1>* >  storeIndex_toSrv ;
157         map<int,int> nbSenders ;
158//         std::deque<ARRAY(int, 1)> out_i_toSrv ;
159//         std::deque<ARRAY(int, 1)> out_j_toSrv ;
160//         std::deque<ARRAY(int, 1)> out_l_toSrv ;
161
162         map<int, CArray<int, 1>* > out_i_fromClient ;
163         map<int, CArray<int, 1>* > out_j_fromClient ;
164         map<int, CArray<int, 1>* > out_l_fromClient ;
165         void checkMask(void) ;
166
167         std::map<int, int> domConnectedServerSide_;
168         bool isDomConServerComputed_;
169   }; // class CGrid
170
171   ///--------------------------------------------------------------
172
173   template <int n>
174      void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const
175   {
176      if (this->getDataSize() != field.numElements())
177         ERROR("void CGrid::inputField(const  CArray<double,n>& field, CArray<double,1>& stored) const",
178                << "[ Awaiting size of the data = " << this->getDataSize()       << ", "
179                << "Received data size = "      << field.numElements() << " ] "
180                << "The array of data has not the good size !")
181      this->storeField_arr(field.dataFirst(), stored) ;
182   }
183
184   ///--------------------------------------------------------------
185
186   // Declare/Define CGridGroup and CGridDefinition
187   DECLARE_GROUP(CGrid);
188
189   ///--------------------------------------------------------------
190
191} // namespace xios
192
193#endif // __XMLIO_CGrid__
Note: See TracBrowser for help on using the repository browser.