Changeset 1025


Ignore:
Timestamp:
01/11/17 15:14:22 (7 years ago)
Author:
mhnguyen
Message:

Merging working version of coupler

+) Add some changes of domain and axis: Retransfer the atttributes in a generic ways for each level of client (or server)
+) Remove some spoiled files from the previous commits

Test
+) No test

Location:
XIOS/dev/dev_olga
Files:
17 deleted
27 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/inputs/iodef.xml

    r987 r1025  
    88   <field_definition level="1" enabled=".TRUE."> 
    99     <field id="field_A"  operation="average" freq_op="3600s" grid_ref="grid_A"/> 
     10     <field id="field_Axis"  operation="average" freq_op="3600s" axis_ref="axis_A"/> 
     11     <field id="field_Domain"  operation="average" freq_op="3600s" domain_ref="domain_A"/> 
    1012     <field id="field_A_zoom"  operation="average" freq_op="3600s" field_ref="field_A" grid_ref="grid_A_zoom"/> 
    1113   </field_definition> 
     
    1416   <file_definition type="one_file" par_access="collective" output_freq="1h" output_level="10" enabled=".TRUE."> 
    1517     <file id="output" name="output"> 
    16         <field field_ref="field_A" name="field_A" /> 
     18        <field field_ref="field_Domain" name="field_A" /> 
    1719     </file> 
    1820   </file_definition> 
  • XIOS/dev/dev_olga/src/attribute.hpp

    r778 r1025  
    5555            //! Returns true if and only if the attribute should be publicly exposed in the API 
    5656            virtual bool isPublic() const { return true; } 
     57             
     58            //! Return true if the attribute should be sent to other clients or servers 
     59            virtual bool doSend() const { return true; } 
    5760 
    5861            virtual void generateCInterface(ostream& oss, const string& className) = 0 ; 
  • XIOS/dev/dev_olga/src/client_server_mapping.cpp

    r843 r1025  
    9797} 
    9898 
     99CClientServerMapping::GlobalIndexMap& CClientServerMapping::getGlobalIndexOnServer() 
     100{ 
     101  return indexGlobalOnServer_; 
     102} 
     103 
    99104} //namespace xios 
  • XIOS/dev/dev_olga/src/client_server_mapping.hpp

    r843 r1025  
    4242    const GlobalIndexMap& getGlobalIndexOnServer() const; 
    4343 
     44    GlobalIndexMap& getGlobalIndexOnServer(); 
     45 
    4446  protected: 
    4547    //! Global index of data on SERVER, which are calculated by client(s) 
  • XIOS/dev/dev_olga/src/config/axis_attribute.conf

    r817 r1025  
    66 
    77DECLARE_ATTRIBUTE(int,       n_glo) 
    8 DECLARE_ENUM2(positive, up, down) 
     8DECLARE_ENUM2(positive, up, down)                
    99 
    1010/* GLOBAL */ 
  • XIOS/dev/dev_olga/src/config/axis_attribute_private.conf

    r821 r1025  
    11DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_begin) 
    22DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_n) 
     3 
     4/* LOCAL DATA*/ 
     5DECLARE_ARRAY_PRIVATE(int    ,   1 , zoom_index) 
  • XIOS/dev/dev_olga/src/config/domain_attribute.conf

    r953 r1025  
    99 
    1010/* LOCAL */ 
    11 DECLARE_ATTRIBUTE(int             , ibegin) 
    12 DECLARE_ATTRIBUTE(int             , ni) 
     11DECLARE_ATTRIBUTE(int             , ibegin, false) 
     12DECLARE_ATTRIBUTE(int             , ni, false) 
    1313 
    1414/* LOCAL */ 
    15 DECLARE_ATTRIBUTE(int             , jbegin) 
    16 DECLARE_ATTRIBUTE(int             , nj) 
     15DECLARE_ATTRIBUTE(int             , jbegin, false) 
     16DECLARE_ATTRIBUTE(int             , nj, false) 
    1717 
    1818 
    19 DECLARE_ARRAY(int,1             , i_index) 
    20 DECLARE_ARRAY(int,1             , j_index) 
     19DECLARE_ARRAY(int,1             , i_index, false) 
     20DECLARE_ARRAY(int,1             , j_index, false) 
    2121 
    2222/* LOCAL */ 
    23 DECLARE_ARRAY(bool, 1 , mask_1d) 
     23DECLARE_ARRAY(bool, 1 , mask_1d, false) 
    2424DECLARE_ARRAY(bool, 2 , mask_2d) 
    2525 
     
    2828 
    2929/* LOCAL */ 
    30 DECLARE_ATTRIBUTE(int             , data_ni) 
    31 DECLARE_ATTRIBUTE(int             , data_nj) 
    32 DECLARE_ATTRIBUTE(int             , data_ibegin) 
    33 DECLARE_ATTRIBUTE(int             , data_jbegin) 
     30DECLARE_ATTRIBUTE(int             , data_ni, false) 
     31DECLARE_ATTRIBUTE(int             , data_nj, false) 
     32DECLARE_ATTRIBUTE(int             , data_ibegin, false) 
     33DECLARE_ATTRIBUTE(int             , data_jbegin, false) 
    3434 
    3535/* LOCAL */ 
    36 DECLARE_ARRAY(int, 1 , data_i_index) 
    37 DECLARE_ARRAY(int, 1,  data_j_index) 
     36DECLARE_ARRAY(int, 1 , data_i_index, false) 
     37DECLARE_ARRAY(int, 1,  data_j_index, false) 
    3838 
    3939/* LOCAL */ 
    40 DECLARE_ARRAY(double, 1, lonvalue_1d) 
    41 DECLARE_ARRAY(double, 1, latvalue_1d) 
    42 DECLARE_ARRAY(double, 2, lonvalue_2d) 
    43 DECLARE_ARRAY(double, 2, latvalue_2d) 
     40DECLARE_ARRAY(double, 1, lonvalue_1d, false) 
     41DECLARE_ARRAY(double, 1, latvalue_1d, false) 
     42DECLARE_ARRAY(double, 2, lonvalue_2d, false) 
     43DECLARE_ARRAY(double, 2, latvalue_2d, false) 
    4444 
    4545DECLARE_ATTRIBUTE(int, nvertex) 
    46 DECLARE_ARRAY(double, 2, bounds_lon_1d) 
    47 DECLARE_ARRAY(double, 2, bounds_lat_1d) 
    48 DECLARE_ARRAY(double, 3, bounds_lon_2d) 
    49 DECLARE_ARRAY(double, 3, bounds_lat_2d) 
     46DECLARE_ARRAY(double, 2, bounds_lon_1d, false) 
     47DECLARE_ARRAY(double, 2, bounds_lat_1d, false) 
     48DECLARE_ARRAY(double, 3, bounds_lon_2d, false) 
     49DECLARE_ARRAY(double, 3, bounds_lat_2d, false) 
    5050 
    5151DECLARE_ARRAY(double, 2, area) 
  • XIOS/dev/dev_olga/src/config/domain_attribute_private.conf

    r821 r1025  
    1818DECLARE_ATTRIBUTE_PRIVATE(int,  global_zoom_jbegin) 
    1919DECLARE_ATTRIBUTE_PRIVATE(int,  global_zoom_nj) 
     20 
     21DECLARE_ARRAY_PRIVATE(int    ,   1 , zoom_i_index, false) 
     22DECLARE_ARRAY_PRIVATE(int    ,   1 , zoom_j_index, false) 
     23//DECLARE_ARRAY_PRIVATE(double ,   1 , areavalue, false) 
     24//DECLARE_ARRAY_PRIVATE(int    ,   1 , lonvalue, false) 
     25//DECLARE_ARRAY_PRIVATE(int    ,   1 , latvalue, false) 
     26//DECLARE_ARRAY_PRIVATE(int    ,   2 , bounds_lonvalue, false) 
     27//DECLARE_ARRAY_PRIVATE(int    ,   2 , bounds_latvalue, false) 
     28 
  • XIOS/dev/dev_olga/src/declare_attribute.hpp

    r778 r1025  
    33 
    44/// ///////////////////////////// Macros ///////////////////////////// /// 
    5 #define DECLARE_ATTRIBUTE(type, name)                             \ 
     5#define DECLARE_ATTRIBUTE(type, name, ...)                        \ 
    66   class name##_attr : public CAttributeTemplate<type>            \ 
    77   {                                                              \ 
    88      public :                                                    \ 
    9          name##_attr(void)                                          \ 
     9         name##_attr(void)                                        \ 
    1010            : CAttributeTemplate<type>                            \ 
    1111            (#name, *CAttributeMap::Current)                      \ 
     
    1313         type operator=(const type & value)                       \ 
    1414         { return (CAttributeTemplate<type>::operator=(value)); } \ 
    15          virtual ~name##_attr(void)                                 \ 
     15         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \ 
     16         bool helper(bool returnTrue=true) const { return returnTrue; }   \ 
     17         virtual ~name##_attr(void)                               \ 
    1618         { /* Ne rien faire de plus */ }                          \ 
    1719   } name; 
    1820 
    19 #define DECLARE_ATTRIBUTE_PRIVATE(type, name)                    \ 
    20    class name##_attr : public CAttributeTemplate<type>           \ 
     21#define DECLARE_ATTRIBUTE_PRIVATE(type, name, ...)                \ 
     22   class name##_attr : public CAttributeTemplate<type>            \ 
    2123   {                                                              \ 
    2224      public :                                                    \ 
    23          name##_attr(void)                                          \ 
     25         name##_attr(void)                                        \ 
    2426            : CAttributeTemplate<type>                            \ 
    2527            (#name, *CAttributeMap::Current)                      \ 
     
    2931         virtual bool isPublic() const                            \ 
    3032         { return false; }                                        \ 
     33         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \ 
     34         bool helper(bool returnTrue=true) const { return returnTrue; }   \ 
    3135         virtual ~name##_attr(void)                               \ 
    3236         { /* Ne rien faire de plus */ }                          \ 
    3337   } name; 
    3438 
    35 #define DECLARE_ARRAY(T_num, T_rank, name)                        \ 
     39#define DECLARE_ARRAY(T_num, T_rank, name, ...)                   \ 
    3640   class name##_attr : public CAttributeArray<T_num, T_rank>      \ 
    3741   {                                                              \ 
     
    3943         using CAttributeArray<T_num, T_rank>::operator = ;       \ 
    4044         name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \ 
     45         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \ 
     46         bool helper(bool returnTrue=true) const { return returnTrue; }   \ 
    4147         virtual ~name##_attr(void) {}                            \ 
    4248   } name; 
    4349 
    44 #define DECLARE_ARRAY_PRIVATE(T_num, T_rank, name)                        \ 
     50#define DECLARE_ARRAY_PRIVATE(T_num, T_rank, name, ...)           \ 
    4551   class name##_attr : public CAttributeArray<T_num, T_rank>      \ 
    4652   {                                                              \ 
     
    5056         virtual bool isPublic() const                            \ 
    5157         { return false; }                                        \ 
     58         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \ 
     59         bool helper(bool returnTrue=true) const { return returnTrue; }   \ 
    5260         virtual ~name##_attr(void) {}                            \ 
    5361   } name; 
    5462 
    55 #define DECLARE_CLASS_ENUM(name)                                   \ 
    56    class name##_attr : public CAttributeEnum<Enum_##name>          \ 
     63#define DECLARE_CLASS_ENUM(name, ...)                             \ 
     64   class name##_attr : public CAttributeEnum<Enum_##name>         \ 
    5765   {                                                              \ 
    5866      public :                                                    \ 
    5967         name##_attr(void) : CAttributeEnum<Enum_##name>(#name, *CAttributeMap::Current) { } \ 
    60          virtual ~name##_attr(void) {}                           \ 
     68         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \ 
     69         bool helper(bool returnTrue=true) const { return returnTrue; }   \ 
     70         virtual ~name##_attr(void) {}                            \ 
    6171   } name; 
    6272 
     
    7181   DECLARE_CLASS_ENUM(name) 
    7282 
    73 #define DECLARE_ENUM3(name,arg1,arg2,arg3)                             \ 
     83#define DECLARE_ENUM3(name,arg1,arg2,arg3)                        \ 
    7484   class Enum_##name                                              \ 
    7585   {                                                              \ 
    7686     public:                                                      \ 
    77      enum t_enum { arg1=0, arg2, arg3} ;                                \ 
     87     enum t_enum { arg1=0, arg2, arg3} ;                          \ 
    7888     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3 } ; return enumStr ; }   \ 
    7989     int getSize(void) const { return 3 ; }                       \ 
     
    8191   DECLARE_CLASS_ENUM(name) 
    8292 
    83 #define DECLARE_ENUM4(name,arg1,arg2,arg3,arg4)                             \ 
     93#define DECLARE_ENUM4(name,arg1,arg2,arg3,arg4)                   \ 
    8494   class Enum_##name                                              \ 
    8595   {                                                              \ 
    8696     public:                                                      \ 
    87      enum t_enum { arg1=0, arg2, arg3,arg4} ;                                \ 
     97     enum t_enum { arg1=0, arg2, arg3,arg4} ;                     \ 
    8898     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4 } ; return enumStr ; }   \ 
    8999     int getSize(void) const { return 4 ; }                       \ 
     
    91101   DECLARE_CLASS_ENUM(name) 
    92102 
    93 #define DECLARE_ENUM5(name,arg1,arg2,arg3,arg4,arg5)                             \ 
     103#define DECLARE_ENUM5(name,arg1,arg2,arg3,arg4,arg5)              \ 
    94104   class Enum_##name                                              \ 
    95105   {                                                              \ 
    96106     public:                                                      \ 
    97      enum t_enum { arg1=0, arg2, arg3,arg4,arg5} ;                                \ 
     107     enum t_enum { arg1=0, arg2, arg3,arg4,arg5} ;                \ 
    98108     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5 } ; return enumStr ; }   \ 
    99109     int getSize(void) const { return 5 ; }                       \ 
     
    101111   DECLARE_CLASS_ENUM(name) 
    102112 
    103 #define DECLARE_ENUM6(name,arg1,arg2,arg3,arg4,arg5,arg6)                             \ 
     113#define DECLARE_ENUM6(name,arg1,arg2,arg3,arg4,arg5,arg6)         \ 
    104114   class Enum_##name                                              \ 
    105115   {                                                              \ 
    106116     public:                                                      \ 
    107      enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6} ;                                \ 
     117     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6} ;           \ 
    108118     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6 } ; return enumStr ; }   \ 
    109119     int getSize(void) const { return 6 ; }                       \ 
     
    111121   DECLARE_CLASS_ENUM(name) 
    112122 
    113 #define DECLARE_ENUM7(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7)                             \ 
     123#define DECLARE_ENUM7(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7)    \ 
    114124   class Enum_##name                                              \ 
    115125   {                                                              \ 
    116126     public:                                                      \ 
    117      enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7} ;                                \ 
     127     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7} ;      \ 
    118128     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7 } ; return enumStr ; }   \ 
    119129     int getSize(void) const { return 7 ; }                       \ 
     
    125135   {                                                              \ 
    126136     public:                                                      \ 
    127      enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8} ;                                \ 
     137     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8} ; \ 
    128138     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7,#arg8 } ; return enumStr ; }   \ 
    129139     int getSize(void) const { return 8 ; }                       \ 
  • XIOS/dev/dev_olga/src/distribution_client.cpp

    r1021 r1025  
    1111namespace xios { 
    1212 
    13 CDistributionClient::CDistributionClient(int rank, const GlobalLocalDataMap& globalLocalIndex) 
     13CDistributionClient::CDistributionClient(int rank, CGrid* grid, const GlobalLocalDataMap& globalLocalIndex) 
    1414  : CDistribution(rank, 0) 
    1515   , axisDomainOrder_() 
     
    3434    ++idx; 
    3535  } 
     36 
     37  std::vector<CDomain*> domList = grid->getDomains(); 
     38  std::vector<CAxis*> axisList = grid->getAxis(); 
     39  std::vector<CScalar*> scalarList = grid->getScalars(); 
     40  CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
     41 
     42  int numElement = axisDomainOrder.numElements(); 
     43  // Because domain and axis can be in any order (axis1, domain1, axis2, axis3, ) 
     44  // their position should be specified. In axisDomainOrder, domain == true, axis == false 
     45  int dims = numElement; 
     46  idx = 0; 
     47  std::vector<int> indexMap(numElement);   
     48  for (int i = 0; i < numElement; ++i) 
     49  { 
     50    indexMap[i] = idx; 
     51    if (2 == axisDomainOrder(i)) 
     52    { 
     53      ++dims; 
     54      idx += 2; 
     55    } 
     56    else ++idx; 
     57  } 
     58 
     59  nGlob_.resize(dims); 
     60 
     61  // Data_n_index of domain or axis (For now, axis uses its size as data_n_index 
     62  dataNIndex_.resize(numElement); 
     63  dataDims_.resize(numElement); 
     64  isDataDistributed_ = false; 
     65  int domIndex = 0, axisIndex = 0, scalarIndex = 0; 
     66  for (idx = 0; idx < numElement; ++idx) 
     67  { 
     68    int eleDim = axisDomainOrder(idx); 
     69 
     70    // If this is a domain 
     71    if (2 == eleDim) 
     72    { 
     73      // On the j axis 
     74      nGlob_.at(indexMap[idx]+1)  = domList[domIndex]->nj_glo.getValue(); 
     75      nGlob_.at(indexMap[idx]) = domList[domIndex]->ni_glo.getValue(); 
     76      dataNIndex_.at(idx) = domList[domIndex]->data_i_index.numElements(); 
     77      dataDims_.at(idx) = domList[domIndex]->data_dim.getValue(); 
     78 
     79      isDataDistributed_ |= domList[domIndex]->isDistributed(); 
     80      ++domIndex; 
     81    } 
     82    else if (1 == eleDim)// So it's an axis 
     83    { 
     84      nGlob_.at(indexMap[idx]) = axisList[axisIndex]->n_glo.getValue(); 
     85      dataNIndex_.at(idx) = axisList[axisIndex]->data_index.numElements(); 
     86      dataDims_.at(idx) = 1; 
     87 
     88      isDataDistributed_ |= axisList[axisIndex]->isDistributed(); 
     89      ++axisIndex; 
     90    } 
     91    else // scalar 
     92    { 
     93      nGlob_.at(indexMap[idx]) = 1; 
     94      dataNIndex_.at(idx) = 1; 
     95      dataDims_.at(idx) = 1; 
     96 
     97      isDataDistributed_ |= false; 
     98      ++scalarIndex; 
     99    } 
     100  } 
     101 
    36102} 
    37103 
     
    192258  infoIndex_.resize(this->dims_); 
    193259 
    194   // A trick to determine position of each domain in domainList 
    195   int domIndex = 0, axisIndex = 0, scalarIndex = 0; 
    196   idx = 0; 
    197  
    198260  elementLocalIndex_.resize(numElement_); 
    199261  elementGlobalIndex_.resize(numElement_); 
     
    202264  elementNLocal_.resize(numElement_); 
    203265  elementNGlobal_.resize(numElement_); 
     266 
    204267  elementNLocal_[0] = 1; 
    205268  elementNGlobal_[0] = 1; 
     269  isDataDistributed_ = false; 
     270 
    206271  size_t localSize = 1, globalSize = 1; 
    207272 
    208   isDataDistributed_ = false; 
     273  // A trick to determine position of each domain in domainList 
     274  int domIndex = 0, axisIndex = 0, scalarIndex = 0; 
     275  idx = 0; 
     276 
     277   
    209278  // Update all the vectors above 
    210279  for (idx = 0; idx < numElement_; ++idx) 
  • XIOS/dev/dev_olga/src/distribution_client.hpp

    r983 r1025  
    3434  public: 
    3535    /** Default constructor */ 
    36     CDistributionClient(int rank, const GlobalLocalDataMap& globalLocalIndex); 
     36    CDistributionClient(int rank, CGrid* grid, const GlobalLocalDataMap& globalLocalIndex); 
    3737    CDistributionClient(int rank, int dims, const CArray<size_t,1>& globalIndex = CArray<size_t,1>()); 
    3838    CDistributionClient(int rank, CGrid* grid); 
  • XIOS/dev/dev_olga/src/distribution_server.cpp

    r930 r1025  
    1313 
    1414CDistributionServer::CDistributionServer(int rank, int dims, const CArray<size_t,1>& globalIndex) 
    15   : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_() 
     15  : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_(), 
     16  globalIndexEachDimension_() 
    1617{ 
    1718} 
     
    1920CDistributionServer::CDistributionServer(int rank, const std::vector<int>& nZoomBegin, 
    2021                                         const std::vector<int>& nZoomSize, const std::vector<int>& nGlobal) 
    21   : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 
     22  : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_(), 
     23  globalIndexEachDimension_() 
    2224{ 
    2325  createGlobalIndex(); 
     
    2931                                         const std::vector<int>& nGlobal) 
    3032  : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(nZoomBeginGlobal), 
    31     nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 
     33    nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_(), 
     34    globalIndexEachDimension_() 
    3235{ 
    3336  createGlobalIndex(); 
     37} 
     38 
     39CDistributionServer::CDistributionServer(int rank,  
     40                                         const std::vector<CArray<int,1> >& globalIndexEachDimension, 
     41                                         const std::vector<int>& nGlobal) 
     42  : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(), 
     43    nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_(),  
     44    globalIndexEachDimension_(globalIndexEachDimension) 
     45{ 
     46  createGlobalIndexFromIndex(globalIndexEachDimension, nGlobal); 
    3447} 
    3548 
     
    88101} 
    89102 
     103void CDistributionServer::createGlobalIndexFromIndex(const std::vector<CArray<int,1> >& globalIndexOnEachDimension, 
     104                                                     const std::vector<int>& nbGlobal) 
     105{ 
     106  size_t idx = 0, ssize = 1; 
     107  for (int i = 0; i < globalIndexOnEachDimension.size(); ++i) ssize *= globalIndexOnEachDimension[i].numElements(); 
     108 
     109  this->globalIndex_.resize(ssize); 
     110  size_t nbDim = nbGlobal.size(); 
     111  std::vector<int> idxLoop(nbDim,0); 
     112  std::vector<int> currentIndex(nbDim); 
     113  int innerLoopSize = globalIndexOnEachDimension[0].numElements(); 
     114 
     115  globalLocalIndexMap_.rehash(std::ceil(ssize/globalLocalIndexMap_.max_load_factor())); 
     116  while (idx<ssize) 
     117  { 
     118    for (int i = 0; i < nbDim-1; ++i) 
     119    { 
     120      if (idxLoop[i] == globalIndexOnEachDimension[i].numElements()) 
     121      { 
     122        idxLoop[i] = 0; 
     123        ++idxLoop[i+1]; 
     124      } 
     125    } 
     126 
     127    for (int i = 1; i < nbDim; ++i) 
     128      currentIndex[i] = globalIndexOnEachDimension[i](idxLoop[i]); 
     129 
     130    size_t mulDim, globalIndex; 
     131    for (int i = 0; i < innerLoopSize; ++i) 
     132    { 
     133      mulDim = 1; 
     134      globalIndex = globalIndexOnEachDimension[0](i); 
     135 
     136      for (int k = 1; k < nbDim; ++k) 
     137      { 
     138        mulDim *= nbGlobal[k-1]; 
     139        globalIndex += (currentIndex[k])*mulDim; 
     140      } 
     141      globalLocalIndexMap_[globalIndex] = idx; 
     142      this->globalIndex_(idx) = globalIndex; 
     143 
     144      ++idx; 
     145    } 
     146    idxLoop[0] += innerLoopSize; 
     147  } 
     148 
     149} 
     150 
    90151/*! 
    91152  Compute local index for writing data on server 
  • XIOS/dev/dev_olga/src/distribution_server.hpp

    r983 r1025  
    3030                        const std::vector<int>& nZoomBeginGlobal, 
    3131                        const std::vector<int>& nGlobal); 
     32    CDistributionServer(int rank,  
     33                        const std::vector<CArray<int,1> >& globalIndexEachDimension, 
     34                        const std::vector<int>& nGlobal); 
    3235 
    3336    /** Default destructor */ 
     
    3841    const std::vector<int>& getZoomSizeServer() const; 
    3942    const GlobalLocalMap& getGlobalLocalIndex() const { return globalLocalIndexMap_; } 
     43    const std::vector<CArray<int,1> >& getGlobalIndexEachDimension() const;  
    4044 
    4145    virtual CArray<size_t,1> computeLocalIndex(const CArray<size_t,1>& globalIndex); 
     
    4549  protected: 
    4650    virtual void createGlobalIndex(); 
     51 
     52    void createGlobalIndexFromIndex(const std::vector<CArray<int,1> >& globalIndexOnEachDimension, 
     53                                    const std::vector<int>& nbGlobal); 
    4754 
    4855  protected: 
     
    5461    std::vector<int> nZoomSize_; 
    5562    std::vector<int> nZoomBegin_; 
     63    std::vector<CArray<int, 1> > globalIndexEachDimension_; 
    5664 
    5765}; 
  • XIOS/dev/dev_olga/src/io/nc4_data_output.cpp

    r1021 r1025  
    7474         else setWrittenDomain(domid); 
    7575 
     76        const std::vector<int>& local_size_write  = domain->getLocalWriteSize(); 
     77        const std::vector<int>& global_size_write = domain->getGlobalWriteSize(); 
     78        const std::vector<int>& start_write = domain->getStartWriteIndex(); 
     79        const std::vector<int>& count_write = domain->getCountWriteIndex(); 
     80        int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 
    7681 
    7782         StdString dimXid, dimYid ; 
     
    135140                 bounds_latid = StdString("bounds_lat").append(appendDomid); 
    136141 
    137                  SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv); 
    138                  SuperClassWriter::addDimension(dimYid, domain->zoom_nj_srv); 
     142                 SuperClassWriter::addDimension(dimXid, local_size_write[0]); 
     143                 SuperClassWriter::addDimension(dimYid, local_size_write[1]); 
    139144 
    140145                 if (domain->hasBounds) 
     
    143148                 if (server->intraCommSize > 1) 
    144149                 { 
    145                    this->writeLocalAttributes(domain->zoom_ibegin_srv, 
    146                                               domain->zoom_ni_srv, 
    147                                               domain->zoom_jbegin_srv, 
    148                                               domain->zoom_nj_srv, 
     150                   this->writeLocalAttributes(0, count_write[0], 
     151                                              0, count_write[1], 
    149152                                              appendDomid); 
    150153 
    151154                   if (singleDomain) 
    152155                    this->writeLocalAttributes_IOIPSL(dimXid, dimYid, 
    153                                                       domain->zoom_ibegin_srv, 
    154                                                       domain->zoom_ni_srv, 
    155                                                       domain->zoom_jbegin_srv, 
    156                                                       domain->zoom_nj_srv, 
     156                                                      0, count_write[0], 
     157                                                      0, count_write[1], 
    157158                                                      domain->ni_glo,domain->nj_glo, 
    158159                                                      server->intraCommRank,server->intraCommSize); 
     
    223224                   { 
    224225                     case CDomain::type_attr::curvilinear : 
    225                        SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0); 
    226                        SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0); 
     226                       SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 
     227                       SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 
    227228                       break; 
    228229                     case CDomain::type_attr::rectilinear : 
    229                        CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ; 
     230                       CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,local_size_write[0])) ; 
    230231                       SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); 
    231                        CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ; 
     232                       CArray<double,1> lon = domain->lonvalue(Range(0,local_size_write[1])) ; 
    232233                       SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); 
    233234                       break; 
     
    236237                   if (domain->hasBounds) 
    237238                   { 
    238                      SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0); 
    239                      SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0); 
     239                     SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 
     240                     SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 
    240241                   } 
    241242                 } 
    242243 
    243244                 if (domain->hasArea) 
    244                    SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0); 
     245                   SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 
    245246 
    246247                 SuperClassWriter::definition_start(); 
     
    250251              case (ONE_FILE) : 
    251252              { 
    252                  SuperClassWriter::addDimension(dimXid, domain->global_zoom_ni); 
    253                  SuperClassWriter::addDimension(dimYid, domain->global_zoom_nj); 
     253                 SuperClassWriter::addDimension(dimXid, global_size_write[0]); 
     254                 SuperClassWriter::addDimension(dimYid, global_size_write[1]); 
    254255 
    255256                 if (domain->hasBounds) 
     
    325326                     else 
    326327                     { 
    327                        start[1]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    328                        start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin; 
    329                        count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 
     328                       // start[1]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     329                       // start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin; 
     330                       // count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 
     331                       start[1]= start_write[0]; 
     332                       start[0]= start_write[1]; 
     333                       count[1]= count_write[0]; 
     334                       count[0]= count_write[1]; 
    330335                     } 
    331336 
    332337                     if (domain->hasLonLat) 
    333338                     { 
    334                        SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); 
    335                        SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); 
     339                       SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 
     340                       SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 
    336341                     } 
    337342                     break; 
     
    347352                         start[0]=0 ; 
    348353                         count[0]=0 ; 
    349                          SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); 
    350                          SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); 
     354                         SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 
     355                         SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 
    351356 
    352357                       } 
    353358                       else 
    354359                       { 
    355                          start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin; 
    356                          count[0]=domain->zoom_nj_srv ; 
    357                          CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ; 
     360                         start[0]= start_write[1]; 
     361                         count[0]= count_write[1]; 
     362                         CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,count_write[0])) ; 
    358363                         SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 
    359364 
    360                          start[0]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    361                          count[0]=domain->zoom_ni_srv ; 
    362                          CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ; 
     365                         start[0]= start_write[0]; 
     366                         count[0]= count_write[0]; 
     367                         CArray<double,1> lon=domain->lonvalue(Range(0,count_write[1])) ; 
    363368                         SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 
    364369                       } 
     
    380385                   { 
    381386                     start[2] = 0; 
    382                      start[1] = domain->zoom_ibegin_srv - domain->global_zoom_ibegin; 
    383                      start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin; 
    384                      count[2] = domain->nvertex; 
    385                      count[1] = domain->zoom_ni_srv; 
    386                      count[0] = domain->zoom_nj_srv; 
     387                     start[1] = start_write[0]; 
     388                     start[0] = start_write[1]; 
     389                     count[2] = nvertex; 
     390                     count[1] = count_write[0]; 
     391                     count[0] = count_write[1]; 
    387392                   } 
    388393 
    389                  SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0, &start, &count); 
    390                  SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0, &start, &count); 
     394                 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0, &start, &count); 
     395                 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0, &start, &count); 
    391396                 } 
    392397 
     
    403408                   else 
    404409                   { 
    405                      start[1] = domain->zoom_ibegin_srv - domain->global_zoom_ibegin; 
    406                      start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin; 
    407                      count[1] = domain->zoom_ni_srv; 
    408                      count[0] = domain->zoom_nj_srv; 
     410                     // start[1] = domain->zoom_ibegin_srv - domain->global_zoom_ibegin; 
     411                     // start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin; 
     412                     // count[1] = domain->zoom_ni_srv; 
     413                     // count[0] = domain->zoom_nj_srv; 
     414 
     415                     start[1]= start_write[0]; 
     416                     start[0]= start_write[1]; 
     417                     count[1]= count_write[0]; 
     418                     count[0]= count_write[1]; 
    409419                   } 
    410420 
    411                    SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0, &start, &count); 
     421                   SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 
    412422                 } 
    413423 
     
    450460      StdString domainName = domain->name; 
    451461      domain->assignMesh(domainName, domain->nvertex); 
    452       domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
     462      domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue); 
    453463 
    454464      StdString node_x = domainName + "_node_x"; 
     
    471481      StdString dimVertex = "n" + domainName + "_vertex"; 
    472482      StdString dimTwo = "Two"; 
     483 
     484      const std::vector<int>& local_size_write  = domain->getLocalWriteSize(); 
     485      const std::vector<int>& global_size_write = domain->getGlobalWriteSize(); 
     486      const std::vector<int>& start_write = domain->getStartWriteIndex(); 
     487      const std::vector<int>& count_write = domain->getCountWriteIndex(); 
    473488 
    474489      if (!SuperClassWriter::dimExist(dimTwo)) SuperClassWriter::addDimension(dimTwo, 2); 
     
    664679                 else 
    665680                 { 
    666                    startNodes[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    667                    countNodes[0] = domain->zoom_ni_srv ; 
     681                   startNodes[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     682                   countNodes[0] = count_write[0]; //domain->zoom_ni_srv ; 
    668683                 } 
    669684 
     
    687702                 else 
    688703                 { 
    689                    startEdges[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    690                    countEdges[0] = domain->zoom_ni_srv ; 
     704                   startEdges[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     705                   countEdges[0] = count_write[0]; 
    691706                   startNodes[0] = domain->mesh->node_start; 
    692707                   countNodes[0] = domain->mesh->node_count; 
    693                    startEdgeNodes[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     708                   startEdgeNodes[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    694709                   startEdgeNodes[1] = 0; 
    695                    countEdgeNodes[0] = domain->zoom_ni_srv; 
     710                   countEdgeNodes[0] = count_write[0]; //domain->zoom_ni_srv; 
    696711                   countEdgeNodes[1]= 2; 
    697712                 } 
     
    723738                 else 
    724739                 { 
    725                    startFaces[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    726                    countFaces[0] = domain->zoom_ni_srv ; 
     740                   startFaces[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     741                   countFaces[0] = count_write[0]; //domain->zoom_ni_srv ; 
    727742                   startNodes[0] = domain->mesh->node_start; 
    728743                   countNodes[0] = domain->mesh->node_count; 
     
    737752                   countEdgeFaces[0] = domain->mesh->edge_count; 
    738753                   countEdgeFaces[1]= 2; 
    739                    startFaceConctv[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    740                    startFaceConctv[1] = 0; 
    741                    countFaceConctv[0] = domain->zoom_ni_srv; 
     754                   startFaceConctv[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     755                   startFaceConctv[1] = 0; //0; 
     756                   countFaceConctv[0] = count_write[0]; //domain->zoom_ni_srv; 
    742757                   countFaceConctv[1] = domain->nvertex; 
    743758                 } 
     
    760775              if (domain->nvertex == 2) 
    761776              { 
    762                 startEdges[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    763                 countEdges[0] = domain->zoom_ni_srv ; 
    764                 startEdgeNodes[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    765                 startEdgeNodes[1] = 0; 
    766                 countEdgeNodes[0] = domain->zoom_ni_srv; 
     777                startEdges[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     778                countEdges[0] = count_write[0]; //domain->zoom_ni_srv ; 
     779                startEdgeNodes[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     780                startEdgeNodes[1] = 0; //0; 
     781                countEdgeNodes[0] = count_write[0]; //domain->zoom_ni_srv; 
    767782                countEdgeNodes[1]= 2; 
    768783                SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); 
     
    785800                  SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); 
    786801                } 
    787                 startFaces[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    788                 countFaces[0] = domain->zoom_ni_srv; 
     802                startFaces[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     803                countFaces[0] = count_write[0]; //domain->zoom_ni_srv; 
    789804                startEdgeFaces[0] = domain->mesh->edge_start; 
    790805                startEdgeFaces[1]= 0; 
    791806                countEdgeFaces[0] = domain->mesh->edge_count; 
    792807                countEdgeFaces[1]= 2; 
    793                 startFaceConctv[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    794                 startFaceConctv[1] = 0; 
    795                 countFaceConctv[0] = domain->zoom_ni_srv; 
     808                startFaceConctv[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     809                startFaceConctv[1] = 0; //0; 
     810                countFaceConctv[0] = count_write[0]; //domain->zoom_ni_srv; 
    796811                countFaceConctv[1]= domain->nvertex; 
    797812                SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces); 
     
    860875         string areaId = "area" + appendDomid; 
    861876 
     877        const std::vector<int>& local_size_write  = domain->getLocalWriteSize(); 
     878        const std::vector<int>& global_size_write = domain->getGlobalWriteSize(); 
     879        const std::vector<int>& start_write = domain->getStartWriteIndex(); 
     880        const std::vector<int>& count_write = domain->getCountWriteIndex(); 
     881        int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 
     882 
    862883         try 
    863884         { 
     
    867888              { 
    868889                 dim0.push_back(dimXid); 
    869                  SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv); 
     890                 SuperClassWriter::addDimension(dimXid, local_size_write[0]); 
    870891 
    871892                 lonid = StdString("lon").append(appendDomid); 
     
    905926                 if (domain->hasLonLat) 
    906927                 { 
    907                    SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0); 
    908                    SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0); 
     928                   SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 
     929                   SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 
    909930                   if (domain->hasBounds) 
    910931                   { 
    911                      SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0); 
    912                      SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0); 
     932                     SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 
     933                     SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 
    913934                   } 
    914935                 } 
    915936 
    916937                 if (domain->hasArea) 
    917                    SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0); 
     938                   SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 
    918939 
    919940                 SuperClassWriter::definition_start(); 
     
    928949                 bounds_latid = StdString("bounds_lat").append(appendDomid); 
    929950                 dim0.push_back(dimXid); 
    930                  SuperClassWriter::addDimension(dimXid, domain->ni_glo); 
     951                 SuperClassWriter::addDimension(dimXid, global_size_write[0]); 
    931952                 if (domain->hasLonLat) 
    932953                 { 
     
    938959                   this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid); 
    939960                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); 
    940                    if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex); 
     961                   if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, nvertex); 
    941962                 } 
    942963                 dim0.clear(); 
     
    968989                   count[0]=0 ; 
    969990                   startBounds[1]=0 ; 
    970                    countBounds[1]=domain->nvertex ; 
     991                   countBounds[1]=nvertex ; 
    971992                   startBounds[0]=0 ; 
    972993                   countBounds[0]=0 ; 
     
    974995                 else 
    975996                 { 
    976                    start[0]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
    977                    count[0]=domain->zoom_ni_srv ; 
    978                    startBounds[0]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 
     997                   start[0]=start_write[0]; 
     998                   count[0]=count_write[0]; 
     999                   startBounds[0]=start_write[0]; 
    9791000                   startBounds[1]=0 ; 
    980                    countBounds[0]=domain->zoom_ni_srv ; 
    981                    countBounds[1]=domain->nvertex ; 
     1001                   countBounds[0]=count_write[0]; 
     1002                   countBounds[1]=nvertex ; 
    9821003                 } 
    9831004 
    9841005                 if (domain->hasLonLat) 
    9851006                 { 
    986                    SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); 
    987                    SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); 
     1007                   SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 
     1008                   SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 
    9881009                   if (domain->hasBounds) 
    9891010                   { 
    990                      SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0,&startBounds,&countBounds); 
    991                      SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0,&startBounds,&countBounds); 
     1011                     SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0,&startBounds,&countBounds); 
     1012                     SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0,&startBounds,&countBounds); 
    9921013                   } 
    9931014                 } 
    9941015 
    9951016                 if (domain->hasArea) 
    996                    SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0, &start, &count); 
     1017                   SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 
    9971018 
    9981019                 SuperClassWriter::definition_start(); 
     
    10211042      void CNc4DataOutput::writeAxis_(CAxis* axis) 
    10221043      { 
     1044        CContext* context = CContext::getCurrent(); 
     1045        CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer; 
     1046 
    10231047        if (axis->IsWritten(this->filename)) return; 
    10241048        axis->checkAttributes(); 
    1025         int zoom_size_srv  = axis->zoom_size_srv; 
    1026         int zoom_begin_srv = axis->zoom_begin_srv; 
    1027         int zoom_size  = (MULTI_FILE == SuperClass::type) ? zoom_size_srv 
    1028                                                               : axis->global_zoom_n; 
    1029         int zoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv 
    1030                                                               : axis->global_zoom_begin; 
    1031  
    1032         if ((0 == zoom_size_srv) && (MULTI_FILE == SuperClass::type)) return; 
     1049 
     1050        int local_size_write  = axis->getLocalWriteSize(); 
     1051        int global_size_write = axis->getGlobalWriteSize(); 
     1052        int start_write = axis->getStartWriteIndex(); 
     1053        int count_write = axis->getCountWriteIndex(); 
     1054 
     1055        if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return; 
    10331056 
    10341057        std::vector<StdString> dims; 
     
    10391062        try 
    10401063        { 
    1041           SuperClassWriter::addDimension(axisid, zoom_size); 
     1064          SuperClassWriter::addDimension(axisid, global_size_write); 
    10421065          if (axis->hasValue) 
    10431066          { 
     
    10791102              case MULTI_FILE: 
    10801103              { 
    1081                 CArray<double,1> axis_value(zoom_size_srv); 
    1082                 for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value_srv(i); 
     1104                CArray<double,1> axis_value(local_size_write); 
     1105                for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i); 
    10831106                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
    10841107 
    10851108                if (!axis->bounds.isEmpty()) 
    1086                   SuperClassWriter::writeData(axis->bound_srv, axisBoundsId, isCollective, 0); 
     1109                  SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 
    10871110 
    10881111                SuperClassWriter::definition_start(); 
     
    10921115              case ONE_FILE: 
    10931116              { 
    1094                 CArray<double,1> axis_value(zoom_size_srv); 
    1095                 axis_value = axis->value_srv; 
     1117                CArray<double,1> axis_value(count_write); 
     1118                axis_value = axis->value; 
    10961119 
    10971120                std::vector<StdSize> start(1), startBounds(2) ; 
    10981121                std::vector<StdSize> count(1), countBounds(2) ; 
    1099                 start[0] = startBounds[0] = zoom_begin_srv-axis->global_zoom_begin; 
    1100                 count[0] = countBounds[0] = zoom_size_srv; 
     1122                start[0] = startBounds[0] = start_write; 
     1123                count[0] = countBounds[0] = count_write; 
    11011124                startBounds[1] = 0; 
    11021125                countBounds[1] = 2; 
     
    11041127 
    11051128                if (!axis->bounds.isEmpty()) 
    1106                   SuperClassWriter::writeData(axis->bound_srv, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
     1129                  SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
    11071130 
    11081131                SuperClassWriter::definition_start(); 
     
    20642087              case (ONE_FILE) : 
    20652088              { 
     2089                // const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); 
     2090                // const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); 
     2091                // const std::vector<int>& nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer(); 
     2092 
     2093                // std::vector<StdSize> start, count; 
     2094 
     2095                // if (field->getUseCompressedOutput()) 
     2096                // { 
     2097                //   if (grid->isCompressible()) 
     2098                //   { 
     2099                //     start.push_back(grid->getOffsetWrittenIndexes()); 
     2100                //     count.push_back(grid->getNumberWrittenIndexes()); 
     2101                //   } 
     2102                //   else 
     2103                //   { 
     2104                //     CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
     2105                //     std::vector<StdString> domainList = grid->getDomainList(); 
     2106                //     std::vector<StdString> axisList   = grid->getAxisList(); 
     2107                //     int numElement = axisDomainOrder.numElements(); 
     2108                //     int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 
     2109                //     int idx = nZoomBeginGlobal.size() - 1; 
     2110 
     2111                //     start.reserve(nZoomBeginGlobal.size()); 
     2112                //     count.reserve(nZoomBeginGlobal.size()); 
     2113 
     2114 
     2115                //     for (int i = numElement - 1; i >= 0; --i) 
     2116                //     { 
     2117                //       if (2 == axisDomainOrder(i)) 
     2118                //       { 
     2119                //         CDomain* domain = CDomain::get(domainList[idxDomain]); 
     2120 
     2121                //         if (domain->isCompressible()) 
     2122                //         { 
     2123                //           start.push_back(domain->getOffsetWrittenIndexes()); 
     2124                //           count.push_back(domain->getNumberWrittenIndexes()); 
     2125                //           idx -= 2; 
     2126                //         } 
     2127                //         else 
     2128                //         { 
     2129                //           if ((domain->type) != CDomain::type_attr::unstructured) 
     2130                //           { 
     2131                //             start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     2132                //             count.push_back(nZoomSizeServer[idx]); 
     2133                //           } 
     2134                //           --idx; 
     2135                //           start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     2136                //           count.push_back(nZoomSizeServer[idx]); 
     2137                //           --idx; 
     2138                //         } 
     2139                //         --idxDomain; 
     2140                //       } 
     2141                //       else if (1 == axisDomainOrder(i)) 
     2142                //       { 
     2143                //         CAxis* axis = CAxis::get(axisList[idxAxis]); 
     2144 
     2145                //         if (axis->isCompressible()) 
     2146                //         { 
     2147                //           start.push_back(axis->getOffsetWrittenIndexes()); 
     2148                //           count.push_back(axis->getNumberWrittenIndexes()); 
     2149                //         } 
     2150                //         else 
     2151                //         { 
     2152                //           start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     2153                //           count.push_back(nZoomSizeServer[idx]); 
     2154                //         } 
     2155 
     2156                //         --idxAxis; 
     2157                //         --idx; 
     2158                //       } 
     2159                //     } 
     2160                //   } 
    20662161                const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); 
    20672162                const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); 
     
    21352230                      } 
    21362231                    } 
    2137                   } 
     2232                  }                 
    21382233                } 
    21392234                else 
    21402235                { 
    2141  
     2236                  // CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
     2237                  // std::vector<StdString> domainList = grid->getDomainList(); 
     2238                  // std::vector<StdString> axisList   = grid->getAxisList(); 
     2239                  // int numElement = axisDomainOrder.numElements(); 
     2240                  // int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 
     2241                  // int idx = nZoomBeginGlobal.size() - 1; 
     2242 
     2243                  // start.reserve(nZoomBeginGlobal.size()); 
     2244                  // count.reserve(nZoomBeginGlobal.size()); 
     2245 
     2246                  // for (int i = numElement - 1; i >= 0; --i) 
     2247                  // { 
     2248                  //   if (2 == axisDomainOrder(i)) 
     2249                  //   { 
     2250                  //     CDomain* domain = CDomain::get(domainList[idxDomain]); 
     2251                  //     if ((domain->type) != CDomain::type_attr::unstructured) 
     2252                  //     { 
     2253                  //       start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     2254                  //       count.push_back(nZoomSizeServer[idx]); 
     2255                  //     } 
     2256                  //     --idx ; 
     2257                  //     start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     2258                  //     count.push_back(nZoomSizeServer[idx]); 
     2259                  //     --idx ; 
     2260                  //     --idxDomain; 
     2261                  //   } 
     2262                  //   else if (1 == axisDomainOrder(i)) 
     2263                  //   { 
     2264                  //     start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     2265                  //     count.push_back(nZoomSizeServer[idx]); 
     2266                  //     --idx; 
     2267                  //   } 
     2268                  //   else 
     2269                  //   { 
     2270                  //     if (1 == axisDomainOrder.numElements()) 
     2271                  //     { 
     2272                  //       start.push_back(0); 
     2273                  //       count.push_back(1); 
     2274                  //     } 
     2275                  //     --idx; 
     2276                  //   } 
    21422277                  CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
    21432278                  std::vector<StdString> domainList = grid->getDomainList(); 
     
    21452280                  int numElement = axisDomainOrder.numElements(); 
    21462281                  int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 
    2147                   int idx = nZoomBeginGlobal.size() - 1; 
     2282                  int idx = domainList.size() * 2 + axisList.size() - 1;// nZoomBeginGlobal.size() - 1; 
    21482283 
    21492284                  start.reserve(nZoomBeginGlobal.size()); 
     
    21572292                      if ((domain->type) != CDomain::type_attr::unstructured) 
    21582293                      { 
    2159                         start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
    2160                         count.push_back(nZoomSizeServer[idx]); 
     2294                        // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     2295                        // count.push_back(nZoomSizeServer[idx]); 
     2296                        start.push_back((domain->getStartWriteIndex())[idx]); 
     2297                        count.push_back((domain->getCountWriteIndex())[idx]); 
    21612298                      } 
    21622299                      --idx ; 
    2163                       start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
    2164                       count.push_back(nZoomSizeServer[idx]); 
     2300                      // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     2301                      // count.push_back(nZoomSizeServer[idx]); 
     2302                      start.push_back((domain->getStartWriteIndex())[idx]); 
     2303                      count.push_back((domain->getCountWriteIndex())[idx]); 
    21652304                      --idx ; 
    21662305                      --idxDomain; 
     
    21682307                    else if (1 == axisDomainOrder(i)) 
    21692308                    { 
    2170                       start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
    2171                       count.push_back(nZoomSizeServer[idx]); 
     2309                      CAxis* axis = CAxis::get(axisList[idxAxis]); 
     2310                      start.push_back(axis->getStartWriteIndex()); 
     2311                      count.push_back(axis->getCountWriteIndex()); 
    21722312                      --idx; 
     2313                      --idxAxis; 
    21732314                    } 
    21742315                    else 
  • XIOS/dev/dev_olga/src/node/axis.cpp

    r1009 r1025  
    131131   } 
    132132 
     133   /*! 
     134     Returns the start of indexes written by each server. 
     135     \return the start of indexes written by each server 
     136   */ 
     137   int CAxis::getStartWriteIndex() const 
     138   { 
     139     return start_write_index_; 
     140   } 
     141 
     142   /*! 
     143     Returns the count of indexes written by each server. 
     144     \return the count of indexes written by each server 
     145   */ 
     146   int CAxis::getCountWriteIndex() const 
     147   { 
     148     return count_write_index_; 
     149   } 
     150 
     151   /*! 
     152     Returns the local data written by each server.      
     153   */ 
     154   int CAxis::getLocalWriteSize() const 
     155   { 
     156     return local_write_size_; 
     157   } 
     158 
     159   /*! 
     160     Returns the global data written by all server.      
     161   */ 
     162   int CAxis::getGlobalWriteSize() const 
     163   { 
     164     return global_write_size_; 
     165   } 
     166 
    133167   //---------------------------------------------------------------- 
    134168 
     
    166200     { 
    167201       // size estimation for sendDistributedValue 
    168        std::map<int, std::vector<size_t> >::const_iterator it, ite = indSrv_.end(); 
     202       boost::unordered_map<int, vector<size_t> >::const_iterator it, ite = indSrv_.end(); 
    169203       for (it = indSrv_.begin(); it != ite; ++it) 
    170204       { 
     
    292326     if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 
    293327     if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 
     328     if (zoom_index.isEmpty()) 
     329     { 
     330       zoom_index.setValue(index.getValue()); 
     331     } 
    294332   } 
    295333 
     
    342380        switch(event.type) 
    343381        { 
    344            case EVENT_ID_SERVER_ATTRIBUT : 
    345              recvServerAttribut(event); 
    346              return true; 
    347              break; 
    348            case EVENT_ID_INDEX: 
    349             recvIndex(event); 
     382           // case EVENT_ID_SERVER_ATTRIBUT : 
     383           //   recvServerAttribut(event); 
     384           //   return true; 
     385           //   break; 
     386          //  case EVENT_ID_INDEX: 
     387          //   recvIndex(event); 
     388          //   return true; 
     389          //   break; 
     390          case EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES: 
     391            recvNonDistributedAttributes(event); 
    350392            return true; 
    351393            break; 
    352           case EVENT_ID_DISTRIBUTED_VALUE: 
    353             recvDistributedValue(event); 
    354             return true; 
    355             break; 
    356           case EVENT_ID_NON_DISTRIBUTED_VALUE: 
    357             recvNonDistributedValue(event); 
     394          case EVENT_ID_DISTRIBUTED_ATTRIBUTES: 
     395            recvDistributedAttributes(event); 
    358396            return true; 
    359397            break; 
     
    383421     if (context->hasClient) 
    384422     { 
    385        if (n.getValue() != n_glo.getValue()) computeConnectedServer(globalDim, orderPositionInGrid, distType); 
     423       if (index.numElements() != n_glo.getValue()) computeConnectedServer(globalDim, orderPositionInGrid, distType); 
    386424     } 
    387425 
     
    398436 
    399437     if (this->isChecked) return; 
    400      if (context->hasClient) 
    401      { 
    402        sendServerAttribut(globalDim, orderPositionInGrid, distType); 
    403        if (hasValue) sendValue(); 
    404      } 
     438     if (context->hasClient) sendAttributes();     
    405439 
    406440     this->isChecked = true; 
    407441   } 
    408442 
    409   void CAxis::sendValue() 
    410   { 
    411      if (n.getValue() == n_glo.getValue()) 
    412        sendNonDistributedValue(); 
     443  void CAxis::sendAttributes() 
     444  { 
     445     if (index.numElements() == n_glo.getValue()) 
     446       sendNonDistributedAttributes(); 
    413447     else 
    414        sendDistributedValue(); 
     448       sendDistributedAttributes(); 
    415449  } 
    416450 
     
    419453  { 
    420454    CContext* context = CContext::getCurrent(); 
    421     CContextClient* client = context->client; 
     455    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    422456    int nbServer = client->serverSize; 
    423457    int range, clientSize = client->clientSize; 
    424458    int rank = client->clientRank; 
    425459 
    426     size_t ni = this->n.getValue(); 
    427     size_t ibegin = this->begin.getValue(); 
    428     size_t zoom_end = global_zoom_begin+global_zoom_n-1; 
    429     size_t nZoomCount = 0; 
     460    // size_t ni = this->n.getValue(); 
     461    // size_t ibegin = this->begin.getValue(); 
     462    // size_t zoom_end = global_zoom_begin+global_zoom_n-1; 
     463    // size_t nZoomCount = 0; 
    430464    size_t nbIndex = index.numElements(); 
    431465    for (size_t idx = 0; idx < nbIndex; ++idx) 
    432466    { 
    433       size_t globalIndex = index(idx); 
    434       if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 
    435     } 
    436  
    437     CArray<size_t,1> globalIndexAxis(nbIndex); 
    438     std::vector<size_t> globalAxisZoom(nZoomCount); 
    439     nZoomCount = 0; 
    440     for (size_t idx = 0; idx < nbIndex; ++idx) 
    441     { 
    442       size_t globalIndex = index(idx); 
    443       globalIndexAxis(idx) = globalIndex; 
    444       if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 
    445       { 
    446         globalAxisZoom[nZoomCount] = globalIndex; 
    447         ++nZoomCount; 
    448       } 
    449     } 
    450  
    451     std::set<int> writtenInd; 
    452     if (isCompressible_) 
    453     { 
    454       for (int idx = 0; idx < data_index.numElements(); ++idx) 
    455       { 
    456         int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
    457  
    458         if (ind >= 0 && ind < ni && mask(ind)) 
    459         { 
    460           ind += ibegin; 
    461           if (ind >= global_zoom_begin && ind <= zoom_end) 
    462             writtenInd.insert(ind); 
    463         } 
    464       } 
    465     } 
    466  
    467     CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer); 
     467      globalLocalIndexMap_[index(idx)] = idx; 
     468      // size_t globalIndex = index(idx); 
     469      // if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 
     470    } 
     471 
     472    // CArray<size_t,1> globalIndexAxis(nbIndex); 
     473    // std::vector<size_t> globalAxisZoom(nZoomCount); 
     474    // nZoomCount = 0; 
     475    // for (size_t idx = 0; idx < nbIndex; ++idx) 
     476    // { 
     477    //   size_t globalIndex = index(idx); 
     478    //   globalIndexAxis(idx) = globalIndex; 
     479    //   if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 
     480    //   { 
     481    //     globalAxisZoom[nZoomCount] = globalIndex; 
     482    //     ++nZoomCount; 
     483    //   } 
     484    // } 
     485 
     486    // std::set<int> writtenInd; 
     487    // if (isCompressible_) 
     488    // { 
     489    //   for (int idx = 0; idx < data_index.numElements(); ++idx) 
     490    //   { 
     491    //     int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
     492 
     493    //     if (ind >= 0 && ind < ni && mask(ind)) 
     494    //     { 
     495    //       ind += ibegin; 
     496    //       if (ind >= global_zoom_begin && ind <= zoom_end) 
     497    //         writtenInd.insert(ind); 
     498    //     } 
     499    //   } 
     500    // } 
     501 
     502    CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer, distType); 
    468503    int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 
    469504    CClientServerMapping::GlobalIndexMap globalIndexAxisOnServer; 
     
    493528      } 
    494529 
     530      CArray<size_t,1> globalIndex(index.numElements()); 
     531      for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
     532        globalIndex(idx) = index(idx); 
     533 
    495534      CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 
    496535      serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 
    497536      CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 
    498       clientServerMap->computeServerIndexMapping(globalIndexAxis); 
     537      clientServerMap->computeServerIndexMapping(globalIndex); 
    499538      globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 
    500539      delete clientServerMap; 
     
    514553    } 
    515554 
    516     CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 
    517                                                          ite = globalIndexAxisOnServer.end(); 
    518     std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 
    519                                         iteVec = (globalAxisZoom).end(); 
    520     indSrv_.clear(); 
    521     indWrittenSrv_.clear(); 
    522     for (; it != ite; ++it) 
    523     { 
    524       int rank = it->first; 
    525       const std::vector<size_t>& globalIndexTmp = it->second; 
    526       int nb = globalIndexTmp.size(); 
    527  
    528       for (int i = 0; i < nb; ++i) 
    529       { 
    530         if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 
    531         { 
    532           indSrv_[rank].push_back(globalIndexTmp[i]); 
    533         } 
    534  
    535         if (writtenInd.count(globalIndexTmp[i])) 
    536         { 
    537           indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 
    538         } 
    539       } 
    540     } 
     555    indSrv_.swap(globalIndexAxisOnServer); 
     556 
     557    // CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 
     558    //                                                      ite = globalIndexAxisOnServer.end(); 
     559    CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_.begin(), 
     560                                                         ite = indSrv_.end(); 
     561    // std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 
     562    //                                     iteVec = (globalAxisZoom).end(); 
     563    // indSrv_.clear(); 
     564    // indWrittenSrv_.clear(); 
     565    // for (; it != ite; ++it) 
     566    // { 
     567    //   int rank = it->first; 
     568    //   const std::vector<size_t>& globalIndexTmp = it->second; 
     569    //   int nb = globalIndexTmp.size(); 
     570 
     571    //   for (int i = 0; i < nb; ++i) 
     572    //   { 
     573    //     if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 
     574    //     { 
     575    //       indSrv_[rank].push_back(globalIndexTmp[i]); 
     576    //     } 
     577 
     578    //     if (writtenInd.count(globalIndexTmp[i])) 
     579    //     { 
     580    //       indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 
     581    //     } 
     582    //   } 
     583    // } 
    541584 
    542585    connectedServerRank_.clear(); 
    543     for (it = globalIndexAxisOnServer.begin(); it != ite; ++it) { 
     586    for (it = indSrv_.begin(); it != ite; ++it) { 
    544587      connectedServerRank_.push_back(it->first); 
    545588    } 
    546589 
    547     if (!indSrv_.empty()) 
    548     { 
    549       std::map<int, vector<size_t> >::const_iterator itIndSrv  = indSrv_.begin(), 
    550                                                      iteIndSrv = indSrv_.end(); 
    551       connectedServerRank_.clear(); 
    552       for (; itIndSrv != iteIndSrv; ++itIndSrv) 
    553         connectedServerRank_.push_back(itIndSrv->first); 
    554     } 
     590    // if (!indSrv_.empty()) 
     591    // { 
     592    //   std::map<int, vector<size_t> >::const_iterator itIndSrv  = indSrv_.begin(), 
     593    //                                                  iteIndSrv = indSrv_.end(); 
     594    //   connectedServerRank_.clear(); 
     595    //   for (; itIndSrv != iteIndSrv; ++itIndSrv) 
     596    //     connectedServerRank_.push_back(itIndSrv->first); 
     597    // } 
    555598    nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    556599  } 
    557600 
    558   void CAxis::sendNonDistributedValue() 
     601 
     602  // void CAxis::computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 
     603  //                                    CServerDistributionDescription::ServerDistributionType distType) 
     604  // { 
     605  //   CContext* context = CContext::getCurrent(); 
     606  //   CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
     607  //   int nbServer = client->serverSize; 
     608  //   int range, clientSize = client->clientSize; 
     609  //   int rank = client->clientRank; 
     610 
     611  //   size_t ni = this->n.getValue(); 
     612  //   size_t ibegin = this->begin.getValue(); 
     613  //   size_t zoom_end = global_zoom_begin+global_zoom_n-1; 
     614  //   size_t nZoomCount = 0; 
     615  //   size_t nbIndex = index.numElements(); 
     616  //   for (size_t idx = 0; idx < nbIndex; ++idx) 
     617  //   { 
     618  //     size_t globalIndex = index(idx); 
     619  //     if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 
     620  //   } 
     621 
     622  //   CArray<size_t,1> globalIndexAxis(nbIndex); 
     623  //   std::vector<size_t> globalAxisZoom(nZoomCount); 
     624  //   nZoomCount = 0; 
     625  //   for (size_t idx = 0; idx < nbIndex; ++idx) 
     626  //   { 
     627  //     size_t globalIndex = index(idx); 
     628  //     globalIndexAxis(idx) = globalIndex; 
     629  //     if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 
     630  //     { 
     631  //       globalAxisZoom[nZoomCount] = globalIndex; 
     632  //       ++nZoomCount; 
     633  //     } 
     634  //   } 
     635 
     636  //   std::set<int> writtenInd; 
     637  //   if (isCompressible_) 
     638  //   { 
     639  //     for (int idx = 0; idx < data_index.numElements(); ++idx) 
     640  //     { 
     641  //       int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
     642 
     643  //       if (ind >= 0 && ind < ni && mask(ind)) 
     644  //       { 
     645  //         ind += ibegin; 
     646  //         if (ind >= global_zoom_begin && ind <= zoom_end) 
     647  //           writtenInd.insert(ind); 
     648  //       } 
     649  //     } 
     650  //   } 
     651 
     652  //   CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer); 
     653  //   int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 
     654  //   CClientServerMapping::GlobalIndexMap globalIndexAxisOnServer; 
     655  //   if (distributedDimensionOnServer == orderPositionInGrid) // So we have distributed axis on client side and also on server side* 
     656  //   { 
     657  //     std::vector<int> nGlobAxis(1); 
     658  //     nGlobAxis[0] = n_glo.getValue(); 
     659 
     660  //     size_t globalSizeIndex = 1, indexBegin, indexEnd; 
     661  //     for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 
     662  //     indexBegin = 0; 
     663  //     if (globalSizeIndex <= clientSize) 
     664  //     { 
     665  //       indexBegin = rank%globalSizeIndex; 
     666  //       indexEnd = indexBegin; 
     667  //     } 
     668  //     else 
     669  //     { 
     670  //       for (int i = 0; i < clientSize; ++i) 
     671  //       { 
     672  //         range = globalSizeIndex / clientSize; 
     673  //         if (i < (globalSizeIndex%clientSize)) ++range; 
     674  //         if (i == client->clientRank) break; 
     675  //         indexBegin += range; 
     676  //       } 
     677  //       indexEnd = indexBegin + range - 1; 
     678  //     } 
     679 
     680  //     CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 
     681  //     serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 
     682  //     CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 
     683  //     clientServerMap->computeServerIndexMapping(globalIndexAxis); 
     684  //     globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 
     685  //     delete clientServerMap; 
     686  //   } 
     687  //   else 
     688  //   { 
     689  //     std::vector<size_t> globalIndexServer(n_glo.getValue()); 
     690  //     for (size_t idx = 0; idx < n_glo.getValue(); ++idx) 
     691  //     { 
     692  //       globalIndexServer[idx] = idx; 
     693  //     } 
     694 
     695  //     for (int idx = 0; idx < nbServer; ++idx) 
     696  //     { 
     697  //       globalIndexAxisOnServer[idx] = globalIndexServer; 
     698  //     } 
     699  //   } 
     700 
     701  //   CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 
     702  //                                                        ite = globalIndexAxisOnServer.end(); 
     703  //   std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 
     704  //                                       iteVec = (globalAxisZoom).end(); 
     705  //   indSrv_.clear(); 
     706  //   indWrittenSrv_.clear(); 
     707  //   for (; it != ite; ++it) 
     708  //   { 
     709  //     int rank = it->first; 
     710  //     const std::vector<size_t>& globalIndexTmp = it->second; 
     711  //     int nb = globalIndexTmp.size(); 
     712 
     713  //     for (int i = 0; i < nb; ++i) 
     714  //     { 
     715  //       if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 
     716  //       { 
     717  //         indSrv_[rank].push_back(globalIndexTmp[i]); 
     718  //       } 
     719 
     720  //       if (writtenInd.count(globalIndexTmp[i])) 
     721  //       { 
     722  //         indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 
     723  //       } 
     724  //     } 
     725  //   } 
     726 
     727  //   connectedServerRank_.clear(); 
     728  //   for (it = globalIndexAxisOnServer.begin(); it != ite; ++it) { 
     729  //     connectedServerRank_.push_back(it->first); 
     730  //   } 
     731 
     732  //   if (!indSrv_.empty()) 
     733  //   { 
     734  //     std::map<int, vector<size_t> >::const_iterator itIndSrv  = indSrv_.begin(), 
     735  //                                                    iteIndSrv = indSrv_.end(); 
     736  //     connectedServerRank_.clear(); 
     737  //     for (; itIndSrv != iteIndSrv; ++itIndSrv) 
     738  //       connectedServerRank_.push_back(itIndSrv->first); 
     739  //   } 
     740  //   nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
     741  // } 
     742 
     743  void CAxis::sendNonDistributedAttributes() 
    559744  { 
    560745    CContext* context = CContext::getCurrent(); 
    561     CContextClient* client = context->client; 
    562     CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_VALUE); 
    563  
    564     int zoom_end = global_zoom_begin + global_zoom_n - 1; 
    565     int nb = 0; 
    566     for (size_t idx = 0; idx < n; ++idx) 
    567     { 
    568       size_t globalIndex = begin + idx; 
    569       if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nb; 
    570     } 
    571  
    572     int nbWritten = 0; 
    573     if (isCompressible_) 
    574     { 
    575       for (int idx = 0; idx < data_index.numElements(); ++idx) 
    576       { 
    577         int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, n); 
    578  
    579         if (ind >= 0 && ind < n && mask(ind)) 
    580         { 
    581           ind += begin; 
    582           if (ind >= global_zoom_begin && ind <= zoom_end) 
    583             ++nbWritten; 
    584         } 
    585       } 
    586     } 
    587  
    588     CArray<double,1> val(nb); 
    589     nb = 0; 
    590     for (size_t idx = 0; idx < n; ++idx) 
    591     { 
    592       size_t globalIndex = begin + idx; 
    593       if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 
    594       { 
    595         val(nb) = value(idx); 
    596         ++nb; 
    597       } 
    598     } 
    599  
    600     CArray<int, 1> writtenInd(nbWritten); 
    601     nbWritten = 0; 
    602     if (isCompressible_) 
    603     { 
    604       for (int idx = 0; idx < data_index.numElements(); ++idx) 
    605       { 
    606         int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, n); 
    607  
    608         if (ind >= 0 && ind < n && mask(ind)) 
    609         { 
    610           ind += begin; 
    611           if (ind >= global_zoom_begin && ind <= zoom_end) 
    612           { 
    613             writtenInd(nbWritten) = ind; 
    614             ++nbWritten; 
    615           } 
    616         } 
    617       } 
     746    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
     747     
     748    CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); 
     749    size_t nbIndex = index.numElements(); 
     750    size_t nbDataIndex = 0; 
     751 
     752    for (int idx = 0; idx < data_index.numElements(); ++idx) 
     753    {       
     754      int ind = data_index(idx); 
     755      if (ind >= 0 && ind < nbIndex) ++nbDataIndex; 
     756    } 
     757 
     758    CArray<int,1> dataIndex(nbDataIndex); 
     759    nbDataIndex = 0; 
     760    for (int idx = 0; idx < data_index.numElements(); ++idx) 
     761    {       
     762      int ind = data_index(idx); 
     763      if (ind >= 0 && ind < nbIndex) 
     764      { 
     765        dataIndex(nbDataIndex) = ind; 
     766        ++nbDataIndex; 
     767      }  
    618768    } 
    619769 
    620770    if (client->isServerLeader()) 
    621     { 
     771    {  
    622772      std::list<CMessage> msgs; 
    623773 
     
    628778        CMessage& msg = msgs.back(); 
    629779        msg << this->getId(); 
    630         msg << val; 
    631         if (isCompressible_) 
    632           msg << writtenInd; 
     780        msg << index.getValue() << dataIndex << zoom_index.getValue() << mask.getValue(); 
     781        msg << hasValue; 
     782        if (hasValue) msg << value.getValue(); 
     783 
     784        msg << hasBounds_; 
     785        if (hasBounds_) msg << bounds.getValue(); 
     786         
    633787        event.push(*itRank, 1, msg); 
    634788      } 
     
    638792  } 
    639793 
    640   void CAxis::sendDistributedValue(void) 
     794  void CAxis::recvNonDistributedAttributes(CEventServer& event) 
     795  { 
     796    list<CEventServer::SSubEvent>::iterator it; 
     797    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     798    { 
     799      CBufferIn* buffer = it->buffer; 
     800      string axisId; 
     801      *buffer >> axisId; 
     802      get(axisId)->recvNonDistributedAttributes(it->rank, *buffer); 
     803    } 
     804  } 
     805 
     806  void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer) 
     807  {  
     808    CArray<int,1> tmp_index, tmp_data_index, tmp_zoom_index; 
     809    CArray<bool,1> tmp_mask; 
     810    CArray<double,1> tmp_val; 
     811    CArray<double,2> tmp_bnds; 
     812 
     813    buffer >> tmp_index; 
     814    index.reference(tmp_index); 
     815    buffer >> tmp_data_index; 
     816    data_index.reference(tmp_data_index); 
     817    buffer >> tmp_zoom_index; 
     818    zoom_index.reference(tmp_zoom_index); 
     819    buffer >> tmp_mask; 
     820    mask.reference(tmp_mask); 
     821    buffer >> hasValue; 
     822    if (hasValue) 
     823    { 
     824      buffer >> tmp_val; 
     825      value.reference(tmp_val); 
     826    } 
     827 
     828    buffer >> hasBounds_; 
     829    if (hasBounds_) 
     830    { 
     831      buffer >> tmp_bnds; 
     832      bounds.reference(tmp_bnds); 
     833    } 
     834 
     835    {       
     836      count_write_index_ = zoom_index.numElements();             
     837      start_write_index_ = 0; 
     838      local_write_size_ = count_write_index_; 
     839      global_write_size_ = count_write_index_; 
     840    } 
     841  } 
     842 
     843  void CAxis::sendDistributedAttributes(void) 
    641844  { 
    642845    int ns, n, i, j, ind, nv, idx; 
    643846    CContext* context = CContext::getCurrent(); 
    644     CContextClient* client=context->client; 
    645  
    646     // send value for each connected server 
    647     CEventClient eventIndex(getType(), EVENT_ID_INDEX); 
    648     CEventClient eventVal(getType(), EVENT_ID_DISTRIBUTED_VALUE); 
    649  
    650     list<CMessage> list_msgsIndex, list_msgsVal; 
    651     list<CArray<int,1> > list_indi; 
    652     list<CArray<int,1> > list_writtenInd; 
     847    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
     848 
     849    CEventClient eventData(getType(), EVENT_ID_DISTRIBUTED_ATTRIBUTES); 
     850     
     851    list<CMessage> listData; 
     852    list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd;     
     853    list<CArray<bool,1> > list_mask; 
    653854    list<CArray<double,1> > list_val; 
    654855    list<CArray<double,2> > list_bounds; 
    655856 
    656     std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     857    int nbIndex = index.numElements(); 
     858    CArray<int,1> dataIndex(nbIndex); 
     859    dataIndex = -1; 
     860    for (int idx = 0; idx < data_index.numElements(); ++idx) 
     861    { 
     862      if (0 <= data_index(idx) && data_index(idx) < nbIndex) 
     863        dataIndex(idx) = data_index(idx); 
     864    } 
     865 
     866    boost::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap; 
    657867    iteMap = indSrv_.end(); 
    658868    for (int k = 0; k < connectedServerRank_.size(); ++k) 
     
    660870      int nbData = 0; 
    661871      int rank = connectedServerRank_[k]; 
     872      int nbSendingClient = nbConnectedClients_[rank]; 
    662873      it = indSrv_.find(rank); 
    663874      if (iteMap != it) 
     
    665876 
    666877      list_indi.push_back(CArray<int,1>(nbData)); 
    667       list_val.push_back(CArray<double,1>(nbData)); 
     878      list_dataInd.push_back(CArray<int,1>(nbData)); 
     879      list_zoomInd.push_back(CArray<int,1>(nbData)); 
     880      list_mask.push_back(CArray<bool,1>(nbData)); 
     881 
     882 
     883      if (hasValue) 
     884        list_val.push_back(CArray<double,1>(nbData)); 
    668885 
    669886      if (hasBounds_) 
     
    673890 
    674891      CArray<int,1>& indi = list_indi.back(); 
    675       CArray<double,1>& val = list_val.back(); 
     892      CArray<int,1>& dataIndi = list_dataInd.back(); 
     893      CArray<int,1>& zoomIndi = list_zoomInd.back(); 
     894      CArray<bool,1>& maskIndi = list_mask.back();       
    676895 
    677896      for (n = 0; n < nbData; ++n) 
    678897      { 
    679898        idx = static_cast<int>(it->second[n]); 
    680         ind = idx - begin; 
    681  
    682         val(n) = value(ind); 
    683899        indi(n) = idx; 
     900 
     901        ind = globalLocalIndexMap_[idx]; 
     902        dataIndi(n) = dataIndex(ind); 
     903        maskIndi(n) = mask(ind); 
     904        zoomIndi(n) = zoom_index(ind);         
     905 
     906        if (hasValue) 
     907        { 
     908          CArray<double,1>& val = list_val.back(); 
     909          val(n) = value(ind); 
     910        } 
    684911 
    685912        if (hasBounds_) 
     
    691918      } 
    692919 
    693       list_msgsIndex.push_back(CMessage()); 
    694       list_msgsIndex.back() << this->getId() << list_indi.back(); 
    695  
    696       if (isCompressible_) 
    697       { 
    698         std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 
    699         list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 
    700         CArray<int,1>& writtenInd = list_writtenInd.back(); 
    701  
    702         for (n = 0; n < writtenInd.numElements(); ++n) 
    703           writtenInd(n) = writtenIndSrc[n]; 
    704  
    705         list_msgsIndex.back() << writtenInd; 
    706       } 
    707  
    708       list_msgsVal.push_back(CMessage()); 
    709       list_msgsVal.back() << this->getId() << list_val.back(); 
    710  
     920      listData.push_back(CMessage()); 
     921      listData.back() << this->getId()   
     922                      << list_indi.back() << list_dataInd.back() << list_zoomInd.back() << list_mask.back() 
     923                      << hasValue; 
     924      if (hasValue) 
     925        listData.back() << list_val.back(); 
     926      listData.back() << hasBounds_; 
    711927      if (hasBounds_) 
    712       { 
    713         list_msgsVal.back() << list_bounds.back(); 
    714       } 
    715  
    716       eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
    717       eventVal.push(rank, nbConnectedClients_[rank], list_msgsVal.back()); 
    718     } 
    719  
    720     client->sendEvent(eventIndex); 
    721     client->sendEvent(eventVal); 
    722   } 
    723  
    724   void CAxis::recvIndex(CEventServer& event) 
    725   { 
    726     CAxis* axis; 
     928        listData.back() << list_bounds.back(); 
     929 
     930      eventData.push(rank, nbConnectedClients_[rank], listData.back()); 
     931    } 
     932 
     933    client->sendEvent(eventData); 
     934  } 
     935 
     936  void CAxis::recvDistributedAttributes(CEventServer& event) 
     937  { 
     938    string axisId; 
     939    vector<int> ranks; 
     940    vector<CBufferIn*> buffers; 
    727941 
    728942    list<CEventServer::SSubEvent>::iterator it; 
    729943    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    730944    { 
     945      ranks.push_back(it->rank); 
    731946      CBufferIn* buffer = it->buffer; 
    732       string axisId; 
    733947      *buffer >> axisId; 
    734       axis = get(axisId); 
    735       axis->recvIndex(it->rank, *buffer); 
    736     } 
    737  
    738     if (axis->isCompressible_) 
    739     { 
    740       std::sort(axis->indexesToWrite.begin(), axis->indexesToWrite.end()); 
    741  
     948      buffers.push_back(buffer); 
     949    } 
     950    get(axisId)->recvDistributedAttributes(ranks, buffers); 
     951  } 
     952 
     953  void CAxis::recvDistributedAttributes(vector<int>& ranks, vector<CBufferIn*> buffers) 
     954  { 
     955    int nbReceived = ranks.size(); 
     956    vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived), vec_zoomInd(nbReceived);     
     957    vector<CArray<bool,1> > vec_mask(nbReceived); 
     958    vector<CArray<double,1> > vec_val(nbReceived); 
     959    vector<CArray<double,2> > vec_bounds(nbReceived); 
     960     
     961    for (int idx = 0; idx < nbReceived; ++idx) 
     962    {       
     963      CBufferIn& buffer = *buffers[idx]; 
     964      buffer >> vec_indi[idx]; 
     965      buffer >> vec_dataInd[idx]; 
     966      buffer >> vec_zoomInd[idx]; 
     967      buffer >> vec_mask[idx]; 
     968 
     969      buffer >> hasValue; 
     970      if (hasValue) 
     971        buffer >> vec_val[idx]; 
     972      buffer >> hasBounds_; 
     973      if (hasBounds_) 
     974        buffer >> vec_bounds[idx]; 
     975    } 
     976 
     977    int nbData = 0; 
     978    for (int idx = 0; idx < nbReceived; ++idx) 
     979    { 
     980      nbData += vec_indi[idx].numElements(); 
     981    } 
     982     
     983    index.resize(nbData); 
     984    CArray<int,1> nonCompressedData(nbData);     
     985    mask.resize(nbData); 
     986    if (hasValue) 
     987      value.resize(nbData); 
     988    if (hasBounds_) 
     989      bounds.resize(2,nbData); 
     990 
     991    nbData = 0; 
     992    for (int idx = 0; idx < nbReceived; ++idx) 
     993    { 
     994      CArray<int,1>& indi = vec_indi[idx]; 
     995      CArray<int,1>& dataIndi = vec_dataInd[idx]; 
     996      CArray<bool,1>& maskIndi = vec_mask[idx]; 
     997      int nb = indi.numElements(); 
     998      for (int n = 0; n < nb; ++n) 
     999      { 
     1000        index(nbData) = indi(n); 
     1001        nonCompressedData(nbData) = (0 <= dataIndi(n)) ? nbData : -1; 
     1002        mask(nbData) = maskIndi(n); 
     1003        if (hasValue) 
     1004          value(nbData) = vec_val[idx](n); 
     1005        if (hasBounds_) 
     1006        { 
     1007          bounds(0,nbData) = vec_bounds[idx](0,n); 
     1008          bounds(1,nbData) = vec_bounds[idx](1,n); 
     1009        } 
     1010        ++nbData; 
     1011      } 
     1012    } 
     1013 
     1014    int nbIndex = index.numElements(); 
     1015    int nbCompressedData = 0;  
     1016    for (int idx = 0; idx < nonCompressedData.numElements(); ++idx) 
     1017    { 
     1018      if (0 <= nonCompressedData(idx) && nonCompressedData(idx) < nbIndex) 
     1019        ++nbCompressedData;         
     1020    } 
     1021 
     1022    data_index.resize(nbCompressedData); 
     1023    nbCompressedData = 0; 
     1024    for (int idx = 0; idx < nonCompressedData.numElements(); ++idx) 
     1025    { 
     1026      if (0 <= nonCompressedData(idx) && nonCompressedData(idx) < nbIndex) 
     1027      { 
     1028        data_index(nbCompressedData) = nonCompressedData(idx); 
     1029        ++nbCompressedData;         
     1030      } 
     1031    } 
     1032 
     1033    int nbZoomIndex = 0; 
     1034    for (int idx = 0; idx < nbReceived; ++idx) 
     1035    { 
     1036      nbZoomIndex += vec_zoomInd[idx].numElements(); 
     1037    } 
     1038 
     1039    zoom_index.resize(nbZoomIndex); 
     1040    nbZoomIndex = 0; 
     1041    CArray<int,1>& zoom_Index_Tmp = this->zoom_index; 
     1042    for (int idx = 0; idx < nbReceived; ++idx) 
     1043    {       
     1044      CArray<int,1> tmp = zoom_Index_Tmp(Range(nbZoomIndex, nbZoomIndex + vec_zoomInd[idx].numElements()-1)); 
     1045      tmp = vec_zoomInd[idx]; 
     1046 
     1047      nbZoomIndex += vec_zoomInd[idx].numElements(); 
     1048    } 
     1049 
     1050 
     1051    { 
    7421052      CContextServer* server = CContext::getCurrent()->server; 
    743       axis->numberWrittenIndexes_ = axis->indexesToWrite.size(); 
    744       MPI_Allreduce(&axis->numberWrittenIndexes_, &axis->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    745       MPI_Scan(&axis->numberWrittenIndexes_, &axis->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    746       axis->offsetWrittenIndexes_ -= axis->numberWrittenIndexes_; 
    747     } 
    748   } 
    749  
    750   void CAxis::recvIndex(int rank, CBufferIn& buffer) 
    751   { 
    752     buffer >> indiSrv_[rank]; 
    753  
    754     if (isCompressible_) 
    755     { 
    756       CArray<int, 1> writtenIndexes; 
    757       buffer >> writtenIndexes; 
    758       indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 
    759       for (int i = 0; i < writtenIndexes.numElements(); ++i) 
    760         indexesToWrite.push_back(writtenIndexes(i)); 
    761     } 
    762   } 
    763  
    764   void CAxis::recvDistributedValue(CEventServer& event) 
    765   { 
    766     list<CEventServer::SSubEvent>::iterator it; 
    767     for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    768     { 
    769       CBufferIn* buffer = it->buffer; 
    770       string axisId; 
    771       *buffer >> axisId; 
    772       get(axisId)->recvDistributedValue(it->rank, *buffer); 
    773     } 
    774   } 
    775  
    776   void CAxis::recvDistributedValue(int rank, CBufferIn& buffer) 
    777   { 
    778     CArray<int,1> &indi = indiSrv_[rank]; 
    779     CArray<double,1> val; 
    780     CArray<double,2> boundsVal; 
    781  
    782     buffer >> val; 
    783     if (hasBounds_) buffer >> boundsVal; 
    784  
    785     int i, j, ind_srv; 
    786     for (int ind = 0; ind < indi.numElements(); ++ind) 
    787     { 
    788       i = indi(ind); 
    789       ind_srv = i - zoom_begin_srv; 
    790       value_srv(ind_srv) = val(ind); 
    791       if (hasBounds_) 
    792       { 
    793         bound_srv(0,ind_srv) = boundsVal(0, ind); 
    794         bound_srv(1,ind_srv) = boundsVal(1, ind); 
    795       } 
    796     } 
    797   } 
    798  
    799    void CAxis::recvNonDistributedValue(CEventServer& event) 
    800   { 
    801     CAxis* axis; 
    802  
    803     list<CEventServer::SSubEvent>::iterator it; 
    804     for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    805     { 
    806       CBufferIn* buffer = it->buffer; 
    807       string axisId; 
    808       *buffer >> axisId; 
    809       axis = get(axisId); 
    810       axis->recvNonDistributedValue(it->rank, *buffer); 
    811     } 
    812  
    813     if (axis->isCompressible_) 
    814     { 
    815       std::sort(axis->indexesToWrite.begin(), axis->indexesToWrite.end()); 
    816  
    817       axis->numberWrittenIndexes_ = axis->totalNumberWrittenIndexes_ = axis->indexesToWrite.size(); 
    818       axis->offsetWrittenIndexes_ = 0; 
    819     } 
    820   } 
    821  
    822   void CAxis::recvNonDistributedValue(int rank, CBufferIn& buffer) 
    823   { 
    824     CArray<double,1> val; 
    825     buffer >> val; 
    826  
    827     for (int ind = 0; ind < val.numElements(); ++ind) 
    828     { 
    829       value_srv(ind) = val(ind); 
    830       if (hasBounds_) 
    831       { 
    832         bound_srv(0,ind) = bounds(0,ind); 
    833         bound_srv(1,ind) = bounds(1,ind); 
    834       } 
    835     } 
    836  
    837     if (isCompressible_) 
    838     { 
    839       CArray<int, 1> writtenIndexes; 
    840       buffer >> writtenIndexes; 
    841       indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 
    842       for (int i = 0; i < writtenIndexes.numElements(); ++i) 
    843         indexesToWrite.push_back(writtenIndexes(i)); 
     1053      count_write_index_ = zoom_index.numElements();       
     1054      MPI_Scan(&count_write_index_, &start_write_index_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     1055      global_write_size_ = start_write_index_; 
     1056      start_write_index_ -= count_write_index_; 
     1057      local_write_size_ = count_write_index_;       
    8441058    } 
    8451059  } 
     
    8491063  // { 
    8501064  //   CContext* context = CContext::getCurrent(); 
    851   //   CContextClient* client = context->client; 
    852   //   int nbServer = client->serverSize; 
     1065 
     1066  //   CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer  
     1067  //                                                                       : context->client; 
     1068 
     1069     
     1070  //   int nbServer = contextClientTmp->serverSize; 
    8531071 
    8541072  //   CServerDistributionDescription serverDescription(globalDim, nbServer); 
     
    8581076  //   std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
    8591077 
     1078  //   globalDimGrid.resize(globalDim.size()); 
     1079  //   for (int idx = 0; idx < globalDim.size(); ++idx) globalDimGrid(idx) = globalDim[idx]; 
     1080 
    8601081  //   CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 
    861   //   if (client->isServerLeader()) 
     1082  //   if (contextClientTmp->isServerLeader()) 
    8621083  //   { 
    8631084  //     std::list<CMessage> msgs; 
    8641085 
    865   //     const std::list<int>& ranks = client->getRanksServerLeader(); 
     1086  //     const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
    8661087  //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    8671088  //     { 
     
    8771098  //       msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 
    8781099  //       msg << isCompressible_; 
     1100  //       msg << orderPositionInGrid; 
     1101  //       msg << globalDimGrid; 
    8791102 
    8801103  //       event.push(*itRank,1,msg); 
    8811104  //     } 
    882   //     client->sendEvent(event); 
     1105  //     contextClientTmp->sendEvent(event); 
    8831106  //   } 
    884   //   else client->sendEvent(event); 
     1107  //   else contextClientTmp->sendEvent(event); 
    8851108  // } 
    8861109 
    887   void CAxis::sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, 
    888                                  CServerDistributionDescription::ServerDistributionType distType) 
    889   { 
    890     CContext* context = CContext::getCurrent(); 
    891     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    892     for (int i = 0; i < nbSrvPools; ++i) 
     1110  // void CAxis::recvServerAttribut(CEventServer& event) 
     1111  // { 
     1112  //   CBufferIn* buffer = event.subEvents.begin()->buffer; 
     1113  //   string axisId; 
     1114  //   *buffer >> axisId; 
     1115  //   get(axisId)->recvServerAttribut(*buffer); 
    8931116    { 
    8941117      CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] 
    895                                                                           : context->client; 
    896       int nbServer = contextClientTmp->serverSize; 
    897  
    898       CServerDistributionDescription serverDescription(globalDim, nbServer); 
    899       serverDescription.computeServerDistribution(); 
    900  
    901       std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
    902       std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
    903  
    904       globalDimGrid.resize(globalDim.size()); 
    905       for (int idx = 0; idx < globalDim.size(); ++idx) globalDimGrid(idx) = globalDim[idx]; 
    906  
    907       CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 
    908       if (contextClientTmp->isServerLeader()) 
    909       { 
    910         std::list<CMessage> msgs; 
    911  
    912         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
    913         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    914         { 
    915           // Use const int to ensure CMessage holds a copy of the value instead of just a reference 
    916           const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 
    917           const int ni    = serverDimensionSizes[*itRank][orderPositionInGrid]; 
    918           const int end   = begin + ni - 1; 
    919  
    920           msgs.push_back(CMessage()); 
    921           CMessage& msg = msgs.back(); 
    922           msg << this->getId(); 
    923           msg << ni << begin << end; 
    924           msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 
    925           msg << isCompressible_; 
    926           msg << orderPositionInGrid; 
    927           msg << globalDimGrid; 
    928  
    929           event.push(*itRank,1,msg); 
    930         } 
    931         contextClientTmp->sendEvent(event); 
    932       } 
    933       else contextClientTmp->sendEvent(event); 
    934     } 
    935   } 
    936  
    937   void CAxis::recvServerAttribut(CEventServer& event) 
    938   { 
    939     CBufferIn* buffer = event.subEvents.begin()->buffer; 
    940     string axisId; 
    941     *buffer >> axisId; 
    942     get(axisId)->recvServerAttribut(*buffer); 
    943  
    944     CContext* context = CContext::getCurrent(); 
    945     if (context->hasClient && context->hasServer) 
    946     { 
    947       std::vector<int> globalDim(get(axisId)->globalDimGrid.numElements()); 
    948       for (int idx = 0; idx < globalDim.size(); ++idx) globalDim[idx] = get(axisId)->globalDimGrid(idx); 
    949       get(axisId)->sendServerAttribut(globalDim, get(axisId)->orderPosInGrid,  
    950                                       CServerDistributionDescription::BAND_DISTRIBUTION); 
    951     } 
    952   } 
    953  
    954   void CAxis::recvServerAttribut(CBufferIn& buffer) 
    955   { 
    956     int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_n_tmp; 
    957  
    958     buffer >> ni_srv >> begin_srv >> end_srv; 
    959     buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp; 
    960     buffer >> isCompressible_; 
    961     buffer >> orderPosInGrid; 
    962     buffer >> globalDimGrid; 
    963  
    964     global_zoom_begin = global_zoom_begin_tmp; 
    965     global_zoom_n  = global_zoom_n_tmp; 
    966     int global_zoom_end = global_zoom_begin + global_zoom_n - 1; 
    967  
    968     zoom_begin_srv = global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
    969     zoom_end_srv   = global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
    970     zoom_size_srv  = zoom_end_srv - zoom_begin_srv + 1; 
    971  
    972     if (zoom_size_srv<=0) 
    973     { 
    974       zoom_begin_srv = 0; zoom_end_srv = 0; zoom_size_srv = 0; 
    975     } 
    976  
    977     if (n_glo == n) 
    978     { 
    979       zoom_begin_srv = global_zoom_begin; 
    980       zoom_end_srv   = global_zoom_end; //zoom_end; 
    981       zoom_size_srv  = zoom_end_srv - zoom_begin_srv + 1; 
    982     } 
    983     if (hasValue) 
    984     { 
    985       value_srv.resize(zoom_size_srv); 
    986       if (hasBounds_)  bound_srv.resize(2,zoom_size_srv); 
    987     } 
    988   } 
     1118    } 
     1119 
     1120  //   CContext* context = CContext::getCurrent(); 
     1121  //   if (context->hasClient && context->hasServer) 
     1122  //   { 
     1123  //     std::vector<int> globalDim(get(axisId)->globalDimGrid.numElements()); 
     1124  //     for (int idx = 0; idx < globalDim.size(); ++idx) globalDim[idx] = get(axisId)->globalDimGrid(idx); 
     1125  //     get(axisId)->sendServerAttribut(globalDim, get(axisId)->orderPosInGrid,  
     1126  //                                     CServerDistributionDescription::BAND_DISTRIBUTION); 
     1127  //   } 
     1128  // } 
     1129 
     1130  // void CAxis::recvServerAttribut(CBufferIn& buffer) 
     1131  // { 
     1132  //   int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_n_tmp; 
     1133 
     1134  //   buffer >> ni_srv >> begin_srv >> end_srv; 
     1135  //   buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp; 
     1136  //   buffer >> isCompressible_; 
     1137  //   buffer >> orderPosInGrid; 
     1138  //   buffer >> globalDimGrid; 
     1139 
     1140  //   global_zoom_begin = global_zoom_begin_tmp; 
     1141  //   global_zoom_n  = global_zoom_n_tmp; 
     1142  //   int global_zoom_end = global_zoom_begin + global_zoom_n - 1; 
     1143 
     1144  //   zoom_begin_srv = global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
     1145  //   zoom_end_srv   = global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
     1146  //   zoom_size_srv  = zoom_end_srv - zoom_begin_srv + 1; 
     1147 
     1148  //   if (zoom_size_srv<=0) 
     1149  //   { 
     1150  //     zoom_begin_srv = 0; zoom_end_srv = 0; zoom_size_srv = 0; 
     1151  //   } 
     1152 
     1153  //   if (n_glo == n) 
     1154  //   { 
     1155  //     zoom_begin_srv = global_zoom_begin; 
     1156  //     zoom_end_srv   = global_zoom_end; //zoom_end; 
     1157  //     zoom_size_srv  = zoom_end_srv - zoom_begin_srv + 1; 
     1158  //   } 
     1159  //   if (hasValue) 
     1160  //   { 
     1161  //     value_srv.resize(zoom_size_srv); 
     1162  //     if (hasBounds_)  bound_srv.resize(2,zoom_size_srv); 
     1163  //   } 
     1164  // } 
    9891165 
    9901166  CTransformation<CAxis>* CAxis::addTransformation(ETranformationType transType, const StdString& id) 
     
    10071183  { 
    10081184    return transformationMap_; 
    1009   } 
    1010  
    1011   /*! 
    1012     Check the validity of all transformations applied on axis 
    1013   This functions is called AFTER all inherited attributes are solved 
    1014   */ 
    1015   void CAxis::checkTransformations() 
    1016   { 
    1017     TransMapTypes::const_iterator itb = transformationMap_.begin(), it, 
    1018                                   ite = transformationMap_.end(); 
    1019 //    for (it = itb; it != ite; ++it) 
    1020 //    { 
    1021 //      (it->second)->checkValid(this); 
    1022 //    } 
    10231185  } 
    10241186 
  • XIOS/dev/dev_olga/src/node/axis.hpp

    r987 r1025  
    4848           EVENT_ID_INDEX, 
    4949           EVENT_ID_DISTRIBUTED_VALUE, 
    50            EVENT_ID_NON_DISTRIBUTED_VALUE 
     50           EVENT_ID_NON_DISTRIBUTED_VALUE, 
     51           EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES, 
     52           EVENT_ID_DISTRIBUTED_ATTRIBUTES 
    5153         } ; 
    5254 
     
    7678         int getOffsetWrittenIndexes() const; 
    7779 
     80         int getStartWriteIndex() const; 
     81         int getCountWriteIndex() const; 
     82         int getLocalWriteSize() const; 
     83         int getGlobalWriteSize() const; 
     84 
    7885         std::map<int, StdSize> getAttributesBufferSize(); 
    7986 
     
    101108         static ENodeType GetType(void); 
    102109 
    103          void sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, 
    104                                  CServerDistributionDescription::ServerDistributionType distType); 
     110         // void sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, 
     111         //                         CServerDistributionDescription::ServerDistributionType distType); 
    105112         static bool dispatchEvent(CEventServer& event); 
    106113         static void recvServerAttribut(CEventServer& event); 
    107          void recvServerAttribut(CBufferIn& buffer) ; 
     114         // void recvServerAttribut(CBufferIn& buffer) ; 
    108115         void checkAttributesOnClient(); 
    109116         void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, 
     
    134141         void checkMask(); 
    135142         void checkZoom(); 
    136          void checkBounds(); 
    137          void checkTransformations(); 
    138          void sendValue(); 
     143         void checkBounds();          
     144         void sendAttributes(); 
    139145         void computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 
    140146                                     CServerDistributionDescription::ServerDistributionType distType); 
    141          void sendDistributedValue(); 
    142          void sendNonDistributedValue(); 
    143147 
    144          static void recvIndex(CEventServer& event); 
    145          static void recvDistributedValue(CEventServer& event); 
    146          static void recvNonDistributedValue(CEventServer& event); 
    147          void recvIndex(int rank, CBufferIn& buffer); 
    148          void recvDistributedValue(int rank, CBufferIn& buffer); 
    149          void recvNonDistributedValue(int rank, CBufferIn& buffer); 
     148         void sendNonDistributedAttributes(void); 
     149         void sendDistributedAttributes(void); 
     150 
     151         static void recvNonDistributedAttributes(CEventServer& event); 
     152         static void recvDistributedAttributes(CEventServer& event); 
     153         void recvNonDistributedAttributes(int rank, CBufferIn& buffer); 
     154         void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers); 
    150155 
    151156         void setTransformations(const TransMapTypes&); 
     
    161166         bool isCompressible_; 
    162167         std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 
    163          std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 
     168         boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 
    164169         std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 
     170         boost::unordered_map<size_t,size_t> globalLocalIndexMap_; 
    165171         std::vector<int> indexesToWrite; 
    166172         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 
     
    168174         std::map<int, CArray<int,1> > indiSrv_; 
    169175         bool hasBounds_; 
     176 
     177         int start_write_index_; 
     178         int count_write_index_; 
     179         int local_write_size_; 
     180         int global_write_size_; 
    170181 
    171182       private: 
  • XIOS/dev/dev_olga/src/node/context.cpp

    r1021 r1025  
    2929      , idServer_(), client(0), server(0) 
    3030//        , clientPrimServer(0), serverPrimServer(0) 
     31      , allProcessed(false) 
    3132   { /* Ne rien faire de plus */ } 
    3233 
     
    3738      , idServer_(), client(0), server(0) 
    3839//        , clientPrimServer(0), serverPrimServer(0) 
     40      , allProcessed(false) 
    3941   { /* Ne rien faire de plus */ } 
    4042 
     
    475477   } 
    476478 
     479 
     480   void CContext::postProcessingGlobalAttributes() 
     481   { 
     482     if (allProcessed) return; 
     483      
     484     if (hasClient) 
     485     { 
     486       // After xml is parsed, there are some more works with post processing 
     487       postProcessing(); 
     488     } 
     489 
     490     setClientServerBuffer(); 
     491 
     492     if (hasClient) 
     493     { 
     494      // Send all attributes of current context to server 
     495      this->sendAllAttributesToServer(); 
     496 
     497      // Send all attributes of current calendar 
     498      CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 
     499 
     500      // We have enough information to send to server 
     501      // First of all, send all enabled files 
     502      sendEnabledFiles(); 
     503 
     504      // Then, send all enabled fields 
     505      sendEnabledFields(); 
     506 
     507      // At last, we have all info of domain and axis, then send them 
     508       sendRefDomainsAxis(); 
     509 
     510       // After that, send all grid (if any) 
     511       sendRefGrid(); 
     512 
     513       // We have a xml tree on the server side and now, it should be also processed 
     514       sendPostProcessing(); 
     515     } 
     516     allProcessed = true; 
     517   } 
     518 
     519   void CContext::sendPostProcessingGlobalAttributes() 
     520   { 
     521         // Use correct context client to send message 
     522     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client; 
     523     CEventClient event(getType(),EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES); 
     524 
     525     if (contextClientTmp->isServerLeader()) 
     526     { 
     527       CMessage msg; 
     528       msg<<this->getIdServer(); 
     529       const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     530       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     531         event.push(*itRank,1,msg); 
     532       contextClientTmp->sendEvent(event); 
     533     } 
     534     else contextClientTmp->sendEvent(event); 
     535   } 
     536 
     537   void CContext::recvPostProcessingGlobalAttributes(CEventServer& event) 
     538   { 
     539      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     540      string id; 
     541      *buffer>>id; 
     542      // get(id)->recvPostProcessingGlobalAttributes(*buffer); 
     543   } 
     544 
     545   void CContext::recvPostProcessingGlobalAttributes(CBufferIn& buffer) 
     546   { 
     547      // CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar(); 
     548      postProcessingGlobalAttributes(); 
     549   } 
     550 
    477551   /*! 
    478552   \brief Close all the context defintion and do processing data 
     
    487561   { 
    488562     // There is nothing client need to send to server 
    489      if (hasClient) 
    490      { 
    491        // After xml is parsed, there are some more works with post processing 
    492        postProcessing(); 
    493      } 
    494  
    495      setClientServerBuffer(); 
    496  
    497      if (hasClient) 
    498      { 
    499       // Send all attributes of current context to server 
    500       this->sendAllAttributesToServer(); 
    501  
    502       // Send all attributes of current calendar 
    503       CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 
    504  
    505       // We have enough information to send to server 
    506       // First of all, send all enabled files 
    507       sendEnabledFiles(); 
    508  
    509       // Then, send all enabled fields 
    510       sendEnabledFields(); 
    511  
    512       // At last, we have all info of domain and axis, then send them 
    513        sendRefDomainsAxis(); 
    514  
    515        // After that, send all grid (if any) 
    516        sendRefGrid(); 
    517  
    518        // We have a xml tree on the server side and now, it should be also processed 
    519        sendPostProcessing(); 
    520      } 
     563//      if (hasClient) 
     564//     if (hasClient && !hasServer) 
     565//      if (hasClient) 
     566//      { 
     567//        // After xml is parsed, there are some more works with post processing 
     568//        postProcessing(); 
     569//      } 
     570 
     571//      setClientServerBuffer(); 
     572 
     573// //     if (hasClient && !hasServer) 
     574//      if (hasClient) 
     575//      { 
     576//       // Send all attributes of current context to server 
     577//       this->sendAllAttributesToServer(); 
     578 
     579//       // Send all attributes of current calendar 
     580//       CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 
     581 
     582//       // We have enough information to send to server 
     583//       // First of all, send all enabled files 
     584//        sendEnabledFiles(); 
     585 
     586//       // Then, send all enabled fields 
     587//        sendEnabledFields(); 
     588 
     589//       // At last, we have all info of domain and axis, then send them 
     590//        sendRefDomainsAxis(); 
     591 
     592//       // After that, send all grid (if any) 
     593//        sendRefGrid(); 
     594 
     595//        // // We have a xml tree on the server side and now, it should be also processed 
     596//        sendPostProcessing(); 
     597//      } 
    521598 
    522599 
    523600     // Now tell server that it can process all messages from client 
    524      if (hasClient) this->sendCloseDefinition(); 
     601     // if (hasClient) this->sendCloseDefinition(); 
     602    postProcessingGlobalAttributes(); 
     603 
     604    if (hasClient) sendPostProcessingGlobalAttributes(); 
    525605 
    526606    // There are some processings that should be done after all of above. For example: check mask or index 
     607    this->buildFilterGraphOfEnabledFields(); 
     608     
    527609     if (hasClient && !hasServer) 
    528610    { 
    529       this->buildFilterGraphOfEnabledFields();  // references are resolved here (access xml file) 
     611      // this->buildFilterGraphOfEnabledFields();  // references are resolved here (access xml file) 
    530612      buildFilterGraphOfFieldsWithReadAccess(); 
    531       this->solveAllRefOfEnabledFields(true); 
     613      // this->solveAllRefOfEnabledFields(true); 
    532614    } 
    533615 
     616    // if (hasClient) this->solveAllRefOfEnabledFields(true); 
     617    this->processGridEnabledFields(); 
     618    if (hasClient) this->sendProcessingGridOfEnabledFields(); 
     619    // if (hasClient)        // We have a xml tree on the server side and now, it should be also processed 
     620    //    sendPostProcessing(); 
    534621//    // Now tell server that it can process all messages from client 
    535622////    if (hasClient && !hasServer) this->sendCloseDefinition(); 
    536 //    if (hasClient) this->sendCloseDefinition(); 
     623   if (hasClient) this->sendCloseDefinition(); 
    537624 
    538625    // Nettoyage de l'arborescence 
     
    564651        (void)this->enabledReadModeFiles[i]->readAttributesOfEnabledFieldsInReadMode(); 
    565652   } 
     653 
     654   void CContext::solveAllEnabledFields() 
     655   { 
     656     int size = this->enabledFiles.size(); 
     657     for (int i = 0; i < size; ++i) 
     658     { 
     659       this->enabledFiles[i]->solveOnlyRefOfEnabledFields(false); 
     660     } 
     661 
     662     for (int i = 0; i < size; ++i) 
     663     { 
     664       this->enabledFiles[i]->generateNewTransformationGridDest(); 
     665     } 
     666   } 
     667 
     668   void CContext::processGridEnabledFields() 
     669   { 
     670     int size = this->enabledFiles.size(); 
     671     for (int i = 0; i < size; ++i) 
     672     { 
     673       this->enabledFiles[i]->checkGridOfEnabledFields(); 
     674       this->enabledFiles[i]->sendGridOfEnabledFields(); 
     675     } 
     676   } 
     677 
     678 
    566679 
    567680   void CContext::solveOnlyRefOfEnabledFields(bool sendToServer) 
     
    754867             recvRegistry(event); 
    755868             return true; 
    756             break; 
    757  
     869             break; 
     870            case EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES: 
     871             recvPostProcessingGlobalAttributes(event); 
     872             return true; 
     873             break; 
     874            case EVENT_ID_PROCESS_GRID_ENABLED_FIELDS: 
     875             recvProcessingGridOfEnabledFields(event); 
     876             return true; 
     877             break; 
    758878           default : 
    759879             ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
     
    802922      *buffer>>id; 
    803923      get(id)->closeDefinition(); 
    804       if (get(id)->hasClient && get(id)->hasServer) 
    805       {         
    806         get(id)->sendCloseDefinition(); 
    807       } 
     924      // if (get(id)->hasClient && get(id)->hasServer) 
     925      // {         
     926      //   get(id)->sendCloseDefinition(); 
     927      // } 
    808928   } 
    809929 
     
    833953         else contextClientTmp->sendEvent(event); 
    834954     } 
    835  
    836      // if (!hasServer) 
    837      // { 
    838      //   if (client->isServerLeader()) 
    839      //   { 
    840      //     CMessage msg; 
    841      //     msg<<this->getIdServer()<<step; 
    842      //     const std::list<int>& ranks = client->getRanksServerLeader(); 
    843      //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    844      //       event.push(*itRank,1,msg); 
    845      //     client->sendEvent(event); 
    846      //   } 
    847      //   else client->sendEvent(event); 
    848      // } 
    849      // else 
    850      // { 
    851      //   if (clientPrimServer->isServerLeader()) 
    852      //   { 
    853      //     CMessage msg; 
    854      //     msg<<this->getIdServer()<<step; 
    855      //     const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
    856      //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    857      //       event.push(*itRank,1,msg); 
    858      //     clientPrimServer->sendEvent(event); 
    859      //   } 
    860      //   else clientPrimServer->sendEvent(event); 
    861      // } 
    862955   } 
    863956 
     
    9071000       else contextClientTmp->sendEvent(event); 
    9081001     } 
    909      // if (!hasServer) 
    910      // { 
    911      //   if (client->isServerLeader()) 
    912      //   { 
    913      //     CMessage msg; 
    914      //     msg<<this->getIdServer(); 
    915      //     const std::list<int>& ranks = client->getRanksServerLeader(); 
    916      //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    917      //       event.push(*itRank,1,msg) ; 
    918      //     client->sendEvent(event); 
    919      //   } 
    920      //   else client->sendEvent(event); 
    921      // } 
    922      // else 
    923      // { 
    924      //   if (clientPrimServer->isServerLeader()) 
    925      //   { 
    926      //     CMessage msg; 
    927      //     msg<<this->getIdServer(); 
    928      //     const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
    929      //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    930      //       event.push(*itRank,1,msg) ; 
    931      //     clientPrimServer->sendEvent(event); 
    932      //   } 
    933      //   else clientPrimServer->sendEvent(event); 
    934      // } 
    9351002   } 
    9361003 
     
    9481015   { 
    9491016     // The creation of header file should be delegated to server2, for now 
    950       if (hasClient && hasServer) 
    951       {         
    952         sendCreateFileHeader(); 
    953       } 
     1017      // if (hasClient && hasServer) 
     1018      // {         
     1019      //   sendCreateFileHeader(); 
     1020      // } 
    9541021       
    9551022      if (!hasClient && hasServer)  
    9561023        createFileHeader(); 
     1024   } 
     1025 
     1026   //! Client side: Send a message to do some post processing on server 
     1027   void CContext::sendProcessingGridOfEnabledFields() 
     1028   { 
     1029      // Use correct context client to send message 
     1030     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client; 
     1031     CEventClient event(getType(),EVENT_ID_PROCESS_GRID_ENABLED_FIELDS); 
     1032 
     1033     if (contextClientTmp->isServerLeader()) 
     1034     { 
     1035       CMessage msg; 
     1036       msg<<this->getIdServer(); 
     1037       const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     1038       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1039         event.push(*itRank,1,msg); 
     1040       contextClientTmp->sendEvent(event); 
     1041     } 
     1042     else contextClientTmp->sendEvent(event); 
     1043   } 
     1044 
     1045   //! Server side: Receive a message to do some post processing 
     1046   void CContext::recvProcessingGridOfEnabledFields(CEventServer& event) 
     1047   { 
     1048      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     1049      string id; 
     1050      *buffer>>id; 
     1051      // get(id)->processGridEnabledFields(); 
    9571052   } 
    9581053 
     
    9801075       else contextClientTmp->sendEvent(event); 
    9811076     } 
    982  
    983      // if (hasClient) 
    984      // { 
    985      //   if (!hasServer) 
    986      //   { 
    987      //     CEventClient event(getType(),EVENT_ID_POST_PROCESS); 
    988      //     if (client->isServerLeader()) 
    989      //     { 
    990      //       CMessage msg; 
    991      //       msg<<this->getIdServer(); 
    992      //       const std::list<int>& ranks = client->getRanksServerLeader(); 
    993      //       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    994      //         event.push(*itRank,1,msg); 
    995      //       client->sendEvent(event); 
    996      //     } 
    997      //     else client->sendEvent(event); 
    998      //   } 
    999      //   else 
    1000      //   { 
    1001      //     CEventClient event(getType(),EVENT_ID_POST_PROCESS); 
    1002      //     if (clientPrimServer->isServerLeader()) 
    1003      //     { 
    1004      //       CMessage msg; 
    1005      //       msg<<this->getIdServer(); 
    1006      //       const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
    1007      //       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1008      //         event.push(*itRank,1,msg); 
    1009      //       clientPrimServer->sendEvent(event); 
    1010      //     } 
    1011      //     else clientPrimServer->sendEvent(event); 
    1012      //   } 
    1013      // } 
    10141077   } 
    10151078 
     
    10751138      // Check if some axis, domains or grids are eligible to for compressed indexed output. 
    10761139      // Warning: This must be done after solving the inheritance and before the rest of post-processing 
    1077       checkAxisDomainsGridsEligibilityForCompressedOutput(); 
     1140      checkAxisDomainsGridsEligibilityForCompressedOutput();       
    10781141 
    10791142      // Check if some automatic time series should be generated 
    10801143      // Warning: This must be done after solving the inheritance and before the rest of post-processing 
    1081       if (!hasServer) 
    1082         prepareTimeseries(); 
     1144      // prepareTimeseries(); 
     1145 
     1146      // The timeseries should only be prepared in client 
     1147      if (hasClient && !hasServer) prepareTimeseries(); 
    10831148 
    10841149      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
    10851150      this->findEnabledFiles(); 
    1086       this->findEnabledReadModeFiles(); 
     1151      // this->findEnabledReadModeFiles(); 
     1152      // For now, only read files with client and only one level server 
     1153      if (hasClient && !hasServer) this->findEnabledReadModeFiles(); 
     1154 
    10871155 
    10881156      // Find all enabled fields of each file 
    10891157      this->findAllEnabledFields(); 
    1090       this->findAllEnabledFieldsInReadModeFiles(); 
     1158      // this->findAllEnabledFieldsInReadModeFiles(); 
     1159      // For now, only read files with client and only one level server 
     1160      if (hasClient && !hasServer) this->findAllEnabledFieldsInReadModeFiles(); 
    10911161 
    10921162//     if (hasClient) 
     
    10971167     } 
    10981168 
     1169      // // Only search and rebuild all reference objects of enable fields, don't transform 
     1170      // this->solveOnlyRefOfEnabledFields(false); 
     1171 
     1172      // // Search and rebuild all reference object of enabled fields 
     1173      // this->solveAllRefOfEnabledFields(false); 
     1174 
     1175      // // Find all fields with read access from the public API 
     1176      // findFieldsWithReadAccess(); 
     1177      // // and solve the all reference for them 
     1178      // solveAllRefOfFieldsWithReadAccess(); 
     1179 
    10991180      // Only search and rebuild all reference objects of enable fields, don't transform 
    1100       this->solveOnlyRefOfEnabledFields(false); 
     1181      if (hasClient) this->solveOnlyRefOfEnabledFields(false); 
    11011182 
    11021183      // Search and rebuild all reference object of enabled fields 
    1103       this->solveAllRefOfEnabledFields(false); 
     1184      // if (hasClient) this->solveAllRefOfEnabledFields(false); 
    11041185 
    11051186      // Find all fields with read access from the public API 
    1106       findFieldsWithReadAccess(); 
     1187      if (hasClient && !hasServer) findFieldsWithReadAccess(); 
    11071188      // and solve the all reference for them 
    1108       solveAllRefOfFieldsWithReadAccess(); 
     1189      if (hasClient && !hasServer) solveAllRefOfFieldsWithReadAccess(); 
    11091190 
    11101191      isPostProcessed = true; 
  • XIOS/dev/dev_olga/src/node/context.hpp

    r1021 r1025  
    5151           EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, 
    5252           EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 
    53            EVENT_ID_POST_PROCESS, EVENT_ID_SEND_REGISTRY 
     53           EVENT_ID_POST_PROCESS, EVENT_ID_SEND_REGISTRY, 
     54           EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES, 
     55           EVENT_ID_PROCESS_GRID_ENABLED_FIELDS 
    5456         }; 
    5557 
     
    122124         void buildFilterGraphOfFieldsWithReadAccess(); 
    123125         void postProcessing(); 
     126         void postProcessingGlobalAttributes();          
     127 
     128         void solveAllEnabledFields(); 
     129         void processGridEnabledFields(); 
    124130 
    125131         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize); 
     
    137143         void sendRefGrid(); 
    138144         void sendPostProcessing(); 
     145         void sendPostProcessingGlobalAttributes(); 
     146         void sendProcessingGridOfEnabledFields(); 
    139147         //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 
    140148         void sendRegistry(void) ; 
     
    153161         static void recvPostProcessing(CEventServer& event); 
    154162         void recvPostProcessing(CBufferIn& buffer); 
     163         static void recvProcessingGridOfEnabledFields(CEventServer& event); 
     164         static void recvPostProcessingGlobalAttributes(CEventServer& event); 
     165         void recvPostProcessingGlobalAttributes(CBufferIn& buffer); 
    155166         static void recvRegistry(CEventServer& event) ; 
    156167         void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the servers 
     
    235246      private: 
    236247         bool isPostProcessed; 
     248         bool allProcessed; 
    237249         bool finalized; 
    238250         StdString idServer_; 
  • XIOS/dev/dev_olga/src/node/domain.cpp

    r1009 r1025  
    3131      : CObjectTemplate<CDomain>(), CDomainAttributes() 
    3232      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    33       , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 
     33      , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 
    3434      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    35       , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
    3635      , isRedistributed_(false), hasPole(false) 
    3736   { 
     
    4140      : CObjectTemplate<CDomain>(id), CDomainAttributes() 
    4241      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    43       , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 
     42      , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 
    4443      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    45       , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
    4644      , isRedistributed_(false), hasPole(false) 
    4745   { 
     
    113111   { 
    114112     return offsetWrittenIndexes_; 
     113   } 
     114 
     115   /*! 
     116     Returns the start of indexes written by each server. 
     117     \return the start of indexes written by each server 
     118   */ 
     119   const std::vector<int>& CDomain::getStartWriteIndex() const 
     120   { 
     121     return start_write_index_; 
     122   } 
     123 
     124   /*! 
     125     Returns the count of indexes written by each server. 
     126     \return the count of indexes written by each server 
     127   */ 
     128   const std::vector<int>& CDomain::getCountWriteIndex() const 
     129   { 
     130     return count_write_index_; 
     131   } 
     132 
     133   /*! 
     134     Returns the local data written by each server.      
     135   */ 
     136   const std::vector<int>& CDomain::getLocalWriteSize() const 
     137   { 
     138     return local_write_size_; 
     139   } 
     140 
     141   /*! 
     142     Returns the global data written by all server.      
     143   */ 
     144   const std::vector<int>& CDomain::getGlobalWriteSize() const 
     145   { 
     146     return global_write_size_; 
    115147   } 
    116148 
     
    130162     if (client->isServerLeader()) 
    131163     { 
    132        // size estimation for sendServerAttribut 
     164       // size estimation for sendDistributionAttribut 
    133165       size_t size = 11 * sizeof(size_t); 
    134166 
     
    141173     } 
    142174 
    143      std::map<int, std::vector<size_t> >::const_iterator itIndexEnd = indSrv_.end(); 
     175     boost::unordered_map<int, vector<size_t> >::const_iterator itIndexEnd = indSrv_.end(); 
    144176     std::map<int, std::vector<int> >::const_iterator itWrittenIndexEnd = indWrittenSrv_.end(); 
    145177     for (size_t k = 0; k < connectedServerRank_.size(); ++k) 
    146178     { 
    147179       int rank = connectedServerRank_[k]; 
    148        std::map<int, std::vector<size_t> >::const_iterator it = indSrv_.find(rank); 
     180       boost::unordered_map<int, std::vector<size_t> >::const_iterator it = indSrv_.find(rank); 
    149181       size_t idxCount = (it != itIndexEnd) ? it->second.size() : 0; 
    150182 
     
    175207   bool CDomain::isEmpty(void) const 
    176208   { 
    177       return ((this->zoom_ni_srv == 0) || 
    178               (this->zoom_nj_srv == 0)); 
     209      return ((this->zoom_i_index.isEmpty()) || (0 == this->zoom_i_index.numElements())); 
     210      // return ((this->zoom_ni_srv == 0) || 
     211      //         (this->zoom_nj_srv == 0)); 
    179212   } 
    180213 
     
    695728       for (int j = 0; j < nj; ++j) 
    696729         for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; 
    697      } 
    698      computeNGlobDomain(); 
     730     }      
    699731     checkZoom(); 
    700732 
     
    715747     if (global_zoom_nj.isEmpty()) 
    716748      global_zoom_nj.setValue(nj_glo); 
     749    if (zoom_i_index.isEmpty()) zoom_i_index.setValue(i_index.getValue()); 
     750    if (zoom_j_index.isEmpty()) zoom_j_index.setValue(j_index.getValue()); 
    717751   } 
    718752 
     
    9931027     localMask.resize(ni*nj) ; 
    9941028     localMask=false ; 
    995      size_t zoom_ibegin=global_zoom_ibegin ; 
    996      size_t zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
    997      size_t zoom_jbegin=global_zoom_jbegin ; 
    998      size_t zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
     1029     size_t zoom_ibegin= global_zoom_ibegin ; 
     1030     size_t zoom_iend= global_zoom_ibegin+global_zoom_ni-1 ; 
     1031     size_t zoom_jbegin= global_zoom_jbegin ; 
     1032     size_t zoom_jend= global_zoom_jbegin+global_zoom_nj-1 ; 
    9991033 
    10001034 
     
    10371071     if (!lonvalue_2d.isEmpty()) 
    10381072     { 
    1039        lonvalue_client.resize(ni * nj); 
    1040        latvalue_client.resize(ni * nj); 
     1073       lonvalue.resize(ni * nj); 
     1074       latvalue.resize(ni * nj); 
    10411075       if (hasBounds) 
    10421076       { 
    1043          bounds_lon_client.resize(nvertex, ni * nj); 
    1044          bounds_lat_client.resize(nvertex, ni * nj); 
     1077         bounds_lonvalue.resize(nvertex, ni * nj); 
     1078         bounds_latvalue.resize(nvertex, ni * nj); 
    10451079       } 
    10461080 
     
    10511085           int k = j * ni + i; 
    10521086 
    1053            lonvalue_client(k) = lonvalue_2d(i,j); 
    1054            latvalue_client(k) = latvalue_2d(i,j); 
     1087           lonvalue(k) = lonvalue_2d(i,j); 
     1088           latvalue(k) = latvalue_2d(i,j); 
    10551089 
    10561090           if (hasBounds) 
     
    10581092             for (int n = 0; n < nvertex; ++n) 
    10591093             { 
    1060                bounds_lon_client(n,k) = bounds_lon_2d(n,i,j); 
    1061                bounds_lat_client(n,k) = bounds_lat_2d(n,i,j); 
     1094               bounds_lonvalue(n,k) = bounds_lon_2d(n,i,j); 
     1095               bounds_latvalue(n,k) = bounds_lat_2d(n,i,j); 
    10621096             } 
    10631097           } 
     
    10711105         if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) 
    10721106         { 
    1073            lonvalue_client.resize(ni * nj); 
    1074            latvalue_client.resize(ni * nj); 
     1107           lonvalue.resize(ni * nj); 
     1108           latvalue.resize(ni * nj); 
    10751109           if (hasBounds) 
    10761110           { 
    1077              bounds_lon_client.resize(nvertex, ni * nj); 
    1078              bounds_lat_client.resize(nvertex, ni * nj); 
     1111             bounds_lonvalue.resize(nvertex, ni * nj); 
     1112             bounds_latvalue.resize(nvertex, ni * nj); 
    10791113           } 
    10801114 
     
    10851119               int k = j * ni + i; 
    10861120 
    1087                lonvalue_client(k) = lonvalue_1d(i); 
    1088                latvalue_client(k) = latvalue_1d(j); 
     1121               lonvalue(k) = lonvalue_1d(i); 
     1122               latvalue(k) = latvalue_1d(j); 
    10891123 
    10901124               if (hasBounds) 
     
    10921126                 for (int n = 0; n < nvertex; ++n) 
    10931127                 { 
    1094                    bounds_lon_client(n,k) = bounds_lon_1d(n,i); 
    1095                    bounds_lat_client(n,k) = bounds_lat_1d(n,j); 
     1128                   bounds_lonvalue(n,k) = bounds_lon_1d(n,i); 
     1129                   bounds_latvalue(n,k) = bounds_lat_1d(n,j); 
    10961130                 } 
    10971131               } 
     
    11011135         else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements()) 
    11021136         { 
    1103            lonvalue_client.reference(lonvalue_1d); 
    1104            latvalue_client.reference(latvalue_1d); 
     1137           lonvalue.reference(lonvalue_1d); 
     1138           latvalue.reference(latvalue_1d); 
    11051139            if (hasBounds) 
    11061140           { 
    1107              bounds_lon_client.reference(bounds_lon_1d); 
    1108              bounds_lat_client.reference(bounds_lat_1d); 
     1141             bounds_lonvalue.reference(bounds_lon_1d); 
     1142             bounds_latvalue.reference(bounds_lat_1d); 
    11091143           } 
    11101144         } 
     
    11201154       else if (type == type_attr::curvilinear || type == type_attr::unstructured) 
    11211155       { 
    1122          lonvalue_client.reference(lonvalue_1d); 
    1123          latvalue_client.reference(latvalue_1d); 
     1156         lonvalue.reference(lonvalue_1d); 
     1157         latvalue.reference(latvalue_1d); 
    11241158         if (hasBounds) 
    11251159         { 
    1126            bounds_lon_client.reference(bounds_lon_1d); 
    1127            bounds_lat_client.reference(bounds_lat_1d); 
     1160           bounds_lonvalue.reference(bounds_lon_1d); 
     1161           bounds_latvalue.reference(bounds_lat_1d); 
    11281162         } 
    11291163       } 
     
    12211255   void CDomain::checkArea(void) 
    12221256   { 
    1223      hasArea = !area.isEmpty(); 
     1257     hasArea = !area.isEmpty() || !areavalue.isEmpty(); 
    12241258     if (hasArea) 
    12251259     { 
     
    12311265               << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl 
    12321266               << "Area size is " << area.extent(0) << " x " << area.extent(1) << "."); 
     1267       } 
     1268       if (areavalue.isEmpty()) 
     1269       { 
     1270          areavalue.resize(ni*nj); 
     1271         for (int j = 0; j < nj; ++j) 
     1272         { 
     1273           for (int i = 0; i < ni; ++i) 
     1274           { 
     1275             int k = j * ni + i; 
     1276             areavalue(k) = area(i,j); 
     1277           } 
     1278         } 
    12331279       } 
    12341280     } 
     
    13021348     if (context->hasClient) 
    13031349     { 
    1304        this->checkMask(); 
    1305        if (hasLonLat || hasArea || isCompressible_) this->computeConnectedServer(); 
     1350       // this->checkMask(); 
     1351      this->computeConnectedClients(); 
     1352       // if (hasLonLat || hasArea || isCompressible_) this->computeConnectedClients(); 
    13061353       if (hasLonLat) this->completeLonLatClient(); 
    13071354     } 
     
    13181365     CContext* context=CContext::getCurrent(); 
    13191366 
     1367      if (context->hasClient && !context->hasServer) 
     1368      { 
     1369        this->checkDomain(); 
     1370        this->checkBounds(); 
     1371        this->checkArea(); 
     1372        this->checkLonLat(); 
     1373      } 
     1374 
     1375      if (context->hasClient && !context->hasServer) 
     1376      { // CÃŽté client uniquement 
     1377         this->checkMask(); 
     1378         this->checkDomainData(); 
     1379         this->checkCompression(); 
     1380         this->computeLocalMask() ; 
     1381      } 
     1382      else 
     1383      { // CÃŽté serveur uniquement 
     1384      } 
     1385 
     1386      this->isClientChecked = true; 
     1387   } 
     1388 
     1389   // Send all checked attributes to server 
     1390   void CDomain::sendCheckedAttributes() 
     1391   { 
     1392     if (!this->isClientChecked) checkAttributesOnClient(); 
     1393     if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(); 
     1394     CContext* context=CContext::getCurrent() ; 
     1395 
     1396     if (this->isChecked) return; 
     1397     if (context->hasClient) 
     1398     { 
     1399       sendAttributes(); 
     1400     } 
     1401     this->isChecked = true; 
     1402   } 
     1403 
     1404   void CDomain::checkAttributes(void) 
     1405   { 
     1406      if (this->isChecked) return; 
     1407      CContext* context=CContext::getCurrent() ; 
     1408 
    13201409      this->checkDomain(); 
     1410      this->checkLonLat(); 
    13211411      this->checkBounds(); 
    13221412      this->checkArea(); 
    1323       this->checkLonLat(); 
    13241413 
    13251414      if (context->hasClient) 
     
    13291418         this->checkCompression(); 
    13301419         this->computeLocalMask() ; 
     1420 
    13311421      } 
    13321422      else 
     
    13341424      } 
    13351425 
    1336       this->isClientChecked = true; 
    1337    } 
    1338  
    1339    // Send all checked attributes to server 
    1340    void CDomain::sendCheckedAttributes() 
    1341    { 
    1342      if (!this->isClientChecked) checkAttributesOnClient(); 
    1343      if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(); 
    1344      CContext* context=CContext::getCurrent() ; 
    1345  
    1346      if (this->isChecked) return; 
    1347      if (context->hasClient) 
    1348      { 
    1349        sendServerAttribut(); 
    1350        if (hasLonLat || hasArea || isCompressible_) sendLonLatArea(); 
    1351      } 
    1352      this->isChecked = true; 
    1353    } 
    1354  
    1355    void CDomain::checkAttributes(void) 
    1356    { 
    1357       if (this->isChecked) return; 
    1358       CContext* context=CContext::getCurrent() ; 
    1359  
    1360       this->checkDomain(); 
    1361       this->checkLonLat(); 
    1362       this->checkBounds(); 
    1363       this->checkArea(); 
    1364  
    13651426      if (context->hasClient) 
    1366       { // CÃŽté client uniquement 
    1367          this->checkMask(); 
    1368          this->checkDomainData(); 
    1369          this->checkCompression(); 
    1370          this->computeLocalMask() ; 
    1371  
    1372       } 
    1373       else 
    1374       { // CÃŽté serveur uniquement 
    1375       } 
    1376  
    1377       if (context->hasClient) 
    1378       { 
    1379         this->computeConnectedServer(); 
     1427      { 
     1428        this->computeConnectedClients(); 
    13801429        this->completeLonLatClient(); 
    1381         this->sendServerAttribut(); 
    1382         this->sendLonLatArea(); 
    13831430      } 
    13841431 
     
    13861433   } 
    13871434 
    1388   void CDomain::sendServerAttribut(void) 
     1435  /*! 
     1436    Send distribution from client to other clients 
     1437    Because a client in a level knows correctly the grid distribution of client on the next level 
     1438    it calculates this distribution then sends it to the corresponding clients on the next level 
     1439  */ 
     1440  void CDomain::sendDistributionAttributes(void) 
    13891441  { 
    13901442    CContext* context = CContext::getCurrent(); 
     
    13941446    { 
    13951447       CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] 
    1396                                                                            : context->client; 
    1397       // CContextClient* client = context->client; 
     1448                                                                         : context->client;     
    13981449      int nbServer = contextClientTmp->serverSize; 
    1399  
    1400       CServerDistributionDescription serverDescription(nGlobDomain_, nbServer); 
     1450    std::vector<int> nGlobDomain(2); 
     1451    nGlobDomain[0] = this->ni_glo; 
     1452    nGlobDomain[1] = this->nj_glo; 
     1453 
     1454    CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
    14011455      if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); 
    14021456      else serverDescription.computeServerDistribution(false, 1); 
     
    14181472          const int ni_srv = serverDimensionSizes[*itRank][0]; 
    14191473          const int nj_srv = serverDimensionSizes[*itRank][1]; 
    1420           const int iend_srv = ibegin_srv + ni_srv - 1; 
    1421           const int jend_srv = jbegin_srv + nj_srv - 1; 
    14221474 
    14231475          msgs.push_back(CMessage()); 
    14241476          CMessage& msg = msgs.back(); 
    14251477          msg << this->getId() ; 
    1426           msg << ni_srv << ibegin_srv << iend_srv << nj_srv << jbegin_srv << jend_srv; 
    1427           msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue(); 
     1478        msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv;         
    14281479          msg << isCompressible_; 
    14291480 
     
    14361487  } 
    14371488 
    1438   void CDomain::computeNGlobDomain() 
    1439   { 
    1440     nGlobDomain_.resize(2); 
    1441     nGlobDomain_[0] = ni_glo.getValue(); 
    1442     nGlobDomain_[1] = nj_glo.getValue(); 
    1443   } 
    1444  
    1445   void CDomain::computeConnectedServer(void) 
     1489  // void CDomain::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, 
     1490  //                                     CServerDistributionDescription::ServerDistributionType distType) 
     1491  /*! 
     1492     Compute the connection of a client to other clients to determine which clients to send attributes to 
     1493  */ 
     1494  void CDomain::computeConnectedClients() 
    14461495  { 
    14471496    CContext* context=CContext::getCurrent() ; 
    1448     CContextClient* client=context->client ; 
     1497    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    14491498    int nbServer=client->serverSize; 
    14501499    int rank = client->clientRank; 
    14511500    bool doComputeGlobalIndexServer = true; 
    14521501 
    1453     int i,j,i_ind,j_ind, nbIndex; 
     1502    int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 
    14541503    int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
    14551504    int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
     
    14581507    int globalIndexCountZoom = 0; 
    14591508    nbIndex = i_index.numElements(); 
    1460     for (i = 0; i < nbIndex; ++i) 
    1461     { 
    1462       i_ind=i_index(i); 
    1463       j_ind=j_index(i); 
    1464  
    1465       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1466       { 
    1467         ++globalIndexCountZoom; 
    1468       } 
    1469     } 
    1470  
    1471     int globalIndexWrittenCount = 0; 
    1472     if (isCompressible_) 
    1473     { 
    1474       for (i = 0; i < data_i_index.numElements(); ++i) 
    1475       { 
    1476         i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
    1477                                                     data_ibegin, data_jbegin, data_dim, ni, 
    1478                                                     j_ind); 
    1479         if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
    1480         { 
    1481           i_ind += ibegin; 
    1482           j_ind += jbegin; 
    1483           if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1484             ++globalIndexWrittenCount; 
    1485         } 
    1486       } 
    1487     } 
     1509    // for (i = 0; i < nbIndex; ++i) 
     1510    // { 
     1511    //   i_ind=i_index(i); 
     1512    //   j_ind=j_index(i); 
     1513 
     1514    //   if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1515    //   { 
     1516    //     ++globalIndexCountZoom; 
     1517    //   } 
     1518    // } 
     1519 
     1520    // int globalIndexWrittenCount = 0; 
     1521    // if (isCompressible_) 
     1522    // { 
     1523    //   for (i = 0; i < data_i_index.numElements(); ++i) 
     1524    //   { 
     1525    //     i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
     1526    //                                                 data_ibegin, data_jbegin, data_dim, ni, 
     1527    //                                                 j_ind); 
     1528    //     if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
     1529    //     { 
     1530    //       i_ind += ibegin; 
     1531    //       j_ind += jbegin; 
     1532    //       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1533    //         ++globalIndexWrittenCount; 
     1534    //     } 
     1535    //   } 
     1536    // } 
    14881537 
    14891538    // Fill in index 
    1490     CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 
     1539     
    14911540    CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 
    14921541    CArray<size_t,1> globalIndexDomain(nbIndex); 
    14931542    size_t globalIndex; 
    14941543    int globalIndexCount = 0; 
    1495     globalIndexCountZoom = 0; 
     1544     
    14961545 
    14971546    for (i = 0; i < nbIndex; ++i) 
     
    15011550      globalIndex = i_ind + j_ind * ni_glo; 
    15021551      globalIndexDomain(globalIndexCount) = globalIndex; 
     1552      globalLocalIndexMap_[globalIndex] = i; 
    15031553      ++globalIndexCount; 
    1504       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1505       { 
    1506         globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    1507         localIndexDomainZoom(globalIndexCountZoom) = i; 
    1508         ++globalIndexCountZoom; 
    1509       } 
    1510     } 
    1511  
    1512     CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 
    1513     if (isCompressible_) 
    1514     { 
    1515       globalIndexWrittenCount = 0; 
    1516       for (i = 0; i < data_i_index.numElements(); ++i) 
    1517       { 
    1518         i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
    1519                                                     data_ibegin, data_jbegin, data_dim, ni, 
    1520                                                     j_ind); 
    1521         if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
    1522         { 
    1523           i_ind += ibegin; 
    1524           j_ind += jbegin; 
    1525           if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1526           { 
    1527             globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 
    1528             ++globalIndexWrittenCount; 
    1529           } 
    1530         } 
    1531       } 
    1532     } 
     1554    } 
     1555 
     1556    nbIndexZoom = zoom_i_index.numElements(); 
     1557    CArray<size_t,1> globalIndexDomainZoom(nbIndexZoom); 
     1558    globalIndexCountZoom = 0; 
     1559    for (i = 0; i < nbIndexZoom; ++i) 
     1560    { 
     1561      i_ind=zoom_i_index(i); 
     1562      j_ind=zoom_j_index(i); 
     1563      globalIndex = i_ind + j_ind * ni_glo; 
     1564      globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     1565 
     1566      ++globalIndexCountZoom; 
     1567      // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1568      // { 
     1569      //   globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     1570      //   localIndexDomainZoom(globalIndexCountZoom) = i; 
     1571      //   ++globalIndexCountZoom; 
     1572      // } 
     1573    } 
     1574 
     1575    // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 
     1576    // if (isCompressible_) 
     1577    // { 
     1578    //   globalIndexWrittenCount = 0; 
     1579    //   for (i = 0; i < data_i_index.numElements(); ++i) 
     1580    //   { 
     1581    //     i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
     1582    //                                                 data_ibegin, data_jbegin, data_dim, ni, 
     1583    //                                                 j_ind); 
     1584    //     if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
     1585    //     { 
     1586    //       i_ind += ibegin; 
     1587    //       j_ind += jbegin; 
     1588    //       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1589    //       { 
     1590    //         globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 
     1591    //         ++globalIndexWrittenCount; 
     1592    //       } 
     1593    //     } 
     1594    //   } 
     1595    // } 
    15331596 
    15341597    size_t globalSizeIndex = 1, indexBegin, indexEnd; 
    15351598    int range, clientSize = client->clientSize; 
    1536     for (int i = 0; i < nGlobDomain_.size(); ++i) globalSizeIndex *= nGlobDomain_[i]; 
     1599    std::vector<int> nGlobDomain(2); 
     1600    nGlobDomain[0] = this->ni_glo; 
     1601    nGlobDomain[1] = this->nj_glo; 
     1602    for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 
    15371603    indexBegin = 0; 
    15381604    if (globalSizeIndex <= clientSize) 
     
    15531619    } 
    15541620 
    1555     CServerDistributionDescription serverDescription(nGlobDomain_, nbServer); 
     1621    CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
    15561622    if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 
    15571623    else serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); 
     
    15601626                                                                                client->intraComm); 
    15611627    clientServerMap->computeServerIndexMapping(globalIndexDomain); 
    1562     const CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 
     1628    CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 
    15631629 
    15641630    CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(), 
    15651631                                                         ite = globalIndexDomainOnServer.end(); 
    1566     typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
    1567     std::vector<int>::iterator itVec; 
    1568  
    1569     indSrv_.clear(); 
    1570     indWrittenSrv_.clear(); 
    1571     for (; it != ite; ++it) 
    1572     { 
    1573       int rank = it->first; 
    1574       int indexSize = it->second.size(); 
    1575       std::vector<int> permutIndex(indexSize); 
    1576       XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
    1577       XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); 
    1578       BinarySearch binSearch(it->second); 
    1579       int nb = globalIndexDomainZoom.numElements(); 
    1580       for (int i = 0; i < nb; ++i) 
    1581       { 
    1582         if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 
    1583         { 
    1584           indSrv_[rank].push_back(localIndexDomainZoom(i)); 
    1585         } 
    1586       } 
    1587       for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 
    1588       { 
    1589         if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 
    1590         { 
    1591           indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 
    1592         } 
    1593       } 
    1594     } 
     1632    // typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
     1633    // std::vector<int>::iterator itVec; 
     1634     
     1635    // indSrv_.clear(); 
     1636    // indWrittenSrv_.clear(); 
     1637    // for (; it != ite; ++it) 
     1638    // { 
     1639    //   int rank = it->first; 
     1640    //   int indexSize = it->second.size(); 
     1641    //   std::vector<int> permutIndex(indexSize); 
     1642    //   XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
     1643    //   XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); 
     1644    //   BinarySearch binSearch(it->second); 
     1645    //   int nb = globalIndexDomainZoom.numElements(); 
     1646    //   for (int i = 0; i < nb; ++i) 
     1647    //   { 
     1648    //     if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 
     1649    //     { 
     1650    //       indSrv_[rank].push_back(localIndexDomainZoom(i)); 
     1651    //     } 
     1652    //   } 
     1653    //   for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 
     1654    //   { 
     1655    //     if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 
     1656    //     { 
     1657    //       indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 
     1658    //     } 
     1659    //   } 
     1660    // } 
    15951661 
    15961662    connectedServerRank_.clear(); 
     
    15991665    } 
    16001666 
     1667    indSrv_.swap(globalIndexDomainOnServer); 
    16011668    nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    16021669 
     1670    clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 
     1671    CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 
     1672    indZoomSrv_.swap(globalIndexDomainZoomOnServer); 
     1673    std::vector<int> connectedServerZoomRank(indZoomSrv_.size()); 
     1674    for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 
     1675      connectedServerZoomRank.push_back(it->first); 
     1676    nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank);        
     1677 
    16031678    delete clientServerMap; 
    16041679  } 
    16051680 
    1606   const std::map<int, vector<size_t> >& CDomain::getIndexServer() const 
     1681  const boost::unordered_map<int, vector<size_t> >& CDomain::getIndexServer() const 
    16071682  { 
    16081683    return indSrv_; 
     
    16101685 
    16111686  /*! 
    1612     Send index from client to server(s) 
     1687    Send all attributes from client to connected clients 
     1688    The attributes will be rebuilt on receiving side 
     1689  */ 
     1690  void CDomain::sendAttributes() 
     1691  { 
     1692    sendIndex(); 
     1693    sendDistributionAttributes(); 
     1694    sendMask(); 
     1695    sendLonLat(); 
     1696    sendArea();     
     1697    sendDataIndex(); 
     1698  } 
     1699 
     1700  /*! 
     1701    Send global index and zoom index from client to connected client(s) 
     1702    zoom index can be smaller than global index 
    16131703  */ 
    16141704  void CDomain::sendIndex() 
     
    16161706    int ns, n, i, j, ind, nv, idx; 
    16171707    CContext* context = CContext::getCurrent(); 
    1618     CContextClient* client=context->client; 
     1708    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    16191709 
    16201710    CEventClient eventIndex(getType(), EVENT_ID_INDEX); 
    16211711 
    16221712    list<CMessage> list_msgsIndex; 
    1623     list<CArray<int,1> > list_indi, list_indj, list_writtenInd; 
    1624  
    1625     std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     1713    list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 
     1714 
     1715    boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex, itZoom, iteZoom; 
     1716    iteIndex = indSrv_.end(); iteZoom = indZoomSrv_.end(); 
     1717    for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1718    { 
     1719      int nbIndGlob = 0; 
     1720      int rank = connectedServerRank_[k]; 
     1721      itIndex = indSrv_.find(rank); 
     1722      if (iteIndex != itIndex) 
     1723        nbIndGlob = itIndex->second.size(); 
     1724      int nbIndZoom = 0; 
     1725      itZoom = indZoomSrv_.find(rank); 
     1726      if (iteZoom != itZoom) 
     1727        nbIndZoom = itZoom->second.size();  
     1728 
     1729      list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 
     1730      list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 
     1731 
     1732      CArray<int,1>& indZoom = list_indZoom.back(); 
     1733      CArray<int,1>& indGlob = list_indGlob.back();       
     1734      for (n = 0; n < nbIndGlob; ++n) 
     1735      { 
     1736        indGlob(n) = static_cast<int>(itIndex->second[n]);         
     1737      } 
     1738 
     1739      for (n = 0; n < nbIndZoom; ++n) 
     1740      { 
     1741        indZoom(n) = static_cast<int>(itZoom->second[n]);         
     1742      } 
     1743 
     1744      list_msgsIndex.push_back(CMessage()); 
     1745      list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
     1746      list_msgsIndex.back() << isCurvilinear; 
     1747      list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back(); //list_indi.back() << list_indj.back(); 
     1748 
     1749      // if (isCompressible_) 
     1750      // { 
     1751      //   std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 
     1752      //   list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 
     1753      //   CArray<int,1>& writtenInd = list_writtenInd.back(); 
     1754 
     1755      //   for (n = 0; n < writtenInd.numElements(); ++n) 
     1756      //     writtenInd(n) = writtenIndSrc[n]; 
     1757 
     1758      //   list_msgsIndex.back() << writtenInd; 
     1759      // } 
     1760 
     1761      eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
     1762    } 
     1763 
     1764    client->sendEvent(eventIndex); 
     1765  } 
     1766 
     1767  /*! 
     1768    Send mask index from client to connected(s) 
     1769  */ 
     1770  void CDomain::sendMask() 
     1771  { 
     1772    int ns, n, i, j, ind, nv, idx; 
     1773    CContext* context = CContext::getCurrent(); 
     1774    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
     1775 
     1776    // send area for each connected server 
     1777    CEventClient eventMask(getType(), EVENT_ID_MASK); 
     1778 
     1779    list<CMessage> list_msgsMask; 
     1780    list<CArray<bool,1> > list_mask; 
     1781 
     1782    boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    16261783    iteMap = indSrv_.end(); 
    16271784    for (int k = 0; k < connectedServerRank_.size(); ++k) 
     
    16321789      if (iteMap != it) 
    16331790        nbData = it->second.size(); 
    1634  
    1635       list_indi.push_back(CArray<int,1>(nbData)); 
    1636       list_indj.push_back(CArray<int,1>(nbData)); 
    1637  
    1638       CArray<int,1>& indi = list_indi.back(); 
    1639       CArray<int,1>& indj = list_indj.back(); 
     1791      list_mask.push_back(CArray<bool,1>(nbData)); 
     1792 
    16401793      const std::vector<size_t>& temp = it->second; 
    16411794      for (n = 0; n < nbData; ++n) 
    16421795      { 
    16431796        idx = static_cast<int>(it->second[n]); 
    1644         indi(n) = i_index(idx); 
    1645         indj(n) = j_index(idx); 
    1646       } 
    1647  
    1648       list_msgsIndex.push_back(CMessage()); 
    1649  
    1650       list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
    1651       list_msgsIndex.back() << isCurvilinear; 
    1652       list_msgsIndex.back() << list_indi.back() << list_indj.back(); 
    1653  
    1654       if (isCompressible_) 
    1655       { 
    1656         std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 
    1657         list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 
    1658         CArray<int,1>& writtenInd = list_writtenInd.back(); 
    1659  
    1660         for (n = 0; n < writtenInd.numElements(); ++n) 
    1661           writtenInd(n) = writtenIndSrc[n]; 
    1662  
    1663         list_msgsIndex.back() << writtenInd; 
    1664       } 
    1665  
    1666       eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
    1667     } 
    1668  
    1669     client->sendEvent(eventIndex); 
     1797        list_mask.back()(n) = mask_1d(globalLocalIndexMap_[idx]);           
     1798      } 
     1799 
     1800      list_msgsMask.push_back(CMessage()); 
     1801      list_msgsMask.back() << this->getId() << list_mask.back(); 
     1802      eventMask.push(rank, nbConnectedClients_[rank], list_msgsMask.back()); 
     1803    } 
     1804    client->sendEvent(eventMask); 
    16701805  } 
    16711806 
    16721807  /*! 
    1673     Send area from client to server(s) 
     1808    Send area from client to connected client(s) 
    16741809  */ 
    16751810  void CDomain::sendArea() 
     
    16791814    int ns, n, i, j, ind, nv, idx; 
    16801815    CContext* context = CContext::getCurrent(); 
    1681     CContextClient* client=context->client; 
     1816    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    16821817 
    16831818    // send area for each connected server 
     
    16871822    list<CArray<double,1> > list_area; 
    16881823 
    1689     std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     1824    boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    16901825    iteMap = indSrv_.end(); 
    16911826    for (int k = 0; k < connectedServerRank_.size(); ++k) 
     
    17021837      { 
    17031838        idx = static_cast<int>(it->second[n]); 
    1704         i = i_index(idx); 
    1705         j = j_index(idx); 
    1706         if (hasArea) 
    1707           list_area.back()(n) = area(i - ibegin, j - jbegin); 
     1839        list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]);  
    17081840      } 
    17091841 
    17101842      list_msgsArea.push_back(CMessage()); 
    1711       list_msgsArea.back() << this->getId() << list_area.back(); 
     1843      list_msgsArea.back() << this->getId() << hasArea; 
     1844      list_msgsArea.back() << list_area.back(); 
    17121845      eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 
    17131846    } 
     
    17261859    int ns, n, i, j, ind, nv, idx; 
    17271860    CContext* context = CContext::getCurrent(); 
    1728     CContextClient* client=context->client; 
     1861    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    17291862 
    17301863    // send lon lat for each connected server 
     
    17361869    list<CArray<double,2> > list_boundslon, list_boundslat; 
    17371870 
    1738     std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     1871    boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    17391872    iteMap = indSrv_.end(); 
    17401873    for (int k = 0; k < connectedServerRank_.size(); ++k) 
     
    17611894      { 
    17621895        idx = static_cast<int>(it->second[n]); 
    1763         lon(n) = lonvalue_client(idx); 
    1764         lat(n) = latvalue_client(idx); 
     1896        int localInd = globalLocalIndexMap_[idx]; 
     1897        lon(n) = lonvalue(localInd); 
     1898        lat(n) = latvalue(localInd); 
    17651899 
    17661900        if (hasBounds) 
     
    17711905          for (nv = 0; nv < nvertex; ++nv) 
    17721906          { 
    1773             boundslon(nv, n) = bounds_lon_client(nv, idx); 
    1774             boundslat(nv, n) = bounds_lat_client(nv, idx); 
     1907            boundslon(nv, n) = bounds_lonvalue(nv, localInd); 
     1908            boundslat(nv, n) = bounds_latvalue(nv, localInd); 
    17751909          } 
    17761910        } 
     
    17801914      list_msgsLat.push_back(CMessage()); 
    17811915 
    1782       list_msgsLon.back() << this->getId() << list_lon.back(); 
    1783       list_msgsLat.back() << this->getId() << list_lat.back(); 
     1916      list_msgsLon.back() << this->getId() << hasLonLat << list_lon.back() << hasBounds; 
     1917      list_msgsLat.back() << this->getId() << hasLonLat << list_lat.back() << hasBounds; 
    17841918 
    17851919      if (hasBounds) 
     
    17981932 
    17991933  /*! 
    1800     Send some optional information to server(s) 
    1801     In the future, this function can be extended with more optional information to send 
     1934    Send data index to corresponding connected clients. 
     1935    Data index can be compressed however, we always send decompressed data index 
     1936    and they will be compressed on receiving. 
    18021937  */ 
    1803   void CDomain::sendLonLatArea(void) 
    1804   { 
    1805     sendIndex(); 
    1806     sendLonLat(); 
    1807     sendArea(); 
    1808   } 
    1809  
     1938  void CDomain::sendDataIndex() 
     1939  { 
     1940    int ns, n, i, j, ind, nv, idx; 
     1941    CContext* context = CContext::getCurrent(); 
     1942    CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
     1943 
     1944    // send area for each connected server 
     1945    CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); 
     1946 
     1947    list<CMessage> list_msgsDataIndex; 
     1948    list<CArray<int,1> > list_data_i_index, list_data_j_index; 
     1949 
     1950    int nbIndex = i_index.numElements(); 
     1951    CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 
     1952    dataIIndex = -1; dataJIndex = -1, ind = 0; 
     1953    for (idx = 0; idx < data_i_index.numElements(); ++idx) 
     1954    { 
     1955      if ((0 <= data_i_index(idx)) && (data_i_index(idx) < ni) && (ind < nbIndex)) 
     1956      { 
     1957        dataIIndex(ind) = data_i_index(idx); 
     1958        dataJIndex(ind) = data_j_index(idx); 
     1959        ++ind; 
     1960      } 
     1961    } 
     1962 
     1963    boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
     1964    iteMap = indSrv_.end(); 
     1965    for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1966    { 
     1967      int nbData = 0; 
     1968      int rank = connectedServerRank_[k]; 
     1969      it = indSrv_.find(rank); 
     1970      if (iteMap != it) 
     1971        nbData = it->second.size(); 
     1972      list_data_i_index.push_back(CArray<int,1>(nbData)); 
     1973      list_data_j_index.push_back(CArray<int,1>(nbData)); 
     1974 
     1975      const std::vector<size_t>& temp = it->second; 
     1976      for (n = 0; n < nbData; ++n) 
     1977      { 
     1978        idx = static_cast<int>(it->second[n]); 
     1979        i = globalLocalIndexMap_[idx]; 
     1980        list_data_i_index.back()(n) = dataIIndex(i); 
     1981        list_data_j_index.back()(n) = dataJIndex(i);           
     1982      } 
     1983 
     1984      list_msgsDataIndex.push_back(CMessage()); 
     1985      list_msgsDataIndex.back() << this->getId(); 
     1986      list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 
     1987      eventDataIndex.push(rank, nbConnectedClients_[rank], list_msgsDataIndex.back()); 
     1988    } 
     1989    client->sendEvent(eventDataIndex); 
     1990  } 
     1991   
    18101992  bool CDomain::dispatchEvent(CEventServer& event) 
    18111993  { 
     
    18161998      { 
    18171999        case EVENT_ID_SERVER_ATTRIBUT: 
    1818           recvServerAttribut(event); 
     2000          recvDistributionAttributes(event); 
    18192001          return true; 
    18202002          break; 
    18212003        case EVENT_ID_INDEX: 
    18222004          recvIndex(event); 
     2005          return true; 
     2006          break; 
     2007        case EVENT_ID_MASK: 
     2008          recvMask(event); 
    18232009          return true; 
    18242010          break; 
     
    18342020          recvArea(event); 
    18352021          return true; 
     2022          break;   
     2023        case EVENT_ID_DATA_INDEX: 
     2024          recvDataIndex(event); 
     2025          return true; 
    18362026          break; 
    18372027        default: 
     
    18472037    \param[in] event event contain info about rank and associated attributes 
    18482038  */ 
    1849   void CDomain::recvServerAttribut(CEventServer& event) 
     2039  void CDomain::recvDistributionAttributes(CEventServer& event) 
    18502040  { 
    18512041    CBufferIn* buffer=event.subEvents.begin()->buffer; 
    18522042    string domainId ; 
    18532043    *buffer>>domainId ; 
    1854     get(domainId)->recvServerAttribut(*buffer) ; 
    1855      
    1856     CContext* context = CContext::getCurrent(); 
    1857     if (context->hasClient && context->hasServer) 
    1858     { 
    1859       get(domainId)->sendServerAttribut(); 
    1860     } 
    1861  
     2044    get(domainId)->recvDistributionAttributes(*buffer) ; 
    18622045  } 
    18632046 
     
    18672050    \param[in] buffer message containing attributes info 
    18682051  */ 
    1869   void CDomain::recvServerAttribut(CBufferIn& buffer) 
    1870   { 
    1871     int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; 
    1872     buffer >> ni_srv >> ibegin_srv >> iend_srv >> nj_srv >> jbegin_srv >> jend_srv 
    1873            >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp 
     2052  void CDomain::recvDistributionAttributes(CBufferIn& buffer) 
     2053  { 
     2054    int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 
     2055    buffer >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp            
    18742056           >> isCompressible_; 
    1875  
    1876     global_zoom_ni.setValue(global_zoom_ni_tmp); 
    1877     global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); 
    1878     global_zoom_nj.setValue(global_zoom_nj_tmp); 
    1879     global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); 
    1880  
    1881     int zoom_iend = global_zoom_ibegin + global_zoom_ni - 1; 
    1882     int zoom_jend = global_zoom_jbegin + global_zoom_nj - 1; 
    1883  
    1884     zoom_ibegin_srv = global_zoom_ibegin > ibegin_srv ? global_zoom_ibegin : ibegin_srv ; 
    1885     zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; 
    1886     zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; 
    1887  
    1888     zoom_jbegin_srv = global_zoom_jbegin > jbegin_srv ? global_zoom_jbegin : jbegin_srv ; 
    1889     zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; 
    1890     zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; 
    1891  
    1892     if (zoom_ni_srv<=0 || zoom_nj_srv<=0) 
    1893     { 
    1894       zoom_ibegin_srv=0 ; zoom_iend_srv=0 ; zoom_ni_srv=0 ; 
    1895       zoom_jbegin_srv=0 ; zoom_jend_srv=0 ; zoom_nj_srv=0 ; 
    1896     } 
    1897     lonvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 
    1898     lonvalue_srv = 0. ; 
    1899     latvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 
    1900     latvalue_srv = 0. ; 
    1901     if (hasBounds) 
    1902     { 
    1903       bounds_lon_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; 
    1904       bounds_lon_srv = 0. ; 
    1905       bounds_lat_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; 
    1906       bounds_lat_srv = 0. ; 
    1907     } 
    1908  
    1909     if (hasArea) 
    1910     { 
    1911       area_srv.resize(zoom_ni_srv * zoom_nj_srv); 
    1912       area_srv = 0.; 
    1913     } 
    1914  
     2057    ni.setValue(ni_tmp); 
     2058    ibegin.setValue(ibegin_tmp); 
     2059    nj.setValue(nj_tmp); 
     2060    jbegin.setValue(jbegin_tmp); 
    19152061  } 
    19162062 
     
    19212067  void CDomain::recvIndex(CEventServer& event) 
    19222068  { 
    1923     CDomain* domain; 
     2069    string domainId; 
     2070    std::map<int, CBufferIn*> rankBuffers; 
    19242071 
    19252072    list<CEventServer::SSubEvent>::iterator it; 
    19262073    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    1927     { 
     2074    {       
    19282075      CBufferIn* buffer = it->buffer; 
    1929       string domainId; 
    19302076      *buffer >> domainId; 
    1931       domain = get(domainId); 
    1932       domain->recvIndex(it->rank, *buffer); 
    1933     } 
    1934  
    1935     if (domain->isCompressible_) 
    1936     { 
    1937       std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); 
    1938  
    1939       CContextServer* server = CContext::getCurrent()->server; 
    1940       domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); 
    1941       MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    1942       MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    1943       domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; 
    1944     } 
     2077      rankBuffers[it->rank] = buffer;         
     2078    } 
     2079    get(domainId)->recvIndex(rankBuffers); 
     2080 
     2081    // if (domain->isCompressible_) 
     2082    // { 
     2083    //   std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); 
     2084 
     2085    //   CContextServer* server = CContext::getCurrent()->server; 
     2086    //   domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); 
     2087    //   MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     2088    //   MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     2089    //   domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; 
     2090    // } 
    19452091  } 
    19462092 
    19472093  /*! 
    19482094    Receive index information from client(s) 
    1949     \param[in] rank rank of client source 
    1950     \param[in] buffer message containing index info 
     2095    \param[in] rankBuffers rank of sending client and the corresponding receive buffer   
    19512096  */ 
    1952   void CDomain::recvIndex(int rank, CBufferIn& buffer) 
    1953   { 
    1954     int type_int; 
    1955     buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; 
    1956     type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 
    1957  
    1958     if (isCompressible_) 
    1959     { 
    1960       CArray<int, 1> writtenIndexes; 
    1961       buffer >> writtenIndexes; 
    1962       indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 
    1963       for (int i = 0; i < writtenIndexes.numElements(); ++i) 
    1964         indexesToWrite.push_back(writtenIndexes(i)); 
    1965     } 
     2097  void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) 
     2098  { 
     2099    int nbReceived = rankBuffers.size(), i, ind, index, type_int; 
     2100    recvClientRanks_.resize(nbReceived); 
     2101    vector<CArray<int,1> > recvZoomInd(nbReceived); 
     2102 
     2103    std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); 
     2104    ind = 0; 
     2105    for (ind = 0; it != ite; ++it, ++ind) 
     2106    {        
     2107       recvClientRanks_[ind] = it->first; 
     2108       CBufferIn& buffer = *(it->second); 
     2109       buffer >> type_int >> isCurvilinear >> indGlob_[it->first] >> recvZoomInd[ind]; //recvIndGlob[ind]; 
     2110       type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 
     2111    } 
     2112    int nbIndGlob = 0; 
     2113    for (i = 0; i < nbReceived; ++i) 
     2114    { 
     2115      nbIndGlob += indGlob_[recvClientRanks_[i]].numElements(); 
     2116    } 
     2117     
     2118    i_index.resize(nbIndGlob); 
     2119    j_index.resize(nbIndGlob); 
     2120 
     2121    nbIndGlob = 0; 
     2122    for (i = 0; i < nbReceived; ++i) 
     2123    { 
     2124      CArray<int,1>& tmp = indGlob_[recvClientRanks_[i]]; 
     2125      for (ind = 0; ind < tmp.numElements(); ++ind) 
     2126      { 
     2127         index = tmp(ind); 
     2128         i_index(nbIndGlob) = index / ni_glo; 
     2129         j_index(nbIndGlob) = index % ni_glo; 
     2130         ++nbIndGlob; 
     2131      }  
     2132    } 
     2133 
     2134    int nbZoomInd = 0; 
     2135    for (i = 0; i < nbReceived; ++i) 
     2136    { 
     2137      nbZoomInd += recvZoomInd[i].numElements(); 
     2138    } 
     2139 
     2140    zoom_i_index.resize(nbZoomInd); 
     2141    zoom_j_index.resize(nbZoomInd); 
     2142     
     2143    nbZoomInd = 0; 
     2144    for (i = 0; i < nbReceived; ++i) 
     2145    { 
     2146      CArray<int,1>& tmp = recvZoomInd[i]; 
     2147      for (ind = 0; ind < tmp.numElements(); ++ind) 
     2148      { 
     2149         index = tmp(ind); 
     2150         zoom_i_index(nbZoomInd) = index / ni_glo; 
     2151         zoom_j_index(nbZoomInd) = index % ni_glo; 
     2152         ++nbZoomInd; 
     2153      }  
     2154    }     
     2155 
     2156    { 
     2157      CContextServer* server = CContext::getCurrent()->server; 
     2158      count_write_index_.resize(2); 
     2159      start_write_index_.resize(2); 
     2160      local_write_size_.resize(2); 
     2161      global_write_size_.resize(2); 
     2162      if ((this->type) == CDomain::type_attr::unstructured) 
     2163      { 
     2164        count_write_index_[0] = zoom_i_index.numElements(); 
     2165        count_write_index_[1] = 0; 
     2166      } 
     2167      else 
     2168      { 
     2169        int ni_zoom = zoom_i_index.numElements(), idx, nbIZoom = 0, nbJZoom = 0; 
     2170        for (idx =0; idx < ni_zoom; ++idx) 
     2171        { 
     2172           if ((ibegin <= zoom_i_index(idx)) && (zoom_i_index(idx) < ibegin+ni) && (nbIZoom < ni)) 
     2173            ++nbIZoom; 
     2174           if ((jbegin <= zoom_j_index(idx)) && (zoom_j_index(idx) < jbegin+nj) && (nbJZoom < nj)) 
     2175            ++nbJZoom; 
     2176        } 
     2177        count_write_index_[0] = nbIZoom; 
     2178        count_write_index_[1] = nbJZoom; 
     2179      } 
     2180             
     2181      MPI_Scan(&count_write_index_[0], &start_write_index_[0], 2, MPI_INT, MPI_SUM, server->intraComm);       
     2182      start_write_index_[0] = 0;  
     2183      start_write_index_[1] -= count_write_index_[1]; 
     2184      local_write_size_[0] = count_write_index_[0]; 
     2185      local_write_size_[1] = count_write_index_[1]; 
     2186      MPI_Allreduce(&count_write_index_[0], &global_write_size_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 
     2187      global_write_size_[0] = count_write_index_[0]; 
     2188      global_write_size_[1] = (global_write_size_[1] > nj_glo) ? nj_glo : global_write_size_[1]; 
     2189          
     2190    } 
     2191 
     2192    // int type_int; 
     2193    // buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; 
     2194    // type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 
     2195 
     2196    // if (isCompressible_) 
     2197    // { 
     2198    //   CArray<int, 1> writtenIndexes; 
     2199    //   buffer >> writtenIndexes; 
     2200    //   indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 
     2201    //   for (int i = 0; i < writtenIndexes.numElements(); ++i) 
     2202    //     indexesToWrite.push_back(writtenIndexes(i)); 
     2203    // } 
     2204  } 
     2205 
     2206  /*! 
     2207    Receive area event from clients(s) 
     2208    \param[in] event event contain info about rank and associated area 
     2209  */ 
     2210  void CDomain::recvMask(CEventServer& event) 
     2211  { 
     2212    string domainId; 
     2213    std::map<int, CBufferIn*> rankBuffers; 
     2214 
     2215    list<CEventServer::SSubEvent>::iterator it; 
     2216    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     2217    {       
     2218      CBufferIn* buffer = it->buffer; 
     2219      *buffer >> domainId; 
     2220      rankBuffers[it->rank] = buffer;      
     2221    } 
     2222    get(domainId)->recvMask(rankBuffers); 
     2223  } 
     2224 
     2225 
     2226  /*! 
     2227    Receive mask information from client(s) 
     2228    \param[in] rankBuffers rank of sending client and the corresponding receive buffer   
     2229  */ 
     2230  void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) 
     2231  { 
     2232    int nbReceived = rankBuffers.size(), i, ind, index; 
     2233    if (nbReceived != recvClientRanks_.size()) 
     2234      ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", 
     2235           << "The number of sending clients is not correct." 
     2236           << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
     2237 
     2238    vector<CArray<bool,1> > recvMaskValue(nbReceived);       
     2239    for (i = 0; i < recvClientRanks_.size(); ++i) 
     2240    { 
     2241      int rank = recvClientRanks_[i]; 
     2242      CBufferIn& buffer = *(rankBuffers[rank]);       
     2243      buffer >> recvMaskValue[i]; 
     2244    } 
     2245 
     2246    int nbMaskInd = 0; 
     2247    for (i = 0; i < nbReceived; ++i) 
     2248    { 
     2249      nbMaskInd += recvMaskValue[i].numElements(); 
     2250    } 
     2251   
     2252    mask_1d.resize(nbMaskInd); 
     2253    nbMaskInd = 0; 
     2254    for (i = 0; i < nbReceived; ++i) 
     2255    { 
     2256      CArray<bool,1>& tmp = recvMaskValue[i]; 
     2257      for (ind = 0; ind < tmp.numElements(); ++ind) 
     2258      { 
     2259        mask_1d(nbMaskInd) = tmp(ind);       
     2260        ++nbMaskInd; 
     2261      } 
     2262    }     
    19662263  } 
    19672264 
     
    19722269  void CDomain::recvLon(CEventServer& event) 
    19732270  { 
     2271    string domainId; 
     2272    std::map<int, CBufferIn*> rankBuffers; 
     2273 
    19742274    list<CEventServer::SSubEvent>::iterator it; 
    19752275    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    1976     { 
     2276    {       
    19772277      CBufferIn* buffer = it->buffer; 
    1978       string domainId; 
    19792278      *buffer >> domainId; 
    1980       get(domainId)->recvLon(it->rank, *buffer); 
    1981     } 
     2279      rankBuffers[it->rank] = buffer;         
     2280    } 
     2281    get(domainId)->recvLon(rankBuffers); 
    19822282  } 
    19832283 
    19842284  /*! 
    19852285    Receive longitude information from client(s) 
    1986     \param[in] rank rank of client source 
    1987     \param[in] buffer message containing longitude info 
     2286    \param[in] rankBuffers rank of sending client and the corresponding receive buffer   
    19882287  */ 
    1989   void CDomain::recvLon(int rank, CBufferIn& buffer) 
    1990   { 
    1991     CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 
    1992     CArray<double,1> lon; 
    1993     CArray<double,2> boundslon; 
    1994  
    1995     buffer >> lon; 
    1996  
    1997     if (hasBounds) buffer >> boundslon; 
    1998  
    1999     int i, j, ind_srv; 
    2000     for (int ind = 0; ind < indi.numElements(); ind++) 
    2001     { 
    2002       i = indi(ind); j = indj(ind); 
    2003       ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 
    2004       lonvalue_srv(ind_srv) = lon(ind); 
     2288  void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 
     2289  { 
     2290    int nbReceived = rankBuffers.size(), i, ind, index; 
     2291    if (nbReceived != recvClientRanks_.size()) 
     2292      ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", 
     2293           << "The number of sending clients is not correct." 
     2294           << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
     2295 
     2296    vector<CArray<double,1> > recvLonValue(nbReceived); 
     2297    vector<CArray<double,2> > recvBoundsLonValue(nbReceived);     
     2298    for (i = 0; i < recvClientRanks_.size(); ++i) 
     2299    { 
     2300      int rank = recvClientRanks_[i]; 
     2301      CBufferIn& buffer = *(rankBuffers[rank]); 
     2302      buffer >> hasLonLat; 
     2303      buffer >> recvLonValue[i]; 
     2304      buffer >> hasBounds; 
    20052305      if (hasBounds) 
    2006       { 
    2007         for (int nv = 0; nv < nvertex; ++nv) 
    2008           bounds_lon_srv(nv, ind_srv) = boundslon(nv, ind); 
     2306        buffer >> recvBoundsLonValue[i]; 
     2307    } 
     2308 
     2309    int nbLonInd = 0; 
     2310    for (i = 0; i < nbReceived; ++i) 
     2311    { 
     2312      nbLonInd += recvLonValue[i].numElements(); 
     2313    } 
     2314 
     2315    lonvalue.resize(nbLonInd); 
     2316    if (hasBounds) 
     2317    { 
     2318      bounds_lonvalue.resize(nvertex, nbLonInd); 
     2319    } 
     2320 
     2321    nbLonInd = 0; 
     2322    for (i = 0; i < nbReceived; ++i) 
     2323    { 
     2324      CArray<double,1>& tmp = recvLonValue[i]; 
     2325      for (ind = 0; ind < tmp.numElements(); ++ind) 
     2326      { 
     2327         lonvalue(nbLonInd) = tmp(ind); 
     2328         if (hasBounds) 
     2329         { 
     2330          CArray<double,2>& tmpBnds = recvBoundsLonValue[i]; 
     2331          for (int nv = 0; nv < nvertex; ++nv) 
     2332            bounds_lonvalue(nv, nbLonInd) = tmpBnds(nv, ind); 
     2333         }        
     2334         ++nbLonInd; 
    20092335      } 
    20102336    } 
     
    20172343  void CDomain::recvLat(CEventServer& event) 
    20182344  { 
     2345    string domainId; 
     2346    std::map<int, CBufferIn*> rankBuffers; 
     2347 
    20192348    list<CEventServer::SSubEvent>::iterator it; 
    20202349    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    2021     { 
     2350    {       
    20222351      CBufferIn* buffer = it->buffer; 
    2023       string domainId; 
    20242352      *buffer >> domainId; 
    2025       get(domainId)->recvLat(it->rank, *buffer); 
    2026     } 
     2353      rankBuffers[it->rank] = buffer;     
     2354    } 
     2355    get(domainId)->recvLat(rankBuffers); 
    20272356  } 
    20282357 
    20292358  /*! 
    20302359    Receive latitude information from client(s) 
    2031     \param[in] rank rank of client source 
    2032     \param[in] buffer message containing latitude info 
     2360    \param[in] rankBuffers rank of sending client and the corresponding receive buffer   
    20332361  */ 
    2034   void CDomain::recvLat(int rank, CBufferIn& buffer) 
    2035   { 
    2036     CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 
    2037     CArray<double,1> lat; 
    2038     CArray<double,2> boundslat; 
    2039  
    2040     buffer >> lat; 
    2041     if (hasBounds) buffer >> boundslat; 
    2042  
    2043     int i, j, ind_srv; 
    2044     for (int ind = 0; ind < indi.numElements(); ind++) 
    2045     { 
    2046       i = indi(ind); j = indj(ind); 
    2047       ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 
    2048       latvalue_srv(ind_srv) = lat(ind); 
     2362  void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 
     2363  { 
     2364    int nbReceived = rankBuffers.size(), i, ind, index; 
     2365    if (nbReceived != recvClientRanks_.size()) 
     2366      ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 
     2367           << "The number of sending clients is not correct." 
     2368           << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
     2369 
     2370    vector<CArray<double,1> > recvLatValue(nbReceived); 
     2371    vector<CArray<double,2> > recvBoundsLatValue(nbReceived);     
     2372    for (i = 0; i < recvClientRanks_.size(); ++i) 
     2373    { 
     2374      int rank = recvClientRanks_[i]; 
     2375      CBufferIn& buffer = *(rankBuffers[rank]); 
     2376      buffer >> hasLonLat; 
     2377      buffer >> recvLatValue[i]; 
     2378      buffer >> hasBounds; 
    20492379      if (hasBounds) 
    2050       { 
    2051         for (int nv = 0; nv < nvertex; nv++) 
    2052           bounds_lat_srv(nv, ind_srv) = boundslat(nv, ind); 
     2380        buffer >> recvBoundsLatValue[i]; 
     2381    } 
     2382 
     2383    int nbLatInd = 0; 
     2384    for (i = 0; i < nbReceived; ++i) 
     2385    { 
     2386      nbLatInd += recvLatValue[i].numElements(); 
     2387    } 
     2388 
     2389    latvalue.resize(nbLatInd); 
     2390    if (hasBounds) 
     2391    { 
     2392      bounds_latvalue.resize(nvertex, nbLatInd); 
     2393    } 
     2394     
     2395    nbLatInd = 0; 
     2396    for (i = 0; i < nbReceived; ++i) 
     2397    { 
     2398      CArray<double,1>& tmp = recvLatValue[i]; 
     2399      for (ind = 0; ind < tmp.numElements(); ++ind) 
     2400      {          
     2401         latvalue(nbLatInd) = tmp(ind); 
     2402         if (hasBounds) 
     2403         { 
     2404          CArray<double,2>& tmpBnds = recvBoundsLatValue[i]; 
     2405          for (int nv = 0; nv < nvertex; ++nv) 
     2406            bounds_latvalue(nv, nbLatInd) = tmpBnds(nv, ind); 
     2407         }        
     2408         ++nbLatInd; 
    20532409      } 
    20542410    } 
     
    20612417  void CDomain::recvArea(CEventServer& event) 
    20622418  { 
     2419    string domainId; 
     2420    std::map<int, CBufferIn*> rankBuffers; 
     2421 
    20632422    list<CEventServer::SSubEvent>::iterator it; 
    20642423    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    2065     { 
     2424    {       
    20662425      CBufferIn* buffer = it->buffer; 
    2067       string domainId; 
    20682426      *buffer >> domainId; 
    2069       get(domainId)->recvArea(it->rank, *buffer); 
    2070     } 
    2071   } 
     2427      rankBuffers[it->rank] = buffer;      
     2428    } 
     2429    get(domainId)->recvArea(rankBuffers); 
     2430  } 
     2431 
    20722432 
    20732433  /*! 
    20742434    Receive area information from client(s) 
    2075     \param[in] rank rank of client source 
    2076     \param[in] buffer message containing area info 
     2435    \param[in] rankBuffers rank of sending client and the corresponding receive buffer      
    20772436  */ 
    2078   void CDomain::recvArea(int rank, CBufferIn& buffer) 
    2079   { 
    2080     CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 
    2081     CArray<double,1> clientArea; 
    2082  
    2083     buffer >> clientArea; 
    2084  
    2085     int i, j, ind_srv; 
    2086     for (int ind = 0; ind < indi.numElements(); ind++) 
    2087     { 
    2088       i = indi(ind); j = indj(ind); 
    2089       ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 
    2090       area_srv(ind_srv) = clientArea(ind); 
     2437  void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 
     2438  { 
     2439    int nbReceived = rankBuffers.size(), i, ind, index; 
     2440    if (nbReceived != recvClientRanks_.size()) 
     2441      ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", 
     2442           << "The number of sending clients is not correct." 
     2443           << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
     2444 
     2445    vector<CArray<double,1> > recvAreaValue(nbReceived);       
     2446    for (i = 0; i < recvClientRanks_.size(); ++i) 
     2447    { 
     2448      int rank = recvClientRanks_[i]; 
     2449      CBufferIn& buffer = *(rankBuffers[rank]);       
     2450      buffer >> hasArea; 
     2451      if (hasArea) 
     2452        buffer >> recvAreaValue[i]; 
     2453    } 
     2454 
     2455    int nbAreaInd = 0; 
     2456    for (i = 0; i < nbReceived; ++i) 
     2457    { 
     2458      if (hasArea) 
     2459        nbAreaInd += recvAreaValue[i].numElements(); 
     2460    } 
     2461   
     2462    areavalue.resize(nbAreaInd); 
     2463    nbAreaInd = 0; 
     2464    if (hasArea) 
     2465    { 
     2466      for (i = 0; i < nbReceived; ++i) 
     2467      { 
     2468        CArray<double,1>& tmp = recvAreaValue[i]; 
     2469        for (ind = 0; ind < tmp.numElements(); ++ind) 
     2470        { 
     2471          area(nbAreaInd) = tmp(ind);       
     2472          ++nbAreaInd; 
     2473        } 
     2474      } 
     2475    } 
     2476  } 
     2477 
     2478  /*! 
     2479    Receive data index event from clients(s) 
     2480    \param[in] event event contain info about rank and associated index 
     2481  */ 
     2482  void CDomain::recvDataIndex(CEventServer& event) 
     2483  { 
     2484    string domainId; 
     2485    std::map<int, CBufferIn*> rankBuffers; 
     2486 
     2487    list<CEventServer::SSubEvent>::iterator it; 
     2488    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     2489    {       
     2490      CBufferIn* buffer = it->buffer; 
     2491      *buffer >> domainId; 
     2492      rankBuffers[it->rank] = buffer;         
     2493    } 
     2494    get(domainId)->recvDataIndex(rankBuffers); 
     2495 
     2496    // if (domain->isCompressible_) 
     2497    // { 
     2498    //   std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); 
     2499 
     2500    //   CContextServer* server = CContext::getCurrent()->server; 
     2501    //   domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); 
     2502    //   MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     2503    //   MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     2504    //   domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; 
     2505    // } 
     2506  } 
     2507 
     2508  /*! 
     2509    Receive data index information from client(s) 
     2510    A client receives data index from different clients to rebuild its own data index. 
     2511    Because the data index is local, to rebuild data index of received client, we should use global index along with.  
     2512    \param[in] rankBuffers rank of sending client and the corresponding receive buffer      
     2513  */ 
     2514  void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 
     2515  { 
     2516    int nbReceived = rankBuffers.size(), i, ind, index, indexI, type_int;     
     2517    if (nbReceived != recvClientRanks_.size()) 
     2518      ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 
     2519           << "The number of sending clients is not correct." 
     2520           << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
     2521 
     2522    vector<CArray<int,1> > recvDataIIndex(nbReceived),recvDataJIndex(nbReceived);      
     2523    for (i = 0; i < recvClientRanks_.size(); ++i) 
     2524    { 
     2525      int rank = recvClientRanks_[i]; 
     2526      CBufferIn& buffer = *(rankBuffers[rank]); 
     2527      buffer >> recvDataIIndex[i]; 
     2528      buffer >> recvDataJIndex[i]; 
     2529    } 
     2530    
     2531    int nbCompressedData = 0;  
     2532    for (i = 0; i < nbReceived; ++i) 
     2533    { 
     2534      CArray<int,1>& tmp = recvDataIIndex[i]; 
     2535      for (ind = 0; ind < tmp.numElements(); ++ind) 
     2536      { 
     2537         index = tmp(ind); 
     2538         if (0 <= index) 
     2539           ++nbCompressedData; 
     2540      }         
     2541    } 
     2542 
     2543    data_i_index.resize(nbCompressedData); 
     2544    data_j_index.resize(nbCompressedData); 
     2545 
     2546    nbCompressedData = 0; 
     2547    for (i = 0; i < nbReceived; ++i) 
     2548    { 
     2549      CArray<int,1>& tmpI = recvDataIIndex[i];       
     2550      CArray<int,1>& tmpIndex = indGlob_[recvClientRanks_[i]]; 
     2551      for (ind = 0; ind < tmpI.numElements(); ++ind) 
     2552      { 
     2553         indexI = tmpI(ind); 
     2554         index  = tmpIndex(ind); 
     2555         if (0 <= indexI) 
     2556         { 
     2557          data_i_index(nbCompressedData) = index % ni_glo - ibegin; 
     2558          data_j_index(nbCompressedData) = index / ni_glo - jbegin; 
     2559          ++nbCompressedData; 
     2560         }          
     2561      }  
    20912562    } 
    20922563  } 
     
    21232594  { 
    21242595    return transformationMap_; 
    2125   } 
    2126  
    2127   /*! 
    2128     Check the validity of all transformations applied on domain 
    2129   This functions is called AFTER all inherited attributes are solved 
    2130   */ 
    2131   void CDomain::checkTransformations() 
    2132   { 
    2133     TransMapTypes::const_iterator itb = transformationMap_.begin(), it, 
    2134                                   ite = transformationMap_.end(); 
    2135 //    for (it = itb; it != ite; ++it) 
    2136 //    { 
    2137 //      (it->second)->checkValid(this); 
    2138 //    } 
    21392596  } 
    21402597 
  • XIOS/dev/dev_olga/src/node/domain.hpp

    r987 r1025  
    1616#include "transformation.hpp" 
    1717#include "transformation_enum.hpp" 
    18  
     18#include "server_distribution_description.hpp" 
    1919#include "mesh.hpp" 
    2020 
     
    4949         enum EEventId 
    5050         { 
    51            EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, EVENT_ID_AREA 
     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 
    5254         } ; 
    5355 
     
    7577         /// Vérifications /// 
    7678         void checkAttributes(void); 
    77  
    7879         void checkAttributesOnClient(); 
    7980         void checkAttributesOnClientAfterTransformation(); 
    80  
    8181         void checkEligibilityForCompressedOutput(void); 
    8282 
     
    100100         int getOffsetWrittenIndexes() const; 
    101101 
     102         const std::vector<int>& getStartWriteIndex() const; 
     103         const std::vector<int>& getCountWriteIndex() const; 
     104         const std::vector<int>& getLocalWriteSize() const; 
     105         const std::vector<int>& getGlobalWriteSize() const; 
     106 
    102107         std::map<int, StdSize> getAttributesBufferSize(); 
    103108 
    104109         bool isEmpty(void) const; 
    105110         bool isDistributed(void) const; 
    106          bool isCompressible(void) const; 
    107  
    108          int ni_srv,ibegin_srv,iend_srv ; 
    109          int zoom_ni_srv,zoom_ibegin_srv,zoom_iend_srv ; 
    110  
    111          int nj_srv,jbegin_srv,jend_srv ; 
    112          int zoom_nj_srv,zoom_jbegin_srv,zoom_jend_srv ; 
    113  
    114          CArray<double, 1> lonvalue_srv, latvalue_srv ; 
    115          CArray<double, 2> bounds_lon_srv, bounds_lat_srv ; 
    116          CArray<double, 1> lonvalue_client, latvalue_client; 
    117          CArray<double, 2> bounds_lon_client, bounds_lat_client; 
    118          CArray<double, 1> area_srv; 
    119  
    120         vector<int> connectedServer ; // list of connected server 
    121         vector<int> nbSenders ; // for each communication with a server, number of communicating client 
    122         vector<int> nbDataSrv ; // size of data to send to each server 
    123         vector< vector<int> > i_indSrv ; // for each server, i global index to send 
    124         vector< vector<int> > j_indSrv ; // for each server, j global index to send 
     111         bool isCompressible(void) const;  
     112  
     113         CArray<double, 1> lonvalue, latvalue; 
     114         CArray<double, 2> bounds_lonvalue, bounds_latvalue; 
     115         CArray<double, 1> areavalue; 
     116 
     117         vector<int> connectedServer ; // list of connected server 
     118         vector<int> nbSenders ; // for each communication with a server, number of communicating client 
     119         vector<int> nbDataSrv ; // size of data to send to each server 
     120         vector< vector<int> > i_indSrv ; // for each server, i global index to send 
     121         vector< vector<int> > j_indSrv ; // for each server, j global index to send 
    125122 
    126123      public: 
     
    128125         void addRelFile(const StdString & filename); 
    129126         void addRelFileCompressed(const StdString& filename); 
    130          void completeLonLatClient(void); 
    131          void sendServerAttribut(void) ; 
    132          void sendLonLatArea(void); 
    133          void computeConnectedServer(void) ; 
     127         void completeLonLatClient(void);          
     128         void computeConnectedClients(); 
    134129 
    135130         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
     
    141136 
    142137         static bool dispatchEvent(CEventServer& event); 
    143          static void recvServerAttribut(CEventServer& event); 
     138         static void recvDistributionAttributes(CEventServer& event); 
    144139         static void recvIndex(CEventServer& event); 
     140         static void recvMask(CEventServer& event); 
     141         static void recvZoom(CEventServer& event); 
    145142         static void recvLon(CEventServer& event); 
    146143         static void recvLat(CEventServer& event); 
    147144         static void recvArea(CEventServer& event); 
    148          void recvServerAttribut(CBufferIn& buffer); 
    149          void recvIndex(int rank, CBufferIn& buffer); 
    150          void recvLon(int rank, CBufferIn& buffer); 
    151          void recvLat(int rank, CBufferIn& buffer); 
    152          void recvArea(int rank, CBufferIn& buffer); 
     145         static void recvDataIndex(CEventServer& event); 
     146         void recvDistributionAttributes(CBufferIn& buffer);          
     147         void recvZoom(std::vector<int>& rank, std::vector<CBufferIn*>& buffers); 
     148         void recvIndex(std::map<int, CBufferIn*>& rankBuffers); 
     149         void recvMask(std::map<int, CBufferIn*>& rankBuffers); 
     150         void recvLon(std::map<int, CBufferIn*>& rankBuffers); 
     151         void recvLat(std::map<int, CBufferIn*>& rankBuffers); 
     152         void recvArea(std::map<int, CBufferIn*>& rankBuffers);          
     153         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers); 
    153154 
    154155         /// Destructeur /// 
     
    160161 
    161162         static ENodeType GetType(void); 
    162          const std::map<int, vector<size_t> >& getIndexServer() const; 
     163         const boost::unordered_map<int, vector<size_t> >& getIndexServer() const; 
    163164         CArray<bool, 1> localMask; 
    164165         bool isCurvilinear ; 
     
    183184         void computeLocalMask(void) ; 
    184185 
    185          void checkTransformations(); 
    186          void setTransformations(const TransMapTypes&); 
    187          void computeNGlobDomain(); 
    188  
     186         void setTransformations(const TransMapTypes&);          
     187 
     188         void sendAttributes(); 
    189189         void sendIndex(); 
     190         void sendDistributionAttributes(); 
     191         void sendMask(); 
    190192         void sendArea(); 
    191193         void sendLonLat(); 
    192  
    193        private: 
     194         void sendZoom(); 
     195         void sendDataIndex(); 
     196 
     197       private:          
     198         std::vector<int> start_write_index_; 
     199         std::vector<int> count_write_index_; 
     200         std::vector<int> local_write_size_; 
     201         std::vector<int> global_write_size_; 
     202 
    194203         bool isChecked; 
    195204         std::set<StdString> relFiles, relFilesCompressed; 
    196205         bool isClientChecked; // Verify whether all attributes of domain on the client side are good 
    197206         bool isClientAfterTransformationChecked; 
    198          std::map<int, CArray<int,1> > indiSrv, indjSrv; 
    199          std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 
    200          std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 
     207         std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_; 
     208         std::map<int,int> nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server 
     209 
     210         boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 
     211         boost::unordered_map<int, vector<size_t> > indZoomSrv_; // Global index of each client sent to server 
    201212         std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 
    202213         std::vector<int> indexesToWrite; 
     214         std::vector<int> recvClientRanks_; 
    203215         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 
    204216         std::vector<int> connectedServerRank_; 
     
    207219         bool isCompressible_; 
    208220         bool isRedistributed_; 
    209          TransMapTypes transformationMap_; 
    210          std::vector<int> nGlobDomain_; 
     221         TransMapTypes transformationMap_;          
    211222         bool isUnstructed_; 
     223         boost::unordered_map<size_t,size_t> globalLocalIndexMap_; 
    212224        
    213225       private: 
  • XIOS/dev/dev_olga/src/node/field.cpp

    r1021 r1025  
    2323#include "temporal_filter.hpp" 
    2424#include "spatial_transform_filter.hpp" 
     25#include "file_server_writer_filter.hpp" 
    2526 
    2627namespace xios{ 
     
    234235  void CField::recvUpdateData(CEventServer& event) 
    235236  { 
    236     vector<int> ranks; 
    237     vector<CBufferIn*> buffers; 
     237    std::map<int,CBufferIn*> rankBuffers; 
    238238 
    239239    list<CEventServer::SSubEvent>::iterator it; 
     
    245245      CBufferIn* buffer = it->buffer; 
    246246      *buffer >> fieldId; 
    247       ranks.push_back(rank); 
    248       buffers.push_back(buffer); 
    249     } 
    250     get(fieldId)->recvUpdateData(ranks,buffers); 
     247      rankBuffers[rank] = buffer; 
     248    } 
     249    get(fieldId)->recvUpdateData(rankBuffers); 
    251250  } 
    252251 
    253   void  CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 
     252  void  CField::recvUpdateData(std::map<int,CBufferIn*>& rankBuffers) 
    254253  { 
    255254    CContext* context = CContext::getCurrent(); 
    256255 
    257     if (data_srv.empty()) 
     256    size_t sizeData = 0; 
     257    if (0 == recvDataSrv.numElements()) 
     258    {       
     259      for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
     260      { 
     261        sizeData += it->second.numElements(); 
     262      } 
     263 
     264      // Gather all data from different clients 
     265      recvDataSrv.resize(sizeData); 
     266      recvFoperationSrv = boost::shared_ptr<func::CFunctor>(new func::CInstant(recvDataSrv)); 
     267    } 
     268 
     269    CArray<double,1> recv_data_tmp(recvDataSrv.numElements()); 
     270    sizeData = 0; 
     271    const CDate& currDate = context->getCalendar()->getCurrentDate(); 
     272    const CDate opeDate      = last_operation_srv +freq_op + freq_operation_srv - freq_op; 
     273 
     274    if (opeDate <= currDate) 
    258275    { 
    259276      for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
    260       { 
    261         int rank = it->first; 
    262         data_srv.insert(std::make_pair(rank, CArray<double,1>(it->second.numElements()))); 
    263         foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(data_srv[rank])))); 
    264       } 
    265     } 
     277      {         
     278        CArray<double,1> tmp;        
     279        *(rankBuffers[it->first]) >> tmp; 
     280        recv_data_tmp(Range(sizeData,sizeData+it->second.numElements()-1)) = tmp;   
     281        sizeData += it->second.numElements();       
     282      } 
     283    } 
     284 
     285    this->setData(recv_data_tmp); 
     286  } 
     287 
     288  void CField::writeUpdateData(const CArray<double,1>& data) 
     289  { 
     290    CContext* context = CContext::getCurrent(); 
    266291 
    267292    const CDate& currDate = context->getCalendar()->getCurrentDate(); 
     
    271296    if (opeDate <= currDate) 
    272297    { 
    273       for (int n = 0; n < ranks.size(); n++) 
    274       { 
    275         CArray<double,1> data_tmp; 
    276         *buffers[n] >> data_tmp; 
    277         (*foperation_srv[ranks[n]])(data_tmp); 
    278       } 
     298      (*recvFoperationSrv)(data); 
    279299      last_operation_srv = currDate; 
     300//        sendUpdateData(fieldData); 
     301        // Redirecting data to the correct secondary server 
     302        //int fileIdx = std::find(context->enabledFiles.begin(), context->enabledFiles.end(), this->file) - context->enabledFiles.begin(); 
     303        //int srvId = fileIdx % context->clientPrimServer.size(); 
     304        //sendUpdateData(fieldData, context->clientPrimServer[srvId]); 
    280305    } 
    281306 
    282307    if (writeDate < (currDate + freq_operation_srv)) 
    283308    { 
    284       for (int n = 0; n < ranks.size(); n++) 
    285       { 
    286         this->foperation_srv[ranks[n]]->final(); 
    287       } 
    288  
     309      recvFoperationSrv->final(); 
    289310      last_Write_srv = writeDate; 
    290     } 
    291  
    292     if (context->hasClient && context->hasServer) 
    293     { 
    294       size_t writtenSize; 
    295 //      if (field->getUseCompressedOutput()) 
    296 //        writtenSize = grid->getNumberWrittenIndexes(); 
    297 //      else 
    298         writtenSize = grid->getWrittenDataSize(); 
    299  
    300       CArray<double,1> fieldData(writtenSize); 
    301 //      if (!field->default_value.isEmpty()) fieldData = field->default_value; 
    302  
    303 //      if (field->getUseCompressedOutput()) 
    304 //        field->outputCompressedField(fieldData); 
    305 //      else 
    306         this->outputField(fieldData); 
    307 //        sendUpdateData(fieldData); 
    308         // Redirecting data to the correct secondary server 
    309         int fileIdx = std::find(context->enabledFiles.begin(), context->enabledFiles.end(), this->file) - context->enabledFiles.begin(); 
    310         int srvId = fileIdx % context->clientPrimServer.size(); 
    311         sendUpdateData(fieldData, context->clientPrimServer[srvId]); 
    312     } 
    313     if (!context->hasClient && context->hasServer) 
    314     { 
    315 //      size_t writtenSize; 
    316 //      if (this->getUseCompressedOutput()) 
    317 //        writtenSize = grid->getNumberWrittenIndexes(); 
    318 //      else 
    319 //        writtenSize = grid->getWrittenDataSize(); 
    320 // 
    321 //      CArray<double,1> fieldData(writtenSize); 
    322  
    323 //      if (this->getUseCompressedOutput()) 
    324 //        this->outputCompressedField(fieldData); 
    325 //      else 
    326 //        this->outputField(fieldData); 
    327311      writeField(); 
    328     } 
    329  
    330     lastlast_Write_srv = last_Write_srv; 
    331  
     312      lastlast_Write_srv = last_Write_srv; 
     313    } 
    332314  } 
     315   
     316//   void  CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 
     317//   { 
     318//     CContext* context = CContext::getCurrent(); 
     319 
     320//     if (data_srv.empty()) 
     321//     { 
     322//       for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
     323//       { 
     324//         int rank = it->first; 
     325//         data_srv.insert(std::make_pair(rank, CArray<double,1>(it->second.numElements()))); 
     326//         foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(data_srv[rank])))); 
     327//       } 
     328//     } 
     329 
     330//     const CDate& currDate = context->getCalendar()->getCurrentDate(); 
     331//     const CDate opeDate      = last_operation_srv +freq_op + freq_operation_srv - freq_op; 
     332//     const CDate writeDate    = last_Write_srv     + freq_write_srv; 
     333 
     334//     if (opeDate <= currDate) 
     335//     { 
     336//       for (int n = 0; n < ranks.size(); n++) 
     337//       { 
     338//         CArray<double,1> data_tmp; 
     339//         *buffers[n] >> data_tmp; 
     340//         (*foperation_srv[ranks[n]])(data_tmp); 
     341//       } 
     342//       last_operation_srv = currDate; 
     343//     } 
     344 
     345//     if (writeDate < (currDate + freq_operation_srv)) 
     346//     { 
     347//       for (int n = 0; n < ranks.size(); n++) 
     348//       { 
     349//         this->foperation_srv[ranks[n]]->final(); 
     350//       } 
     351 
     352//       last_Write_srv = writeDate; 
     353//     } 
     354 
     355//     if (context->hasClient && context->hasServer) 
     356//     { 
     357//       size_t writtenSize; 
     358// //      if (field->getUseCompressedOutput()) 
     359// //        writtenSize = grid->getNumberWrittenIndexes(); 
     360// //      else 
     361//         writtenSize = grid->getWrittenDataSize(); 
     362 
     363//       CArray<double,1> fieldData(writtenSize); 
     364// //      if (!field->default_value.isEmpty()) fieldData = field->default_value; 
     365 
     366// //      if (field->getUseCompressedOutput()) 
     367// //        field->outputCompressedField(fieldData); 
     368// //      else 
     369//         this->outputField(fieldData); 
     370//       sendUpdateData(fieldData); 
     371//     } 
     372//     if (!context->hasClient && context->hasServer) 
     373//     { 
     374//       writeField(); 
     375//     } 
     376 
     377//     lastlast_Write_srv = last_Write_srv; 
     378 
     379//   } 
    333380 
    334381  void CField::writeField(void) 
     
    656703 
    657704   //---------------------------------------------------------------- 
    658  
    659    void CField::solveOnlyReferenceEnabledField(bool doSending2Server) 
    660    { 
    661      CContext* context = CContext::getCurrent(); 
    662      if (!isReferenceSolved) 
    663      { 
    664         isReferenceSolved = true; 
    665  
    666         if (context->hasClient && !context->hasServer) 
    667 //        if (context->hasClient) 
    668         { 
    669           solveRefInheritance(true); 
    670           if (hasDirectFieldReference()) getDirectFieldReference()->solveOnlyReferenceEnabledField(false); 
    671         } 
    672 //        else if (context->hasServer) 
    673         if (context->hasServer) 
    674           solveServerOperation(); 
    675  
    676         solveGridReference(); 
    677  
    678         if (context->hasClient && !context->hasServer) 
    679 //       if (context->hasClient) 
    680        { 
    681          solveGenerateGrid(); 
    682          buildGridTransformationGraph(); 
    683        } 
    684      } 
    685    } 
    686705 
    687706   /*! 
     
    784803     } 
    785804   } 
    786  
     805    
     806   void CField::solveAllEnabledFields() 
     807   { 
     808     CContext* context = CContext::getCurrent(); 
     809     bool hasClient = context->hasClient; 
     810     bool hasServer = context->hasServer; 
     811 
     812     if (!isReferenceSolved) 
     813     { 
     814        isReferenceSolved = true; 
     815 
     816        if (hasClient && !hasServer) 
     817        { 
     818          solveRefInheritance(true); 
     819          if (hasDirectFieldReference()) getDirectFieldReference()->solveAllEnabledFields(); 
     820        } 
     821 
     822        if (hasServer) 
     823          solveServerOperation(); 
     824 
     825        solveGridReference(); 
     826 
     827        if (hasClient && !hasServer) 
     828       { 
     829         solveGenerateGrid(); 
     830         buildGridTransformationGraph(); 
     831       } 
     832 
     833       solveGridDomainAxisRef(false); 
     834 
     835       if (hasClient && !hasServer) 
     836       { 
     837         solveTransformedGrid(); 
     838       } 
     839 
     840       solveGridDomainAxisRef(false); 
     841     } 
     842   } 
     843 
     844   void CField::checkGridOfEnabledFields() 
     845   { 
     846      solveCheckMaskIndex(false); 
     847   } 
     848 
     849   void CField::sendGridOfEnabledFields() 
     850   { 
     851      solveGridDomainAxisRef(true); 
     852      solveCheckMaskIndex(true); 
     853   } 
     854 
     855 
     856    void CField::solveOnlyReferenceEnabledField(bool doSending2Server) 
     857   { 
     858     CContext* context = CContext::getCurrent(); 
     859     if (!isReferenceSolved) 
     860     { 
     861        isReferenceSolved = true; 
     862 
     863        if (context->hasClient && !context->hasServer) 
     864//        if (context->hasClient) 
     865        { 
     866          solveRefInheritance(true); 
     867          if (hasDirectFieldReference()) getDirectFieldReference()->solveOnlyReferenceEnabledField(false); 
     868        } 
     869//        else if (context->hasServer) 
     870        if (context->hasServer) 
     871          solveServerOperation(); 
     872 
     873        solveGridReference(); 
     874 
     875        if (context->hasClient && !context->hasServer) 
     876//       if (context->hasClient) 
     877       { 
     878         solveGenerateGrid(); 
     879         buildGridTransformationGraph(); 
     880       } 
     881     } 
     882   } 
     883      
    787884   void CField::solveAllReferenceEnabledField(bool doSending2Server) 
    788885   { 
     
    794891        areAllReferenceSolved = true; 
    795892 
    796 //        if (context->hasClient) 
     893       // if (context->hasClient) 
    797894        if (context->hasClient && !context->hasServer) 
    798895        { 
     
    800897          if (hasDirectFieldReference()) getDirectFieldReference()->solveAllReferenceEnabledField(false); 
    801898        } 
    802 //        else if (context->hasServer) 
    803         if (context->hasServer && !context->hasClient) 
     899       else if (context->hasServer) 
     900        // if (context->hasServer && !context->hasClient) 
    804901          solveServerOperation(); 
    805902 
     
    885982   void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput) 
    886983   { 
    887      if (!areAllReferenceSolved) solveAllReferenceEnabledField(false); 
    888  
    889      // Start by building a filter which can provide the field's instant data 
    890      if (!instantDataFilter) 
    891      { 
    892        // Check if we have an expression to parse 
     984     // if (!areAllReferenceSolved) solveAllReferenceEnabledField(false); 
     985    if (!isReferenceSolved) solveAllEnabledFields(); 
     986     CContext* context = CContext::getCurrent(); 
     987     bool hasWriterServer = context->hasServer && !context->hasClient; 
     988     bool hasIntermediateServer = context->hasServer && context->hasClient; 
     989 
     990     if (hasWriterServer) 
     991     { 
     992        if (!instantDataFilter) 
     993          instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 
     994 
     995             // If the field data is to be read by the client or/and written to a file 
     996       if (enableOutput && !storeFilter && !fileWriterFilter) 
     997       { 
     998         if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write)) 
     999         { 
     1000           fileServerWriterFilter = boost::shared_ptr<CFileServerWriterFilter>(new CFileServerWriterFilter(gc, this)); 
     1001           instantDataFilter->connectOutput(fileServerWriterFilter, 0); 
     1002         } 
     1003       } 
     1004     } 
     1005     else if (hasIntermediateServer) 
     1006     { 
     1007       if (!instantDataFilter) 
     1008          instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 
     1009 
     1010             // If the field data is to be read by the client or/and written to a file 
     1011       if (enableOutput && !storeFilter && !fileWriterFilter) 
     1012       { 
     1013         if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write)) 
     1014         { 
     1015           fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this)); 
     1016           instantDataFilter->connectOutput(fileWriterFilter, 0); 
     1017         } 
     1018       } 
     1019     } 
     1020     else 
     1021     { 
     1022       // Start by building a filter which can provide the field's instant data 
     1023       if (!instantDataFilter) 
     1024       { 
     1025         // Check if we have an expression to parse 
    8931026       if (hasExpression()) 
    894        { 
     1027         { 
    8951028         boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0')); 
    8961029         boost::shared_ptr<COutputPin> filter = expr->reduce(gc, *this); 
     
    9121045 
    9131046         instantDataFilter = filter; 
    914        } 
    915        // Check if we have a reference on another field 
    916        else if (!field_ref.isEmpty()) 
    917          instantDataFilter = getFieldReference(gc); 
    918        // Check if the data is to be read from a file 
    919        else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) 
     1047         } 
     1048         // Check if we have a reference on another field 
     1049         else if (!field_ref.isEmpty()) 
     1050           instantDataFilter = getFieldReference(gc); 
     1051         // Check if the data is to be read from a file 
     1052         else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) 
    9201053         instantDataFilter = serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, 
    9211054                                                                                                     freq_offset.isEmpty() ? NoneDu : freq_offset, 
    9221055                                                                                                     true)); 
    923        else // The data might be passed from the model 
     1056         else // The data might be passed from the model 
    9241057         instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid)); 
    925      } 
    926  
    927      // If the field data is to be read by the client or/and written to a file 
    928      if (enableOutput && !storeFilter && !fileWriterFilter) 
    929      { 
    930        if (!read_access.isEmpty() && read_access) 
    931        { 
    932          storeFilter = boost::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid)); 
    933          instantDataFilter->connectOutput(storeFilter, 0); 
    934        } 
    935  
    936        if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write)) 
    937        { 
    938          fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this)); 
    939          getTemporalDataFilter(gc, file->output_freq)->connectOutput(fileWriterFilter, 0); 
     1058       } 
     1059 
     1060       // If the field data is to be read by the client or/and written to a file 
     1061       if (enableOutput && !storeFilter && !fileWriterFilter) 
     1062       { 
     1063         if (!read_access.isEmpty() && read_access) 
     1064         { 
     1065           storeFilter = boost::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid)); 
     1066           instantDataFilter->connectOutput(storeFilter, 0); 
     1067         } 
     1068 
     1069         if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write)) 
     1070         { 
     1071           fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this)); 
     1072           getTemporalDataFilter(gc, file->output_freq)->connectOutput(fileWriterFilter, 0); 
     1073         } 
    9401074       } 
    9411075     } 
     
    12851419   void CField::outputField(CArray<double,1>& fieldOut) 
    12861420   { 
    1287       map<int, CArray<double,1> >::iterator it; 
    1288  
    1289       for (it = data_srv.begin(); it != data_srv.end(); it++) 
    1290       { 
    1291          grid->outputField(it->first, it->second, fieldOut.dataFirst()); 
    1292       } 
     1421      // map<int, CArray<double,1> >::iterator it; 
     1422 
     1423      // for (it = data_srv.begin(); it != data_srv.end(); it++) 
     1424      // { 
     1425      //    grid->outputField(it->first, it->second, fieldOut.dataFirst()); 
     1426      // } 
     1427    grid->outputField(recvDataSrv, fieldOut); 
    12931428   } 
    12941429 
  • XIOS/dev/dev_olga/src/node/file.cpp

    r1021 r1025  
    689689     for (int i = 0; i < size; ++i) 
    690690     { 
    691        this->enabledFields[i]->solveOnlyReferenceEnabledField(sendToServer); 
     691       // this->enabledFields[i]->solveOnlyReferenceEnabledField(sendToServer); 
     692       this->enabledFields[i]->solveAllEnabledFields(); 
    692693//       this->enabledFields[i]->buildGridTransformationGraph(); 
     694     } 
     695   } 
     696 
     697   void CFile::checkGridOfEnabledFields() 
     698   {  
     699     int size = this->enabledFields.size(); 
     700     for (int i = 0; i < size; ++i) 
     701     { 
     702       this->enabledFields[i]->checkGridOfEnabledFields(); 
     703     } 
     704   } 
     705 
     706   void CFile::sendGridOfEnabledFields() 
     707   {  
     708     int size = this->enabledFields.size(); 
     709     for (int i = 0; i < size; ++i) 
     710     { 
     711       this->enabledFields[i]->sendGridOfEnabledFields(); 
    693712     } 
    694713   } 
  • XIOS/dev/dev_olga/src/node/file.hpp

    r1021 r1025  
    110110         void prefetchEnabledReadModeFieldsIfNeeded(); 
    111111 
     112         void checkGridOfEnabledFields(); 
     113         void sendGridOfEnabledFields(); 
     114 
    112115         // Add component into file 
    113116         CField* addField(const string& id = ""); 
  • XIOS/dev/dev_olga/src/node/grid.hpp

    r1021 r1025  
    225225 
    226226         map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient; 
     227         CArray<size_t,1> indexFromClients; 
    227228         void checkMask(void); 
    228229         void createMask(void); 
     
    260261        void computeIndexByElement(const std::vector<boost::unordered_map<size_t,std::vector<int> > >& indexServerOnElement, 
    261262                                   CClientServerMapping::GlobalIndexMap& globalIndexOnServer); 
     263 
     264        void computeClientIndex(); 
     265        void computeConnectedClients(); 
    262266 
    263267      private: 
  • XIOS/dev/dev_olga/src/object_template_impl.hpp

    r1021 r1025  
    256256      CAttributeMap & attrMap = *this; 
    257257      CAttribute* attr=attrMap[id]; 
    258       sendAttributToServer(*attr); 
     258      if (attr->doSend())  
     259        sendAttributToServer(*attr); 
    259260   } 
    260261 
  • XIOS/dev/dev_olga/src/test/test_client.f90

    r987 r1025  
    1717  CHARACTER(len=15) :: calendar_type 
    1818  TYPE(xios_context) :: ctx_hdl 
    19   INTEGER,PARAMETER :: ni_glo=2 
    20   INTEGER,PARAMETER :: nj_glo=2 
    21   INTEGER,PARAMETER :: llm=1 
     19  INTEGER,PARAMETER :: ni_glo=4 
     20  INTEGER,PARAMETER :: nj_glo=4 
     21  INTEGER,PARAMETER :: llm=5 
    2222  DOUBLE PRECISION  :: lval(llm)=1 
    2323  TYPE(xios_field) :: field_hdl 
     
    2828  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 
    2929  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) 
    30   DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), lonvalue(:,:) ; 
     30  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), lonvalue(:,:), axisValue(:), field_domain(:,:) ; 
    3131  INTEGER :: ni,ibegin,iend,nj,jbegin,jend 
    3232  INTEGER :: i,j,l,ts,n 
     
    6666  iend=ibegin+ni-1 ; jend=jbegin+nj-1 
    6767 
    68   ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni,nj)) 
     68  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni,nj), axisValue(nj), field_domain(0:ni+1,-1:nj+2)) 
    6969  lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1) 
    7070  lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1) 
    7171  field_A(1:ni,1:nj,:)=field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:) 
     72  field_domain(1:ni,1:nj) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,1) 
     73  axisValue(1:nj)=field_A(1,1:nj,1); 
    7274 
    7375  CALL xios_context_initialize("test",comm) 
     
    7880  PRINT *, "calendar_type = ", calendar_type 
    7981 
     82  ! CALL xios_set_axis_attr("axis_A",n_glo=nj_glo ,value=axisValue, n=nj, begin=jbegin) ; 
    8083  CALL xios_set_axis_attr("axis_A",n_glo=llm ,value=lval) ; 
    8184  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj,type='curvilinear') 
     
    128131 
    129132  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
    130   DO ts=1,24 
     133  DO ts=1,40 
    131134    CALL xios_update_calendar(ts) 
    132     CALL xios_send_field("field_A",field_A) 
     135    ! CALL xios_send_field("field_A",field_A) 
     136    ! CALL xios_send_field("field_Axis",axisValue) 
     137    ! CALL xios_send_field("field_Axis",lval) 
     138    CALL xios_send_field("field_Domain",field_domain) 
    133139    CALL wait_us(5000) ; 
    134140  ENDDO 
  • XIOS/dev/dev_olga/src/test/test_remap.f90

    r978 r1025  
    166166 
    167167  CALL xios_close_context_definition() 
    168   ! CALL xios_get_domain_attr("src_domain_regular_read", ni=src_tmp_ni, nj=src_tmp_nj) 
    169   ! ALLOCATE(tmp_field_0(src_tmp_ni*src_tmp_nj)) 
     168  CALL xios_get_domain_attr("src_domain_regular_read", ni=src_tmp_ni, nj=src_tmp_nj) 
     169  ALLOCATE(tmp_field_0(src_tmp_ni*src_tmp_nj)) 
    170170 
    171171  ! CALL xios_get_axis_attr("src_axis_curvilinear_read", n=src_tmp_n) 
     
    177177 
    178178  DO ts=1,5 
    179     ! CALL xios_recv_field("src_field_regular", tmp_field_0) 
     179    CALL xios_recv_field("src_field_regular", tmp_field_0) 
    180180    ! CALL xios_recv_field("src_field_curvilinear", tmp_field_1) 
    181181    ! CALL xios_recv_field("src_field_unstructured", tmp_field_2) 
     
    186186    CALL xios_send_field("src_field_4D",src_field_4D) 
    187187    CALL xios_send_field("src_field_3D_pression",src_field_pression) 
    188     ! CALL xios_send_field("tmp_field_0",tmp_field_0) 
     188    CALL xios_send_field("tmp_field_0",tmp_field_0) 
    189189    ! CALL xios_send_field("tmp_field_1",tmp_field_1) 
    190190    ! CALL xios_send_field("tmp_field_2",tmp_field_2) 
Note: See TracChangeset for help on using the changeset viewer.