source: vendor/nemo/current/NEMOGCM/EXTERNAL/XIOS/src/node/grid.cpp @ 44

Last change on this file since 44 was 44, checked in by cholod, 12 years ago

Load NEMO_TMP into vendor/nemo/current.

File size: 24.0 KB
Line 
1
2#include "grid.hpp"
3
4#include "attribute_template.hpp"
5#include "object_template.hpp"
6#include "group_template.hpp"
7#include "message.hpp"
8#include <iostream>
9#include "xmlioserver_spl.hpp"
10#include "type.hpp"
11#include "context.hpp"
12#include "context_client.hpp"
13
14namespace xios {
15
16   /// ////////////////////// Définitions ////////////////////// ///
17
18   CGrid::CGrid(void)
19      : CObjectTemplate<CGrid>(), CGridAttributes()
20      , withAxis(false), isChecked(false), axis(), domain()
21      , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1)
22   { /* Ne rien faire de plus */ }
23
24   CGrid::CGrid(const StdString & id)
25      : CObjectTemplate<CGrid>(id), CGridAttributes()
26      , withAxis(false), isChecked(false), axis(), domain()
27      , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1)
28   { /* Ne rien faire de plus */ }
29
30   CGrid::~CGrid(void)
31   { 
32 //     this->axis.reset() ;
33//      this->domain.reset() ;
34     
35      for (StdSize i = 0; i < this->storeIndex.size(); i++)
36      {
37         this->storeIndex[i].reset();
38         this->out_i_index[i].reset();
39         this->out_j_index[i].reset();
40         this->out_l_index[i].reset();
41      }
42   }
43
44   ///---------------------------------------------------------------
45
46   StdString CGrid::GetName(void)    { return (StdString("grid")); }
47   StdString CGrid::GetDefName(void) { return (CGrid::GetName()); }
48   ENodeType CGrid::GetType(void)    { return (eGrid); }
49
50   //----------------------------------------------------------------
51
52   const std::deque<ARRAY(int, 1)> & CGrid::getStoreIndex(void) const
53   { 
54      return (this->storeIndex );
55   }
56
57   //---------------------------------------------------------------
58
59   const std::deque<ARRAY(int, 1)> & CGrid::getOutIIndex(void)  const
60   { 
61      return (this->out_i_index ); 
62   }
63
64   //---------------------------------------------------------------
65
66   const std::deque<ARRAY(int, 1)> & CGrid::getOutJIndex(void)  const
67   { 
68      return (this->out_j_index ); 
69   }
70
71   //---------------------------------------------------------------
72
73   const std::deque<ARRAY(int, 1)> & CGrid::getOutLIndex(void)  const
74   { 
75      return (this->out_l_index ); 
76   }
77
78   //---------------------------------------------------------------
79
80   const CAxis*   CGrid::getRelAxis  (void) const
81   { 
82      return (this->axis ); 
83   }
84
85   //---------------------------------------------------------------
86
87   const CDomain* CGrid::getRelDomain(void) const
88   { 
89      return (this->domain ); 
90   }
91
92   //---------------------------------------------------------------
93
94   bool CGrid::hasAxis(void) const 
95   { 
96      return (this->withAxis); 
97   }
98
99   //---------------------------------------------------------------
100
101   StdSize CGrid::getDimension(void) const
102   {
103      return ((this->withAxis)?3:2);
104   }
105
106   //---------------------------------------------------------------
107
108/*
109   std::vector<StdSize> CGrid::getLocalShape(void) const
110   {
111      std::vector<StdSize> retvalue;
112      retvalue.push_back(domain->zoom_ni_loc.getValue());
113      retvalue.push_back(domain->zoom_nj_loc.getValue());
114      if (this->withAxis)
115         retvalue.push_back(this->axis->zoom_size.getValue());
116      return (retvalue);
117   }
118*/
119   //---------------------------------------------------------------
120   
121/*
122   StdSize CGrid::getLocalSize(void) const
123   {
124      StdSize retvalue = 1;
125      std::vector<StdSize> shape_ = this->getLocalShape();
126      for (StdSize s = 0; s < shape_.size(); s++)
127         retvalue *= shape_[s];
128      return (retvalue);
129   }
130*/
131   //---------------------------------------------------------------
132/*
133   std::vector<StdSize> CGrid::getGlobalShape(void) const
134   {
135      std::vector<StdSize> retvalue;
136      retvalue.push_back(domain->ni.getValue());
137      retvalue.push_back(domain->nj.getValue());
138      if (this->withAxis)
139         retvalue.push_back(this->axis->size.getValue());
140      return (retvalue);
141   }
142*/
143   //---------------------------------------------------------------
144
145/*   
146   StdSize CGrid::getGlobalSize(void) const
147   {
148      StdSize retvalue = 1;
149      std::vector<StdSize> shape_ = this->getGlobalShape();
150      for (StdSize s = 0; s < shape_.size(); s++)
151         retvalue *= shape_[s];
152      return (retvalue);
153   }
154*/
155   StdSize CGrid::getDataSize(void) const
156   {
157      StdSize retvalue ;
158      retvalue=domain->data_ni.getValue() ;
159      if (domain->data_dim.getValue()==2) retvalue*=domain->data_nj.getValue() ;
160      if (this->withAxis) retvalue*=this->axis->size.getValue() ;
161
162      return (retvalue);
163   }
164
165   //---------------------------------------------------------------
166
167   void CGrid::solveReference(void)
168   {
169      if (this->isChecked) return;
170      CContext* context = CContext::getCurrent() ;
171      CContextClient* client=context->client ;
172     
173      this->solveDomainRef() ;
174      this->solveAxisRef() ;
175      if (context->hasClient)
176      {
177         
178         this->computeIndex() ;
179         ARRAY_CREATE(storeIndex_ , int, 1, [0]);
180         ARRAY_CREATE(out_l_index_, int, 1, [0]);
181         ARRAY_CREATE(out_i_index_, int, 1, [0]);
182         ARRAY_CREATE(out_j_index_, int, 1, [0]);
183                 
184         this->storeIndex .push_front(storeIndex_);
185         this->out_i_index.push_front(out_i_index_);
186         this->out_j_index.push_front(out_j_index_);
187         this->out_l_index.push_front(out_l_index_);
188      }
189//      this->computeIndexServer();
190      this->isChecked = true;
191   }
192
193   //---------------------------------------------------------------
194
195   void CGrid::solveDomainRef(void)
196   {
197      if (!domain_ref.isEmpty())
198      {
199         if (CDomain::has(domain_ref.getValue()))
200         {
201            this->domain = CDomain::get(domain_ref.getValue()) ;
202            domain->checkAttributes() ;
203         }
204         else ERROR("CGrid::solveDomainRef(void)",
205                     << "Référence au domaine incorrecte") ;
206      }
207      else ERROR("CGrid::solveDomainRef(void)",
208                  << "Domaine non défini") ;
209   }
210
211   //---------------------------------------------------------------
212
213   void CGrid::solveAxisRef(void)
214   {
215      if (!axis_ref.isEmpty())
216      {
217         this->withAxis = true ;
218         if (CAxis::get(axis_ref.getValue()))
219         {
220            this->axis = CAxis::get(axis_ref.getValue()) ;
221            axis->checkAttributes() ;
222         }
223         else ERROR("CGrid::solveAxisRef(void)",
224                    << "Référence a l'axe incorrecte") ;
225      }
226      else withAxis = false ;
227   }
228
229   //---------------------------------------------------------------
230
231   void CGrid::computeIndex(void)
232   {   
233   
234      const int ni   = domain->ni.getValue() ,
235                nj   = domain->nj.getValue() ,
236                size = (this->hasAxis()) ? axis->size.getValue() : 1 ,
237                lbegin = (this->hasAxis()) ? axis->zoom_begin.getValue()-1 : 0 ,
238                lend = (this->hasAxis()) ? axis->zoom_end.getValue()-1 : 0 ;
239
240
241      const int data_dim     = domain->data_dim.getValue() ,
242                data_n_index = domain->data_n_index.getValue() ,
243                data_ibegin  = domain->data_ibegin.getValue() ,
244                data_jbegin  = (data_dim == 2)
245                             ? domain->data_jbegin.getValue() : -1;
246
247      ARRAY(int, 1) data_i_index = domain->data_i_index.getValue() ,
248                    data_j_index = domain->data_j_index.getValue() ;
249
250
251      ARRAY(bool, 2) mask = domain->mask.getValue() ;
252      ARRAY(int, 2) local_mask =  this->domain->getLocalMask();
253
254      int indexCount = 0;
255
256      for(int l = 0; l < size ; l++)
257      {
258         for(int n = 0, i = 0, j = 0; n < data_n_index; n++)
259         {
260            int temp_i = (*data_i_index)[n] + data_ibegin,
261                temp_j = (data_dim == 1) ? -1
262                       : (*data_j_index)[n] + data_jbegin;
263            i = (data_dim == 1) ? (temp_i - 1) % ni
264                                : (temp_i - 1) ;
265            j = (data_dim == 1) ? (temp_i - 1) / ni
266                                : (temp_j - 1) ;
267
268            if ((l >=lbegin && l<= lend) &&
269                (i >= 0 && i < ni) &&
270                (j >= 0 && j < nj) && (*mask)[i][j])
271               indexCount++ ;
272         }
273      }
274     
275      ARRAY_ASSIGN(this->storeIndex[0] , int, 1, [indexCount]);
276      ARRAY_ASSIGN(this->out_l_index[0], int, 1, [indexCount]);
277      ARRAY_ASSIGN(this->out_i_index[0], int, 1, [indexCount]);
278      ARRAY_ASSIGN(this->out_j_index[0], int, 1, [indexCount]);
279     
280      ARRAY_ASSIGN(storeIndex_client,int,1,[indexCount]);
281      ARRAY_ASSIGN(out_i_client,int,1,[indexCount]);
282      ARRAY_ASSIGN(out_j_client,int,1,[indexCount]);
283      ARRAY_ASSIGN(out_l_client,int,1,[indexCount]);
284     
285     
286      for(int count = 0, indexCount = 0,  l = 0; l < size; l++)
287      {
288         for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++)
289         {
290            int temp_i = (*data_i_index)[n] + data_ibegin,
291                temp_j = (data_dim == 1) ? -1
292                       : (*data_j_index)[n] + data_jbegin;
293            i = (data_dim == 1) ? (temp_i - 1) % ni
294                                : (temp_i - 1) ;
295            j = (data_dim == 1) ? (temp_i - 1) / ni
296                                : (temp_j - 1) ;
297
298            if ((l >= lbegin && l <= lend) &&
299                (i >= 0 && i < ni) &&
300                (j >= 0 && j < nj) && (*mask)[i][j])
301            {
302               (*this->storeIndex[0]) [indexCount] = count ;
303               (*this->out_l_index[0])[indexCount] = l ;
304               (*this->out_i_index[0])[indexCount] = i ;
305               (*this->out_j_index[0])[indexCount] = j ;
306               
307               (*storeIndex_client)[indexCount] = count ;
308               (*out_i_client)[indexCount]=i+domain->ibegin_client-1 ;
309               (*out_j_client)[indexCount]=j+domain->jbegin_client-1 ;
310               (*out_l_client)[indexCount]=l-lbegin ;
311               indexCount++ ;
312            }
313         }
314      }
315      sendIndex() ;
316
317
318   }
319
320   //----------------------------------------------------------------
321
322   CGrid* CGrid::createGrid(CDomain* domain)
323   {
324      StdString new_id = StdString("__") + domain->getId() + StdString("__") ;
325      CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ;
326      grid->domain_ref.setValue(domain->getId());
327      return (grid);
328   }
329
330   CGrid* CGrid::createGrid(CDomain* domain, CAxis* axis)
331   {
332      StdString new_id = StdString("__") + domain->getId() +
333                         StdString("_") + axis->getId() + StdString("__") ;
334      CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ;
335      grid->domain_ref.setValue(domain->getId());
336      grid->axis_ref.setValue(axis->getId());
337      return (grid);
338   }
339
340   //----------------------------------------------------------------
341
342   void CGrid::outputField(int rank, const ARRAY(double, 1) stored,  ARRAY(double, 3) field) 
343   {
344      ARRAY(int,1) out_i=out_i_fromClient[rank] ;
345      ARRAY(int,1) out_j=out_j_fromClient[rank] ;
346      ARRAY(int,1) out_l=out_l_fromClient[rank] ;
347     
348      for(StdSize n = 0; n < stored->num_elements(); n++)
349         (*field)[(*out_i)[n]][(*out_j)[n]][(*out_l)[n]] = (*stored)[n] ;
350   }
351
352   void CGrid::outputField(int rank, const ARRAY(double, 1) stored,  ARRAY(double, 2) field) 
353   {
354      ARRAY(int,1) out_i=out_i_fromClient[rank] ;
355      ARRAY(int,1) out_j=out_j_fromClient[rank] ;
356
357       for(StdSize n = 0; n < stored->num_elements(); n++)
358         (*field)[(*out_i)[n]][(*out_j)[n]] = (*stored)[n] ;
359   }
360
361   //---------------------------------------------------------------
362
363   void CGrid::outputField(int rank,const ARRAY(double, 1) stored,  ARRAY(double, 1) field)
364   {
365      ARRAY(int,1) out_i = out_i_fromClient[rank] ;
366      for(StdSize n = 0; n < stored->num_elements(); n++)
367         (*field)[(*out_i)[n]] = (*stored)[n] ;
368   }
369
370   //----------------------------------------------------------------
371 
372
373   void CGrid::storeField_arr
374      (const double * const data, ARRAY(double, 1) stored) const
375   {
376      const StdSize size = (this->storeIndex_client)->num_elements() ;
377
378      stored->resize(boost::extents[size]) ;
379      for(StdSize i = 0; i < size; i++)
380         (*stored)[i] = data[(*storeIndex_client)[i]] ;
381   }
382   
383   //---------------------------------------------------------------
384   
385   void CGrid::toBinary  (StdOStream & os) const
386   {
387      SuperClass::toBinary(os);
388     
389      os.write (reinterpret_cast<const char*>(&this->isChecked), sizeof(bool)); 
390     
391      if (this->isChecked)
392      {
393         this->storeIndex [0]->toBinary(os);
394         this->out_i_index[0]->toBinary(os);
395         this->out_j_index[0]->toBinary(os);
396         this->out_l_index[0]->toBinary(os);
397      }
398   }
399
400   //---------------------------------------------------------------
401   
402   void CGrid::fromBinary(StdIStream & is)
403   {
404      bool hasIndex = false;
405      SuperClass::fromBinary(is);           
406      is.read (reinterpret_cast<char*>(&hasIndex), sizeof(bool)); 
407     
408      if (hasIndex)
409      {
410         ARRAY_CREATE(storeIndex_ , int, 1, [0]);
411         ARRAY_CREATE(out_l_index_, int, 1, [0]);
412         ARRAY_CREATE(out_i_index_, int, 1, [0]);
413         ARRAY_CREATE(out_j_index_, int, 1, [0]);
414         
415         storeIndex_ ->fromBinary(is);
416         out_i_index_->fromBinary(is);
417         out_j_index_->fromBinary(is);
418         out_l_index_->fromBinary(is);
419         
420         this->storeIndex .push_back(storeIndex_);
421         this->out_i_index.push_back(out_i_index_);
422         this->out_j_index.push_back(out_j_index_);
423         this->out_l_index.push_back(out_l_index_);
424      }
425   }
426   
427   //---------------------------------------------------------------
428  void CGrid::sendIndex(void)
429  {
430    CContext* context = CContext::getCurrent() ;
431    CContextClient* client=context->client ;
432   
433    CEventClient event(getType(),EVENT_ID_INDEX) ;
434    int rank ;
435    list<shared_ptr<CMessage> > list_msg ;
436    list<ARRAY(int,1) > list_out_i,list_out_j,list_out_l ;
437     
438    for(int ns=0;ns<domain->connectedServer.size();ns++)
439    {
440       rank=domain->connectedServer[ns] ;
441       int ib=domain->ib_srv[ns] ;
442       int ie=domain->ie_srv[ns] ;
443       int jb=domain->jb_srv[ns] ;
444       int je=domain->je_srv[ns] ;
445       
446       int i,j ;
447       int nb=0 ;
448       for(int k=0;k<storeIndex_client->num_elements();k++)
449       {
450         i=(*out_i_client)[k] ;
451         j=(*out_j_client)[k] ;
452         if (i>=ib-1 && i<=ie-1 && j>=jb-1 && j<=je-1) nb++ ; 
453       }
454       
455       ARRAY_CREATE(storeIndex,int,1,[nb]) ;
456       ARRAY_CREATE(out_i,int,1,[nb]) ;
457       ARRAY_CREATE(out_j,int,1,[nb]) ;
458       ARRAY_CREATE(out_l,int,1,[nb]) ;
459       
460       nb=0 ;
461       for(int k=0;k<storeIndex_client->num_elements();k++)
462       {
463         i=(*out_i_client)[k] ;
464         j=(*out_j_client)[k] ;
465         if (i>=ib-1 && i<=ie-1 && j>=jb-1 && j<=je-1) 
466         {
467            (*storeIndex)[nb]=k ;
468            (*out_i)[nb]=(*out_i_client)[k] ;
469            (*out_j)[nb]=(*out_j_client)[k] ;
470            (*out_l)[nb]=(*out_l_client)[k] ;
471            nb++ ;
472         }
473       }
474       
475       storeIndex_toSrv.insert(pair<int,ARRAY(int,1) >(rank,storeIndex)) ;
476       nbSenders.insert(pair<int,int>(rank,domain->nbSenders[ns])) ;
477       list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ;
478       list_out_i.push_back(out_i) ;
479       list_out_j.push_back(out_j) ;
480       list_out_l.push_back(out_l) ;
481
482       *list_msg.back()<<getId()<<list_out_i.back()<<list_out_j.back()<<list_out_l.back() ;
483       event.push(rank,domain->nbSenders[ns],*list_msg.back()) ;
484    }
485    client->sendEvent(event) ;
486  }
487 
488  void CGrid::recvIndex(CEventServer& event)
489  {
490    list<CEventServer::SSubEvent>::iterator it ;
491    for (it=event.subEvents.begin();it!=event.subEvents.end();++it)
492    {
493      int rank=it->rank;
494      CBufferIn* buffer=it->buffer;
495      string domainId ;
496      *buffer>>domainId ;
497      get(domainId)->recvIndex(rank,*buffer) ;
498    }
499  }
500 
501  void CGrid::recvIndex(int rank, CBufferIn& buffer)
502  {
503    ARRAY_CREATE(out_i,int,1,[0]) ;
504    ARRAY_CREATE(out_j,int,1,[0]) ;
505    ARRAY_CREATE(out_l,int,1,[0]) ;
506   
507    buffer>>out_i>>out_j>>out_l ;
508    int offset ;
509   
510    offset=domain->zoom_ibegin_srv-1 ;
511    for(int k=0;k<out_i->num_elements();k++) (*out_i)[k]=(*out_i)[k]-offset ;
512   
513    offset=domain->zoom_jbegin_srv-1 ;
514    for(int k=0;k<out_i->num_elements();k++) (*out_j)[k]=(*out_j)[k]-offset ;
515   
516    out_i_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_i)) ;
517    out_j_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_j)) ;
518    out_l_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_l)) ;
519  }
520
521  bool CGrid::dispatchEvent(CEventServer& event)
522  {
523     
524    if (SuperClass::dispatchEvent(event)) return true ;
525    else
526    {
527      switch(event.type)
528      {
529        case EVENT_ID_INDEX :
530          recvIndex(event) ;
531          return true ;
532          break ;
533 
534        default :
535          ERROR("bool CDomain::dispatchEvent(CEventServer& event)",
536                <<"Unknown Event") ;
537          return false ;
538      }
539    }
540  }
541
542
543/*
544   void CGrid::computeIndexServer(void)
545   {
546      ARRAY(int, 2) local_mask =  this->domain->getLocalMask();
547     
548      const std::vector<int> & ibegin = this->domain->getIBeginSub();
549      const std::vector<int> & jbegin = this->domain->getJBeginSub();
550      const std::vector<int> & iend = this->domain->getIEndSub();
551      const std::vector<int> & jend = this->domain->getJEndSub();
552      const std::vector<int> & ibegin_zoom = this->domain->getIBeginZoomSub();
553      const std::vector<int> & jbegin_zoom = this->domain->getJBeginZoomSub();
554      const std::vector<int> & ni_zoom = this->domain->getNiZoomSub();
555      const std::vector<int> & nj_zoom = this->domain->getNjZoomSub();
556     
557      const int ibegin_srv  = this->domain->ibegin.getValue();
558      const int jbegin_srv  = this->domain->jbegin.getValue();
559      const int iend_srv  = this->domain->iend.getValue();
560      const int jend_srv  = this->domain->jend.getValue();
561      const int zoom_ni_srv = this->domain->zoom_ni_loc.getValue();
562      const int zoom_nj_srv = this->domain->zoom_nj_loc.getValue();
563     
564      const int ibegin_zoom_srv = this->domain->zoom_ibegin_loc.getValue();
565      const int jbegin_zoom_srv = this->domain->zoom_jbegin_loc.getValue();
566       const int iend_zoom_srv = ibegin_zoom_srv + zoom_ni_srv-1 ;
567      const int  jend_zoom_srv = jbegin_zoom_srv + zoom_nj_srv-1 ;
568       
569      StdSize dn = 0;     
570      for (StdSize j = 1; j < this->out_i_index.size(); j++)
571         dn += this->out_i_index[j]->size();
572         
573      ARRAY_CREATE(storeIndex_srv , int, 1, [dn]);
574      ARRAY_CREATE(out_i_index_srv, int, 1, [dn]);
575      ARRAY_CREATE(out_j_index_srv, int, 1, [dn]);
576      ARRAY_CREATE(out_l_index_srv, int, 1, [dn]);
577     
578      for (StdSize i = 0, dn = 0; i < ibegin.size(); i++)
579      {
580         ARRAY(int, 1) storeIndex_cl   =  this->storeIndex [i + 1];
581         ARRAY(int, 1) out_i_index_cl  =  this->out_i_index[i + 1];
582         ARRAY(int, 1) out_j_index_cl  =  this->out_j_index[i + 1];
583         ARRAY(int, 1) out_l_index_cl  =  this->out_l_index[i + 1];
584                 
585         int ibegin_zoom_cl = ibegin[i]; //ibegin_zoom[i];
586         int jbegin_zoom_cl = jbegin[i]; //jbegin_zoom[i];
587         int iend_zoom_cl = iend[i]; //ibegin_zoom[i];
588         int jend_zoom_cl = jend[i]; //jbegin_zoom[i];
589
590         int ibegin_cl = ibegin[i]; //ibegin[i];
591         int jbegin_cl = jbegin[i]; //jbegin[i];
592         int iend_cl = iend[i]; //ibegin[i];
593         int jend_cl = jend[i]; //jbegin[i];
594         
595         if (ibegin_zoom.size() != 0)
596         {
597            ibegin_zoom_cl = ibegin_zoom[i];
598            jbegin_zoom_cl = jbegin_zoom[i];
599            iend_zoom_cl = ibegin_zoom[i]+ni_zoom[i]-1;
600            jend_zoom_cl = jbegin_zoom[i]+nj_zoom[i]-1;
601         }
602         
603
604         if (comm::CMPIManager::IsClient())
605         {
606           for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++)
607           {
608              (*storeIndex_srv)[n]  = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur.
609
610              (*out_i_index_srv)[n] = (*out_i_index_cl)[m] + ibegin_cl - 1 - (ibegin_srv + ibegin_zoom_srv - 1) + 1 ;
611              (*out_j_index_srv)[n] = (*out_j_index_cl)[m] + jbegin_cl - 1 - (jbegin_srv + jbegin_zoom_srv - 1) + 1 ;
612              (*out_l_index_srv)[n] = (*out_l_index_cl)[m];
613           }
614         }
615         else
616         {
617           for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++)
618           {
619              (*storeIndex_srv)[n]  = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur.
620            (*out_i_index_srv)[n] = (*out_i_index_cl)[m]
621                                   + (ibegin_cl - 1) - (ibegin_srv - 1) + (ibegin_zoom_cl - 1) - (ibegin_zoom_srv - 1);
622            (*out_j_index_srv)[n] = (*out_j_index_cl)[m]
623                                   + (jbegin_cl - 1) - (jbegin_srv - 1) + (jbegin_zoom_cl - 1) - (jbegin_zoom_srv - 1);
624            (*out_l_index_srv)[n] = (*out_l_index_cl)[m];
625           }         
626           
627         }
628                 
629         dn += storeIndex_cl->size();
630      }
631     
632      if (storeIndex_srv->size() != 0)
633      {
634         const int ibegin_t =
635            *std::min_element(out_i_index_srv->begin(), out_i_index_srv->end());
636         const int iend_t   =
637            *std::max_element(out_i_index_srv->begin(), out_i_index_srv->end());
638         const int jbegin_t =   
639            *std::min_element(out_j_index_srv->begin(), out_j_index_srv->end());
640         const int jend_t   =
641            *std::max_element(out_j_index_srv->begin(), out_j_index_srv->end());
642               
643                                 
644         if ((ibegin_t < 0) || (jbegin_t < 0) ||
645             (iend_t >= zoom_ni_srv) || (jend_t >= zoom_nj_srv))
646         {
647            ERROR("CGrid::computeIndexServer(void)",
648                  << "[ grille = "      << this->getId()
649                  << ", ibegin_t = "    << ibegin_t
650                  << ", jbegin_t = "    << jbegin_t
651                  << ", iend_t = "      << iend_t
652                  << ", jend_t = "      << jend_t
653                  << ", zoom_ni_srv = " << zoom_ni_srv
654                  << ", zoom_nj_srv = " << zoom_nj_srv
655                  << ", nb subdomain = "   << out_i_index.size()-1
656                  <<" ] Erreur d'indexation de la grille au niveau du serveur") ;
657         }
658      }
659
660      if (storeIndex_srv->size() != 0)
661         for (StdSize u = 0; u < storeIndex_srv->size(); u++)
662            (*local_mask)[(*out_i_index_srv)[u]][(*out_j_index_srv)[u]] = 1;
663
664//      StdOFStream ofs(("log_server_"+this->getId()).c_str());
665//      for (StdSize h = 0; h < storeIndex_srv->size(); h++)
666//      {
667//        ofs << "(" << (*storeIndex_srv)[h]  << ";"
668//            << (*out_i_index_srv)[h] << ","
669//            << (*out_j_index_srv)[h] << ","
670//            << (*out_l_index_srv)[h] << ")" << std::endl;
671//      }
672//       ofs.close();
673   
674      this->storeIndex [0] = storeIndex_srv ;
675      this->out_i_index[0] = out_i_index_srv;
676      this->out_j_index[0] = out_j_index_srv;
677      this->out_l_index[0] = out_l_index_srv;     
678   }
679*/
680   
681   void CGrid::inputFieldServer
682         (const std::deque<ARRAY(double, 1)> storedClient,
683                           ARRAY(double, 1)  storedServer) const
684   {
685      if ((this->storeIndex.size()-1 ) != storedClient.size())
686         ERROR("CGrid::inputFieldServer(...)",
687                << "[ Nombre de tableau attendu = " << (this->storeIndex.size()-1) << ", "
688                << "[ Nombre de tableau reçu = "    << storedClient.size() << "] "
689                << "Les données d'un client sont manquantes !") ;
690      if (storedServer.get() != NULL)
691         storedServer->resize(boost::extents[this->storeIndex[0]->num_elements()]);
692      else 
693         ARRAY_ASSIGN(storedServer, double, 1, [this->storeIndex[0]->num_elements()]);
694         
695      for (StdSize i = 0, n = 0; i < storedClient.size(); i++)
696         for (StdSize j = 0; j < storedClient[i]->num_elements(); j++)
697            (*storedServer)[n++] = (*storedClient[i])[j];
698   }
699
700   void CGrid::outputFieldToServer(ARRAY(double, 1) fieldIn, int rank, ARRAY(double, 1) fieldOut)
701   {
702     ARRAY(int,1) index=storeIndex_toSrv[rank] ;
703     int nb=index->num_elements() ;
704     fieldOut->resize(extents[nb]) ;
705     
706     for(int k=0;k<nb;k++) (*fieldOut)[k]=(*fieldIn)[(*index)[k]] ;
707    }
708   ///---------------------------------------------------------------
709
710} // namespace xios
Note: See TracBrowser for help on using the repository browser.