Changeset 1568


Ignore:
Timestamp:
08/28/18 16:38:30 (6 years ago)
Author:
oabramkina
Message:

Grid mask is now applied in the source filter of clients: unmasked values are replaced by NaN. It is not reconstructed any more by servers.

This needs to be tested more rigorously before commiting to trunk.

Location:
XIOS/dev/dev_olga/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/distribution_client.cpp

    r1564 r1568  
    3636  GlobalLocalMap void2 ; 
    3737  std::vector<int> void3 ; 
    38   std::vector<int> void4 ; 
     38  std::vector<bool> void4 ; 
    3939 
    4040  globalLocalDataSendToServerMap_.swap(void1) ; 
     
    6161  // Then check mask of grid 
    6262  int gridDim = domList.size() * 2 + axisList.size(); 
    63   grid->checkMask(); 
     63//  grid->checkMask(); 
    6464  switch (gridDim) { 
    6565    case 0: 
     
    282282 
    283283        if ((iIdx >= nBeginLocal_[indexMap_[i]]) && (iIdx < nLocal_[indexMap_[i]]) && 
    284            (jIdx >= nBeginLocal_[indexMap_[i]+1]) && (jIdx < nLocal_[indexMap_[i]+1]) && 
    285            (domainMasks_[idxDomain](iIdx + jIdx*nLocal_[indexMap_[i]]))) 
     284           (jIdx >= nBeginLocal_[indexMap_[i]+1]) && (jIdx < nLocal_[indexMap_[i]+1]) 
     285           && (domainMasks_[idxDomain](iIdx + jIdx*nLocal_[indexMap_[i]]))) 
    286286        { 
    287287          ++count; 
     
    325325      elementIndexData_[i].resize(dataNIndex_[i]); 
    326326      elementIndexData_[i] = false; 
    327       int iIdx = 0, count = 0, localIndex = 0; 
     327      int iIdx = 0, count = 0; 
    328328      for (int j = 0; j < dataNIndex_[i]; ++j) 
    329329      { 
     
    438438      currentIndex[0] = elementLocalIndex_[0](i); 
    439439 
    440       // If defined, iterate on grid mask 
    441       if (!gridMask_.isEmpty()) 
    442       { 
    443         for (int k = 0; k < this->numElement_; ++k) 
    444         { 
    445           gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 
    446         } 
    447         if (gridMask_(gridMaskIndex)) ++indexLocalDataOnClientCount; 
    448       } 
    449       // If grid mask is not defined, iterate on elements' mask 
    450       else 
    451       { 
    452         bool maskTmp = true; 
    453         int idxDomain = 0, idxAxis = 0; 
    454         for (int elem = 0; elem < numElement_; ++elem) 
    455         { 
    456           if (2 == axisDomainOrder_(elem)) 
    457           { 
    458             maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 
    459             ++idxDomain; 
    460           } 
    461           else if (1 == axisDomainOrder_(elem)) 
    462           { 
    463             maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 
    464             ++idxAxis; 
    465           } 
    466         } 
    467         if (maskTmp) ++indexLocalDataOnClientCount; 
    468       } 
    469  
     440      bool maskTmp = true; 
     441      int idxDomain = 0, idxAxis = 0; 
     442      for (int elem = 0; elem < numElement_; ++elem) 
     443      { 
     444        if (2 == axisDomainOrder_(elem)) 
     445        { 
     446          maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 
     447          ++idxDomain; 
     448        } 
     449        else if (1 == axisDomainOrder_(elem)) 
     450        { 
     451          maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 
     452          ++idxAxis; 
     453        } 
     454      } 
     455      if (maskTmp) ++indexLocalDataOnClientCount; 
    470456    } 
    471457    idxLoop[0] += innerLoopSize; 
     
    535521        if (isCurrentIndexDataCorrect) 
    536522        { 
    537           int gridMaskIndex = 0; 
    538           for (int k = 0; k < this->numElement_; ++k) 
     523          bool maskTmp = true; 
     524          bool maskGridTmp = true; 
     525 
     526          // Domain or axis mask: only unmasked values will be sent 
     527          int idxDomain = 0, idxAxis = 0; 
     528          for (int elem = 0; elem < numElement_; ++elem) 
    539529          { 
    540             gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 
     530            if (2 == axisDomainOrder_(elem)) 
     531            { 
     532              maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 
     533              ++idxDomain; 
     534            } 
     535            else if (1 == axisDomainOrder_(elem)) 
     536            { 
     537              maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 
     538              ++idxAxis; 
     539            } 
    541540          } 
    542541 
    543           bool maskTmp = true; 
    544           // If defined, apply grid mask 
    545          if (!gridMask_.isEmpty()) 
     542          // Grid mask: unmasked values will be replaces by NaN and then all values will be sent 
     543          if (!gridMask_.isEmpty()) 
    546544          { 
    547             maskTmp =  gridMask_(gridMaskIndex); 
    548           } 
    549           // If grid mask is not defined, apply elements' mask 
    550           else 
    551           { 
    552             int idxDomain = 0, idxAxis = 0; 
    553             for (int elem = 0; elem < numElement_; ++elem) 
     545            int gridMaskIndex = 0; 
     546            for (int k = 0; k < this->numElement_; ++k) 
    554547            { 
    555               if (2 == axisDomainOrder_(elem)) 
    556               { 
    557                 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 
    558                 ++idxDomain; 
    559               } 
    560               else if (1 == axisDomainOrder_(elem)) 
    561               { 
    562                 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 
    563                 ++idxAxis; 
    564               } 
     548              gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 
    565549            } 
     550            maskGridTmp =  gridMask_(gridMaskIndex); 
    566551          } 
    567552 
     
    575560            globalDataIndex_[globalIndex] = indexLocalDataOnClientCount; 
    576561            localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 
     562            if (maskGridTmp) 
     563              localMaskIndex_[indexLocalDataOnClientCount] = true; 
     564            else 
     565              localMaskIndex_[indexLocalDataOnClientCount] = false; 
    577566            globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount; 
    578             localMaskIndex_[indexLocalDataOnClientCount] = gridMaskIndex; 
    579567            localMaskedDataIndex_[indexLocalDataOnClientCount] = indexLocalDataOnClientCount; 
    580568            ++indexLocalDataOnClientCount; 
     
    641629    return -1; 
    642630  } 
    643   int tempI = dataIndex + dataBegin; 
     631  int tempI = dataIndex; //+ dataBegin; 
    644632  if ((tempI < 0) || (tempI > ni)) 
    645633    return -1; 
     
    675663  Return local mask index of client 
    676664*/ 
    677 const std::vector<int>& CDistributionClient::getLocalMaskIndexOnClient() 
     665const std::vector<bool>& CDistributionClient::getLocalMaskIndexOnClient() 
    678666{ 
    679667  if (!isComputed_) createGlobalIndexSendToServer(); 
     
    691679 
    692680} // namespace xios 
     681 
  • XIOS/dev/dev_olga/src/distribution_client.hpp

    r1562 r1568  
    3333 
    3434  public: 
    35     /** Default constructor */         
     35    /** Default constructor */ 
    3636    CDistributionClient(int rank, CGrid* grid); 
    3737 
     
    4444    GlobalLocalDataMap& getGlobalLocalDataSendToServer(); 
    4545    GlobalLocalDataMap& getGlobalDataIndexOnClient(); 
    46     const std::vector<int>& getLocalMaskIndexOnClient(); 
     46    const std::vector<bool>& getLocalMaskIndexOnClient(); 
    4747    const std::vector<int>& getLocalMaskedDataIndexOnClient(); 
    4848 
     
    8383    GlobalLocalDataMap globalLocalDataSendToServerMap_; 
    8484    GlobalLocalDataMap globalDataIndex_; 
     85 
     86    /*! Array holding masked data indexes. 
     87     * It includes: 
     88     *  masking on data (data_i/j_index or data_ni/nj and data_ibegin) 
     89     *  masking on grid elements (domains, axes or scalars) 
     90     * It DOES NOT include grid mask. 
     91     * The array size defines the data size entering the workflow. It is used by source filter of client or server1. 
     92    */ 
    8593    std::vector<int> localDataIndex_; 
    86     std::vector<int> localMaskIndex_; 
     94 
     95    /*! Array holding grid mask. 
     96     * It is used by source filter of client for replacing unmasked data by NaN. 
     97    */ 
     98    std::vector<bool> localMaskIndex_; 
     99 
    87100    std::vector<int> localMaskedDataIndex_; 
    88101 
     
    172185} // namespace xios 
    173186#endif // __XIOS_DISTRIBUTIONCLIENT_HPP__ 
     187 
  • XIOS/dev/dev_olga/src/filter/source_filter.cpp

    r1250 r1568  
    77namespace xios 
    88{ 
    9   CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid, bool compression,  
     9  CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid, 
     10                               bool compression /*= true*/, bool mask /*= false*/, 
    1011                               const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/, 
    1112                               bool hasMissingValue /*= false*/, 
     
    1415    , grid(grid) 
    1516    , compression(compression) 
     17    , mask(mask) 
    1618    , offset(offset) 
    1719    , hasMissingValue(hasMissingValue), defaultValue(defaultValue) 
     
    4042    } 
    4143    else 
    42       grid->inputField(data, packet->data); 
    43  
    44      
    45      
    46     // if (compression) grid->inputField(data, packet->data) ; 
    47     // else 
    48     // { 
    49     //   // just make a flat copy 
    50     //   CArray<double, N> data_tmp(data.copy()) ; // supress const attribute 
    51     //   CArray<double,1> dataTmp2(data_tmp.dataFirst(),shape(data.numElements()),neverDeleteData) ; 
    52     //   packet->data = dataTmp2 ; 
    53     // } 
     44    { 
     45      if (mask) 
     46        grid->maskField(data, packet->data); 
     47      else 
     48        grid->inputField(data, packet->data); 
     49    } 
    5450    // Convert missing values to NaN 
    5551    if (hasMissingValue) 
  • XIOS/dev/dev_olga/src/filter/source_filter.hpp

    r1241 r1568  
    2121       * \param gc the garbage collector associated with this filter 
    2222       * \param grid the grid to which the data is attached 
     23       * \param compression 
     24       * \param mask 
    2325       * \param offset the offset applied to the timestamp of all packets 
    2426       * \param manualTrigger whether the output should be triggered manually 
     
    2729       */ 
    2830      CSourceFilter(CGarbageCollector& gc, CGrid* grid, 
    29                     bool compression=true, 
     31                    bool compression = true, 
     32                    bool mask = false, 
    3033                    const CDuration offset = NoneDu, bool manualTrigger = false, 
    3134                    bool hasMissingValue = false, 
     
    6164 
    6265    private: 
    63       CGrid* grid; //!< The grid attached to the data the filter can accept 
    64       const CDuration offset; //!< The offset applied to the timestamp of all packets 
     66      CGrid* grid;             //!< The grid attached to the data the filter can accept 
     67      const CDuration offset;  //!< The offset applied to the timestamp of all packets 
    6568      const bool hasMissingValue; 
    6669      const double defaultValue; 
    67       const bool compression ; //!< indicate if the data need to be compressed : on client size : true, on server side : false 
     70      const bool compression ; //!< indicates if data need to be compressed : on client side : true, on server side : false 
     71      const bool mask ;        //!< indicates whether grid mask should be applied (true for clients, false for servers) 
    6872  }; // class CSourceFilter 
    6973} // namespace xios 
  • XIOS/dev/dev_olga/src/node/axis.cpp

    r1566 r1568  
    285285      } 
    286286 
    287       // Remove this check because it doen't make sense in case of a hole or overlapping axes 
    288287      if (!this->value.isEmpty()) 
    289288      { 
    290 //        StdSize true_size = value.numElements(); 
    291 //        if (this->n.getValue() != true_size) 
    292 //          ERROR("CAxis::checkAttributes(void)", 
    293 //                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
    294 //                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     289        StdSize true_size = value.numElements(); 
     290        if (this->n.getValue() != true_size) 
     291          ERROR("CAxis::checkAttributes(void)", 
     292                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     293                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
    295294        this->hasValue = true; 
    296295      } 
     
    310309      Check the validity of data and fill in values if any. 
    311310   */ 
     311 
    312312   void CAxis::checkData() 
    313313   { 
     
    328328      { 
    329329        data_index.resize(data_n); 
    330         for (int i = 0; i < data_n; ++i) data_index(i) = i; 
    331       } 
     330        for (int i = 0; i < data_n; ++i) 
     331        { 
     332          if ((i+data_begin) >= 0 && (i+data_begin<n)) 
     333            data_index(i) = i+data_begin; 
     334          else 
     335            data_index(i) = -1; 
     336        } 
     337      } 
     338      else 
     339      { 
     340        if (data_index.numElements() != data_n) 
     341        { 
     342          ERROR("CAxis::checkData(void)", 
     343                << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     344                << "The size of data_index = "<< data_index.numElements() << "is not equal to the data size data_n = " << data_n.getValue() << ")."); 
     345        } 
     346        data_index.resize(data_n); 
     347        for (int i = 0; i < data_n; ++i) 
     348        { 
     349          if ((i+data_begin) >= 0 && (i+data_begin<n)) 
     350            data_index(i) = data_index(i); 
     351          else 
     352            data_index(i) = -1; 
     353        } 
     354      } 
     355 
    332356   } 
    333357 
     
    344368      if (!mask.isEmpty()) 
    345369      { 
    346          if (mask.extent(0) != n) 
    347            ERROR("CAxis::checkMask(void)", 
    348                  << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    349                  << "The mask does not have the same size as the local domain." << std::endl 
    350                  << "Local size is " << n.getValue() << "." << std::endl 
    351                  << "Mask size is " << mask.extent(0) << "."); 
    352       } 
    353       else // (mask.isEmpty()) 
    354       { // If no mask was defined, we create a default one without any masked point. 
    355          mask.resize(n); 
    356          for (int i = 0; i < n; ++i) 
    357          { 
    358            mask(i) = true; 
    359          } 
     370        if (mask.extent(0) != n) 
     371        { 
     372          ERROR("CAxis::checkMask(void)", 
     373              << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     374              << "The mask does not have the same size as the local domain." << std::endl 
     375              << "Local size is " << n.getValue() << "." << std::endl 
     376              << "Mask size is " << mask.extent(0) << "."); 
     377        } 
     378      } 
     379      else 
     380      { 
     381        mask.resize(n); 
     382        mask = true; 
    360383      } 
    361384   } 
     
    547570 
    548571        // Calculate the compressed index if any 
    549         std::set<int> writtenInd; 
    550         if (isCompressible_) 
    551         { 
    552           for (int idx = 0; idx < data_index.numElements(); ++idx) 
    553           { 
    554             int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
    555  
    556             if (ind >= 0 && ind < ni && mask(ind)) 
    557             { 
    558               ind += ibegin; 
    559               writtenInd.insert(ind); 
    560             } 
    561           } 
    562         } 
     572//        std::set<int> writtenInd; 
     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, ni); 
     578// 
     579//            if (ind >= 0 && ind < ni && mask(ind)) 
     580//            { 
     581//              ind += ibegin; 
     582//              writtenInd.insert(ind); 
     583//            } 
     584//          } 
     585//        } 
    563586 
    564587        // Compute the global index of the current client (process) hold 
     
    725748        }                  
    726749      } 
     750// 
     751//      nbWritten = 0; 
     752//      for (int idx = 0; idx < data_index.numElements(); ++idx) 
     753//      { 
     754//        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
     755//        { 
     756//          ++nbWritten; 
     757//        } 
     758//      } 
     759// 
     760//      compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); 
     761//      nbWritten = 0; 
     762//      for (int idx = 0; idx < data_index.numElements(); ++idx) 
     763//      { 
     764//        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
     765//        { 
     766//          compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)]; 
     767//          ++nbWritten; 
     768//        } 
     769//      } 
    727770 
    728771      nbWritten = 0; 
     
    9591002 
    9601003  /* 
    961     Send attributes of axis from a group of client to other group of clients/servers  
    962     on supposing that these attributes are distributed among the clients of the sending group 
    963     In the future, if new attributes are added, they should also be processed in this function 
     1004    Send axis attributes from a group of clients to another group of clients/servers 
     1005    supposing that these attributes are distributed among the clients of the sending group 
     1006    In future, if new attributes are added, they should also be processed in this function 
    9641007  */ 
    9651008  void CAxis::sendDistributedAttributes(void) 
    9661009  { 
    967     int ns, n, i, j, ind, nv, idx; 
     1010    int ind, idx; 
    9681011    std::list<CContextClient*>::iterator it; 
    9691012 
     
    9821025      list<CArray<string,1> > list_label; 
    9831026 
     1027      // Cut off the ghost points 
    9841028      int nbIndex = index.numElements(); 
    9851029      CArray<int,1> dataIndex(nbIndex); 
     
    9881032      { 
    9891033        if (0 <= data_index(idx) && data_index(idx) < nbIndex) 
    990           dataIndex(idx) = 1; 
     1034          dataIndex(data_index(idx)) = 1; 
    9911035      } 
    9921036 
     
    9951039      for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 
    9961040      { 
    997         int nbData = 0; 
     1041        int nbData = 0, nbDataCount = 0; 
    9981042        int rank = connectedServerRank_[nbServer][k]; 
    9991043        it = indSrv_[nbServer].find(rank); 
     
    10021046 
    10031047        list_indi.push_back(CArray<int,1>(nbData)); 
    1004         list_dataInd.push_back(CArray<int,1>(nbData));         
     1048        list_dataInd.push_back(CArray<int,1>(nbData)); 
    10051049        list_mask.push_back(CArray<bool,1>(nbData)); 
    10061050 
     
    10151059 
    10161060        CArray<int,1>& indi = list_indi.back(); 
    1017         CArray<int,1>& dataIndi = list_dataInd.back();         
     1061        CArray<int,1>& dataIndi = list_dataInd.back(); 
     1062        dataIndi = -1; 
    10181063        CArray<bool,1>& maskIndi = list_mask.back(); 
    10191064 
    1020         for (n = 0; n < nbData; ++n) 
     1065        for (int n = 0; n < nbData; ++n) 
    10211066        { 
    10221067          idx = static_cast<int>(it->second[n]); 
     
    11621207    nonCompressedData = -1;    
    11631208    mask.resize(nbData); 
     1209    mask = true; 
    11641210    if (hasValue) 
    11651211      value.resize(nbData); 
     
    11991245    } 
    12001246     
    1201     int nbCompressedData = 0;  
     1247    int nbCompressedData = 0; 
    12021248    for (idx = 0; idx < nonCompressedData.numElements(); ++idx) 
    12031249    { 
    12041250      if (0 <= nonCompressedData(idx)) 
    1205         ++nbCompressedData;         
     1251        ++nbCompressedData; 
    12061252    } 
    12071253 
     
    12131259      { 
    12141260        data_index(nbCompressedData) = idx % n; 
    1215         ++nbCompressedData;         
     1261        ++nbCompressedData; 
    12161262      } 
    12171263    } 
    12181264 
    12191265    data_begin.setValue(0); 
     1266    data_n.setValue(data_index.numElements()); 
    12201267  } 
    12211268 
     
    13301377      clientsSet.insert(contextClient); 
    13311378    } 
    1332 } 
     1379  } 
    13331380 
    13341381  void CAxis::parse(xml::CXMLNode & node) 
  • XIOS/dev/dev_olga/src/node/axis.hpp

    r1562 r1568  
    126126        bool hasLabel; 
    127127 
    128         CArray<size_t,1> localIndexToWriteOnServer;         
     128        CArray<size_t,1> localIndexToWriteOnServer; 
    129129 
    130130      private: 
  • XIOS/dev/dev_olga/src/node/domain.cpp

    r1565 r1568  
    24472447         { 
    24482448           iIndex = (index%ni_glo)-ibegin; 
    2449            iIndex = (iIndex < 0) ? 0 : iIndex; 
     2449           iIndex = (iIndex < 0) ? 0 : iIndex;    // ?? 
    24502450           jIndex = (index/ni_glo)-jbegin; 
    2451            jIndex = (jIndex < 0) ? 0 : jIndex; 
     2451           jIndex = (jIndex < 0) ? 0 : jIndex;    // ?? 
    24522452           nbIndLoc = iIndex + ni * jIndex; 
    24532453           if (nbIndLoc < nbIndexGlobMax) 
     
    28962896      buffer >> recvDataJIndex[i]; 
    28972897    } 
    2898     
     2898 
    28992899    int nbIndex = i_index.numElements(); 
    29002900    CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 
    29012901    dataIIndex = -1; dataJIndex = -1; 
    2902       
     2902 
    29032903    nbIndex = 0; 
    29042904    for (i = 0; i < nbReceived; ++i) 
  • XIOS/dev/dev_olga/src/node/field.cpp

    r1542 r1568  
    10271027     { 
    10281028        if (!instantDataFilter) 
    1029           instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid,true)); 
     1029          instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false)); 
    10301030 
    10311031 
     
    10431043     { 
    10441044       if (!instantDataFilter) 
    1045          instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true)); 
     1045         instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, false)); 
    10461046 
    10471047             // If the field data is to be read by the client or/and written to a file 
     
    10891089         { 
    10901090           checkTimeAttributes(); 
    1091            instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, freq_offset, true, 
     1091           instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true, 
    10921092                                                                                                       detectMissingValues, defaultValue)); 
    10931093         } 
     
    10951095         { 
    10961096            if (check_if_active.isEmpty()) check_if_active = false;  
    1097             instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, NoneDu, false, 
     1097            instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, true, NoneDu, false, 
    10981098                                                                                                        detectMissingValues, defaultValue)); 
    10991099         } 
     
    11761176         { 
    11771177           checkTimeAttributes(); 
    1178            serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, freq_offset, true, 
     1178           serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true, 
    11791179                                                                                   detectMissingValues, defaultValue)); 
    11801180         } 
     
    11931193         { 
    11941194           if (check_if_active.isEmpty()) check_if_active = false; 
    1195            clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, NoneDu, false, 
     1195           clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, true, NoneDu, false, 
    11961196                                                                                   detectMissingValues, defaultValue)); 
    11971197         } 
  • XIOS/dev/dev_olga/src/node/grid.cpp

    r1562 r1568  
    698698     clientDistribution_ = new CDistributionClient(rank, this); 
    699699     // Get local data index on client 
    700      storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
    701      int nbStoreIndex = storeIndex_client.numElements(); 
    702      for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 
     700     int nbStoreIndex = clientDistribution_->getLocalDataIndexOnClient().size(); 
     701     storeIndex_client.resize(nbStoreIndex); 
     702     storeMask_client.resize(nbStoreIndex); 
     703     for (int idx = 0; idx < nbStoreIndex; ++idx) 
     704     { 
     705       storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 
     706       storeMask_client(idx) = (clientDistribution_->getLocalMaskIndexOnClient())[idx]; 
     707     } 
    703708 
    704709     if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); 
     
    12931298   } 
    12941299 
     1300   void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) const 
     1301   { 
     1302      const StdSize size = storeIndex_client.numElements(); 
     1303      stored.resize(size); 
     1304 
     1305      const double nanValue = std::numeric_limits<double>::quiet_NaN(); 
     1306      for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue; 
     1307   } 
     1308 
    12951309   void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const 
    12961310   { 
     
    17491763        } 
    17501764 
    1751         modifyMaskSize(nSize, false); 
    1752  
    1753         // These below codes are reserved for future 
    1754         CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob);  
    1755         map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 
    1756                                                ite = outGlobalIndexFromClient.end(), it;   
    1757         const CDistributionServer::GlobalLocalMap&  globalLocalMask = srvDist.getGlobalLocalIndex(); 
    1758         CDistributionServer::GlobalLocalMap::const_iterator itSrv; 
    1759         size_t nb = 0; 
    1760         for (it = itb; it != ite; ++it) 
    1761         { 
    1762           CArray<size_t,1>& globalInd = it->second; 
    1763           for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
    1764           { 
    1765             if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb; 
    1766           } 
    1767         } 
    1768          
    1769         CArray<int,1> indexToModify(nb); 
    1770         nb = 0;     
    1771         for (it = itb; it != ite; ++it) 
    1772         { 
    1773           CArray<size_t,1>& globalInd = it->second; 
    1774           for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
    1775           { 
    1776             itSrv = globalLocalMask.find(globalInd(idx)); 
    1777             if (globalLocalMask.end() != itSrv)  
    1778             { 
    1779               indexToModify(nb) = itSrv->second; 
    1780               ++nb; 
    1781             } 
    1782           } 
    1783         } 
    1784  
    1785         modifyMask(indexToModify, true); 
     1765//        modifyMaskSize(nSize, false); 
     1766//        modifyMaskSize(nSize, true);   // Grid mask should be gone beyond client source filter 
     1767// 
     1768//        // These below codes are reserved for future 
     1769//        CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob); 
     1770//        map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 
     1771//                                               ite = outGlobalIndexFromClient.end(), it; 
     1772//        const CDistributionServer::GlobalLocalMap&  globalLocalMask = srvDist.getGlobalLocalIndex(); 
     1773//        CDistributionServer::GlobalLocalMap::const_iterator itSrv; 
     1774//        size_t nb = 0; 
     1775//        for (it = itb; it != ite; ++it) 
     1776//        { 
     1777//          CArray<size_t,1>& globalInd = it->second; 
     1778//          for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
     1779//          { 
     1780//            if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb; 
     1781//          } 
     1782//        } 
     1783// 
     1784//        CArray<int,1> indexToModify(nb); 
     1785//        nb = 0; 
     1786//        for (it = itb; it != ite; ++it) 
     1787//        { 
     1788//          CArray<size_t,1>& globalInd = it->second; 
     1789//          for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
     1790//          { 
     1791//            itSrv = globalLocalMask.find(globalInd(idx)); 
     1792//            if (globalLocalMask.end() != itSrv) 
     1793//            { 
     1794//              indexToModify(nb) = itSrv->second; 
     1795//              ++nb; 
     1796//            } 
     1797//          } 
     1798//        } 
     1799 
     1800//        modifyMask(indexToModify, true); 
    17861801      } 
    17871802 
  • XIOS/dev/dev_olga/src/node/grid.hpp

    r1564 r1568  
    9494         template <int n> 
    9595         void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; 
     96         template <int n> 
     97         void maskField(const CArray<double,n>& field, CArray<double,1>& stored) const; 
    9698         template <int n> 
    9799         void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const;   
     
    208210      public: 
    209211         CArray<int, 1> storeIndex_client; 
     212         CArray<bool, 1> storeMask_client; 
    210213 
    211214/** Map containing indexes that will be sent in sendIndex(). */ 
     
    273276        void restoreField_arr(const CArray<double, 1>& stored, double* const data) const; 
    274277        void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const; 
     278        void maskField_arr(const double* const data, CArray<double, 1>& stored) const; 
    275279 
    276280        void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); 
     
    385389 
    386390   template <int n> 
     391   void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const 
     392   { 
     393//#ifdef __XIOS_DEBUG 
     394      if (this->getDataSize() != field.numElements()) 
     395         ERROR("void CGrid::inputField(const  CArray<double,n>& field, CArray<double,1>& stored) const", 
     396                << "[ Awaiting data of size = " << this->getDataSize() << ", " 
     397                << "Received data size = "      << field.numElements() << " ] " 
     398                << "The data array does not have the right size! " 
     399                << "Grid = " << this->getId()) 
     400//#endif 
     401      this->maskField_arr(field.dataFirst(), stored); 
     402   } 
     403 
     404   template <int n> 
    387405   void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const 
    388406   { 
     
    417435                             bool createMask) 
    418436   { 
    419      if (!gridMask.isEmpty() || createMask) 
    420      { 
    421        int idx = 0; 
    422        int numElement = axisDomainOrder.numElements(); 
    423        int dim = domainMasks.size() * 2 + axisMasks.size(); 
    424        std::vector<CDomain*> domainP = this->getDomains(); 
    425        std::vector<CAxis*> axisP = this->getAxis(); 
    426  
    427        std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); 
    428        std::vector<int> currentIndex(dim); 
    429        int idxDomain = 0, idxAxis = 0; 
     437     int idx = 0; 
     438     int numElement = axisDomainOrder.numElements(); 
     439     int dim = domainMasks.size() * 2 + axisMasks.size(); 
     440     std::vector<CDomain*> domainP = this->getDomains(); 
     441     std::vector<CAxis*> axisP = this->getAxis(); 
     442 
     443     std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); 
     444     std::vector<int> currentIndex(dim); 
     445     int idxDomain = 0, idxAxis = 0; 
     446    for (int i = 0; i < numElement; ++i) 
     447    { 
     448      indexMap[i] = idx; 
     449      if (2 == axisDomainOrder(i)) { 
     450          eachDimSize[indexMap[i]]   = domainP[idxDomain]->ni; 
     451          eachDimSize[indexMap[i]+1] = domainP[idxDomain]->nj; 
     452          idx += 2; ++idxDomain; 
     453      } 
     454      else if (1 == axisDomainOrder(i)) { 
     455//        eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements(); 
     456        eachDimSize[indexMap[i]] = axisP[idxAxis]->n; 
     457        ++idx; ++idxAxis; 
     458      } 
     459      else {}; 
     460    } 
     461 
     462    if (!gridMask.isEmpty() && !createMask) 
     463    { 
     464      for (int i = 0; i < dim; ++i) 
     465      { 
     466        if (gridMask.extent(i) != eachDimSize[i]) 
     467          ERROR("CGrid::checkMask(void)", 
     468                << "The mask has one dimension whose size is different from the one of the local grid." << std::endl 
     469                << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl 
     470                << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl 
     471                << "Grid = " << this->getId()) 
     472      } 
     473    } 
     474    else { 
     475        CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); 
     476        gridMask = true; 
     477    } 
     478 
     479    int ssize = gridMask.numElements(); 
     480    idx = 0; 
     481    while (idx < ssize) 
     482    { 
     483      for (int i = 0; i < dim-1; ++i) 
     484      { 
     485        if (idxLoop[i] == eachDimSize[i]) 
     486        { 
     487          idxLoop[i] = 0; 
     488          ++idxLoop[i+1]; 
     489        } 
     490      } 
     491 
     492      // Find out outer index 
     493      idxDomain = idxAxis = 0; 
     494      bool maskValue = true; 
    430495      for (int i = 0; i < numElement; ++i) 
    431496      { 
    432         indexMap[i] = idx; 
    433         if (2 == axisDomainOrder(i)) { 
    434             eachDimSize[indexMap[i]]   = domainP[idxDomain]->ni; 
    435             eachDimSize[indexMap[i]+1] = domainP[idxDomain]->nj; 
    436             idx += 2; ++idxDomain; 
     497        if (2 == axisDomainOrder(i)) 
     498        { 
     499          int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]]; 
     500          if (idxTmp < (*domainMasks[idxDomain]).numElements()) 
     501            maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp); 
     502          else 
     503            maskValue = false; 
     504          ++idxDomain; 
    437505        } 
    438         else if (1 == axisDomainOrder(i)) { 
    439   //        eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements(); 
    440           eachDimSize[indexMap[i]] = axisP[idxAxis]->n; 
    441           ++idx; ++idxAxis; 
     506        else if (1 == axisDomainOrder(i)) 
     507        { 
     508          int idxTmp = idxLoop[indexMap[i]]; 
     509          if (idxTmp < (*axisMasks[idxAxis]).numElements()) 
     510            maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp); 
     511          else 
     512            maskValue = false; 
     513 
     514          ++idxAxis; 
    442515        } 
    443         else {}; 
    444       } 
    445  
    446 //      if (!gridMask.isEmpty() && !createMask) 
    447       if (!createMask) 
     516      } 
     517 
     518      int maskIndex = idxLoop[0]; 
     519      int mulDim = 1; 
     520      for (int k = 1; k < dim; ++k) 
    448521      { 
    449         for (int i = 0; i < dim; ++i) 
    450         { 
    451           if (gridMask.extent(i) != eachDimSize[i]) 
    452             ERROR("CGrid::checkMask(void)", 
    453                   << "The mask has one dimension whose size is different from the one of the local grid." << std::endl 
    454                   << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl 
    455                   << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl 
    456                   << "Grid = " << this->getId()) 
    457         } 
    458       } 
    459       else { 
    460           CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); 
    461           gridMask = true; 
    462       } 
    463  
    464       int ssize = gridMask.numElements(); 
    465       idx = 0; 
    466       while (idx < ssize) 
    467       { 
    468         for (int i = 0; i < dim-1; ++i) 
    469         { 
    470           if (idxLoop[i] == eachDimSize[i]) 
    471           { 
    472             idxLoop[i] = 0; 
    473             ++idxLoop[i+1]; 
    474           } 
    475         } 
    476  
    477         // Find out outer index 
    478         idxDomain = idxAxis = 0; 
    479         bool maskValue = true; 
    480         for (int i = 0; i < numElement; ++i) 
    481         { 
    482           if (2 == axisDomainOrder(i)) 
    483           { 
    484             int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]]; 
    485             if (idxTmp < (*domainMasks[idxDomain]).numElements()) 
    486               maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp); 
    487             else 
    488               maskValue = false; 
    489             ++idxDomain; 
    490           } 
    491           else if (1 == axisDomainOrder(i)) 
    492           { 
    493             int idxTmp = idxLoop[indexMap[i]]; 
    494             if (idxTmp < (*axisMasks[idxAxis]).numElements()) 
    495               maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp); 
    496             else 
    497               maskValue = false; 
    498  
    499             ++idxAxis; 
    500           } 
    501         } 
    502  
    503         int maskIndex = idxLoop[0]; 
    504         int mulDim = 1; 
    505         for (int k = 1; k < dim; ++k) 
    506         { 
    507           mulDim *= eachDimSize[k-1]; 
    508           maskIndex += idxLoop[k]*mulDim; 
    509         } 
    510         *(gridMask.dataFirst()+maskIndex) &= maskValue; 
    511  
    512         ++idxLoop[0]; 
    513         ++idx; 
    514       } 
    515      } 
     522        mulDim *= eachDimSize[k-1]; 
     523        maskIndex += idxLoop[k]*mulDim; 
     524      } 
     525      *(gridMask.dataFirst()+maskIndex) &= maskValue; 
     526 
     527      ++idxLoop[0]; 
     528      ++idx; 
     529    } 
    516530   } 
    517531 
Note: See TracChangeset for help on using the changeset viewer.