Ignore:
Timestamp:
01/23/19 10:31:44 (6 years ago)
Author:
yushan
Message:

dev on ADA. add flag switch _usingEP/_usingMPI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/src/node/grid.cpp

    r1545 r1642  
    8282 
    8383   StdSize CGrid::getDimension(void) 
     84   TRY 
    8485   { 
    8586      return getGlobalDimension().size(); 
    8687   } 
     88   CATCH_DUMP_ATTR 
    8789 
    8890   //--------------------------------------------------------------- 
    8991 
    9092   StdSize CGrid::getDataSize(void) const 
     93   TRY 
    9194   { 
    9295     StdSize retvalue = 1; 
     
    98101     return retvalue; 
    99102   } 
     103   CATCH 
    100104 
    101105   /*! 
     
    106110    */ 
    107111   std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client, bool bufferForWriting) 
     112   TRY 
    108113   { 
    109114     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client); 
     
    147152     return attributesSizes; 
    148153  } 
     154   CATCH_DUMP_ATTR 
    149155 
    150156   /*! 
     
    156162    */ 
    157163   std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/, bool bufferForWriting /*= "false"*/) 
     164   TRY 
    158165   {      
    159166     // The record index is sometimes sent along with the data but we always 
     
    180187     return dataSizes; 
    181188   } 
     189   CATCH_DUMP_ATTR 
    182190 
    183191   size_t CGrid::getGlobalWrittenSize(void) 
     192   TRY 
    184193   { 
    185194         std::vector<CDomain*> domainP = this->getDomains(); 
     
    191200     return globalGridSize ; 
    192201   } 
    193     
     202   CATCH_DUMP_ATTR 
    194203    
    195204   void CGrid::checkAttributesAfterTransformation() 
     205   TRY 
    196206   { 
    197207      setAxisList(); 
     
    228238      } 
    229239   } 
     240   CATCH_DUMP_ATTR 
    230241 
    231242   //--------------------------------------------------------------- 
     
    237248    */ 
    238249   bool CGrid::isCompressible(void) const 
     250   TRY 
    239251   { 
    240252      return isCompressible_; 
    241253   } 
     254   CATCH 
    242255 
    243256   //--------------------------------------------------------------- 
    244257 
    245258   void CGrid::addRelFileCompressed(const StdString& filename) 
     259   TRY 
    246260   { 
    247261      this->relFilesCompressed.insert(filename); 
    248262   } 
     263   CATCH_DUMP_ATTR 
    249264 
    250265   bool CGrid::isWrittenCompressed(const StdString& filename) const 
     266   TRY 
    251267   { 
    252268      return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 
    253269   } 
     270   CATCH 
    254271 
    255272   //--------------------------------------------------------------- 
     
    258275   */ 
    259276   void CGrid::solveDomainAxisRef(bool areAttributesChecked) 
     277   TRY 
    260278   { 
    261279     if (this->isDomainAxisChecked) return; 
     
    266284     this->isDomainAxisChecked = areAttributesChecked; 
    267285   } 
     286   CATCH_DUMP_ATTR 
    268287 
    269288   /* 
     
    272291   */ 
    273292   void CGrid::solveDomainAxisBaseRef() 
     293   TRY 
    274294   { 
    275295     if (this->hasDomainAxisBaseRef_) return; 
     
    297317     this->hasDomainAxisBaseRef_ = true; 
    298318   } 
     319   CATCH_DUMP_ATTR 
    299320 
    300321   void CGrid::checkEligibilityForCompressedOutput() 
     322   TRY 
    301323   { 
    302324     // We don't check if the mask is valid here, just if a mask has been defined at this point. 
    303325     isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty(); 
    304326   } 
     327   CATCH_DUMP_ATTR 
    305328 
    306329   void CGrid::checkMaskIndex(bool doSendingIndex) 
     330   TRY 
    307331   { 
    308332     CContext* context = CContext::getCurrent(); 
     
    339363      this->isChecked = true; 
    340364   } 
     365   CATCH_DUMP_ATTR 
     366   bool CGrid::hasMask() const 
     367   TRY 
     368   { 
     369     return (!mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty() || 
     370             !mask_4d.isEmpty() || !mask_5d.isEmpty() || !mask_6d.isEmpty() || !mask_7d.isEmpty()); 
     371   } 
     372   CATCH 
    341373 
    342374   /* 
     
    344376   */ 
    345377   void CGrid::createMask(void) 
     378   TRY 
    346379   { 
    347380      using namespace std; 
     
    381414      } 
    382415   } 
     416   CATCH_DUMP_ATTR 
    383417 
    384418   /* 
     
    386420   */ 
    387421   void CGrid::checkMask(void) 
     422   TRY 
    388423   { 
    389424      using namespace std; 
     
    423458      } 
    424459   } 
    425  
    426  
    427 /*! 
    428   A grid can have multiple dimension, so can its mask in the form of multi-dimension array. 
    429 It's not a good idea to store all multi-dimension arrays corresponding to each mask. 
    430 One of the ways is to convert this array into 1-dimension one and every process is taken place on it. 
    431   \param [in] multi-dimension array grid mask 
    432 */ 
    433  
    434   void CGrid::getLocalMask(CArray<bool,1>& localMask) 
    435   { 
    436       std::vector<CDomain*> domainP = this->getDomains(); 
    437       std::vector<CAxis*> axisP = this->getAxis(); 
    438       int dim = domainP.size() * 2 + axisP.size(); 
    439  
    440       switch (dim) 
    441       { 
    442         case 0: 
    443           getLocalMask(mask_0d, localMask); 
    444           break; 
    445         case 1: 
    446           getLocalMask(mask_1d, localMask); 
    447           break; 
    448         case 2: 
    449           getLocalMask(mask_2d, localMask); 
    450           break; 
    451         case 3: 
    452           getLocalMask(mask_3d, localMask); 
    453           break; 
    454         case 4: 
    455           getLocalMask(mask_4d, localMask); 
    456           break; 
    457         case 5: 
    458           getLocalMask(mask_5d, localMask); 
    459           break; 
    460         case 6: 
    461           getLocalMask(mask_6d, localMask); 
    462           break; 
    463         case 7: 
    464           getLocalMask(mask_7d, localMask); 
    465           break; 
    466         default: 
    467           break; 
    468       } 
    469   } 
    470        
     460   CATCH_DUMP_ATTR 
     461 
    471462   /* 
    472463     Modify value of mask in a certain index 
     
    476467   */ 
    477468   void CGrid::modifyMask(const CArray<int,1>& indexToModify, bool modifyValue) 
     469   TRY 
    478470   { 
    479471      using namespace std; 
     
    511503      } 
    512504   } 
     505   CATCH_DUMP_ATTR 
    513506 
    514507   /* 
     
    518511   */ 
    519512   void CGrid::modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue) 
     513   TRY 
    520514   {       
    521515      std::vector<CDomain*> domainP = this->getDomains(); 
     
    552546      } 
    553547   } 
     548   CATCH_DUMP_ATTR 
    554549 
    555550   //--------------------------------------------------------------- 
    556551 
    557552   void CGrid::solveDomainRef(bool sendAtt) 
     553   TRY 
    558554   { 
    559555      setDomainList(); 
     
    568564      } 
    569565   } 
     566   CATCH_DUMP_ATTR 
    570567 
    571568   //--------------------------------------------------------------- 
    572569 
    573570   void CGrid::solveAxisRef(bool sendAtt) 
     571   TRY 
    574572   { 
    575573      setAxisList(); 
     
    599597      } 
    600598   } 
     599   CATCH_DUMP_ATTR 
    601600 
    602601   //--------------------------------------------------------------- 
    603602 
    604603   void CGrid::solveScalarRef(bool sendAtt) 
     604   TRY 
    605605   { 
    606606      setScalarList(); 
     
    616616      } 
    617617   } 
     618   CATCH_DUMP_ATTR 
    618619 
    619620   /*! 
     
    621622   */ 
    622623   void CGrid::computeWrittenIndex() 
     624   TRY 
    623625   {       
    624626      if (computedWrittenIndex_) return; 
     
    659661        { 
    660662          CContextServer* server = CContext::getCurrent()->server;       
    661           MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    662           MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
     663          ep_lib::MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, EP_INT, EP_SUM, server->intraComm); 
     664          ep_lib::MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, EP_INT, EP_SUM, server->intraComm); 
    663665          offsetWrittenIndexes_ -= numberWrittenIndexes_; 
    664666        } 
     
    680682      } 
    681683   } 
     684   CATCH_DUMP_ATTR 
    682685 
    683686   //--------------------------------------------------------------- 
     
    690693   */ 
    691694   void CGrid::computeClientIndex() 
     695   TRY 
    692696   { 
    693697     CContext* context = CContext::getCurrent(); 
    694698 
    695      CContextClient* client = context->client;  // Here it's not important which contextClient to recuperate 
     699     CContextClient* client = context->client; 
    696700     int rank = client->clientRank; 
    697701 
    698702     clientDistribution_ = new CDistributionClient(rank, this); 
    699703     // Get local data index on client 
    700      storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
    701      int nbStoreIndex = storeIndex_client.numElements(); 
     704     int nbStoreIndex = clientDistribution_->getLocalDataIndexOnClient().size(); 
     705     int nbStoreGridMask = clientDistribution_->getLocalMaskIndexOnClient().size(); 
     706     // nbStoreGridMask = nbStoreIndex if grid mask is defined, and 0 otherwise 
     707     storeIndex_client.resize(nbStoreIndex); 
     708     storeMask_client.resize(nbStoreGridMask); 
    702709     for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 
     710     for (int idx = 0; idx < nbStoreGridMask; ++idx) storeMask_client(idx) = (clientDistribution_->getLocalMaskIndexOnClient())[idx]; 
    703711 
    704712     if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); 
     
    746754      } 
    747755   } 
     756   CATCH_DUMP_ATTR 
    748757 
    749758   /*! 
     
    751760   */ 
    752761   void CGrid::computeConnectedClients() 
     762   TRY 
    753763   { 
    754764     CContext* context = CContext::getCurrent(); 
     
    840850          connectedServerRank_[receiverSize].push_back(client->clientRank % client->serverSize); 
    841851 
     852         // Now check if all servers have data to receive. If not, master client will send empty data. 
     853         // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive. 
     854         std::vector<int> counts (client->clientSize); 
     855         std::vector<int> displs (client->clientSize); 
     856         displs[0] = 0; 
     857         int localCount = connectedServerRank_[receiverSize].size() ; 
     858         ep_lib::MPI_Gather(&localCount, 1, EP_INT, &counts[0], 1, EP_INT, 0, client->intraComm) ; 
     859         for (int i = 0; i < client->clientSize-1; ++i) 
     860         { 
     861           displs[i+1] = displs[i] + counts[i]; 
     862         } 
     863         std::vector<int> allConnectedServers(displs[client->clientSize-1]+counts[client->clientSize-1]); 
     864         ep_lib::MPI_Gatherv(&(connectedServerRank_[receiverSize])[0], localCount, EP_INT, &allConnectedServers[0], &counts[0], &displs[0], EP_INT, 0, client->intraComm); 
     865 
     866         if ((allConnectedServers.size() != receiverSize) && (client->clientRank == 0)) 
     867         { 
     868           std::vector<bool> isSrvConnected (receiverSize, false); 
     869           for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true; 
     870           for (int i = 0; i < receiverSize; ++i) 
     871           { 
     872             if (!isSrvConnected[i]) connectedServerRank_[receiverSize].push_back(i); 
     873           } 
     874         } 
     875 
    842876         nbSenders[receiverSize] = clientServerMap_->computeConnectedClients(receiverSize, client->clientSize, client->intraComm, connectedServerRank_[receiverSize]); 
    843877       } 
    844878     } 
    845879   } 
     880   CATCH_DUMP_ATTR 
    846881 
    847882   /*! 
     
    853888   */ 
    854889   void CGrid::computeIndex(void) 
     890   TRY 
    855891   { 
    856892     CContext* context = CContext::getCurrent(); 
     
    879915     } 
    880916   } 
     917   CATCH_DUMP_ATTR 
    881918 
    882919   /*! 
     
    892929                                     const CContextClient* client, 
    893930                                     CClientServerMapping::GlobalIndexMap& globalIndexOnServer) 
     931   TRY 
    894932   { 
    895933     int serverSize = client->serverSize; 
     
    10581096    } 
    10591097   } 
    1060    //---------------------------------------------------------------- 
     1098   CATCH_DUMP_ATTR 
     1099//---------------------------------------------------------------- 
    10611100 
    10621101   CGrid* CGrid::createGrid(CDomain* domain) 
     1102   TRY 
    10631103   { 
    10641104      std::vector<CDomain*> vecDom(1, domain); 
     
    10671107      return createGrid(vecDom, vecAxis); 
    10681108   } 
     1109   CATCH 
    10691110 
    10701111   CGrid* CGrid::createGrid(CDomain* domain, CAxis* axis) 
    1071    { 
     1112   TRY 
     1113  { 
    10721114      std::vector<CDomain*> vecDom(1, domain); 
    10731115      std::vector<CAxis*> vecAxis(1, axis); 
     
    10751117      return createGrid(vecDom, vecAxis); 
    10761118   } 
     1119   CATCH 
    10771120 
    10781121   CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 
    10791122                            const CArray<int,1>& axisDomainOrder) 
     1123   TRY 
    10801124   { 
    10811125     std::vector<CScalar*> vecScalar; 
    10821126     return createGrid(generateId(domains, axis, vecScalar, axisDomainOrder), domains, axis, vecScalar, axisDomainOrder); 
    10831127   } 
     1128   CATCH 
    10841129 
    10851130   CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 
    10861131                            const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 
     1132   TRY 
    10871133   { 
    10881134     return createGrid(generateId(domains, axis, scalars, axisDomainOrder), domains, axis, scalars, axisDomainOrder); 
    10891135   } 
     1136   CATCH 
    10901137 
    10911138   CGrid* CGrid::createGrid(StdString id, const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 
    10921139                            const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 
     1140   TRY 
    10931141   { 
    10941142      if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size())) 
     
    11321180      return grid; 
    11331181   } 
     1182   CATCH 
    11341183 
    11351184   CGrid* CGrid::cloneGrid(const StdString& idNewGrid, CGrid* gridSrc) 
     1185   TRY 
    11361186   { 
    11371187     std::vector<CDomain*> domainSrcTmp = gridSrc->getDomains(), domainSrc; 
     
    11731223      return grid; 
    11741224   } 
     1225   CATCH 
    11751226 
    11761227   StdString CGrid::generateId(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 
    11771228                               const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 
     1229   TRY 
    11781230   { 
    11791231      if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size())) 
     
    12161268      return id.str(); 
    12171269   } 
     1270   CATCH 
    12181271 
    12191272   StdString CGrid::generateId(const CGrid* gridSrc, const CGrid* gridDest) 
     1273   TRY 
    12201274   { 
    12211275     StdString idSrc  = gridSrc->getId(); 
     
    12271281     return id.str(); 
    12281282   } 
     1283   CATCH 
    12291284 
    12301285   //---------------------------------------------------------------- 
    12311286 
    12321287   CDomainGroup* CGrid::getVirtualDomainGroup() const 
     1288   TRY 
    12331289   { 
    12341290     return this->vDomainGroup_; 
    12351291   } 
     1292   CATCH 
    12361293 
    12371294   CAxisGroup* CGrid::getVirtualAxisGroup() const 
     1295   TRY 
    12381296   { 
    12391297     return this->vAxisGroup_; 
    12401298   } 
     1299   CATCH 
    12411300 
    12421301   CScalarGroup* CGrid::getVirtualScalarGroup() const 
     1302   TRY 
    12431303   { 
    12441304     return this->vScalarGroup_; 
    12451305   } 
     1306   CATCH 
    12461307 
    12471308/* 
     
    12791340 
    12801341   void CGrid::storeField_arr(const double* const data, CArray<double, 1>& stored) const 
     1342   TRY 
    12811343   { 
    12821344      const StdSize size = storeIndex_client.numElements(); 
     
    12851347      for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 
    12861348   } 
     1349   CATCH 
    12871350 
    12881351   void CGrid::restoreField_arr(const CArray<double, 1>& stored, double* const data) const 
     1352   TRY 
    12891353   { 
    12901354      const StdSize size = storeIndex_client.numElements(); 
     
    12921356      for(StdSize i = 0; i < size; i++) data[storeIndex_client(i)] = stored(i); 
    12931357   } 
     1358   CATCH 
     1359 
     1360   void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) const 
     1361   { 
     1362      const StdSize size = storeIndex_client.numElements(); 
     1363      stored.resize(size); 
     1364      const double nanValue = std::numeric_limits<double>::quiet_NaN(); 
     1365 
     1366      if (storeMask_client.numElements() != 0) 
     1367        for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue; 
     1368      else 
     1369        for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 
     1370   } 
    12941371 
    12951372   void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const 
     1373   TRY 
    12961374   { 
    12971375      const std::vector<int>& localMaskedDataIndex = clientDistribution_->getLocalMaskedDataIndexOnClient(); 
    12981376      const int size = localMaskedDataIndex.size(); 
    1299        
    13001377      for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i]; 
    13011378   } 
    1302  
     1379   CATCH 
    13031380 
    13041381  void CGrid::computeClientIndexScalarGrid() 
     1382  TRY 
    13051383  { 
    13061384    CContext* context = CContext::getCurrent();     
    1307 //    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; // This should be changed soon 
    1308 //    for (int p = 0; p < nbSrvPools; ++p) 
    1309     { 
    1310 //      CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[p] : context->client) 
    1311 //                                                    : context->client; 
     1385    { 
    13121386      CContextClient* client = context->client; 
    13131387 
     
    13401414    } 
    13411415  } 
     1416  CATCH_DUMP_ATTR 
    13421417 
    13431418  void CGrid::computeConnectedClientsScalarGrid() 
     1419  TRY 
    13441420  { 
    13451421    CContext* context = CContext::getCurrent();     
     
    13861462    } 
    13871463  } 
     1464  CATCH_DUMP_ATTR 
    13881465 
    13891466  void CGrid::sendIndexScalarGrid() 
     1467  TRY 
    13901468  { 
    13911469    CContext* context = CContext::getCurrent(); 
     
    14511529    } 
    14521530  } 
     1531  CATCH_DUMP_ATTR 
    14531532 
    14541533  void CGrid::sendIndex(void) 
     1534  TRY 
    14551535  { 
    14561536    CContext* context = CContext::getCurrent(); 
     
    15721652    } 
    15731653  } 
     1654  CATCH_DUMP_ATTR 
    15741655 
    15751656  void CGrid::recvIndex(CEventServer& event) 
     1657  TRY 
    15761658  { 
    15771659    string gridId; 
     
    15891671    get(gridId)->recvIndex(ranks, buffers); 
    15901672  } 
     1673  CATCH 
    15911674 
    15921675  void CGrid::recvIndex(vector<int> ranks, vector<CBufferIn*> buffers) 
     1676  TRY 
    15931677  { 
    15941678    CContext* context = CContext::getCurrent(); 
     
    16311715          std::vector<CDomain*> domainList = getDomains(); 
    16321716          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); 
     1717          std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize), nGlobElement(numElement); 
     1718          std::vector<CArray<int,1> > globalIndex(numElement); 
    16351719          for (int i = 0; i < numElement; ++i) 
    16361720          { 
     
    16381722            if (2 == axis_domain_order(i)) //domain 
    16391723            { 
    1640               nZoomBegin[indexMap[i]] = domainList[domainId]->zoom_ibegin; 
    1641               nZoomSize[indexMap[i]]  = domainList[domainId]->zoom_ni; 
    1642               nZoomBeginGlobal[indexMap[i]] = domainList[domainId]->global_zoom_ibegin;               
     1724              nBegin[indexMap[i]] = domainList[domainId]->ibegin; 
     1725              nSize[indexMap[i]]  = domainList[domainId]->ni; 
     1726              nBeginGlobal[indexMap[i]] = 0; 
    16431727              nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 
    16441728 
    1645               nZoomBegin[indexMap[i] + 1] = domainList[domainId]->zoom_jbegin; 
    1646               nZoomSize[indexMap[i] + 1] = domainList[domainId]->zoom_nj; 
    1647               nZoomBeginGlobal[indexMap[i] + 1] = domainList[domainId]->global_zoom_jbegin;               
     1729              nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin; 
     1730              nSize[indexMap[i] + 1] = domainList[domainId]->nj; 
     1731              nBeginGlobal[indexMap[i] + 1] = 0; 
    16481732              nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 
    16491733 
    16501734              { 
    16511735                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)                 
     1736                globalIndex[i].resize(nSize[indexMap[i]]*nSize[indexMap[i]+1]); 
     1737                for (int jdx = 0; jdx < nSize[indexMap[i]+1]; ++jdx) 
     1738                  for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 
    16551739                  { 
    1656                     globalZoomIndex[i](count) = (nZoomBegin[indexMap[i]] + idx) + (nZoomBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]]; 
     1740                    globalIndex[i](count) = (nBegin[indexMap[i]] + idx) + (nBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]]; 
    16571741                    ++count; 
    16581742                  } 
     
    16631747            else if (1 == axis_domain_order(i)) // axis 
    16641748            { 
    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;               
     1749              nBegin[indexMap[i]] = axisList[axisId]->begin; 
     1750              nSize[indexMap[i]]  = axisList[axisId]->n; 
     1751              nBeginGlobal[indexMap[i]] = 0; 
    16681752              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               } 
     1753              globalIndex[i].resize(nSize[indexMap[i]]); 
     1754              for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 
     1755                globalIndex[i](idx) = nBegin[indexMap[i]] + idx; 
    16791756 
    16801757              ++axisId; 
     
    16821759            else // scalar 
    16831760            {  
    1684               nZoomBegin[indexMap[i]] = 0; 
    1685               nZoomSize[indexMap[i]]  = 1; 
    1686               nZoomBeginGlobal[indexMap[i]] = 0;               
     1761              nBegin[indexMap[i]] = 0; 
     1762              nSize[indexMap[i]]  = 1; 
     1763              nBeginGlobal[indexMap[i]] = 0; 
    16871764              nGlob[indexMap[i]] = 1; 
    1688               globalZoomIndex[i].resize(1); 
    1689               globalZoomIndex[i](0) = 0; 
     1765              globalIndex[i].resize(1); 
     1766              globalIndex[i](0) = 0; 
    16901767              ++scalarId; 
    16911768            } 
     
    16931770          dataSize = 1; 
    16941771 
    1695           for (int i = 0; i < nZoomSize.size(); ++i) 
    1696             dataSize *= nZoomSize[i]; 
     1772          for (int i = 0; i < nSize.size(); ++i) 
     1773            dataSize *= nSize[i]; 
    16971774          serverDistribution_ = new CDistributionServer(server->intraCommRank,  
    1698                                                         globalZoomIndex, axis_domain_order, 
    1699                                                         nZoomBegin, nZoomSize, nZoomBeginGlobal, nGlob); 
     1775                                                        globalIndex, axis_domain_order, 
     1776                                                        nBegin, nSize, nBeginGlobal, nGlob); 
    17001777        } 
    17011778 
     
    17601837          nGlob.push_back(1);   
    17611838        } 
    1762  
    1763         modifyMaskSize(nSize, false); 
    1764  
    1765         // These below codes are reserved for future 
    1766         CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob);  
    1767         map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 
    1768                                                ite = outGlobalIndexFromClient.end(), it;   
    1769         const CDistributionServer::GlobalLocalMap&  globalLocalMask = srvDist.getGlobalLocalIndex(); 
    1770         CDistributionServer::GlobalLocalMap::const_iterator itSrv; 
    1771         size_t nb = 0; 
    1772         for (it = itb; it != ite; ++it) 
    1773         { 
    1774           CArray<size_t,1>& globalInd = it->second; 
    1775           for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
    1776           { 
    1777             if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb; 
    1778           } 
    1779         } 
    1780          
    1781         CArray<int,1> indexToModify(nb); 
    1782         nb = 0;     
    1783         for (it = itb; it != ite; ++it) 
    1784         { 
    1785           CArray<size_t,1>& globalInd = it->second; 
    1786           for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
    1787           { 
    1788             itSrv = globalLocalMask.find(globalInd(idx)); 
    1789             if (globalLocalMask.end() != itSrv)  
    1790             { 
    1791               indexToModify(nb) = itSrv->second; 
    1792               ++nb; 
    1793             } 
    1794           } 
    1795         } 
    1796  
    1797         modifyMask(indexToModify, true); 
    17981839      } 
    17991840 
     
    18031844    } 
    18041845  } 
     1846  CATCH_DUMP_ATTR 
    18051847 
    18061848  /* 
     
    18181860                                        const std::vector<CScalar*> scalars, 
    18191861                                        const CArray<int,1>& axisDomainOrder) 
    1820   { 
     1862  TRY 
     1863 { 
    18211864 //   globalDim.resize(domains.size()*2+axis.size()+scalars.size()); 
    18221865    globalDim.resize(domains.size()*2+axis.size()); 
     
    18581901    return positionDimensionDistributed; 
    18591902  } 
     1903  CATCH_DUMP_ATTR 
    18601904 
    18611905  // Retrieve the global dimension of grid 
    18621906  std::vector<int> CGrid::getGlobalDimension() 
     1907  TRY 
    18631908  { 
    18641909    std::vector<int> globalDim; 
     
    18671912    return globalDim; 
    18681913  } 
     1914  CATCH_DUMP_ATTR 
    18691915 
    18701916  // Retrieve dimension on which we do distribution (Very often, it should be 2nd dimension) 
    18711917  int CGrid::getDistributedDimension() 
     1918  TRY 
    18721919  { 
    18731920    std::vector<int> globalDim; 
    18741921    return computeGridGlobalDimension(globalDim, getDomains(), getAxis(), getScalars(), axis_domain_order);     
    18751922  } 
     1923  CATCH_DUMP_ATTR 
    18761924 
    18771925  bool CGrid::isScalarGrid() const 
     1926  TRY 
    18781927  { 
    18791928    return (axisList_.empty() && domList_.empty()); 
    18801929  } 
     1930  CATCH 
    18811931 
    18821932  /*! 
     
    18861936  */ 
    18871937  bool CGrid::doGridHaveDataToWrite() 
     1938  TRY 
    18881939  { 
    18891940     return (0 != writtenDataSize_); 
    18901941  } 
     1942  CATCH_DUMP_ATTR 
    18911943 
    18921944  /*! 
     
    18971949  */ 
    18981950  size_t CGrid::getWrittenDataSize() const 
     1951  TRY 
    18991952  { 
    19001953    return writtenDataSize_; 
    19011954  } 
     1955  CATCH 
    19021956 
    19031957  /*! 
     
    19061960  */ 
    19071961  int CGrid::getNumberWrittenIndexes() const 
     1962  TRY 
    19081963  { 
    19091964    return numberWrittenIndexes_; 
    19101965  } 
     1966  CATCH 
    19111967 
    19121968  /*! 
     
    19151971  */ 
    19161972  int CGrid::getTotalNumberWrittenIndexes() const 
     1973  TRY 
    19171974  { 
    19181975    return totalNumberWrittenIndexes_; 
    19191976  } 
     1977  CATCH 
    19201978 
    19211979  /*! 
     
    19241982  */ 
    19251983  int CGrid::getOffsetWrittenIndexes() const 
     1984  TRY 
    19261985  { 
    19271986    return offsetWrittenIndexes_; 
    19281987  } 
     1988  CATCH 
    19291989 
    19301990  CDistributionServer* CGrid::getDistributionServer() 
     1991  TRY 
    19311992  { 
    19321993    return serverDistribution_; 
    19331994  } 
     1995  CATCH_DUMP_ATTR 
    19341996 
    19351997  CDistributionClient* CGrid::getDistributionClient() 
     1998  TRY 
    19361999  { 
    19372000    return clientDistribution_; 
    19382001  } 
     2002  CATCH_DUMP_ATTR 
    19392003 
    19402004  bool CGrid::doGridHaveDataDistributed(CContextClient* client) 
     2005  TRY 
    19412006  { 
    19422007    if (isScalarGrid()) return false; 
     
    19482013      return isDataDistributed_;     
    19492014  } 
     2015  CATCH_DUMP_ATTR 
    19502016 
    19512017   /*! 
     
    19572023   */ 
    19582024  bool CGrid::dispatchEvent(CEventServer& event) 
     2025  TRY 
    19592026  { 
    19602027 
     
    19902057    } 
    19912058  } 
     2059  CATCH 
    19922060 
    19932061   ///--------------------------------------------------------------- 
    19942062 
    19952063   CDomain* CGrid::addDomain(const std::string& id) 
     2064   TRY 
    19962065   { 
    19972066     order_.push_back(2); 
     
    20002069     return vDomainGroup_->createChild(id); 
    20012070   } 
     2071   CATCH_DUMP_ATTR 
    20022072 
    20032073   CAxis* CGrid::addAxis(const std::string& id) 
     2074   TRY 
    20042075   { 
    20052076     order_.push_back(1); 
     
    20082079     return vAxisGroup_->createChild(id); 
    20092080   } 
     2081   CATCH_DUMP_ATTR 
    20102082 
    20112083   CScalar* CGrid::addScalar(const std::string& id) 
     2084   TRY 
    20122085   { 
    20132086     order_.push_back(0); 
     
    20162089     return vScalarGroup_->createChild(id); 
    20172090   } 
     2091   CATCH_DUMP_ATTR 
    20182092 
    20192093   //! Change virtual field group to a new one 
    20202094   void CGrid::setVirtualDomainGroup(CDomainGroup* newVDomainGroup) 
     2095   TRY 
    20212096   { 
    20222097      this->vDomainGroup_ = newVDomainGroup; 
    20232098   } 
     2099   CATCH_DUMP_ATTR 
    20242100 
    20252101   //! Change virtual variable group to new one 
    20262102   void CGrid::setVirtualAxisGroup(CAxisGroup* newVAxisGroup) 
     2103   TRY 
    20272104   { 
    20282105      this->vAxisGroup_ = newVAxisGroup; 
    20292106   } 
     2107   CATCH_DUMP_ATTR 
    20302108 
    20312109   //! Change virtual variable group to new one 
    20322110   void CGrid::setVirtualScalarGroup(CScalarGroup* newVScalarGroup) 
     2111   TRY 
    20332112   { 
    20342113      this->vScalarGroup_ = newVScalarGroup; 
    20352114   } 
     2115   CATCH_DUMP_ATTR 
    20362116 
    20372117   /*! 
     
    20402120   */ 
    20412121   void CGrid::sendAddDomain(const string& id) 
    2042    { 
     2122   TRY 
     2123  { 
    20432124      sendAddItem(id, (int)EVENT_ID_ADD_DOMAIN); 
    20442125   } 
     2126   CATCH_DUMP_ATTR 
    20452127 
    20462128   /*! 
     
    20492131   */ 
    20502132   void CGrid::sendAddAxis(const string& id) 
     2133   TRY 
    20512134   { 
    20522135      sendAddItem(id, (int)EVENT_ID_ADD_AXIS); 
    20532136   } 
     2137   CATCH_DUMP_ATTR 
    20542138 
    20552139   /*! 
     
    20582142   */ 
    20592143   void CGrid::sendAddScalar(const string& id) 
     2144   TRY 
    20602145   { 
    20612146      sendAddItem(id, (int)EVENT_ID_ADD_SCALAR); 
    20622147   } 
     2148   CATCH_DUMP_ATTR 
    20632149 
    20642150   /*! 
     
    20672153   */ 
    20682154   void CGrid::recvAddDomain(CEventServer& event) 
     2155   TRY 
    20692156   { 
    20702157 
     
    20742161      get(id)->recvAddDomain(*buffer); 
    20752162   } 
     2163   CATCH 
    20762164 
    20772165   /*! 
     
    20802168   */ 
    20812169   void CGrid::recvAddDomain(CBufferIn& buffer) 
     2170   TRY 
    20822171   { 
    20832172      string id; 
     
    20852174      addDomain(id); 
    20862175   } 
     2176   CATCH_DUMP_ATTR 
    20872177 
    20882178   /*! 
     
    20912181   */ 
    20922182   void CGrid::recvAddAxis(CEventServer& event) 
     2183   TRY 
    20932184   { 
    20942185 
     
    20982189      get(id)->recvAddAxis(*buffer); 
    20992190   } 
     2191   CATCH 
    21002192 
    21012193   /*! 
     
    21042196   */ 
    21052197   void CGrid::recvAddAxis(CBufferIn& buffer) 
     2198   TRY 
    21062199   { 
    21072200      string id; 
     
    21092202      addAxis(id); 
    21102203   } 
     2204   CATCH_DUMP_ATTR 
    21112205 
    21122206   /*! 
     
    21152209   */ 
    21162210   void CGrid::recvAddScalar(CEventServer& event) 
     2211   TRY 
    21172212   { 
    21182213 
     
    21222217      get(id)->recvAddScalar(*buffer); 
    21232218   } 
     2219   CATCH 
    21242220 
    21252221   /*! 
     
    21282224   */ 
    21292225   void CGrid::recvAddScalar(CBufferIn& buffer) 
     2226   TRY 
    21302227   { 
    21312228      string id; 
     
    21332230      addScalar(id); 
    21342231   } 
     2232   CATCH_DUMP_ATTR 
    21352233 
    21362234  /*! 
     
    21412239  */ 
    21422240  void CGrid::solveDomainAxisRefInheritance(bool apply) 
     2241  TRY 
    21432242  { 
    21442243    CContext* context = CContext::getCurrent(); 
     
    21812280    } 
    21822281  } 
     2282  CATCH_DUMP_ATTR 
    21832283 
    21842284  bool CGrid::isTransformed() 
     2285  TRY 
    21852286  { 
    21862287    return isTransformed_; 
    21872288  } 
     2289  CATCH_DUMP_ATTR 
    21882290 
    21892291  void CGrid::setTransformed() 
     2292  TRY 
    21902293  { 
    21912294    isTransformed_ = true; 
    21922295  } 
     2296  CATCH_DUMP_ATTR 
    21932297 
    21942298  CGridTransformation* CGrid::getTransformations() 
     2299  TRY 
    21952300  { 
    21962301    return transformations_; 
    21972302  } 
     2303  CATCH_DUMP_ATTR 
    21982304 
    21992305  void CGrid::addTransGridSource(CGrid* gridSrc) 
     2306  TRY 
    22002307  { 
    22012308    if (gridSrc_.end() == gridSrc_.find(gridSrc)) 
    22022309      gridSrc_.insert(make_pair(gridSrc,make_pair(false,""))); 
    22032310  } 
     2311  CATCH_DUMP_ATTR 
    22042312 
    22052313  std::map<CGrid*,std::pair<bool,StdString> >& CGrid::getTransGridSource() 
     2314  TRY 
    22062315  { 
    22072316    return gridSrc_; 
    22082317  } 
     2318  CATCH_DUMP_ATTR 
    22092319 
    22102320  /*! 
     
    22132323  */ 
    22142324  void CGrid::completeGrid(CGrid* transformGridSrc) 
     2325  TRY 
    22152326  { 
    22162327    if (0 != transformGridSrc) 
     
    22312342    gridGenerate.completeGrid(); 
    22322343  } 
     2344  CATCH_DUMP_ATTR 
    22332345 
    22342346  bool CGrid::isGenerated() 
     2347  TRY 
    22352348  { 
    22362349    return isGenerated_; 
    22372350  } 
     2351  CATCH 
    22382352 
    22392353  void CGrid::setGenerated() 
     2354  TRY 
    22402355  { 
    22412356    isGenerated_ = true; 
    22422357  } 
     2358  CATCH_DUMP_ATTR 
    22432359 
    22442360  void CGrid::transformGrid(CGrid* transformGridSrc) 
     2361  TRY 
    22452362  { 
    22462363    if (!transformGridSrc) 
     
    22682385    transformGridSrc->checkMaskIndex(false); 
    22692386  } 
     2387  CATCH_DUMP_ATTR 
    22702388 
    22712389  bool CGrid::hasTransform() 
     2390  TRY 
    22722391  { 
    22732392    if (hasTransform_) return hasTransform_; 
     
    22832402    return hasTransform_; 
    22842403  } 
     2404  CATCH_DUMP_ATTR 
    22852405 
    22862406  /*! 
     
    22892409  */ 
    22902410  std::vector<CDomain*> CGrid::getDomains() 
     2411  TRY 
    22912412  { 
    22922413    std::vector<CDomain*> domList; 
     
    22972418    return domList; 
    22982419  } 
     2420  CATCH_DUMP_ATTR 
    22992421 
    23002422  /*! 
     
    23032425  */ 
    23042426  std::vector<CAxis*> CGrid::getAxis() 
     2427  TRY 
    23052428  { 
    23062429    std::vector<CAxis*> aList; 
     
    23102433    return aList; 
    23112434  } 
     2435  CATCH_DUMP_ATTR 
    23122436 
    23132437  /*! 
     
    23162440  */ 
    23172441  std::vector<CScalar*> CGrid::getScalars() 
     2442  TRY 
    23182443  { 
    23192444    std::vector<CScalar*> sList; 
     
    23232448    return sList; 
    23242449  } 
     2450  CATCH_DUMP_ATTR 
    23252451 
    23262452  /*! 
     
    23292455  */ 
    23302456  CDomain* CGrid::getDomain(int domainIndex) 
     2457  TRY 
    23312458  { 
    23322459    std::vector<CDomain*> domainListP = this->getDomains(); 
     
    23462473    return domainListP[domainIndex]; 
    23472474  } 
     2475  CATCH_DUMP_ATTR 
    23482476 
    23492477  /*! 
     
    23522480  */ 
    23532481  CAxis* CGrid::getAxis(int axisIndex) 
     2482  TRY 
    23542483  { 
    23552484    std::vector<CAxis*> axisListP = this->getAxis(); 
     
    23692498    return axisListP[axisIndex]; 
    23702499  } 
     2500  CATCH_DUMP_ATTR 
    23712501 
    23722502  /*! 
     
    23752505  */ 
    23762506  CScalar* CGrid::getScalar(int scalarIndex) 
     2507  TRY 
    23772508  { 
    23782509    std::vector<CScalar*> scalarListP = this->getScalars(); 
     
    23922523    return scalarListP[scalarIndex]; 
    23932524  } 
     2525  CATCH_DUMP_ATTR 
    23942526 
    23952527  /*! 
     
    23982530  */ 
    23992531  void CGrid::setDomainList(const std::vector<CDomain*> domains) 
     2532  TRY 
    24002533  { 
    24012534    if (isDomListSet) return; 
     
    24182551      isDomListSet = true; 
    24192552    } 
    2420  
    2421   } 
     2553  } 
     2554  CATCH_DUMP_ATTR 
    24222555 
    24232556  /*! 
     
    24262559  */ 
    24272560  void CGrid::setAxisList(const std::vector<CAxis*> axis) 
     2561  TRY 
    24282562  { 
    24292563    if (isAxisListSet) return; 
     
    24472581    } 
    24482582  } 
     2583  CATCH_DUMP_ATTR 
    24492584 
    24502585  /*! 
     
    24532588  */ 
    24542589  void CGrid::setScalarList(const std::vector<CScalar*> scalars) 
     2590  TRY 
    24552591  { 
    24562592    if (isScalarListSet) return; 
     
    24742610    } 
    24752611  } 
     2612  CATCH_DUMP_ATTR 
    24762613 
    24772614  /*! 
     
    24802617  */ 
    24812618  std::vector<StdString> CGrid::getDomainList() 
     2619  TRY 
    24822620  { 
    24832621    setDomainList(); 
    24842622    return domList_; 
    24852623  } 
     2624  CATCH 
    24862625 
    24872626  /*! 
     
    24902629  */ 
    24912630  std::vector<StdString> CGrid::getAxisList() 
     2631  TRY 
    24922632  { 
    24932633    setAxisList(); 
    24942634    return axisList_; 
    24952635  } 
     2636  CATCH 
    24962637 
    24972638  /*! 
     
    25002641  */ 
    25012642  std::vector<StdString> CGrid::getScalarList() 
     2643  TRY 
    25022644  { 
    25032645    setScalarList(); 
    25042646    return scalarList_; 
    25052647  } 
     2648  CATCH 
    25062649 
    25072650  /*! 
     
    25092652  */ 
    25102653  void CGrid::sendAllDomains() 
     2654  TRY 
    25112655  { 
    25122656    std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren(); 
     
    25182662    } 
    25192663  } 
     2664  CATCH_DUMP_ATTR 
    25202665 
    25212666  /*! 
     
    25232668  */ 
    25242669  void CGrid::sendAllAxis() 
     2670  TRY 
    25252671  { 
    25262672    std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren(); 
     
    25332679    } 
    25342680  } 
     2681  CATCH_DUMP_ATTR 
    25352682 
    25362683  /*! 
     
    25382685  */ 
    25392686  void CGrid::sendAllScalars() 
     2687  TRY 
    25402688  { 
    25412689    std::vector<CScalar*> sList = this->getVirtualScalarGroup()->getAllChildren(); 
     
    25482696    } 
    25492697  } 
     2698  CATCH_DUMP_ATTR 
    25502699 
    25512700  void CGrid::setContextClient(CContextClient* contextClient) 
     2701  TRY 
    25522702  { 
    25532703    if (clientsSet.find(contextClient)==clientsSet.end()) 
     
    25612711        this->getAxis()[i]->setContextClient(contextClient); 
    25622712  } 
     2713  CATCH_DUMP_ATTR 
    25632714 
    25642715  /*! 
     
    25662717  */ 
    25672718  void CGrid::parse(xml::CXMLNode& node) 
     2719  TRY 
    25682720  { 
    25692721    SuperClass::parse(node); 
     
    26062758    setScalarList(); 
    26072759   } 
     2760  CATCH_DUMP_ATTR 
     2761 
    26082762} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.