Ignore:
Timestamp:
01/31/19 12:12:52 (5 years ago)
Author:
yushan
Message:

branch merged with trunk @1645. arch file (ep&mpi) added for ADA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_trunk_omp/src/node/domain.cpp

    r1601 r1646  
    1919#include "client_server_mapping_distributed.hpp" 
    2020 
     21#ifdef _usingEP 
    2122using namespace ep_lib; 
     23#endif 
    2224 
    2325#include <algorithm> 
     
    6062 
    6163   void CDomain::assignMesh(const StdString meshName, const int nvertex) 
     64   TRY 
    6265   { 
    6366     mesh = CMesh::getMesh(meshName, nvertex); 
    6467   } 
     68   CATCH_DUMP_ATTR 
    6569 
    6670   CDomain* CDomain::createDomain() 
     71   TRY 
    6772   { 
    6873     CDomain* domain = CDomainGroup::get("domain_definition")->createChild(); 
    6974     return domain; 
    7075   } 
     76   CATCH 
    7177 
    7278   std::map<StdString, ETranformationType> *CDomain::transformationMapList_ptr = 0; 
    7379 
    7480   bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
     81   TRY 
    7582   { 
    7683     m["zoom_domain"] = TRANS_ZOOM_DOMAIN; 
     
    8289     m["extract_domain"] = TRANS_EXTRACT_DOMAIN; 
    8390   } 
     91   CATCH 
    8492 
    8593   bool CDomain::initializeTransformationMap() 
     94   TRY 
    8695   { 
    8796     CDomain::transformationMapList_ptr = new std::map<StdString, ETranformationType>(); 
     
    94103     (*CDomain::transformationMapList_ptr)["extract_domain"] = TRANS_EXTRACT_DOMAIN; 
    95104   } 
     105   CATCH 
    96106 
    97107   const std::set<StdString> & CDomain::getRelFiles(void) const 
     108   TRY 
    98109   { 
    99110      return (this->relFiles); 
    100111   } 
    101  
     112   CATCH 
    102113 
    103114   /*! 
     
    106117   */ 
    107118   int CDomain::getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     119   TRY 
    108120   { 
    109121     int writtenSize; 
     
    111123     return numberWrittenIndexes_[writtenSize]; 
    112124   } 
     125   CATCH_DUMP_ATTR 
    113126 
    114127   /*! 
     
    117130   */ 
    118131   int CDomain::getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     132   TRY 
    119133   { 
    120134     int writtenSize; 
     
    122136     return totalNumberWrittenIndexes_[writtenSize]; 
    123137   } 
     138   CATCH_DUMP_ATTR 
    124139 
    125140   /*! 
     
    128143   */ 
    129144   int CDomain::getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     145   TRY 
    130146   { 
    131147     int writtenSize; 
     
    133149     return offsetWrittenIndexes_[writtenSize]; 
    134150   } 
     151   CATCH_DUMP_ATTR 
    135152 
    136153   CArray<int, 1>& CDomain::getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom) 
     154   TRY 
    137155   { 
    138156     int writtenSize; 
     
    140158     return compressedIndexToWriteOnServer[writtenSize]; 
    141159   } 
     160   CATCH_DUMP_ATTR 
    142161 
    143162   //---------------------------------------------------------------- 
     
    149168    */ 
    150169   std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/) 
     170   TRY 
    151171   { 
    152172 
     
    176196       // size estimation for sendIndex (and sendArea which is always smaller or equal) 
    177197       size_t sizeIndexEvent = 2 * sizeof(size_t) + 2 * CArray<int,1>::size(idxCount); 
    178        // if (isCompressible_) 
    179        // { 
    180        //   std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank); 
    181        //   size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0; 
    182        //   sizeIndexEvent += CArray<int,1>::size(writtenIdxCount); 
    183        // } 
    184198 
    185199       // size estimation for sendLonLat 
     
    195209     return attributesSizes; 
    196210   } 
     211   CATCH_DUMP_ATTR 
    197212 
    198213   //---------------------------------------------------------------- 
    199214 
    200215   bool CDomain::isEmpty(void) const 
     216   TRY 
    201217   { 
    202218     return ((this->i_index.isEmpty()) || (0 == this->i_index.numElements())); 
    203219   } 
     220   CATCH 
    204221 
    205222   //---------------------------------------------------------------- 
    206223 
    207224   bool CDomain::IsWritten(const StdString & filename) const 
     225   TRY 
    208226   { 
    209227      return (this->relFiles.find(filename) != this->relFiles.end()); 
    210228   } 
     229   CATCH 
    211230 
    212231   bool CDomain::isWrittenCompressed(const StdString& filename) const 
     232   TRY 
    213233   { 
    214234      return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 
    215235   } 
     236   CATCH 
    216237 
    217238   //---------------------------------------------------------------- 
    218239 
    219240   bool CDomain::isDistributed(void) const 
     241   TRY 
    220242   { 
    221243      bool distributed =  !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || 
     
    225247      return distributed; 
    226248   } 
     249   CATCH 
    227250 
    228251   //---------------------------------------------------------------- 
     
    234257    */ 
    235258   bool CDomain::isCompressible(void) const 
     259   TRY 
    236260   { 
    237261      return isCompressible_; 
    238262   } 
     263   CATCH 
    239264 
    240265   void CDomain::addRelFile(const StdString & filename) 
     266   TRY 
    241267   { 
    242268      this->relFiles.insert(filename); 
    243269   } 
     270   CATCH_DUMP_ATTR 
    244271 
    245272   void CDomain::addRelFileCompressed(const StdString& filename) 
     273   TRY 
    246274   { 
    247275      this->relFilesCompressed.insert(filename); 
    248276   } 
     277   CATCH_DUMP_ATTR 
    249278 
    250279   StdString CDomain::GetName(void)   { return (StdString("domain")); } 
     
    259288   */ 
    260289   bool CDomain::distributionAttributesHaveValue() const 
     290   TRY 
    261291   { 
    262292      bool hasValues = true; 
     
    270300      return hasValues; 
    271301   } 
     302   CATCH 
    272303 
    273304   /*! 
     
    279310   */ 
    280311   void CDomain::redistribute(int nbLocalDomain) 
     312   TRY 
    281313   { 
    282314     if (this->isRedistributed_) return; 
     
    441473     checkDomain(); 
    442474   } 
     475   CATCH_DUMP_ATTR 
    443476 
    444477   /*! 
     
    446479   */ 
    447480   void CDomain::fillInLonLat() 
     481   TRY 
    448482   { 
    449483     switch (type) 
     
    463497     } 
    464498     completeLonLatClient() ; 
    465  
    466    } 
     499   } 
     500   CATCH_DUMP_ATTR 
    467501 
    468502   /*! 
     
    472506   */ 
    473507   void CDomain::fillInRectilinearLonLat() 
     508   TRY 
    474509   { 
    475510     if (!lonvalue_rectilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) 
     
    540575     } 
    541576   } 
     577   CATCH_DUMP_ATTR 
    542578 
    543579    /* 
     
    546582    */ 
    547583   void CDomain::fillInCurvilinearLonLat() 
     584   TRY 
    548585   { 
    549586     if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) 
     
    588625       bounds_latvalue_curvilinear_read_from_file.free(); 
    589626     } 
    590  
    591    } 
     627   } 
     628   CATCH_DUMP_ATTR 
    592629 
    593630    /* 
     
    596633    */ 
    597634   void CDomain::fillInUnstructuredLonLat() 
     635   TRY 
    598636   { 
    599637     if (i_index.isEmpty()) 
     
    647685     } 
    648686   } 
     687   CATCH_DUMP_ATTR 
    649688 
    650689  /* 
     
    652691  */ 
    653692   void CDomain::AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, CArray<double,1>& lon_g, CArray<double,1>& lat_g) 
     693   TRY 
    654694   { 
    655695     CContext* context = CContext::getCurrent(); 
     
    683723      delete[] nj_g ; 
    684724   } 
     725   CATCH_DUMP_ATTR 
    685726 
    686727   void CDomain::fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
    687728                                              CArray<double,2>& boundsLon, CArray<double,2>& boundsLat) 
    688    { 
     729   TRY 
     730  { 
    689731     int i,j,k; 
    690732 
     
    785827      } 
    786828   } 
     829   CATCH_DUMP_ATTR 
    787830 
    788831   /* 
     
    790833   */ 
    791834   void CDomain::checkDomain(void) 
     835   TRY 
    792836   { 
    793837     if (type.isEmpty()) 
     
    881925     } 
    882926   } 
     927   CATCH_DUMP_ATTR 
    883928 
    884929   size_t CDomain::getGlobalWrittenSize(void) 
     
    890935   // Check validity of local domain on using the combination of 3 parameters: ibegin, ni and i_index 
    891936   void CDomain::checkLocalIDomain(void) 
     937   TRY 
    892938   { 
    893939      // If ibegin and ni are provided then we use them to check the validity of local domain 
     
    948994      } 
    949995   } 
     996   CATCH_DUMP_ATTR 
    950997 
    951998   // Check validity of local domain on using the combination of 3 parameters: jbegin, nj and j_index 
    952999   void CDomain::checkLocalJDomain(void) 
     1000   TRY 
    9531001   { 
    9541002    // If jbegin and nj are provided then we use them to check the validity of local domain 
     
    9991047     } 
    10001048   } 
     1049   CATCH_DUMP_ATTR 
    10011050 
    10021051   //---------------------------------------------------------------- 
    10031052 
    10041053   void CDomain::checkMask(void) 
     1054   TRY 
    10051055   { 
    10061056      if (!mask_1d.isEmpty() && !mask_2d.isEmpty()) 
     
    10481098     } 
    10491099   } 
     1100   CATCH_DUMP_ATTR 
    10501101 
    10511102   //---------------------------------------------------------------- 
    10521103 
    10531104   void CDomain::checkDomainData(void) 
     1105   TRY 
    10541106   { 
    10551107      if (data_dim.isEmpty()) 
     
    10911143      } 
    10921144   } 
     1145   CATCH_DUMP_ATTR 
    10931146 
    10941147   //---------------------------------------------------------------- 
    10951148 
    10961149   void CDomain::checkCompression(void) 
    1097    { 
     1150   TRY 
     1151   { 
     1152     int i,j,ind; 
    10981153      if (!data_i_index.isEmpty()) 
    10991154      { 
     
    11161171                   << "'data_j_index' must be defined when 'data_i_index' is set and 'data_dim' is 2."); 
    11171172          } 
     1173          for (int k=0; k<data_i_index.numElements(); ++k) 
     1174          { 
     1175            i = data_i_index(k)+data_ibegin ; 
     1176            j = data_j_index(k)+data_jbegin ; 
     1177            if (i>=0 && i<ni && j>=0 && j<nj) 
     1178            { 
     1179              ind=j*ni+i ; 
     1180              if (!domainMask(ind)) 
     1181              { 
     1182                data_i_index(k) = -1; 
     1183                data_j_index(k) = -1; 
     1184              } 
     1185            } 
     1186            else 
     1187            { 
     1188              data_i_index(k) = -1; 
     1189              data_j_index(k) = -1; 
     1190            } 
     1191          } 
    11181192        } 
    11191193        else // (1 == data_dim) 
     
    11221196          { 
    11231197            data_j_index.resize(data_ni); 
    1124             for (int j = 0; j < data_ni; ++j) data_j_index(j) = 0; 
     1198            data_j_index = 0; 
     1199          } 
     1200          for (int k=0; k<data_i_index.numElements(); ++k) 
     1201          { 
     1202            i=data_i_index(k)+data_ibegin ; 
     1203            if (i>=0 && i < domainMask.size()) 
     1204            { 
     1205              if (!domainMask(i)) data_i_index(k) = -1; 
     1206            } 
     1207            else 
     1208              data_i_index(k) = -1; 
     1209 
     1210            if (!domainMask(i)) data_i_index(k) = -1; 
    11251211          } 
    11261212        } 
     
    11371223          data_i_index.resize(data_ni); 
    11381224          data_j_index.resize(data_ni); 
    1139  
    1140           for (int i = 0; i < data_ni; ++i) 
     1225          data_j_index = 0; 
     1226 
     1227          for (int k = 0; k < data_ni; ++k) 
    11411228          { 
    1142             data_i_index(i) = i; 
    1143             data_j_index(i) = 0; 
     1229            i=k+data_ibegin ; 
     1230            if (i>=0 && i < domainMask.size()) 
     1231            { 
     1232              if (domainMask(i)) 
     1233                data_i_index(k) = k; 
     1234              else 
     1235                data_i_index(k) = -1; 
     1236            } 
     1237            else 
     1238              data_i_index(k) = -1; 
    11441239          } 
    11451240        } 
     
    11501245          data_j_index.resize(dsize); 
    11511246 
    1152           for(int count = 0, j = 0; j < data_nj; ++j) 
     1247          for(int count = 0, kj = 0; kj < data_nj; ++kj) 
    11531248          { 
    1154             for(int i = 0; i < data_ni; ++i, ++count) 
     1249            for(int ki = 0; ki < data_ni; ++ki, ++count) 
    11551250            { 
    1156               data_i_index(count) = i; 
    1157               data_j_index(count) = j; 
     1251              i = ki + data_ibegin; 
     1252              j = kj + data_jbegin; 
     1253              ind=j*ni+i ; 
     1254              if (i>=0 && i<ni && j>=0 && j<nj) 
     1255              { 
     1256                if (domainMask(ind)) 
     1257                { 
     1258                  data_i_index(count) = ki; 
     1259                  data_j_index(count) = kj; 
     1260                } 
     1261                else 
     1262                { 
     1263                  data_i_index(count) = -1; 
     1264                  data_j_index(count) = -1; 
     1265                } 
     1266              } 
     1267              else 
     1268              { 
     1269                data_i_index(count) = -1; 
     1270                data_j_index(count) = -1; 
     1271              } 
    11581272            } 
    11591273          } 
     
    11611275      } 
    11621276   } 
     1277   CATCH_DUMP_ATTR 
    11631278 
    11641279   //---------------------------------------------------------------- 
    11651280   void CDomain::computeLocalMask(void) 
     1281   TRY 
    11661282   { 
    11671283     localMask.resize(i_index.numElements()) ; 
     
    11951311     } 
    11961312   } 
     1313   CATCH_DUMP_ATTR 
    11971314 
    11981315   void CDomain::checkEligibilityForCompressedOutput(void) 
     1316   TRY 
    11991317   { 
    12001318     // We don't check if the mask or the indexes are valid here, just if they have been defined at this point. 
    12011319     isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !data_i_index.isEmpty(); 
    12021320   } 
     1321   CATCH_DUMP_ATTR 
    12031322 
    12041323   //---------------------------------------------------------------- 
     
    12091328   */ 
    12101329   void CDomain::completeLonLatClient(void) 
     1330   TRY 
    12111331   { 
    12121332     bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 
     
    13221442     } 
    13231443   } 
     1444   CATCH_DUMP_ATTR 
    13241445 
    13251446   /* 
     
    13271448   */ 
    13281449   void CDomain::convertLonLatValue(void) 
     1450   TRY 
    13291451   { 
    13301452     bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 
     
    14241546     } 
    14251547   } 
    1426  
     1548   CATCH_DUMP_ATTR 
    14271549 
    14281550   void CDomain::checkBounds(void) 
     1551   TRY 
    14291552   { 
    14301553     bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); 
     
    15181641     } 
    15191642   } 
     1643   CATCH_DUMP_ATTR 
    15201644 
    15211645   void CDomain::checkArea(void) 
     1646   TRY 
    15221647   { 
    15231648     bool hasAreaValue = (!areavalue.isEmpty() && 0 != areavalue.numElements()); 
     
    15471672     } 
    15481673   } 
     1674   CATCH_DUMP_ATTR 
    15491675 
    15501676   void CDomain::checkLonLat() 
     1677   TRY 
    15511678   { 
    15521679     if (!hasLonLat) hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || 
     
    16081735     } 
    16091736   } 
     1737   CATCH_DUMP_ATTR 
    16101738 
    16111739   void CDomain::checkAttributesOnClientAfterTransformation() 
     1740   TRY 
    16121741   { 
    16131742     CContext* context=CContext::getCurrent() ; 
     
    16241753     this->isClientAfterTransformationChecked = true; 
    16251754   } 
     1755   CATCH_DUMP_ATTR 
    16261756 
    16271757   //---------------------------------------------------------------- 
     
    16291759   // This function only checks all attributes of current domain 
    16301760   void CDomain::checkAttributesOnClient() 
     1761   TRY 
    16311762   { 
    16321763     if (this->isClientChecked) return; 
     
    16541785      this->isClientChecked = true; 
    16551786   } 
     1787   CATCH_DUMP_ATTR 
    16561788 
    16571789   // Send all checked attributes to server 
    16581790   void CDomain::sendCheckedAttributes() 
     1791   TRY 
    16591792   { 
    16601793     if (!this->isClientChecked) checkAttributesOnClient(); 
     
    16691802     this->isChecked = true; 
    16701803   } 
     1804   CATCH_DUMP_ATTR 
    16711805 
    16721806   void CDomain::checkAttributes(void) 
     1807   TRY 
    16731808   { 
    16741809      if (this->isChecked) return; 
     
    17001835      this->isChecked = true; 
    17011836   } 
     1837   CATCH_DUMP_ATTR 
    17021838 
    17031839  /*! 
     
    17081844  */ 
    17091845  void CDomain::computeConnectedClients() 
     1846  TRY 
    17101847  { 
    17111848    CContext* context=CContext::getCurrent() ; 
     
    18061943            connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
    18071944 
     1945          // Now check if all servers have data to receive. If not, master client will send empty data. 
     1946          // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive. 
     1947          std::vector<int> counts (clientSize); 
     1948          std::vector<int> displs (clientSize); 
     1949          displs[0] = 0; 
     1950          int localCount = connectedServerRank_[nbServer].size() ; 
     1951          ep_lib::MPI_Gather(&localCount, 1, MPI_INT, &counts[0], 1, MPI_INT, 0, client->intraComm) ; 
     1952          for (int i = 0; i < clientSize-1; ++i) 
     1953          { 
     1954            displs[i+1] = displs[i] + counts[i]; 
     1955          } 
     1956          std::vector<int> allConnectedServers(displs[clientSize-1]+counts[clientSize-1]); 
     1957 
     1958          ep_lib::MPI_Gatherv(&(connectedServerRank_[nbServer])[0], localCount, MPI_INT, &allConnectedServers[0], &counts[0], &displs[0], MPI_INT, 0, client->intraComm); 
     1959 
     1960 
     1961          if ((allConnectedServers.size() != nbServer) && (rank == 0)) 
     1962          { 
     1963            std::vector<bool> isSrvConnected (nbServer, false); 
     1964            for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true; 
     1965            for (int i = 0; i < nbServer; ++i) 
     1966            { 
     1967              if (!isSrvConnected[i]) connectedServerRank_[nbServer].push_back(i); 
     1968            } 
     1969          } 
    18081970          nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
    18091971          delete clientServerMap; 
     
    18121974    } 
    18131975  } 
     1976  CATCH_DUMP_ATTR 
    18141977 
    18151978   /*! 
     
    18191982   */ 
    18201983   void CDomain::computeWrittenIndex() 
     1984   TRY 
    18211985   {   
    18221986      if (computedWrittenIndex_) return; 
     
    18402004                                       itSrve = writtenGlobalIndex.end(), itSrv; 
    18412005 
    1842 //      for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    1843 //      { 
    1844 //        indGlo = *itSrv; 
    1845 //        if (ite != globalLocalIndexMap_.find(indGlo)) 
    1846 //        { 
    1847 //          ++nbWritten; 
    1848 //        } 
    1849 //      } 
    1850  
    1851 //      localIndexToWriteOnServer.resize(nbWritten); 
    18522006      localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
    1853  
    18542007      nbWritten = 0; 
    18552008      for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     
    18592012        { 
    18602013          localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    1861           ++nbWritten; 
    18622014        } 
    18632015        else 
    18642016        { 
    1865           localIndexToWriteOnServer(nbWritten) = 0; 
    1866           ++nbWritten; 
    1867         } 
    1868       } 
    1869        
    1870       // if (isCompressible()) 
    1871       // { 
    1872       //   nbWritten = 0; 
    1873       //   std::unordered_map<size_t,size_t> localGlobalIndexMap; 
    1874       //   for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    1875       //   { 
    1876       //     indGlo = *itSrv; 
    1877       //     if (ite != globalLocalIndexMap_.find(indGlo)) 
    1878       //     { 
    1879       //       localGlobalIndexMap[localIndexToWriteOnServer(nbWritten)] = indGlo; 
    1880       //       ++nbWritten; 
    1881       //     }                  
    1882       //   } 
    1883  
    1884       //   nbWritten = 0; 
    1885       //   for (int idx = 0; idx < data_i_index.numElements(); ++idx) 
    1886       //   { 
    1887       //     if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_i_index(idx))) 
    1888       //     { 
    1889       //       ++nbWritten; 
    1890       //     } 
    1891       //   } 
    1892  
    1893       //   compressedIndexToWriteOnServer.resize(nbWritten); 
    1894       //   nbWritten = 0; 
    1895       //   for (int idx = 0; idx < data_i_index.numElements(); ++idx) 
    1896       //   { 
    1897       //     if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_i_index(idx))) 
    1898       //     { 
    1899       //       compressedIndexToWriteOnServer(nbWritten) = localGlobalIndexMap[data_i_index(idx)]; 
    1900       //       ++nbWritten; 
    1901       //     } 
    1902       //   } 
    1903  
    1904       //   numberWrittenIndexes_ = nbWritten; 
    1905       //   if (isDistributed()) 
    1906       //   {             
    1907       //     MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    1908       //     MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    1909       //     offsetWrittenIndexes_ -= numberWrittenIndexes_; 
    1910       //   } 
    1911       //   else 
    1912       //     totalNumberWrittenIndexes_ = numberWrittenIndexes_; 
    1913       // }       
    1914    } 
     2017          localIndexToWriteOnServer(nbWritten) = -1; 
     2018        } 
     2019        ++nbWritten; 
     2020      } 
     2021   } 
     2022   CATCH_DUMP_ATTR 
    19152023 
    19162024  void CDomain::computeWrittenCompressedIndex(ep_lib::MPI_Comm writtenComm) 
     2025  TRY 
    19172026  { 
    19182027    int writtenCommSize; 
     
    19822091      } 
    19832092  } 
     2093  CATCH_DUMP_ATTR 
    19842094 
    19852095  /*! 
     
    19882098  */ 
    19892099  void CDomain::sendAttributes() 
     2100  TRY 
    19902101  { 
    19912102    sendDistributionAttributes(); 
    19922103    sendIndex();        
    1993     sendMask(); 
    19942104    sendLonLat(); 
    19952105    sendArea();     
    19962106    sendDataIndex(); 
    19972107  } 
    1998  
     2108  CATCH 
    19992109  /*! 
    20002110    Send global index from client to connected client(s) 
    20012111  */ 
    20022112  void CDomain::sendIndex() 
     2113  TRY 
    20032114  { 
    20042115    int ns, n, i, j, ind, nv, idx; 
     
    20432154    } 
    20442155  } 
     2156  CATCH_DUMP_ATTR 
    20452157 
    20462158  /*! 
     
    20502162  */ 
    20512163  void CDomain::sendDistributionAttributes(void) 
     2164  TRY 
    20522165  { 
    20532166    std::list<CContextClient*>::iterator it; 
     
    20962209    } 
    20972210  } 
    2098  
    2099   /*! 
    2100     Send mask index from client to connected(s) clients     
    2101   */ 
    2102   void CDomain::sendMask() 
    2103   { 
    2104     int ns, n, i, j, ind, nv, idx; 
    2105     std::list<CContextClient*>::iterator it; 
    2106     for (it=clients.begin(); it!=clients.end(); ++it) 
    2107     { 
    2108       CContextClient* client = *it; 
    2109       int serverSize = client->serverSize; 
    2110  
    2111       // send area for each connected server 
    2112       CEventClient eventMask(getType(), EVENT_ID_MASK); 
    2113  
    2114       list<CMessage> list_msgsMask; 
    2115       list<CArray<bool,1> > list_mask; 
    2116  
    2117       std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2118       iteMap = indSrv_[serverSize].end(); 
    2119       for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    2120       { 
    2121         int nbData = 0; 
    2122         int rank = connectedServerRank_[serverSize][k]; 
    2123         it = indSrv_[serverSize].find(rank); 
    2124         if (iteMap != it) 
    2125           nbData = it->second.size(); 
    2126         list_mask.push_back(CArray<bool,1>(nbData)); 
    2127  
    2128         const std::vector<size_t>& temp = it->second; 
    2129         for (n = 0; n < nbData; ++n) 
    2130         { 
    2131           idx = static_cast<int>(it->second[n]); 
    2132           list_mask.back()(n) = domainMask(globalLocalIndexMap_[idx]); 
    2133         } 
    2134  
    2135         list_msgsMask.push_back(CMessage()); 
    2136         list_msgsMask.back() << this->getId() << list_mask.back(); 
    2137         eventMask.push(rank, nbSenders[serverSize][rank], list_msgsMask.back()); 
    2138       } 
    2139       client->sendEvent(eventMask); 
    2140     } 
    2141   } 
     2211  CATCH_DUMP_ATTR 
    21422212 
    21432213  /*! 
     
    21452215  */ 
    21462216  void CDomain::sendArea() 
     2217  TRY 
    21472218  { 
    21482219    if (!hasArea) return; 
     
    21882259    } 
    21892260  } 
     2261  CATCH_DUMP_ATTR 
    21902262 
    21912263  /*! 
     
    21952267  */ 
    21962268  void CDomain::sendLonLat() 
     2269  TRY 
    21972270  { 
    21982271    if (!hasLonLat) return; 
     
    22832356    } 
    22842357  } 
     2358  CATCH_DUMP_ATTR 
    22852359 
    22862360  /*! 
     
    22912365  */ 
    22922366  void CDomain::sendDataIndex() 
     2367  TRY 
    22932368  { 
    22942369    int ns, n, i, j, ind, nv, idx; 
     
    23592434    } 
    23602435  } 
     2436  CATCH 
    23612437   
    23622438  bool CDomain::dispatchEvent(CEventServer& event) 
     2439  TRY 
    23632440  { 
    23642441    if (SuperClass::dispatchEvent(event)) return true; 
     
    23732450        case EVENT_ID_INDEX: 
    23742451          recvIndex(event); 
    2375           return true; 
    2376           break; 
    2377         case EVENT_ID_MASK: 
    2378           recvMask(event); 
    23792452          return true; 
    23802453          break; 
     
    24022475    } 
    24032476  } 
     2477  CATCH 
    24042478 
    24052479  /*! 
     
    24082482  */ 
    24092483  void CDomain::recvIndex(CEventServer& event) 
     2484  TRY 
    24102485  { 
    24112486    string domainId; 
     
    24212496    get(domainId)->recvIndex(rankBuffers); 
    24222497  } 
     2498  CATCH 
    24232499 
    24242500  /*! 
     
    24282504  */ 
    24292505  void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) 
     2506  TRY 
    24302507  { 
    24312508    int nbReceived = rankBuffers.size(), i, ind, index, type_int, iIndex, jIndex; 
     
    24662543           jIndex = (jIndex < 0) ? 0 : jIndex; 
    24672544           nbIndLoc = iIndex + ni * jIndex; 
    2468            if (nbIndLoc < nbIndexGlobMax) 
    2469            { 
    2470              i_index(nbIndLoc) = index % ni_glo; 
    2471              j_index(nbIndLoc) = index / ni_glo; 
    2472              globalLocalIndexMap_[index] = nbIndLoc;   
    2473              ++nbIndGlob; 
    2474            } 
    2475            // i_index(nbIndGlob) = index % ni_glo; 
    2476            // j_index(nbIndGlob) = index / ni_glo; 
    2477            // globalLocalIndexMap_[index] = nbIndGlob;   
    2478            // ++nbIndGlob; 
     2545           i_index(nbIndGlob) = index % ni_glo; 
     2546           j_index(nbIndGlob) = index / ni_glo; 
     2547           globalLocalIndexMap_[index] = nbIndGlob; 
     2548           ++nbIndGlob; 
    24792549         }  
    24802550      }  
     
    24912561      j_index.resizeAndPreserve(nbIndGlob); 
    24922562    } 
     2563 
     2564    domainMask.resize(0); // Mask is not defined anymore on servers 
    24932565  } 
     2566  CATCH 
    24942567 
    24952568  /*! 
     
    24982571  */ 
    24992572  void CDomain::recvDistributionAttributes(CEventServer& event) 
     2573  TRY 
    25002574  { 
    25012575    CBufferIn* buffer=event.subEvents.begin()->buffer; 
     
    25042578    get(domainId)->recvDistributionAttributes(*buffer); 
    25052579  } 
     2580  CATCH 
    25062581 
    25072582  /*! 
     
    25112586  */ 
    25122587  void CDomain::recvDistributionAttributes(CBufferIn& buffer) 
     2588  TRY 
    25132589  { 
    25142590    int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 
     
    25262602 
    25272603  } 
    2528  
    2529   /*! 
    2530     Receive area event from clients(s) 
    2531     \param[in] event event contain info about rank and associated area 
    2532   */ 
    2533   void CDomain::recvMask(CEventServer& event) 
    2534   { 
    2535     string domainId; 
    2536     std::map<int, CBufferIn*> rankBuffers; 
    2537  
    2538     list<CEventServer::SSubEvent>::iterator it; 
    2539     for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    2540     {       
    2541       CBufferIn* buffer = it->buffer; 
    2542       *buffer >> domainId; 
    2543       rankBuffers[it->rank] = buffer;      
    2544     } 
    2545     get(domainId)->recvMask(rankBuffers); 
    2546   } 
    2547  
    2548  
    2549   /*! 
    2550     Receive mask information from client(s) 
    2551     \param[in] rankBuffers rank of sending client and the corresponding receive buffer   
    2552   */ 
    2553   void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) 
    2554   { 
    2555     int nbReceived = rankBuffers.size(), i, ind, index, lInd; 
    2556     if (nbReceived != recvClientRanks_.size()) 
    2557       ERROR("void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers)", 
    2558            << "The number of sending clients is not correct." 
    2559            << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
    2560  
    2561     vector<CArray<bool,1> > recvMaskValue(nbReceived);       
    2562     for (i = 0; i < recvClientRanks_.size(); ++i) 
    2563     { 
    2564       int rank = recvClientRanks_[i]; 
    2565       CBufferIn& buffer = *(rankBuffers[rank]);       
    2566       buffer >> recvMaskValue[i]; 
    2567     } 
    2568  
    2569     int nbMaskInd = 0; 
    2570     for (i = 0; i < nbReceived; ++i) 
    2571     { 
    2572       nbMaskInd += recvMaskValue[i].numElements(); 
    2573     } 
    2574    
    2575     if (nbMaskInd != globalLocalIndexMap_.size()) 
    2576       info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " 
    2577                << "something must be wrong with mask index "<< std::endl; 
    2578  
    2579     nbMaskInd = globalLocalIndexMap_.size(); 
    2580     mask_1d.resize(nbMaskInd); 
    2581     domainMask.resize(nbMaskInd); 
    2582     mask_1d = false; 
    2583      
    2584     for (i = 0; i < nbReceived; ++i) 
    2585     { 
    2586       CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 
    2587       CArray<bool,1>& tmp = recvMaskValue[i]; 
    2588       for (ind = 0; ind < tmp.numElements(); ++ind) 
    2589       { 
    2590         lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 
    2591         if (!mask_1d(lInd)) // Only rewrite mask_1d if it's not true 
    2592           mask_1d(lInd) = tmp(ind); 
    2593       } 
    2594     } 
    2595     domainMask=mask_1d ; 
    2596   } 
    2597  
     2604 CATCH_DUMP_ATTR 
    25982605  /*! 
    25992606    Receive longitude event from clients(s) 
     
    26012608  */ 
    26022609  void CDomain::recvLon(CEventServer& event) 
     2610  TRY 
    26032611  { 
    26042612    string domainId; 
     
    26142622    get(domainId)->recvLon(rankBuffers); 
    26152623  } 
     2624  CATCH 
    26162625 
    26172626  /*! 
     
    26202629  */ 
    26212630  void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 
     2631  TRY 
    26222632  { 
    26232633    int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 
     
    26792689    } 
    26802690  } 
     2691  CATCH_DUMP_ATTR 
    26812692 
    26822693  /*! 
     
    26852696  */ 
    26862697  void CDomain::recvLat(CEventServer& event) 
     2698  TRY 
    26872699  { 
    26882700    string domainId; 
     
    26982710    get(domainId)->recvLat(rankBuffers); 
    26992711  } 
     2712  CATCH 
    27002713 
    27012714  /*! 
     
    27042717  */ 
    27052718  void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 
     2719  TRY 
    27062720  { 
    27072721    int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 
     
    27652779    } 
    27662780  } 
     2781  CATCH_DUMP_ATTR 
    27672782 
    27682783  /*! 
     
    27712786  */ 
    27722787  void CDomain::recvArea(CEventServer& event) 
     2788  TRY 
    27732789  { 
    27742790    string domainId; 
     
    27842800    get(domainId)->recvArea(rankBuffers); 
    27852801  } 
     2802  CATCH 
    27862803 
    27872804  /*! 
     
    27902807  */ 
    27912808  void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 
     2809  TRY 
    27922810  { 
    27932811    int nbReceived = rankBuffers.size(), i, ind, index, lInd; 
     
    28352853    } 
    28362854  } 
     2855  CATCH_DUMP_ATTR 
    28372856 
    28382857  /*! 
     
    28442863  */ 
    28452864  bool CDomain::isEqual(CDomain* obj) 
     2865  TRY 
    28462866  { 
    28472867    vector<StdString> excludedAttr; 
     
    28662886    return objEqual; 
    28672887  } 
     2888  CATCH_DUMP_ATTR 
    28682889 
    28692890  /*! 
     
    28722893  */ 
    28732894  void CDomain::recvDataIndex(CEventServer& event) 
     2895  TRY 
    28742896  { 
    28752897    string domainId; 
     
    28852907    get(domainId)->recvDataIndex(rankBuffers); 
    28862908  } 
     2909  CATCH 
    28872910 
    28882911  /*! 
     
    28962919  */ 
    28972920  void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 
     2921  TRY 
    28982922  { 
    28992923    int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd;     
     
    29322956         dataIIndex(lInd) = (-1 == dataIIndex(lInd)) ? tmpI(ind) : dataIIndex(lInd); // Only fill in dataIndex if there is no data 
    29332957         dataJIndex(lInd) = (-1 == dataJIndex(lInd)) ? tmpJ(ind) : dataJIndex(lInd);   
    2934  
    2935          if (!domainMask(lInd))   // Include mask info into data index on the RECEIVE getServerDimensionSizes 
    2936          { 
    2937            dataIIndex(lInd) = dataJIndex(lInd) = -1; 
    2938          } 
    29392958      }  
    29402959    } 
     
    29672986    data_jbegin.setValue(0); 
    29682987  } 
     2988  CATCH_DUMP_ATTR 
    29692989 
    29702990  CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) 
     2991  TRY 
    29712992  { 
    29722993    transformationMap_.push_back(std::make_pair(transType, CTransformation<CDomain>::createTransformation(transType,id))); 
    29732994    return transformationMap_.back().second; 
    29742995  } 
     2996  CATCH_DUMP_ATTR 
    29752997 
    29762998  /*! 
     
    29793001  */ 
    29803002  bool CDomain::hasTransformation() 
     3003  TRY 
    29813004  { 
    29823005    return (!transformationMap_.empty()); 
    29833006  } 
     3007  CATCH_DUMP_ATTR 
    29843008 
    29853009  /*! 
     
    29883012  */ 
    29893013  void CDomain::setTransformations(const TransMapTypes& domTrans) 
     3014  TRY 
    29903015  { 
    29913016    transformationMap_ = domTrans; 
    29923017  } 
     3018  CATCH_DUMP_ATTR 
    29933019 
    29943020  /*! 
     
    29973023  */ 
    29983024  CDomain::TransMapTypes CDomain::getAllTransformations(void) 
     3025  TRY 
    29993026  { 
    30003027    return transformationMap_; 
    30013028  } 
     3029  CATCH_DUMP_ATTR 
    30023030 
    30033031  void CDomain::duplicateTransformation(CDomain* src) 
     3032  TRY 
    30043033  { 
    30053034    if (src->hasTransformation()) 
     
    30083037    } 
    30093038  } 
     3039  CATCH_DUMP_ATTR 
    30103040 
    30113041  /*! 
     
    30133043   */ 
    30143044  void CDomain::solveInheritanceTransformation() 
     3045  TRY 
    30153046  { 
    30163047    if (hasTransformation() || !hasDirectDomainReference()) 
     
    30293060        refDomains[i]->setTransformations(domain->getAllTransformations()); 
    30303061  } 
     3062  CATCH_DUMP_ATTR 
    30313063 
    30323064  void CDomain::setContextClient(CContextClient* contextClient) 
     3065  TRY 
    30333066  { 
    30343067    if (clientsSet.find(contextClient)==clientsSet.end()) 
     
    30383071    } 
    30393072  } 
     3073  CATCH_DUMP_ATTR 
    30403074 
    30413075  /*! 
     
    30453079  */ 
    30463080  void CDomain::parse(xml::CXMLNode & node) 
     3081  TRY 
    30473082  { 
    30483083    SuperClass::parse(node); 
     
    30763111    } 
    30773112  } 
     3113  CATCH_DUMP_ATTR 
    30783114   //---------------------------------------------------------------- 
    30793115 
Note: See TracChangeset for help on using the changeset viewer.