Changeset 1559


Ignore:
Timestamp:
07/12/18 19:12:32 (6 years ago)
Author:
oabramkina
Message:

Replacing axis zoom by axis extract.
Zoom private attributes are gone for good.

Location:
XIOS/trunk/src
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r1553 r1559  
    11751175        axis->computeWrittenCompressedIndex(comm_file); 
    11761176        
    1177         int zoom_size  = (MULTI_FILE == SuperClass::type) ? axis->zoom_n.getValue() 
    1178                                                           : axis->global_zoom_n.getValue(); 
    1179  
    1180         int zoom_count = axis->zoom_n;                                                  
    1181         int zoom_begin = axis->zoom_begin; 
    1182  
    1183         if ((0 == axis->zoom_n) && (MULTI_FILE == SuperClass::type)) return; 
     1177        int size  = (MULTI_FILE == SuperClass::type) ? axis->n.getValue() 
     1178                                                          : axis->n_glo.getValue(); 
     1179 
     1180        if ((0 == axis->n) && (MULTI_FILE == SuperClass::type)) return; 
    11841181 
    11851182        std::vector<StdString> dims; 
     
    12001197          if (axis->dim_name.isEmpty()) axisDim = axisid; 
    12011198          else axisDim=axis->dim_name.getValue(); 
    1202           SuperClassWriter::addDimension(axisDim, zoom_size); 
     1199          SuperClassWriter::addDimension(axisDim, size); 
    12031200          dims.push_back(axisDim); 
    12041201 
     
    13441341              std::vector<StdSize> start(1), startBounds(2) ; 
    13451342              std::vector<StdSize> count(1), countBounds(2) ; 
    1346               start[0] = startBounds[0] = zoom_begin - axis->global_zoom_begin; 
    1347               count[0] = countBounds[0] = zoom_count; // zoom_size 
     1343              start[0] = startBounds[0] = axis->begin; 
     1344              count[0] = countBounds[0] = axis->n; 
    13481345              startBounds[1] = 0; 
    13491346              countBounds[1] = 2; 
     
    26162613                    { 
    26172614                        CAxis* axis = CAxis::get(axisList[idxAxis]); 
    2618                         start.push_back(axis->zoom_begin - axis->global_zoom_begin); 
    2619                         count.push_back(axis->zoom_n); 
     2615                        start.push_back(axis->begin); 
     2616                        count.push_back(axis->n); 
    26202617                      --idx; 
    26212618                      --idxAxis; 
  • XIOS/trunk/src/node/axis.cpp

    r1558 r1559  
    302302      { 
    303303        this->checkData(); 
    304         this->checkZoom(); 
    305304        this->checkMask(); 
    306305        this->checkLabel(); 
     
    333332   } 
    334333 
    335    /*! 
    336      Check validity of zoom info and fill in values if any. 
    337    */ 
    338    void CAxis::checkZoom(void) 
    339    { 
    340      if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 
    341      if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 
    342      if (zoom_index.isEmpty()) 
    343      { 
    344        zoom_index.setValue(index.getValue()); 
    345      } 
    346      if (zoom_n.isEmpty()) zoom_n.setValue(n); 
    347      if (zoom_begin.isEmpty()) zoom_begin.setValue(begin); 
    348    } 
    349  
    350334    size_t CAxis::getGlobalWrittenSize(void) 
    351335    { 
    352       if (zoomByIndex()) return  global_zoom_index.numElements(); 
    353       else return global_zoom_n ; 
     336      return n_glo ; 
    354337    } 
    355338 
     
    416399    // We don't check if the mask is valid here, just if a mask has been defined at this point. 
    417400    isCompressible_ = !mask.isEmpty(); 
    418   } 
    419  
    420   /* 
    421     Check whether we do zooming by indexing 
    422     return true if do zooming by index 
    423   */ 
    424   bool CAxis::zoomByIndex() 
    425   { 
    426     return (!global_zoom_index.isEmpty() && (0 != global_zoom_index.numElements())); 
    427401  } 
    428402 
     
    561535        size_t ni = this->n.getValue(); 
    562536        size_t ibegin = this->begin.getValue(); 
    563         size_t global_zoom_end = global_zoom_begin+global_zoom_n-1; 
    564         size_t nZoomCount = 0; 
    565537        size_t nbIndex = index.numElements(); 
    566538 
     
    585557            { 
    586558              ind += ibegin; 
    587               if (ind >= global_zoom_begin && ind <= global_zoom_end) 
    588                 writtenInd.insert(ind); 
     559              writtenInd.insert(ind); 
    589560            } 
    590561          } 
     
    680651    // We describe the distribution of client (server) on which data are written 
    681652    std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 
    682     nBegin[0]       = zoom_begin; 
    683     nSize[0]        = zoom_n;    
     653    nBegin[0]       = 0; 
     654    nSize[0]        = n; 
    684655    nBeginGlobal[0] = 0;  
    685656    nGlob[0]        = n_glo; 
     
    694665    CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 
    695666                                     itSrve = writtenGlobalIndex.end(), itSrv;   
    696     if (!zoomByIndex()) 
    697     {    
    698       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    699       { 
    700         indGlo = *itSrv; 
    701         if (ite != globalLocalIndexMap_.find(indGlo)) 
    702         {           
    703           ++nbWritten; 
    704         }                  
    705       } 
    706  
    707       localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
     667    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     668    { 
     669      indGlo = *itSrv; 
     670      if (ite != globalLocalIndexMap_.find(indGlo)) 
     671      { 
     672        ++nbWritten; 
     673      } 
     674    } 
     675 
     676    localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
    708677//      localIndexToWriteOnServer.resize(nbWritten); 
    709678 
    710       nbWritten = 0; 
    711       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    712       { 
    713         indGlo = *itSrv; 
    714         if (ite != globalLocalIndexMap_.find(indGlo)) 
    715         { 
    716           localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    717           ++nbWritten; 
    718         }                  
    719       } 
    720     } 
    721     else 
    722     { 
    723       nbWritten = 0; 
    724       std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 
    725                                                           ite = globalLocalIndexMap_.end(), it; 
    726       for (int i = 0; i < zoom_index.numElements(); ++i) 
    727       { 
    728          if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
    729           ++nbWritten; 
    730       } 
    731  
    732       localIndexToWriteOnServer.resize(nbWritten); 
    733  
    734       nbWritten = 0; 
    735       for (int i = 0; i < zoom_index.numElements(); ++i) 
    736       { 
    737          if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
    738          { 
    739            localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[zoom_index(i)]; 
    740            ++nbWritten; 
    741          } 
    742       } 
    743     } 
    744  
    745     // if (isCompressible()) 
    746     // { 
    747     //   nbWritten = 0; 
    748     //   std::unordered_map<size_t,size_t> localGlobalIndexMap; 
    749     //   for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    750     //   { 
    751     //     indGlo = *itSrv; 
    752     //     if (ite != globalLocalIndexMap_.find(indGlo)) 
    753     //     { 
    754     //       localGlobalIndexMap[localIndexToWriteOnServer(nbWritten)] = indGlo; 
    755     //       ++nbWritten; 
    756     //     }                  
    757     //   } 
    758  
    759     //   nbWritten = 0; 
    760     //   for (int idx = 0; idx < data_index.numElements(); ++idx) 
    761     //   { 
    762     //     if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
    763     //     { 
    764     //       ++nbWritten; 
    765     //     } 
    766     //   } 
    767  
    768     //   compressedIndexToWriteOnServer.resize(nbWritten); 
    769     //   nbWritten = 0; 
    770     //   for (int idx = 0; idx < data_index.numElements(); ++idx) 
    771     //   { 
    772     //     if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
    773     //     { 
    774     //       compressedIndexToWriteOnServer(nbWritten) = localGlobalIndexMap[data_index(idx)]; 
    775     //       ++nbWritten; 
    776     //     } 
    777     //   } 
    778  
    779     //   numberWrittenIndexes_ = nbWritten; 
    780     //   if (isDistributed()) 
    781     //   { 
    782               
    783     //     MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    784     //     MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    785     //     offsetWrittenIndexes_ -= numberWrittenIndexes_; 
    786     //   } 
    787     //   else 
    788     //     totalNumberWrittenIndexes_ = numberWrittenIndexes_; 
    789     // } 
     679    nbWritten = 0; 
     680    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     681    { 
     682      indGlo = *itSrv; 
     683      if (ite != globalLocalIndexMap_.find(indGlo)) 
     684      { 
     685        localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
     686        ++nbWritten; 
     687      } 
     688    } 
    790689  } 
    791690 
     
    805704      // We describe the distribution of client (server) on which data are written 
    806705      std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 
    807       nBegin[0]       = zoom_begin; 
    808       nSize[0]        = zoom_n;    
     706      nBegin[0]       = 0; 
     707      nSize[0]        = n; 
    809708      nBeginGlobal[0] = 0;  
    810709      nGlob[0]        = n_glo; 
     
    928827  { 
    929828    int ni_srv, begin_srv, end_srv; 
    930     int global_zoom_end, zoom_end; 
    931     bool zoomIndex = zoomByIndex(); 
    932      
    933     std::vector<int> zoom_index_tmp; 
    934     std::vector<int>::iterator itZoomBegin, itZoomEnd, itZoom; 
    935  
    936829    buffer >> ni_srv >> begin_srv >> end_srv;     
    937830    buffer >> isCompressible_;             
     
    940833    n.setValue(ni_srv); 
    941834    begin.setValue(begin_srv); 
    942  
    943     // If we have zoom by index then process it 
    944     if (zoomIndex) 
    945     { 
    946       zoom_index_tmp.resize(global_zoom_index.numElements()); 
    947       std::copy(global_zoom_index.begin(), global_zoom_index.end(), zoom_index_tmp.begin()); 
    948       std::sort(zoom_index_tmp.begin(), zoom_index_tmp.end()); 
    949       itZoomBegin = std::lower_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), begin_srv); 
    950       itZoomEnd   = std::upper_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), end_srv);       
    951       int sz = std::distance(itZoomBegin, itZoomEnd); 
    952       zoom_index.resize(sz); 
    953       itZoom = itZoomBegin; 
    954       for (int i = 0; i < sz; ++i, ++itZoom) 
    955       { 
    956         zoom_index(i) = *(itZoom); 
    957       } 
    958     } 
    959  
    960     global_zoom_begin = zoomIndex ? 0 : global_zoom_begin ; 
    961     global_zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
    962     global_zoom_end   = global_zoom_begin + global_zoom_n - 1; 
    963  
    964     zoom_begin = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomBegin) 
    965                            : global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
    966     zoom_end   = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomEnd) - 1  
    967                            : global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
    968     zoom_n     = zoom_end - zoom_begin + 1; 
    969  
    970     if (zoom_n<=0) 
    971     { 
    972       zoom_n = 0; zoom_begin=global_zoom_begin; //0; zoom_begin = 0;  
    973     } 
    974  
    975     if (n_glo == n) 
    976     { 
    977       zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 
    978                              : global_zoom_begin;       
    979       zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
    980     } 
    981835  } 
    982836 
     
    1064918  void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer) 
    1065919  {  
    1066     CArray<int,1> tmp_index, tmp_data_index, tmp_zoom_index; 
     920    CArray<int,1> tmp_index, tmp_data_index; 
    1067921    CArray<bool,1> tmp_mask; 
    1068922    CArray<double,1> tmp_val; 
     
    1123977 
    1124978      list<CMessage> listData; 
    1125       list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd; 
     979      list<CArray<int,1> > list_indi, list_dataInd; 
    1126980      list<CArray<bool,1> > list_mask; 
    1127981      list<CArray<double,1> > list_val; 
     
    12461100  { 
    12471101    int nbReceived = ranks.size(), idx, ind, gloInd, locInd; 
    1248     vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived), vec_zoomInd(nbReceived);     
     1102    vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived); 
    12491103    vector<CArray<bool,1> > vec_mask(nbReceived); 
    12501104    vector<CArray<double,1> > vec_val(nbReceived); 
  • XIOS/trunk/src/node/axis.hpp

    r1558 r1559  
    121121         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); 
    122122         bool isEqual(CAxis* axis); 
    123          bool zoomByIndex(); 
    124123 
    125124      public:  
     
    133132         void checkData(); 
    134133         void checkMask(); 
    135          void checkZoom(); 
    136134         void checkBounds(); 
    137135         void checkLabel(); 
  • XIOS/trunk/src/node/grid.cpp

    r1553 r1559  
    16311631          std::vector<CDomain*> domainList = getDomains(); 
    16321632          std::vector<CAxis*> axisList = getAxis(); 
    1633           std::vector<int> nZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize), nGlobElement(numElement); 
    1634           std::vector<CArray<int,1> > globalZoomIndex(numElement);  // RENAME INTO globalIndex 
     1633          std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize), nGlobElement(numElement); 
     1634          std::vector<CArray<int,1> > globalIndex(numElement); 
    16351635          for (int i = 0; i < numElement; ++i) 
    16361636          { 
     
    16381638            if (2 == axis_domain_order(i)) //domain 
    16391639            { 
    1640               nZoomBegin[indexMap[i]] = domainList[domainId]->ibegin; 
    1641               nZoomSize[indexMap[i]]  = domainList[domainId]->ni; 
    1642               nZoomBeginGlobal[indexMap[i]] = 0; 
     1640              nBegin[indexMap[i]] = domainList[domainId]->ibegin; 
     1641              nSize[indexMap[i]]  = domainList[domainId]->ni; 
     1642              nBeginGlobal[indexMap[i]] = 0; 
    16431643              nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 
    16441644 
    1645               nZoomBegin[indexMap[i] + 1] = domainList[domainId]->jbegin; 
    1646               nZoomSize[indexMap[i] + 1] = domainList[domainId]->nj; 
    1647               nZoomBeginGlobal[indexMap[i] + 1] = 0; 
     1645              nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin; 
     1646              nSize[indexMap[i] + 1] = domainList[domainId]->nj; 
     1647              nBeginGlobal[indexMap[i] + 1] = 0; 
    16481648              nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 
    16491649 
    16501650              { 
    16511651                int count = 0; 
    1652                 globalZoomIndex[i].resize(nZoomSize[indexMap[i]]*nZoomSize[indexMap[i]+1]); 
    1653                 for (int jdx = 0; jdx < nZoomSize[indexMap[i]+1]; ++jdx) 
    1654                   for (int idx = 0; idx < nZoomSize[indexMap[i]]; ++idx)                 
     1652                globalIndex[i].resize(nSize[indexMap[i]]*nSize[indexMap[i]+1]); 
     1653                for (int jdx = 0; jdx < nSize[indexMap[i]+1]; ++jdx) 
     1654                  for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 
    16551655                  { 
    1656                     globalZoomIndex[i](count) = (nZoomBegin[indexMap[i]] + idx) + (nZoomBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]]; 
     1656                    globalIndex[i](count) = (nBegin[indexMap[i]] + idx) + (nBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]]; 
    16571657                    ++count; 
    16581658                  } 
     
    16631663            else if (1 == axis_domain_order(i)) // axis 
    16641664            { 
    1665               nZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin; 
    1666               nZoomSize[indexMap[i]]  = axisList[axisId]->zoom_n; 
    1667               nZoomBeginGlobal[indexMap[i]] = axisList[axisId]->global_zoom_begin;               
     1665              nBegin[indexMap[i]] = axisList[axisId]->begin; 
     1666              nSize[indexMap[i]]  = axisList[axisId]->n; 
     1667              nBeginGlobal[indexMap[i]] = 0; 
    16681668              nGlob[indexMap[i]] = axisList[axisId]->n_glo;      
    1669               if (axisList[axisId]->zoomByIndex()) 
    1670               { 
    1671                 globalZoomIndex[i].reference(axisList[axisId]->zoom_index);                 
    1672               } 
    1673               else 
    1674               { 
    1675                 globalZoomIndex[i].resize(nZoomSize[indexMap[i]]); 
    1676                 for (int idx = 0; idx < nZoomSize[indexMap[i]]; ++idx) 
    1677                   globalZoomIndex[i](idx) = nZoomBegin[indexMap[i]] + idx; 
    1678               } 
     1669              globalIndex[i].resize(nSize[indexMap[i]]); 
     1670              for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 
     1671                globalIndex[i](idx) = nBegin[indexMap[i]] + idx; 
    16791672 
    16801673              ++axisId; 
     
    16821675            else // scalar 
    16831676            {  
    1684               nZoomBegin[indexMap[i]] = 0; 
    1685               nZoomSize[indexMap[i]]  = 1; 
    1686               nZoomBeginGlobal[indexMap[i]] = 0;               
     1677              nBegin[indexMap[i]] = 0; 
     1678              nSize[indexMap[i]]  = 1; 
     1679              nBeginGlobal[indexMap[i]] = 0; 
    16871680              nGlob[indexMap[i]] = 1; 
    1688               globalZoomIndex[i].resize(1); 
    1689               globalZoomIndex[i](0) = 0; 
     1681              globalIndex[i].resize(1); 
     1682              globalIndex[i](0) = 0; 
    16901683              ++scalarId; 
    16911684            } 
     
    16931686          dataSize = 1; 
    16941687 
    1695           for (int i = 0; i < nZoomSize.size(); ++i) 
    1696             dataSize *= nZoomSize[i]; 
     1688          for (int i = 0; i < nSize.size(); ++i) 
     1689            dataSize *= nSize[i]; 
    16971690          serverDistribution_ = new CDistributionServer(server->intraCommRank,  
    1698                                                         globalZoomIndex, axis_domain_order, 
    1699                                                         nZoomBegin, nZoomSize, nZoomBeginGlobal, nGlob); 
     1691                                                        globalIndex, axis_domain_order, 
     1692                                                        nBegin, nSize, nBeginGlobal, nGlob); 
    17001693        } 
    17011694 
  • XIOS/trunk/src/transformation/axis_algorithm_zoom.cpp

    r1202 r1559  
    11/*! 
    22   \file axis_algorithm_zoom.cpp 
    3    \author Ha NGUYEN 
    4    \since 03 June 2015 
    5    \date 12 June 2015 
    6  
    7    \brief Algorithm for zooming on an axis. 
     3   \brief Algorithm for zooming an axis. 
    84 */ 
    95#include "axis_algorithm_zoom.hpp" 
     
    4339  zoomAxis->checkValid(axisSource); 
    4440  zoomBegin_ = zoomAxis->begin.getValue(); 
    45   zoomSize_  = zoomAxis->n.getValue(); 
    46   zoomEnd_   = zoomBegin_ + zoomSize_ - 1; 
     41  zoomN_  = zoomAxis->n.getValue(); 
     42  zoomEnd_   = zoomBegin_ + zoomN_ - 1; 
    4743 
    48   if (zoomSize_ > axisSource->n_glo.getValue()) 
     44  if (zoomN_ > axisSource->n_glo.getValue()) 
    4945  { 
    5046    ERROR("CAxisAlgorithmZoom::CAxisAlgorithmZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis)", 
    51            << "Zoom size is greater than global size of axis source" 
    52            << "Global size of axis source " <<axisSource->getId() << " is " << axisSource->n_glo.getValue()  << std::endl 
    53            << "Zoom size is " << zoomSize_ ); 
     47           << "Zoom size is greater than global size of source axis" 
     48           << "Global size of source axis " <<axisSource->getId() << " is " << axisSource->n_glo.getValue()  << std::endl 
     49           << "Zoom size is " << zoomN_ ); 
    5450  } 
    5551 
    56   if (!zoomAxis->index.isEmpty()) 
     52  int idxSrc, nDest = 0, beginDestLoc, beginDestGlo = 0 ; 
     53  int indGloDest, indGloSrc, iSrc; 
     54  for (int i = 0; i < axisSrc_->n.getValue(); i++) 
    5755  { 
    58     int sz = zoomAxis->index.numElements(); 
    59     zoomIndex_.resize(sz); 
    60     for (int i = 0; i < sz; ++i) 
    61       zoomIndex_[i] = zoomAxis->index(i); 
     56    idxSrc = axisSrc_->index(i); 
     57    if ((idxSrc >= zoomBegin_) && (idxSrc <= zoomEnd_)) 
     58    { 
     59      if (nDest == 0) beginDestLoc = i; 
     60      ++nDest; 
     61    } 
     62  } 
     63  beginDestGlo = beginDestLoc + axisSrc_->begin - zoomBegin_; 
     64  axisDest_->n_glo.setValue(zoomN_); 
     65  axisDest_->n.setValue(nDest); 
     66  axisDest_->begin.setValue(beginDestGlo); 
     67  axisDest_->index.resize(nDest); 
    6268 
    63     std::sort(zoomIndex_.begin(), zoomIndex_.end()); 
    64   } 
     69  axisDest_->data_n.setValue(nDest); 
     70  axisDest_->data_begin.setValue(0); 
     71  axisDest_->data_index.resize(nDest); 
    6572 
    66 } 
    67  
    68 /*! 
    69   Compute the index mapping between axis on grid source and one on grid destination 
    70 */ 
    71 void CAxisAlgorithmZoom::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    72 { 
    73   // We use all index of source and destination to calculate the mapping index of zoom. 
    74   // The server who receives the "zoomed" fields will decide whether it will forward these fields or write "real zoomed" fields into file 
    75   // That means servers need to change to cover this problem. 
    76   StdSize niSource = axisSrc_->n.getValue(); 
    77   StdSize ibeginSource = axisSrc_->begin.getValue(); 
    78   StdSize iendSource = ibeginSource + niSource - 1; 
    79  
    80   StdSize ibegin = std::max(ibeginSource, zoomBegin_); 
    81   StdSize iend = std::min(iendSource, zoomEnd_); 
    82   StdSize ni = iend + 1 - ibegin; 
    83   if (iend < ibegin) ni = 0; 
     73  axisDest_->mask.resize(nDest); 
     74  if (axisSrc_->hasValue) axisDest_->value.resize(nDest); 
     75  if (axisSrc_->hasLabel) axisDest_->label.resize(nDest); 
     76  if (axisSrc_->hasBounds) axisDest_->bounds.resize(2,nDest); 
    8477 
    8578  this->transformationMapping_.resize(1); 
    8679  this->transformationWeight_.resize(1); 
    87  
    8880  TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    8981  TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    9082 
    91   if (!zoomIndex_.empty()) 
     83  for (int iDest = 0; iDest < nDest; iDest++) 
    9284  { 
    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) 
     85    iSrc = iDest + beginDestLoc; 
     86    axisDest_->index(iDest) = iDest + beginDestGlo; 
     87    axisDest_->data_index(iDest) = axisSrc_->data_index(iSrc) - beginDestLoc; 
     88    axisDest_->mask(iDest) = axisSrc_->mask(iSrc); 
     89 
     90    if (axisSrc_->hasValue) 
     91      axisDest_->value(iDest) = axisSrc_->value(iSrc); 
     92    if (axisSrc_->hasLabel) 
     93      axisDest_->label(iDest) = axisSrc_->label(iSrc); 
     94    if (axisSrc_->hasBounds) 
    9795    { 
    98       transMap[*itZoomBegin].push_back(*itZoomBegin); 
    99       transWeight[*itZoomBegin].push_back(1.0); 
     96      axisDest_->bounds(0,iDest) = axisSrc_->bounds(0,iSrc); 
     97      axisDest_->bounds(1,iDest) = axisSrc_->bounds(1,iSrc); 
    10098    } 
    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     } 
    109   } 
     99    indGloDest = axisDest_->index(iDest); 
     100    indGloSrc = axisSrc_->index(iSrc); 
     101    transMap[indGloDest].push_back(indGloSrc); 
     102    transWeight[indGloDest].push_back(1.0); 
    110103 
    111   updateZoom(); 
    112   // updateAxisDestinationMask(); 
    113 } 
    114  
    115 /*! 
    116   After a zoom on axis, it should be certain that (global) zoom begin and (global) zoom size are updated 
    117 */ 
    118 void CAxisAlgorithmZoom::updateZoom() 
    119 { 
    120   axisDest_->global_zoom_begin = zoomBegin_; 
    121   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()); 
    126104  } 
    127105} 
    128106 
    129107/*! 
    130   Update mask on axis 
    131   Because only zoomed region on axis is not masked, the remaining must be masked to make sure 
    132 correct index be extracted 
     108  Compute the index mapping between domain on grid source and one on grid destination 
    133109*/ 
    134 // void CAxisAlgorithmZoom::updateAxisDestinationMask() 
    135 // { 
    136 //   StdSize niMask = axisDest_->mask.numElements(); 
    137 //   StdSize iBeginMask = axisDest_->begin.getValue(); 
    138 //   StdSize globalIndexMask = 0; 
    139 //   TransformationIndexMap& transMap = this->transformationMapping_[0]; 
    140 //   TransformationIndexMap::const_iterator ite = (transMap).end(); 
    141 //   for (StdSize idx = 0; idx < niMask; ++idx) 
    142 //   { 
    143 //     globalIndexMask = iBeginMask + idx; 
    144 //     if (transMap.find(globalIndexMask) == ite) 
    145 //       (axisDest_->mask)(idx) = false; 
    146 //   } 
    147 // } 
     110void CAxisAlgorithmZoom::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
     111{ 
     112} 
    148113 
    149114} 
  • XIOS/trunk/src/transformation/axis_algorithm_zoom.hpp

    r1201 r1559  
    11/*! 
    22   \file axis_algorithm_zoom.hpp 
    3    \author Ha NGUYEN 
    4    \since 03 June 2015 
    5    \date 12 June 2015 
    6  
    7    \brief Algorithm for zooming on an axis. 
     3   \brief Algorithm for zooming an axis. 
    84 */ 
    95#ifndef __XIOS_AXIS_ALGORITHM_ZOOM_HPP__ 
     
    2117  Implementing zoom on axis 
    2218  A zoomed region can be considered as region that isn't masked. 
    23   Only this zoomed region is extracted to write on Netcdf. 
     19  Only this zoomed region is zoomed to write on Netcdf. 
    2420*/ 
    2521class CAxisAlgorithmZoom : public CAxisAlgorithmTransformation 
     
    3531 
    3632private: 
    37   // void updateAxisDestinationMask(); 
    38   void updateZoom(); 
    3933 
    4034private: 
     
    4640 
    4741  //! Global zoom size on axis 
    48   StdSize zoomSize_; 
     42  StdSize zoomN_; 
    4943 
    5044  std::vector<int> zoomIndex_; 
Note: See TracChangeset for help on using the changeset viewer.