Changeset 1202 for XIOS/dev


Ignore:
Timestamp:
07/10/17 15:16:17 (7 years ago)
Author:
mhnguyen
Message:

Porting non-continuous axis zoom to dev branch

+) Port axis zoom
+) Resolve some merge conflicts
+) Revert some codes

Test
+) On Curie
+) Ok

Location:
XIOS/dev/dev_olga
Files:
11 edited

Legend:

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

    r1099 r1202  
    1111     <field id="field_Domain"  operation="average" freq_op="3600s" domain_ref="domain_A"/> 
    1212     <field id="field_A_zoom"  operation="average" freq_op="3600s" field_ref="field_A" grid_ref="grid_A_zoom"/> 
     13     <field id="field_Scalar"  operation="average" freq_op="3600s" grid_ref="grid_Scalar"/> 
    1314   </field_definition> 
    1415 
    1516 
    16    <file_definition type="one_file" par_access="collective" output_freq="1h" output_level="10" enabled=".TRUE."> 
    17      <file id="output" name="output"> 
     17   <file_definition type="one_file" par_access="collective" output_freq="1h" output_level="10" enabled=".FALSE."> 
     18      <file id="output" name="output" enabled=".TRUE."> 
    1819        <!-- <field field_ref="field_Domain" name="field_A" /> --> 
    1920        <field field_ref="field_A" name="field_A" />  
    20         <field field_ref="field_A" name="field_B" /> 
     21        <field field_ref="field_A_zoom" name="field_B" /> 
    2122     </file> 
    22      <file id="output1" name="output1"> 
     23     <file id="output1" name="output1" enabled=".TRUE."> 
    2324        <!-- <field field_ref="field_Domain" name="field_A" /> --> 
    2425        <field field_ref="field_A" name="field_A" />         
     26     </file>  
     27     <file id="output2" name="output2" enabled=".TRUE."> 
     28        <!-- <field field_ref="field_Domain" name="field_A" /> --> 
     29        <field field_ref="field_Scalar" name="field_A" />         
    2530     </file> 
     31 <!--     <file id="output_s" name="output_s" mode="read" > 
     32       <field id="field" name="field_A" grid_ref="grid_Scalar" operation="instant" /> 
     33     </file> --> 
    2634   </file_definition> 
    2735 
     36  <scalar_defintion> 
     37    <scalar id="scalar_A"/> 
     38  </scalar_defintion> 
    2839 
    2940   <axis_definition> 
    3041     <axis id="axis_A"/> 
    3142     <axis id="axis_A_zoom" axis_ref="axis_A"> 
    32        <zoom_axis begin="0" n="1" /> 
     43       <zoom_axis index="(0,1)[0 2]" /> 
    3344     </axis> 
    3445   </axis_definition> 
     
    4758       <domain domain_ref="domain_A" /> 
    4859       <axis axis_ref="axis_A_zoom" /> 
     60     </grid> 
     61     <grid id="grid_Scalar"> 
     62      <scalar id="scalar_A"/> 
    4963     </grid> 
    5064   </grid_definition> 
  • XIOS/dev/dev_olga/src/config/axis_attribute_private.conf

    r1201 r1202  
    22DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_n) 
    33DECLARE_ARRAY_PRIVATE(int,  1, global_zoom_index) 
    4 DECLARE_ATTRIBUTE_PRIVATE(int, zoom_begin) 
    5 DECLARE_ATTRIBUTE_PRIVATE(int, zoom_n) 
    64 
    75/* LOCAL DATA*/ 
    86DECLARE_ARRAY_PRIVATE(int    ,   1 , zoom_index) 
     7DECLARE_ATTRIBUTE_PRIVATE(int, zoom_begin) 
     8DECLARE_ATTRIBUTE_PRIVATE(int, zoom_n) 
  • XIOS/dev/dev_olga/src/distribution_server.cpp

    r1144 r1202  
    2222} 
    2323 
     24CDistributionServer::CDistributionServer(int rank,  
     25                                        const std::vector<CArray<int,1> >& globalIndexElements, 
     26                                        const CArray<int,1>& elementOrder, 
     27                                        const std::vector<int>& nZoomBegin, 
     28                                        const std::vector<int>& nZoomSize, 
     29                                        const std::vector<int>& nZoomBeginGlobal, 
     30                                        const std::vector<int>& nGlobal) 
     31  : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(nZoomBeginGlobal), 
     32    nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 
     33{ 
     34  createGlobalIndex(globalIndexElements, elementOrder); 
     35} 
     36 
    2437CDistributionServer::~CDistributionServer() 
    2538{ 
     
    7083      this->globalIndex_(idx) = globalIndex; 
    7184 
     85      ++idx; 
     86    } 
     87    idxLoop[0] += innerLoopSize; 
     88  } 
     89} 
     90 
     91/*! 
     92  Create global index on server side 
     93  Like the similar function on client side, this function serves on creating global index 
     94for data written by the server. The global index is used to calculating local index of data 
     95written on each server 
     96  \param[in] globalIndexElement global index on server side of each element of grid (scalar, axis, domain) 
     97  \param[in] elementOrder the order of elements of grid (e.x: domain->axis or domain->scalar) 
     98*/ 
     99void CDistributionServer::createGlobalIndex(const std::vector<CArray<int,1> >& globalIndexElements, 
     100                                            const CArray<int,1>& elementOrder) 
     101{ 
     102  int numElement = elementOrder.numElements(), elementIdx = 0;   
     103  std::vector<int> indexMap(numElement); 
     104  for (int i = 0; i < numElement; ++i) 
     105  { 
     106    indexMap[i] = elementIdx; 
     107    if (2 == elementOrder(i)) 
     108    {       
     109      elementIdx += 2; 
     110    } 
     111    else 
     112      ++elementIdx; 
     113  } 
     114 
     115  std::vector<size_t> elementGlobalSize(numElement); 
     116  size_t globalSize = 1; 
     117  for (int i = 0; i < numElement; ++i) 
     118  { 
     119    int elementType = elementOrder(i); 
     120    elementGlobalSize[i] = globalSize; 
     121    if (2 == elementType) // domain 
     122    { 
     123      globalSize *= nGlobal_[indexMap[i]+1] * nGlobal_[indexMap[i]]; 
     124    } 
     125    else // axis or scalar 
     126    { 
     127      globalSize *= nGlobal_[indexMap[i]]; 
     128    } 
     129  }  
     130 
     131  size_t ssize = 1; 
     132  for (int i = 0; i < globalIndexElements.size(); ++i) ssize *= globalIndexElements[i].numElements(); 
     133  this->globalIndex_.resize(ssize); 
     134  globalLocalIndexMap_.rehash(std::ceil(ssize/globalLocalIndexMap_.max_load_factor())); 
     135 
     136  std::vector<int> idxLoop(numElement,0); 
     137  std::vector<int> currentIndex(numElement); 
     138  int innerLoopSize = globalIndexElements[0].numElements(); 
     139 
     140  size_t idx = 0; 
     141  while (idx<ssize) 
     142  { 
     143    for (int i = 0; i < numElement-1; ++i) 
     144    { 
     145      if (idxLoop[i] == globalIndexElements[i].numElements()) 
     146      { 
     147        idxLoop[i] = 0; 
     148        ++idxLoop[i+1]; 
     149      } 
     150    } 
     151 
     152    for (int i = 1; i < numElement; ++i)  currentIndex[i] = globalIndexElements[i](idxLoop[i]); 
     153 
     154    size_t mulDim, globalIndex; 
     155    for (int i = 0; i < innerLoopSize; ++i) 
     156    {       
     157      globalIndex = 0; 
     158      currentIndex[0] = globalIndexElements[0](i); 
     159 
     160      for (int k = 0; k < numElement; ++k) 
     161      {      
     162        globalIndex += (currentIndex[k])*elementGlobalSize[k]; 
     163      } 
     164      globalLocalIndexMap_[globalIndex] = idx; 
     165      this->globalIndex_(idx) = globalIndex; 
    72166      ++idx; 
    73167    } 
  • XIOS/dev/dev_olga/src/distribution_server.hpp

    r1201 r1202  
    5353  protected: 
    5454    virtual void createGlobalIndex(); 
    55  
     55    void createGlobalIndex(const std::vector<CArray<int,1> >& globalIndexElements, 
     56                           const CArray<int,1>& elementOrder); 
     57     
    5658  protected: 
    5759    GlobalLocalMap globalLocalIndexMap_; 
  • XIOS/dev/dev_olga/src/node/axis.cpp

    r1158 r1202  
    2727      , hasBounds_(false), isCompressible_(false) 
    2828      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    29       , transformationMap_(), hasValue(false), doZoomByIndex_(false), hasLabel(false) 
     29      , transformationMap_(), hasValue(false), hasLabel(false) 
    3030      , computedWrittenIndex_(false) 
    3131   { 
     
    3838      , hasBounds_(false), isCompressible_(false) 
    3939      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    40       , transformationMap_(), hasValue(false), doZoomByIndex_(false), hasLabel(false) 
     40      , transformationMap_(), hasValue(false), hasLabel(false) 
    4141      , computedWrittenIndex_(false) 
    4242   { 
     
    365365    else hasLabel = false; 
    366366  } 
     367 
    367368  void CAxis::checkEligibilityForCompressedOutput() 
    368369  { 
    369370    // We don't check if the mask is valid here, just if a mask has been defined at this point. 
    370371    isCompressible_ = !mask.isEmpty(); 
     372  } 
     373 
     374  bool CAxis::zoomByIndex() 
     375  { 
     376    return (!global_zoom_index.isEmpty() && (0 != global_zoom_index.numElements())); 
    371377  } 
    372378 
     
    477483      size_t nbIndex = index.numElements(); 
    478484 
    479       if (doZoomByIndex_)  
    480       { 
    481         nZoomCount = zoom_index.numElements(); 
    482       } 
    483       else 
    484       { 
    485         for (size_t idx = 0; idx < nbIndex; ++idx) 
    486         { 
    487           globalLocalIndexMap_[index(idx)] = idx; 
    488           size_t globalIndex = index(idx); 
    489           if (globalIndex >= global_zoom_begin && globalIndex <= global_zoom_end) ++nZoomCount; 
    490         } 
    491       } 
    492  
    493  
    494       CArray<size_t,1> globalIndexAxis(nbIndex); 
    495       std::vector<size_t> globalAxisZoom(nZoomCount); 
    496       nZoomCount = 0; 
    497       if (doZoomByIndex_)  
    498       { 
    499         int nbIndexZoom = zoom_index.numElements();         
    500         for (int i = 0; i < nbIndexZoom; ++i) 
    501         {    
    502           globalIndexAxis(i) = zoom_index(i); 
    503         } 
    504       } 
    505       else  
    506       { 
    507         for (size_t idx = 0; idx < nbIndex; ++idx) 
    508         { 
    509           size_t globalIndex = index(idx); 
    510           globalIndexAxis(idx) = globalIndex; 
    511           if (globalIndex >= global_zoom_begin && globalIndex <= global_zoom_end) 
    512           { 
    513             globalAxisZoom[nZoomCount] = globalIndex; 
    514             ++nZoomCount; 
    515           } 
    516         } 
    517  
    518         int end       = begin + n -1;         
    519         zoom_begin    = global_zoom_begin > begin ? global_zoom_begin : begin; 
    520         int zoom_end  = global_zoom_end < end ? zoom_end : end; 
    521         zoom_n        = zoom_end-zoom_begin+1; 
    522       } 
    523  
     485      for (size_t idx = 0; idx < nbIndex; ++idx) 
     486      { 
     487        globalLocalIndexMap_[index(idx)] = idx; 
     488      } 
    524489      std::set<int> writtenInd; 
    525490      if (isCompressible_) 
     
    593558      indSrv_.swap(globalIndexAxisOnServer); 
    594559 
    595       CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_.begin(), 
     560      CClientServerMapping::GlobalIndexMap::const_iterator it  = indSrv_.begin(), 
    596561                                                           ite = indSrv_.end(); 
    597562 
     
    625590                                                          ite = globalLocalIndexMap_.end(), it;           
    626591      CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 
    627                                        itSrve = writtenGlobalIndex.end(), itSrv;       
    628  
    629       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    630       { 
    631         indGlo = *itSrv; 
    632         if (ite != globalLocalIndexMap_.find(indGlo)) 
    633         {           
    634           ++nbWritten; 
    635         }                  
    636       } 
    637  
    638       localIndexToWriteOnServer.resize(nbWritten); 
    639  
    640       nbWritten = 0; 
    641       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    642       { 
    643         indGlo = *itSrv; 
    644         if (ite != globalLocalIndexMap_.find(indGlo)) 
    645         { 
    646           localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    647           ++nbWritten; 
    648         }                  
     592                                       itSrve = writtenGlobalIndex.end(), itSrv;   
     593      if (!zoomByIndex()) 
     594      {    
     595        for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     596        { 
     597          indGlo = *itSrv; 
     598          if (ite != globalLocalIndexMap_.find(indGlo)) 
     599          {           
     600            ++nbWritten; 
     601          }                  
     602        } 
     603 
     604        localIndexToWriteOnServer.resize(nbWritten); 
     605 
     606        nbWritten = 0; 
     607        for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     608        { 
     609          indGlo = *itSrv; 
     610          if (ite != globalLocalIndexMap_.find(indGlo)) 
     611          { 
     612            localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
     613            ++nbWritten; 
     614          }                  
     615        } 
     616      } 
     617      else 
     618      { 
     619        nbWritten = 0; 
     620        boost::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 
     621                                                            ite = globalLocalIndexMap_.end(), it; 
     622        for (int i = 0; i < zoom_index.numElements(); ++i) 
     623        { 
     624           if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
     625            ++nbWritten; 
     626        } 
     627 
     628        localIndexToWriteOnServer.resize(nbWritten); 
     629 
     630        nbWritten = 0; 
     631        for (int i = 0; i < zoom_index.numElements(); ++i) 
     632        { 
     633           if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
     634           { 
     635             localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[zoom_index(i)]; 
     636             ++nbWritten; 
     637           } 
     638        } 
    649639      } 
    650640 
     
    731721          const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 
    732722          const int ni    = serverDimensionSizes[*itRank][orderPositionInGrid]; 
    733           const int end   = begin + ni - 1; 
     723          const int end   = begin + ni - 1;           
    734724 
    735725          msgs.push_back(CMessage()); 
     
    737727          msg << this->getId(); 
    738728          msg << ni << begin << end; 
    739           msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 
     729          // msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 
    740730          msg << isCompressible_; 
    741731          msg << orderPositionInGrid; 
     
    792782          msg << this->getId(); 
    793783          msg << index.getValue() << dataIndex << mask.getValue(); 
    794  
    795           msg << doZoomByIndex_; 
    796           if (doZoomByIndex_) msg << zoom_index.getValue(); 
    797784          msg << hasValue; 
    798785          if (hasValue) msg << value.getValue(); 
     
    834821    mask.reference(tmp_mask); 
    835822 
    836     buffer >> doZoomByIndex_; 
    837     if (doZoomByIndex_) 
    838     { 
    839       buffer >> tmp_zoom_index; 
    840       zoom_index.reference(tmp_zoom_index); 
    841     } 
    842  
    843823    buffer >> hasValue; 
    844824    if (hasValue) 
     
    864844    int ns, n, i, j, ind, nv, idx; 
    865845    CContext* context = CContext::getCurrent(); 
    866  
    867     //int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     846     
    868847    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    869848    for (int p = 0; p < nbSrvPools; ++p) 
     
    903882        list_mask.push_back(CArray<bool,1>(nbData)); 
    904883 
    905         if (doZoomByIndex_) 
    906           list_zoomInd.push_back(CArray<int,1>(nbData)); 
    907  
    908884        if (hasValue) 
    909885          list_val.push_back(CArray<double,1>(nbData)); 
     
    926902          dataIndi(n) = dataIndex(ind); 
    927903          maskIndi(n) = mask(ind); 
    928  
    929           if (doZoomByIndex_) 
    930           { 
    931             CArray<int,1>& zoomIndi = list_zoomInd.back(); 
    932             zoomIndi(n) = zoom_index(ind); 
    933           } 
    934904 
    935905          if (hasValue) 
     
    950920        listData.back() << this->getId() 
    951921                        << list_indi.back() << list_dataInd.back() << list_mask.back(); 
    952  
    953         listData.back() << doZoomByIndex_;            
    954         if (doZoomByIndex_) 
    955           listData.back() << list_zoomInd.back(); 
    956922 
    957923        listData.back() << hasValue; 
     
    1003969      buffer >> vec_mask[idx]; 
    1004970 
    1005       buffer >> doZoomByIndex_; 
    1006       if (doZoomByIndex_) 
    1007         buffer >> vec_zoomInd[idx]; 
    1008  
    1009971      buffer >> hasValue; 
    1010972      if (hasValue) 
     
    10751037    data_begin.setValue(0); 
    10761038 
    1077     if (doZoomByIndex_) 
    1078     { 
    1079       int nbZoomIndex = 0; 
    1080       for (int idx = 0; idx < nbReceived; ++idx) 
    1081       { 
    1082         nbZoomIndex += vec_zoomInd[idx].numElements(); 
    1083       } 
    1084  
    1085       zoom_index.resize(nbZoomIndex); 
    1086       nbZoomIndex = 0;       
    1087       for (int idx = 0; idx < nbReceived; ++idx) 
    1088       {       
    1089         CArray<int,1>& tmp = vec_zoomInd[idx]; 
    1090         for (int i = 0; i < tmp.size(); ++i) 
    1091         { 
    1092           zoom_index(nbZoomIndex) = tmp(i); 
    1093           ++nbZoomIndex; 
    1094         }        
    1095       } 
    1096     } 
    1097  
    10981039    if (hasLabel) 
    10991040    { 
     
    11121053  void CAxis::recvDistributionAttribute(CBufferIn& buffer) 
    11131054  { 
    1114     int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_n_tmp; 
     1055    int ni_srv, begin_srv, end_srv; 
     1056    int global_zoom_end, zoom_end; 
     1057    bool zoomIndex = zoomByIndex(); 
     1058     
     1059    std::vector<int> zoom_index_tmp; 
     1060    std::vector<int>::iterator itZoomBegin, itZoomEnd, itZoom; 
    11151061 
    11161062    buffer >> ni_srv >> begin_srv >> end_srv; 
    1117     buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp; 
     1063    // buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp;    
    11181064    buffer >> isCompressible_; 
    11191065    buffer >> orderPosInGrid; 
    1120     buffer >> globalDimGrid; 
    1121  
     1066    buffer >> globalDimGrid;     
     1067 
     1068    // Set up new local size of axis on the receiving clients 
    11221069    n.setValue(ni_srv); 
    11231070    begin.setValue(begin_srv); 
    1124     global_zoom_begin = global_zoom_begin_tmp; 
    1125     global_zoom_n  = global_zoom_n_tmp; 
    1126     int global_zoom_end = global_zoom_begin + global_zoom_n - 1; 
    1127  
    1128     zoom_begin = global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
    1129     zoom_end_srv   = global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
    1130     zoom_n  = zoom_end_srv - zoom_begin_srv + 1; 
     1071 
     1072    // If we have zoom by index then process it 
     1073    if (zoomIndex) 
     1074    { 
     1075      zoom_index_tmp.resize(global_zoom_index.numElements()); 
     1076      std::copy(global_zoom_index.begin(), global_zoom_index.end(), zoom_index_tmp.begin()); 
     1077      std::sort(zoom_index_tmp.begin(), zoom_index_tmp.end()); 
     1078      itZoomBegin = std::lower_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), begin_srv); 
     1079      itZoomEnd   = std::upper_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), end_srv);       
     1080      int sz = std::distance(itZoomBegin, itZoomEnd); 
     1081      zoom_index.resize(sz); 
     1082      itZoom = itZoomBegin; 
     1083      for (int i = 0; i < sz; ++i, ++itZoom) 
     1084      { 
     1085        zoom_index(i) = *(itZoom); 
     1086      } 
     1087    } 
     1088 
     1089    global_zoom_begin = zoomIndex ? 0 : global_zoom_begin ; 
     1090    global_zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
     1091    global_zoom_end   = global_zoom_begin + global_zoom_n - 1; 
     1092 
     1093    zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 
     1094                           : global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
     1095    zoom_end   = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomEnd) - 1  
     1096                           : global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
     1097    zoom_n     = zoom_end - zoom_begin + 1; 
    11311098 
    11321099    if (zoom_n<=0) 
    11331100    { 
    1134       zoom_begin = 0; zoom_end_srv = 0; zoom_n = 0; 
     1101      zoom_begin = 0; zoom_n = 0; 
    11351102    } 
    11361103 
    11371104    if (n_glo == n) 
    11381105    { 
    1139       zoom_begin = global_zoom_begin; 
    1140       zoom_end_srv   = global_zoom_end; //zoom_end; 
    1141       zoom_n     = zoom_end_srv - zoom_begin + 1; 
     1106      zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 
     1107                             : global_zoom_begin;       
     1108      zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
    11421109    } 
    11431110  } 
  • XIOS/dev/dev_olga/src/node/axis.hpp

    r1201 r1202  
    119119         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); 
    120120         bool isEqual(CAxis* axis); 
     121         bool zoomByIndex(); 
    121122 
    122       public: 
    123         int zoom_begin_srv, zoom_end_srv, zoom_size_srv; 
    124         int ni_srv, begin_srv, end_srv; 
    125         int global_zoom_begin_srv, global_zoom_end_srv, global_zoom_size_srv; 
    126         CArray<double,1> value_srv; 
    127         CArray<double,2> bound_srv; 
     123      public:                 
    128124        CArray<StdString,1> label_srv; 
    129         CArray<int,1> zoom_index_srv; 
    130125        bool hasValue; 
    131126        CArray<int,1> globalDimGrid; 
     
    146141         void computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 
    147142                                     CServerDistributionDescription::ServerDistributionType distType); 
    148          bool zoomByIndex(); 
    149143 
    150144         void sendNonDistributedAttributes(void); 
     
    175169         std::map<int, CArray<int,1> > indiSrv_; 
    176170         bool hasBounds_; 
    177          bool hasLabel; 
    178          bool doZoomByIndex_; 
     171         bool hasLabel;          
    179172         bool computedWrittenIndex_; 
    180173 
  • XIOS/dev/dev_olga/src/node/domain.cpp

    r1201 r1202  
    24632463    } 
    24642464     
     2465    globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 
    24652466    i_index.resize(nbIndGlob); 
    2466     j_index.resize(nbIndGlob); 
    2467  
    2468     globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 
     2467    j_index.resize(nbIndGlob);     
    24692468    nbIndGlob = 0; 
    24702469    for (i = 0; i < nbReceived; ++i) 
     
    24742473      { 
    24752474         index = tmp(ind); 
    2476          i_index(nbIndGlob) = index % ni_glo; 
    2477          j_index(nbIndGlob) = index / ni_glo; 
    2478          globalLocalIndexMap_[index] = nbIndGlob;   
    2479          ++nbIndGlob; 
     2475         if (0 == globalLocalIndexMap_.count(index)) 
     2476         { 
     2477           i_index(nbIndGlob) = index % ni_glo; 
     2478           j_index(nbIndGlob) = index / ni_glo; 
     2479           globalLocalIndexMap_[index] = nbIndGlob;   
     2480           ++nbIndGlob; 
     2481         }  
    24802482      }  
    24812483    }  
     2484 
     2485    i_index.resizeAndPreserve(nbIndGlob); 
     2486    j_index.resizeAndPreserve(nbIndGlob); 
    24822487  } 
    24832488 
     
    26302635  void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) 
    26312636  { 
    2632     int nbReceived = rankBuffers.size(), i, ind, index; 
     2637    int nbReceived = rankBuffers.size(), i, ind, index, lInd; 
    26332638    if (nbReceived != recvClientRanks_.size()) 
    2634       ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", 
     2639      ERROR("void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers)", 
    26352640           << "The number of sending clients is not correct." 
    26362641           << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
     
    26502655    } 
    26512656   
     2657    if (nbMaskInd != globalLocalIndexMap_.size()) 
     2658      info (0) << "If the domain " << this->getDomainOutputName() <<" does not have overlapped region between processes." 
     2659               << "Something must be wrong with mask index "<< std::endl; 
     2660 
     2661    nbMaskInd = globalLocalIndexMap_.size(); 
    26522662    mask_1d.resize(nbMaskInd); 
    2653     nbMaskInd = 0; 
     2663     
    26542664    for (i = 0; i < nbReceived; ++i) 
    26552665    { 
     2666      CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 
    26562667      CArray<bool,1>& tmp = recvMaskValue[i]; 
    26572668      for (ind = 0; ind < tmp.numElements(); ++ind) 
    26582669      { 
    2659         mask_1d(nbMaskInd) = tmp(ind);       
    2660         ++nbMaskInd; 
     2670        lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 
     2671        mask_1d(lInd) = tmp(ind); 
    26612672      } 
    26622673    }     
     
    27172728     
    27182729      if (nbLonInd != globalLocalIndexMap_.size()) 
    2719         info (0) << "Something wrong with longitude index "<< std::endl; 
    2720  
     2730        info (0) << "If the domain " << this->getDomainOutputName() <<" does not have overlapped region between processes." 
     2731                 << "Something must be wrong with longitude index "<< std::endl; 
     2732 
     2733      nbLonInd = globalLocalIndexMap_.size(); 
    27212734      lonvalue.resize(nbLonInd); 
    27222735      if (hasBounds) 
     
    27992812     
    28002813      if (nbLatInd != globalLocalIndexMap_.size()) 
    2801         info (0) << "Something wrong with latitude index "<< std::endl; 
    2802  
     2814        info (0) << "If the domain " << this->getDomainOutputName() <<" does not have overlapped region between processes." 
     2815                << "Something must be wrong with latitude index "<< std::endl; 
     2816 
     2817      nbLatInd = globalLocalIndexMap_.size(); 
    28032818      latvalue.resize(nbLatInd); 
    28042819      if (hasBounds) 
     
    28702885    } 
    28712886 
    2872     int nbAreaInd = 0; 
    2873     for (i = 0; i < nbReceived; ++i) 
    2874     {       
    2875       nbAreaInd += recvAreaValue[i].numElements(); 
    2876     } 
    2877    
    2878     if (nbAreaInd != globalLocalIndexMap_.size()) 
    2879       info (0) << "Something wrong with latitude index "<< std::endl; 
    2880  
    28812887    if (hasArea) 
    28822888    { 
     2889      int nbAreaInd = 0; 
     2890      for (i = 0; i < nbReceived; ++i) 
     2891      {       
     2892        nbAreaInd += recvAreaValue[i].numElements(); 
     2893      } 
     2894 
     2895      if (nbAreaInd != globalLocalIndexMap_.size()) 
     2896        info (0) << "If the domain " << this->getDomainOutputName() <<" does not have overlapped region between processes." 
     2897                 << "Something must be wrong with area index "<< std::endl; 
     2898 
     2899      nbAreaInd = globalLocalIndexMap_.size(); 
    28832900      areavalue.resize(nbAreaInd); 
    28842901      nbAreaInd = 0;       
     
    29883005      { 
    29893006         lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 
    2990          dataIIndex(lInd) = tmpI(ind); 
    2991          dataJIndex(lInd) = tmpJ(ind);          
     3007         dataIIndex(lInd) = (-1 == dataIIndex(lInd)) ? tmpI(ind) : dataIIndex(lInd); // Only fill in dataIndex if there is no data 
     3008         dataJIndex(lInd) = (-1 == dataJIndex(lInd)) ? tmpJ(ind) : dataJIndex(lInd);          
    29923009      }  
    29933010    } 
  • XIOS/dev/dev_olga/src/node/grid.cpp

    r1201 r1202  
    287287     nbSrvPools = 1;   
    288288     for (int p = 0; p < nbSrvPools; ++p) 
    289      {        
    290        if (isScalarGrid()) 
    291        {   
    292           if (context->hasClient) 
    293             if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndexScalarGrid(); this->isIndexSent = true; } 
    294  
    295           if (this->isChecked) continue; 
    296    
    297           if (context->hasClient) 
    298           { 
    299             this->computeIndexScalarGrid(); 
    300           } 
    301    
    302          if (!(this->hasTransform() && !this->isTransformed())) 
    303           this->isChecked = true; 
    304          continue; 
     289     {     
     290       if (context->hasClient && this->isChecked && doSendingIndex && !isIndexSent)  
     291       {  
     292         if (isScalarGrid()) 
     293           sendIndexScalarGrid(); 
     294         else 
     295           sendIndex(); 
     296         this->isIndexSent = true;  
    305297       } 
    306298 
    307        if (context->hasClient) 
    308        { 
    309          if (this->isChecked && doSendingIndex && !isIndexSent) 
    310             {sendIndex(); this->isIndexSent = true;} 
    311        } 
     299       // Not sure about this 
     300       //if (!(this->hasTransform() && !this->isTransformed())) 
     301       // this->isChecked = true; 
     302       //return; 
    312303     } 
    313304     
     
    546537      if (computedWrittenIndex_) return; 
    547538      computedWrittenIndex_ = true; 
     539 
     540      if (isScalarGrid()) 
     541      { 
     542        size_t nbWritten = 1; 
     543        int writtenIndex = 0; 
     544 
     545        localIndexToWriteOnClient.resize(nbWritten);   
     546        localIndexToWriteOnServer.resize(nbWritten); 
     547        localIndexToWriteOnServer(0) = writtenIndex; 
     548        localIndexToWriteOnClient(0) = writtenIndex; 
     549         
     550        return; 
     551      } 
    548552 
    549553      size_t nbWritten = 0, indGlo; 
     
    746750   { 
    747751     CContext* context = CContext::getCurrent(); 
    748      computeClientIndex(); 
    749      if (context->hasClient) 
     752     if (isScalarGrid()) 
    750753     { 
    751        computeConnectedClients(); 
     754       computeClientIndexScalarGrid(); 
     755       if (context->hasClient) 
     756       { 
     757         computeConnectedClientsScalarGrid(); 
     758       } 
     759     } 
     760     else 
     761     { 
     762       computeClientIndex(); 
     763       if (context->hasClient) 
     764       { 
     765         computeConnectedClients(); 
     766       } 
    752767     } 
    753768   } 
     
    11711186   } 
    11721187 
    1173   void CGrid::computeIndexScalarGrid() 
     1188  void CGrid::computeClientIndexScalarGrid() 
     1189  { 
     1190    CContext* context = CContext::getCurrent();     
     1191    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; // This should be changed soon 
     1192    for (int p = 0; p < nbSrvPools; ++p) 
     1193    { 
     1194      CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[p] : context->client)  
     1195                                                    : context->client; 
     1196 
     1197      storeIndex_client.resize(1); 
     1198      storeIndex_client(0) = 0;       
     1199 
     1200      if (0 != serverDistribution_) 
     1201      { 
     1202        map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 
     1203                                               ite = outGlobalIndexFromClient.end(), it; 
     1204        for (it = itb; it != ite; ++it) 
     1205        { 
     1206          int rank = it->first; 
     1207          CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank]; 
     1208          outLocalIndexStoreOnClient.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 
     1209          CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient[rank]; 
     1210          if (1 != globalIndex.numElements()) 
     1211            ERROR("void CGrid::computeClientIndexScalarGrid()", 
     1212              << "Something wrong happened. " 
     1213              << "Number of received global index on scalar grid should equal to 1"  
     1214              << "Number of received global index " << globalIndex.numElements() << "."); 
     1215 
     1216          localIndex(0) = globalIndex(0); 
     1217        } 
     1218      } 
     1219    } 
     1220  } 
     1221 
     1222  void CGrid::computeConnectedClientsScalarGrid() 
    11741223  { 
    11751224    CContext* context = CContext::getCurrent();     
     
    11811230    for (int p = 0; p < nbSrvPools; ++p) 
    11821231    { 
    1183       CContextClient* client = context->hasServer ? context->clientPrimServer[p] : context->client; 
    1184  
    1185       storeIndex_client.resize(1); 
    1186       storeIndex_client(0) = 0; 
     1232      CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[p] : context->client)  
     1233                                                    : context->client; 
    11871234 
    11881235      connectedServerRank_[p].clear(); 
    11891236 
    1190       if (0 == client->clientRank) 
    1191       { 
    1192         for (int rank = 0; rank < client->serverSize; ++rank) 
    1193         { 
     1237      if (client->isServerLeader()) 
     1238      { 
     1239        const std::list<int>& ranks = client->getRanksServerLeader(); 
     1240        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1241        { 
     1242          int rank = *itRank; 
     1243          int nb = 1; 
    11941244          connectedServerRank_[p].push_back(rank); 
    1195           connectedDataSize_[p][rank] = 1; 
    1196           nbSenders[p][rank] = 1; 
    1197         } 
    1198       } 
     1245          connectedDataSize_[p][rank] = nb; 
     1246          nbSenders[p][rank] = nb; 
     1247        } 
     1248      } 
     1249      else 
     1250      { 
     1251        const std::list<int>& ranks = client->getRanksServerNotLeader(); 
     1252        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1253        { 
     1254          int rank = *itRank; 
     1255          int nb = 1; 
     1256          connectedServerRank_[p].push_back(rank); 
     1257          connectedDataSize_[p][rank] = nb; 
     1258          nbSenders[p][rank] = nb; 
     1259        }         
     1260      } 
     1261 
    11991262      isDataDistributed_ = false; 
    12001263    } 
     
    14331496          std::vector<CAxis*> axisList = getAxis(); 
    14341497          std::vector<int> nZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize), nGlobElement(numElement); 
    1435           std::vector<CArray<int,1> > zoomIndex; 
     1498          std::vector<CArray<int,1> > globalZoomIndex(numElement); 
    14361499          for (int i = 0; i < numElement; ++i) 
    14371500          { 
     
    14491512              nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 
    14501513 
     1514              { 
     1515                int count = 0; 
     1516                globalZoomIndex[i].resize(nZoomSize[indexMap[i]]*nZoomSize[indexMap[i]+1]); 
     1517                for (int jdx = 0; jdx < nZoomSize[indexMap[i]+1]; ++jdx) 
     1518                  for (int idx = 0; idx < nZoomSize[indexMap[i]]; ++idx)                 
     1519                  { 
     1520                    globalZoomIndex[i](count) = (nZoomBegin[indexMap[i]] + idx) + (nZoomBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]]; 
     1521                    ++count; 
     1522                  } 
     1523              } 
     1524 
    14511525              ++domainId; 
    14521526            } 
     
    14561530              nZoomSize[indexMap[i]]  = axisList[axisId]->zoom_n; 
    14571531              nZoomBeginGlobal[indexMap[i]] = axisList[axisId]->global_zoom_begin;               
    1458               nGlob[indexMap[i]] = axisList[axisId]->n_glo;               
     1532              nGlob[indexMap[i]] = axisList[axisId]->n_glo;      
     1533              if (axisList[axisId]->zoomByIndex()) 
     1534              { 
     1535                globalZoomIndex[i].reference(axisList[axisId]->zoom_index);                 
     1536              } 
     1537              else 
     1538              { 
     1539                globalZoomIndex[i].resize(nZoomSize[indexMap[i]]); 
     1540                for (int idx = 0; idx < nZoomSize[indexMap[i]]; ++idx) 
     1541                  globalZoomIndex[i](idx) = nZoomBegin[indexMap[i]] + idx; 
     1542              } 
     1543 
    14591544              ++axisId; 
    14601545            } 
     
    14651550              nZoomBeginGlobal[indexMap[i]] = 0;               
    14661551              nGlob[indexMap[i]] = 1; 
    1467  
     1552              globalZoomIndex[i].resize(1); 
     1553              globalZoomIndex[i](0) = 0; 
    14681554              ++scalarId; 
    14691555            } 
     
    14731559          for (int i = 0; i < nZoomSize.size(); ++i) 
    14741560            dataSize *= nZoomSize[i]; 
    1475           serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
    1476                                                         nZoomBeginGlobal, nGlob); 
     1561          // serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
     1562          //                                               nZoomBeginGlobal, nGlob); 
     1563          serverDistribution_ = new CDistributionServer(server->intraCommRank,  
     1564                                                        globalZoomIndex, axis_domain_order, 
     1565                                                        nZoomBegin, nZoomSize, nZoomBeginGlobal, nGlob); 
    14771566        } 
    14781567 
  • XIOS/dev/dev_olga/src/node/grid.hpp

    r1201 r1202  
    278278        void computeClientIndex(); 
    279279        void computeConnectedClients(); 
     280        void computeClientIndexScalarGrid();  
     281        void computeConnectedClientsScalarGrid();  
    280282 
    281283      private: 
  • XIOS/dev/dev_olga/src/test/test_client.f90

    r1099 r1202  
    1919  INTEGER,PARAMETER :: ni_glo=100 
    2020  INTEGER,PARAMETER :: nj_glo=100 
    21   INTEGER,PARAMETER :: llm=2 
    22   DOUBLE PRECISION  :: lval(llm)=1 
     21  INTEGER,PARAMETER :: llm=5 
     22  DOUBLE PRECISION  :: lval(llm)=1, scalar = 5 
    2323  TYPE(xios_field) :: field_hdl 
    2424  TYPE(xios_fieldgroup) :: fieldgroup_hdl 
     
    131131 
    132132  PRINT*,"field field_A is active ? ",xios_field_is_active("field_A") 
     133  ! CALL xios_recv_field("field", scalar) 
    133134  DO ts=1,4 
    134135    CALL xios_update_calendar(ts) 
     
    137138    ! CALL xios_send_field("field_Axis",lval) 
    138139    CALL xios_send_field("field_Domain",field_domain) 
     140    CALL xios_send_field("field_Scalar",scalar) 
    139141    CALL wait_us(5000) ; 
    140142  ENDDO 
  • XIOS/dev/dev_olga/src/transformation/axis_algorithm_zoom.cpp

    r1144 r1202  
    5353           << "Zoom size is " << zoomSize_ ); 
    5454  } 
     55 
     56  if (!zoomAxis->index.isEmpty()) 
     57  { 
     58    int sz = zoomAxis->index.numElements(); 
     59    zoomIndex_.resize(sz); 
     60    for (int i = 0; i < sz; ++i) 
     61      zoomIndex_[i] = zoomAxis->index(i); 
     62 
     63    std::sort(zoomIndex_.begin(), zoomIndex_.end()); 
     64  } 
     65 
    5566} 
    5667 
     
    6980  StdSize ibegin = std::max(ibeginSource, zoomBegin_); 
    7081  StdSize iend = std::min(iendSource, zoomEnd_); 
    71   // StdSize ibegin = ibeginSource; 
    72   // StdSize iend = iendSource; 
    7382  StdSize ni = iend + 1 - ibegin; 
    7483  if (iend < ibegin) ni = 0; 
     
    8089  TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    8190 
    82   for (StdSize idx = 0; idx < ni; ++idx) 
     91  if (!zoomIndex_.empty()) 
    8392  { 
    84     transMap[ibegin+idx].push_back(ibegin+idx); 
    85     transWeight[ibegin+idx].push_back(1.0); 
     93    std::vector<int>::iterator itZoomBegin, itZoomEnd; 
     94    itZoomBegin = std::lower_bound(zoomIndex_.begin(), zoomIndex_.end(), ibeginSource); 
     95    itZoomEnd   = std::upper_bound(zoomIndex_.begin(), zoomIndex_.end(), iendSource);             
     96    for (; itZoomBegin != itZoomEnd; ++itZoomBegin) 
     97    { 
     98      transMap[*itZoomBegin].push_back(*itZoomBegin); 
     99      transWeight[*itZoomBegin].push_back(1.0); 
     100    } 
     101  } 
     102  else 
     103  { 
     104    for (StdSize idx = 0; idx < ni; ++idx) 
     105    { 
     106      transMap[ibegin+idx].push_back(ibegin+idx); 
     107      transWeight[ibegin+idx].push_back(1.0); 
     108    } 
    86109  } 
    87110 
     
    97120  axisDest_->global_zoom_begin = zoomBegin_; 
    98121  axisDest_->global_zoom_n  = zoomSize_; 
     122  if (!zoomIndex_.empty()) 
     123  { 
     124    axisDest_->global_zoom_index.resize(zoomIndex_.size()); 
     125    std::copy(zoomIndex_.begin(), zoomIndex_.end(), axisDest_->global_zoom_index.begin()); 
     126  } 
    99127} 
    100128 
Note: See TracChangeset for help on using the changeset viewer.