- Timestamp:
- 11/05/20 15:53:27 (4 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src/node
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp
r1973 r1974 1243 1243 for (unsigned int i = 0; i < this->enabledReadModeFiles.size(); ++i) 1244 1244 (void)this->enabledReadModeFiles[i]->readAttributesOfEnabledFieldsInReadMode(); 1245 }1246 CATCH_DUMP_ATTR1247 1248 void CContext::sendGridComponentEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles)1249 TRY1250 {1251 int size = activeFiles.size();1252 for (int i = 0; i < size; ++i)1253 {1254 activeFiles[i]->sendGridComponentOfEnabledFields();1255 }1256 }1257 CATCH_DUMP_ATTR1258 1259 /*!1260 Send active (enabled) fields in file from a client to others1261 \param [in] activeFiles files contains enabled fields to send1262 */1263 void CContext::sendGridEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles)1264 TRY1265 {1266 int size = activeFiles.size();1267 for (int i = 0; i < size; ++i)1268 {1269 activeFiles[i]->sendGridOfEnabledFields();1270 }1271 }1272 CATCH_DUMP_ATTR1273 1274 void CContext::checkGridEnabledFields()1275 TRY1276 {1277 int size = enabledFiles.size();1278 for (int i = 0; i < size; ++i)1279 {1280 enabledFiles[i]->checkGridOfEnabledFields();1281 }1282 1283 size = enabledCouplerOut.size();1284 for (int i = 0; i < size; ++i)1285 {1286 enabledCouplerOut[i]->checkGridOfEnabledFields();1287 }1288 }1289 CATCH_DUMP_ATTR1290 1291 /*!1292 Check grid of active (enabled) fields in file1293 \param [in] activeFiles files contains enabled fields whose grid needs checking1294 */1295 void CContext::checkGridEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles)1296 TRY1297 {1298 int size = activeFiles.size();1299 for (int i = 0; i < size; ++i)1300 {1301 activeFiles[i]->checkGridOfEnabledFields();1302 }1303 1245 } 1304 1246 CATCH_DUMP_ATTR … … 2157 2099 CATCH_DUMP_ATTR 2158 2100 2159 //! Client side: Send information of reference grid of active fields 2160 void CContext::sendRefGrid(const std::vector<CFile*>& activeFiles) 2161 TRY 2162 { 2163 std::set<pair<StdString,CContextClient*>> gridIds; 2164 2165 int sizeFile = activeFiles.size(); 2166 CFile* filePtr(NULL); 2167 2168 // Firstly, find all reference grids of all active fields 2169 for (int i = 0; i < sizeFile; ++i) 2170 { 2171 filePtr = activeFiles[i]; 2172 std::vector<CField*> enabledFields = filePtr->getEnabledFields(); 2173 int sizeField = enabledFields.size(); 2174 for (int numField = 0; numField < sizeField; ++numField) 2175 { 2176 if (0 != enabledFields[numField]->getRelGrid()) 2177 gridIds.insert(make_pair(CGrid::get(enabledFields[numField]->getRelGrid())->getId(),enabledFields[numField]->getContextClient())); 2178 } 2179 } 2180 2181 // Create all reference grids on server side 2182 StdString gridDefRoot("grid_definition"); 2183 CGridGroup* gridPtr = CGridGroup::get(gridDefRoot); 2184 for (auto it = gridIds.begin(); it != gridIds.end(); ++it) 2185 { 2186 gridPtr->sendCreateChild(it->first,it->second); 2187 CGrid::get(it->first)->sendAllAttributesToServer(it->second); 2188 CGrid::get(it->first)->sendAllDomains(it->second); 2189 CGrid::get(it->first)->sendAllAxis(it->second); 2190 CGrid::get(it->first)->sendAllScalars(it->second); 2191 } 2192 } 2193 CATCH_DUMP_ATTR 2194 2101 2195 2102 //! Client side: Send information of reference domain, axis and scalar of active fields 2196 2103 void CContext::sendRefDomainsAxisScalars(const std::vector<CFile*>& activeFiles) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp
r1973 r1974 149 149 void triggerLateFields(void) ; 150 150 void solveAllRefOfEnabledFieldsAndTransform(void); 151 void checkGridEnabledFields(); 152 void checkGridEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles); 153 void sendGridEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles); 154 void sendGridComponentEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles) ; 155 151 156 152 std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 157 153 std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); … … 177 173 void sendEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles); 178 174 void sendRefDomainsAxisScalars(const std::vector<CFile*>& activeFiles); 179 void sendRefGrid(const std::vector<CFile*>& activeFiles);180 175 //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 181 176 void sendRegistry(void) ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp
r1956 r1974 37 37 CDomain::CDomain(void) 38 38 : CObjectTemplate<CDomain>(), CDomainAttributes() 39 , isChecked(false), relFiles(), isClientChecked(false), nbSenders(),indSrv_(), connectedServerRank_()39 , isChecked(false), relFiles(), indSrv_(), connectedServerRank_() 40 40 , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 41 , isClientAfterTransformationChecked(false),hasLonLat(false)41 , hasLonLat(false) 42 42 , isRedistributed_(false), hasPole(false) 43 43 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 44 , globalLocalIndexMap_(), computedWrittenIndex_(false)45 44 , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 46 45 , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) … … 50 49 CDomain::CDomain(const StdString & id) 51 50 : CObjectTemplate<CDomain>(id), CDomainAttributes() 52 , isChecked(false), relFiles(), i sClientChecked(false), nbSenders(), indSrv_(), connectedServerRank_()51 , isChecked(false), relFiles(), indSrv_(), connectedServerRank_() 53 52 , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 54 , isClientAfterTransformationChecked(false),hasLonLat(false)53 , hasLonLat(false) 55 54 , isRedistributed_(false), hasPole(false) 56 55 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 57 , globalLocalIndexMap_(), computedWrittenIndex_(false)58 56 , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 59 57 , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) … … 105 103 CATCH 106 104 107 /*! 108 Returns the number of indexes written by each server. 109 \return the number of indexes written by each server 110 */ 111 int CDomain::getNumberWrittenIndexes(MPI_Comm writtenCom) 112 TRY 113 { 114 int writtenSize; 115 MPI_Comm_size(writtenCom, &writtenSize); 116 return numberWrittenIndexes_[writtenSize]; 117 } 118 CATCH_DUMP_ATTR 119 120 /*! 121 Returns the total number of indexes written by the servers. 122 \return the total number of indexes written by the servers 123 */ 124 int CDomain::getTotalNumberWrittenIndexes(MPI_Comm writtenCom) 125 TRY 126 { 127 int writtenSize; 128 MPI_Comm_size(writtenCom, &writtenSize); 129 return totalNumberWrittenIndexes_[writtenSize]; 130 } 131 CATCH_DUMP_ATTR 132 133 /*! 134 Returns the offset of indexes written by each server. 135 \return the offset of indexes written by each server 136 */ 137 int CDomain::getOffsetWrittenIndexes(MPI_Comm writtenCom) 138 TRY 139 { 140 int writtenSize; 141 MPI_Comm_size(writtenCom, &writtenSize); 142 return offsetWrittenIndexes_[writtenSize]; 143 } 144 CATCH_DUMP_ATTR 145 146 CArray<int, 1>& CDomain::getCompressedIndexToWriteOnServer(MPI_Comm writtenCom) 147 TRY 148 { 149 int writtenSize; 150 MPI_Comm_size(writtenCom, &writtenSize); 151 return compressedIndexToWriteOnServer[writtenSize]; 152 } 153 CATCH_DUMP_ATTR 154 155 //---------------------------------------------------------------- 105 //---------------------------------------------------------------- 156 106 157 107 /*! … … 1847 1797 1848 1798 1849 //----------------------------------------------------------------1850 // Divide function checkAttributes into 2 seperate ones1851 // This function only checks all attributes of current domain1852 void CDomain::checkAttributesOnClient()1853 TRY1854 {1855 if (this->isClientChecked) return;1856 CContext* context=CContext::getCurrent();1857 1858 if (context->getServiceType()==CServicesManager::CLIENT)1859 {1860 this->checkDomain();1861 this->checkBounds();1862 this->checkArea();1863 this->checkLonLat();1864 }1865 1866 if (context->getServiceType()==CServicesManager::CLIENT)1867 { // Ct client uniquement1868 this->checkMask();1869 this->checkDomainData();1870 this->checkCompression();1871 this->computeLocalMask() ;1872 }1873 else1874 { // Ct serveur uniquement1875 }1876 1877 this->isClientChecked = true;1878 }1879 CATCH_DUMP_ATTR1880 1799 1881 // ym obselete, to be removed 1882 void CDomain::checkAttributesOnClientAfterTransformation() 1883 TRY 1884 { 1885 CContext* context=CContext::getCurrent() ; 1886 1887 if (this->isClientAfterTransformationChecked) return; 1888 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 1889 { 1890 // this->computeConnectedClients(); 1891 if (hasLonLat) 1892 if (context->getServiceType()==CServicesManager::CLIENT) 1893 this->completeLonLatClient(); 1894 } 1895 1896 this->isClientAfterTransformationChecked = true; 1897 } 1898 CATCH_DUMP_ATTR 1899 1900 // Send all checked attributes to server 1901 void CDomain::sendCheckedAttributes() 1902 TRY 1903 { 1904 if (!this->isClientChecked) checkAttributesOnClient(); 1905 if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(); 1906 CContext* context=CContext::getCurrent() ; 1907 1908 if (this->isChecked) return; 1909 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 1910 { 1911 sendAttributes(); 1912 } 1913 this->isChecked = true; 1914 } 1915 CATCH_DUMP_ATTR 1916 1917 /* old version 1918 void CDomain::checkAttributes(void) 1919 TRY 1920 { 1921 if (this->isChecked) return; 1922 CContext* context=CContext::getCurrent() ; 1923 1924 this->checkDomain(); 1925 this->checkLonLat(); 1926 this->checkBounds(); 1927 this->checkArea(); 1928 1929 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 1930 { // Ct client uniquement 1931 this->checkMask(); 1932 this->checkDomainData(); 1933 this->checkCompression(); 1934 this->computeLocalMask() ; 1935 1936 } 1937 else 1938 { // Ct serveur uniquement 1939 } 1940 1941 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 1942 { 1943 this->computeConnectedClients(); 1944 this->completeLonLatClient(); 1945 } 1946 1947 this->isChecked = true; 1948 } 1949 CATCH_DUMP_ATTR 1950 */ 1951 1952 /*! 1953 Compute the connection of a client to other clients to determine which clients to send attributes to. 1954 The sending clients are supposed to already know the distribution of receiving clients (In simple cases, it's band) 1955 The connection among clients is calculated by using global index. 1956 A client connects to other clients which holds the same global index as it. 1957 */ 1958 void CDomain::computeConnectedClients(CContextClient* client) 1959 TRY 1960 { 1961 if (computeConnectedClients_done_.count(client)!=0) return ; 1962 else computeConnectedClients_done_.insert(client) ; 1963 1964 CContext* context=CContext::getCurrent() ; 1965 1966 int nbServer = client->serverSize; 1967 int nbClient = client->clientSize; 1968 int rank = client->clientRank; 1969 1970 if (listNbServer_.count(nbServer) == 0) 1971 { 1972 listNbServer_.insert(nbServer) ; 1973 1974 if (connectedServerRank_.find(nbServer) != connectedServerRank_.end()) 1975 { 1976 nbSenders.erase(nbServer); 1977 connectedServerRank_.erase(nbServer); 1978 } 1979 1980 if (indSrv_.find(nbServer) == indSrv_.end()) 1981 { 1982 int i,j,i_ind,j_ind, nbIndex=i_index.numElements(); 1983 int globalIndexCount = i_index.numElements(); 1984 // Fill in index 1985 CArray<size_t,1> globalIndexDomain(nbIndex); 1986 size_t globalIndex; 1987 1988 for (i = 0; i < nbIndex; ++i) 1989 { 1990 i_ind=i_index(i); 1991 j_ind=j_index(i); 1992 globalIndex = i_ind + j_ind * ni_glo; 1993 globalIndexDomain(i) = globalIndex; 1994 } 1995 1996 if (globalLocalIndexMap_.empty()) 1997 for (i = 0; i < nbIndex; ++i) globalLocalIndexMap_[globalIndexDomain(i)] = i; 1998 1999 2000 size_t globalSizeIndex = 1, indexBegin, indexEnd; 2001 int range, clientSize = client->clientSize; 2002 std::vector<int> nGlobDomain(2); 2003 nGlobDomain[0] = this->ni_glo; 2004 nGlobDomain[1] = this->nj_glo; 2005 for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 2006 indexBegin = 0; 2007 if (globalSizeIndex <= clientSize) 2008 { 2009 indexBegin = rank%globalSizeIndex; 2010 indexEnd = indexBegin; 2011 } 2012 else 2013 { 2014 for (int i = 0; i < clientSize; ++i) 2015 { 2016 range = globalSizeIndex / clientSize; 2017 if (i < (globalSizeIndex%clientSize)) ++range; 2018 if (i == client->clientRank) break; 2019 indexBegin += range; 2020 } 2021 indexEnd = indexBegin + range - 1; 2022 } 2023 2024 // Even if servers have no index, they must received something from client 2025 // We only use several client to send "empty" message to these servers 2026 CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 2027 std::vector<int> serverZeroIndex; 2028 if (isUnstructed_) serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0); 2029 else serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 1); 2030 2031 std::list<int> serverZeroIndexLeader; 2032 std::list<int> serverZeroIndexNotLeader; 2033 CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader); 2034 for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 2035 *it = serverZeroIndex[*it]; 2036 2037 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 2038 clientServerMap->computeServerIndexMapping(globalIndexDomain, nbServer); 2039 CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 2040 2041 CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), ite = globalIndexDomainOnServer.end(); 2042 indSrv_[nbServer].swap(globalIndexDomainOnServer); 2043 connectedServerRank_[nbServer].clear(); 2044 for (it = indSrv_[nbServer].begin(); it != ite; ++it) connectedServerRank_[nbServer].push_back(it->first); 2045 2046 for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 2047 connectedServerRank_[nbServer].push_back(*it); 2048 2049 // Even if a client has no index, it must connect to at least one server and 2050 // send an "empty" data to this server 2051 if (connectedServerRank_[nbServer].empty()) 2052 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 2053 2054 // Now check if all servers have data to receive. If not, master client will send empty data. 2055 // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive. 2056 std::vector<int> counts (clientSize); 2057 std::vector<int> displs (clientSize); 2058 displs[0] = 0; 2059 int localCount = connectedServerRank_[nbServer].size() ; 2060 MPI_Gather(&localCount, 1, MPI_INT, &counts[0], 1, MPI_INT, 0, client->intraComm) ; 2061 for (int i = 0; i < clientSize-1; ++i) displs[i+1] = displs[i] + counts[i]; 2062 std::vector<int> allConnectedServers(displs[clientSize-1]+counts[clientSize-1]); 2063 MPI_Gatherv(&(connectedServerRank_[nbServer])[0], localCount, MPI_INT, &allConnectedServers[0], &counts[0], &displs[0], MPI_INT, 0, client->intraComm); 2064 2065 if ((allConnectedServers.size() != nbServer) && (rank == 0)) 2066 { 2067 std::vector<bool> isSrvConnected (nbServer, false); 2068 for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true; 2069 for (int i = 0; i < nbServer; ++i) if (!isSrvConnected[i]) connectedServerRank_[nbServer].push_back(i); 2070 } 2071 nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 2072 delete clientServerMap; 2073 } 2074 } 2075 } 2076 CATCH_DUMP_ATTR 2077 2078 /*! 2079 Compute index to write data. We only write data on the zoomed region, therefore, there should 2080 be a map between the complete grid and the reduced grid where we write data. 2081 By using global index we can easily create this kind of mapping. 2082 */ 2083 void CDomain::computeWrittenIndex() 2084 TRY 2085 { 2086 if (computedWrittenIndex_) return; 2087 computedWrittenIndex_ = true; 2088 2089 CContext* context=CContext::getCurrent(); 2090 2091 std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); 2092 nBegin[0] = ibegin; nBegin[1] = jbegin; 2093 nSize[0] = ni; nSize[1] = nj; 2094 nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; 2095 nGlob[0] = ni_glo; nGlob[1] = nj_glo; 2096 CDistributionServer srvDist(context->intraCommSize_, nBegin, nSize, nBeginGlobal, nGlob); 2097 const CArray<size_t,1>& writtenGlobalIndex = srvDist.getGlobalIndex(); 2098 2099 size_t nbWritten = 0, indGlo; 2100 std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 2101 ite = globalLocalIndexMap_.end(), it; 2102 CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 2103 itSrve = writtenGlobalIndex.end(), itSrv; 2104 2105 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 2106 nbWritten = 0; 2107 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 2108 { 2109 indGlo = *itSrv; 2110 if (ite != globalLocalIndexMap_.find(indGlo)) 2111 { 2112 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 2113 } 2114 else 2115 { 2116 localIndexToWriteOnServer(nbWritten) = -1; 2117 } 2118 ++nbWritten; 2119 } 2120 } 2121 CATCH_DUMP_ATTR 2122 2123 void CDomain::computeWrittenCompressedIndex(MPI_Comm writtenComm) 2124 TRY 2125 { 2126 int writtenCommSize; 2127 MPI_Comm_size(writtenComm, &writtenCommSize); 2128 if (compressedIndexToWriteOnServer.find(writtenCommSize) != compressedIndexToWriteOnServer.end()) 2129 return; 2130 2131 if (isCompressible()) 2132 { 2133 size_t nbWritten = 0, indGlo; 2134 CContext* context=CContext::getCurrent(); 2135 2136 std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); 2137 nBegin[0] = ibegin; nBegin[1] = jbegin; 2138 nSize[0] = ni; nSize[1] = nj; 2139 nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; 2140 nGlob[0] = ni_glo; nGlob[1] = nj_glo; 2141 CDistributionServer srvDist(context->intraCommSize_, nBegin, nSize, nBeginGlobal, nGlob); 2142 const CArray<size_t,1>& writtenGlobalIndex = srvDist.getGlobalIndex(); 2143 2144 std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 2145 ite = globalLocalIndexMap_.end(), it; 2146 CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 2147 itSrve = writtenGlobalIndex.end(), itSrv; 2148 std::unordered_map<size_t,size_t> localGlobalIndexMap; 2149 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 2150 { 2151 indGlo = *itSrv; 2152 if (ite != globalLocalIndexMap_.find(indGlo)) 2153 { 2154 localGlobalIndexMap[localIndexToWriteOnServer(nbWritten)] = indGlo; 2155 ++nbWritten; 2156 } 2157 } 2158 2159 nbWritten = 0; 2160 for (int idx = 0; idx < data_i_index.numElements(); ++idx) 2161 { 2162 if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_i_index(idx))) 2163 { 2164 ++nbWritten; 2165 } 2166 } 2167 2168 compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); 2169 nbWritten = 0; 2170 for (int idx = 0; idx < data_i_index.numElements(); ++idx) 2171 { 2172 if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_i_index(idx))) 2173 { 2174 compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_i_index(idx)]; 2175 ++nbWritten; 2176 } 2177 } 2178 2179 numberWrittenIndexes_[writtenCommSize] = nbWritten; 2180 bool distributed_glo, distributed=isDistributed() ; 2181 MPI_Allreduce(&distributed,&distributed_glo, 1, MPI_INT, MPI_LOR, writtenComm) ; 2182 2183 if (distributed_glo) 2184 { 2185 2186 MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm); 2187 MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm); 2188 offsetWrittenIndexes_[writtenCommSize] -= numberWrittenIndexes_[writtenCommSize]; 2189 } 2190 else 2191 totalNumberWrittenIndexes_[writtenCommSize] = numberWrittenIndexes_[writtenCommSize]; 2192 } 2193 } 2194 CATCH_DUMP_ATTR 2195 2196 void CDomain::sendDomainToFileServer(CContextClient* client) 2197 { 2198 if (sendDomainToFileServer_done_.count(client)!=0) return ; 2199 else sendDomainToFileServer_done_.insert(client) ; 2200 2201 StdString domDefRoot("domain_definition"); 2202 CDomainGroup* domPtr = CDomainGroup::get(domDefRoot); 2203 domPtr->sendCreateChild(this->getId(), client); 2204 this->sendAllAttributesToServer(client) ; 2205 this->sendDistributionAttributes(client); 2206 //this->sendIndex(client); 2207 //this->sendLonLat(client); 2208 //this->sendArea(client); 2209 //this->sendDataIndex(client); 2210 2211 } 2212 1800 /* to be removed later when coupling will be reimplemented, just to not forget */ 2213 1801 void CDomain::sendDomainToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) 2214 1802 { … … 2226 1814 } 2227 1815 else this->sendAllAttributesToServer(client, domainId) ; 2228 2229 this->sendDistributionAttributes(client, domainId);2230 this->sendIndex(client, domainId);2231 this->sendLonLat(client, domainId);2232 this->sendArea(client, domainId);2233 this->sendDataIndex(client, domainId);2234 1816 } 1817 1818 1819 2235 1820 2236 1821 void CDomain::makeAliasForCoupling(const string& fieldId, int posInGrid) … … 2534 2119 } 2535 2120 CATCH 2536 2537 void CDomain::sendDomainDistribution(CContextClient* client, const string& domainId)2538 TRY2539 {2540 string serverDomainId = domainId.empty() ? this->getId() : domainId ;2541 CContext* context = CContext::getCurrent();2542 int nbServer = client->serverSize;2543 std::vector<int> nGlobDomain(2);2544 nGlobDomain[0] = this->ni_glo;2545 nGlobDomain[1] = this->nj_glo;2546 2547 CServerDistributionDescription serverDescription(nGlobDomain, nbServer);2548 int distributedPosition ;2549 if (isUnstructed_) distributedPosition = 0 ;2550 else distributedPosition = 1 ;2551 2552 serverDescription.computeServerDistribution(false, distributedPosition);2553 2121 2554 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin();2555 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();2556 2557 vector<unordered_map<size_t,vector<int>>> indexServerOnElement ;2558 CArray<int,1> axisDomainOrder(1) ; axisDomainOrder(0)=2 ;2559 auto zeroIndex=serverDescription.computeServerGlobalByElement(indexServerOnElement, context->getIntraCommRank(), context->getIntraCommSize(),2560 axisDomainOrder,distributedPosition) ;2561 // distribution is very bad => to redo2562 // convert indexServerOnElement => map<int,CArray<size_t,1>> - need to be changed later2563 map<int, vector<size_t>> vectGlobalIndex ;2564 for(auto& indexRanks : indexServerOnElement[0])2565 {2566 size_t index=indexRanks.first ;2567 auto& ranks=indexRanks.second ;2568 for(int rank : ranks) vectGlobalIndex[rank].push_back(index) ;2569 }2570 map<int, CArray<size_t,1>> globalIndex ;2571 for(auto& vect : vectGlobalIndex ) globalIndex.emplace(vect.first, CArray<size_t,1>(vect.second.data(), shape(vect.second.size()))) ;2572 2573 CDistributedElement remoteElement(ni_glo*nj_glo, globalIndex) ;2574 remoteElement.addFullView() ;2575 2576 CRemoteConnector remoteConnector(localElement_->getView(CElementView::FULL), remoteElement.getView(CElementView::FULL),context->getIntraComm()) ;2577 remoteConnector.computeConnector() ;2578 CDistributedElement scatteredElement(remoteElement.getGlobalSize(), remoteConnector.getDistributedGlobalIndex()) ;2579 scatteredElement.addFullView() ;2580 CScattererConnector scatterConnector(localElement_->getView(CElementView::FULL), scatteredElement.getView(CElementView::FULL),2581 context->getIntraComm(), client->getRemoteSize()) ;2582 scatterConnector.computeConnector() ;2583 CGridScattererConnector gridScatter({&scatterConnector}) ;2584 2585 CEventClient event0(getType(), EVENT_ID_DOMAIN_DISTRIBUTION);2586 CMessage message0 ;2587 message0<<serverDomainId<<0 ;2588 remoteElement.sendToServer(client,event0,message0) ;2589 2590 CEventClient event1(getType(), EVENT_ID_DOMAIN_DISTRIBUTION);2591 CMessage message1 ;2592 message1<<serverDomainId<<1<<localElement_->getView(CElementView::FULL)->getGlobalSize() ;2593 scatterConnector.transfer(localElement_->getView(CElementView::FULL)->getGlobalIndex(),client,event1,message1) ;2594 2595 CEventClient event2(getType(), EVENT_ID_DOMAIN_DISTRIBUTION);2596 CMessage message2 ;2597 message2<<serverDomainId<<2 ;2598 // scatterConnector.transfer(localElement_->getView(CElementView::FULL)->getGlobalIndex(),client,event2,message2) ;2599 scatterConnector.transfer(localElement_->getView(CElementView::FULL)->getGlobalIndex(),client,event2,message2) ;2600 2601 /*2602 localElement_->getView(CElementView::FULL)->sendRemoteElement(remoteConnector, client, event1, message1) ;2603 CEventClient event2(getType(), EVENT_ID_DOMAIN_DISTRIBUTION);2604 CMessage message2 ;2605 message2<<serverDomainId<<2 ;2606 remoteConnector.transferToServer(localElement_->getView(CElementView::FULL)->getGlobalIndex(),client,event2,message2) ;2607 */2608 2609 }2610 CATCH2611 2612 2613 2614 2615 2616 /*!2617 Send all attributes from client to connected clients2618 The attributes will be rebuilt on receiving side2619 */2620 // ym obsolete to be removed2621 void CDomain::sendAttributes()2622 TRY2623 {2624 //sendDistributionAttributes();2625 //sendIndex();2626 //sendLonLat();2627 //sendArea();2628 //sendDataIndex();2629 }2630 CATCH2631 /*!2632 Send global index from client to connected client(s)2633 */2634 void CDomain::sendIndex(CContextClient* client, const string& domainId)2635 TRY2636 {2637 string serverDomainId = domainId.empty() ? this->getId() : domainId ;2638 2639 int ns, n, i, j, ind, nv, idx;2640 int serverSize = client->serverSize;2641 CEventClient eventIndex(getType(), EVENT_ID_INDEX);2642 2643 list<CMessage> list_msgsIndex;2644 list<CArray<int,1> > list_indGlob;2645 2646 std::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex;2647 iteIndex = indSrv_[serverSize].end();2648 for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k)2649 {2650 int nbIndGlob = 0;2651 int rank = connectedServerRank_[serverSize][k];2652 itIndex = indSrv_[serverSize].find(rank);2653 if (iteIndex != itIndex)2654 nbIndGlob = itIndex->second.size();2655 2656 list_indGlob.push_back(CArray<int,1>(nbIndGlob));2657 2658 CArray<int,1>& indGlob = list_indGlob.back();2659 for (n = 0; n < nbIndGlob; ++n) indGlob(n) = static_cast<int>(itIndex->second[n]);2660 2661 list_msgsIndex.push_back(CMessage());2662 list_msgsIndex.back() << serverDomainId << (int)type; // enum ne fonctionne pour les message => ToFix2663 list_msgsIndex.back() << isCurvilinear;2664 list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back();2665 2666 eventIndex.push(rank, nbSenders[serverSize][rank], list_msgsIndex.back());2667 }2668 client->sendEvent(eventIndex);2669 }2670 CATCH_DUMP_ATTR2671 2672 /*!2673 Send distribution from client to other clients2674 Because a client in a level knows correctly the grid distribution of client on the next level2675 it calculates this distribution then sends it to the corresponding clients on the next level2676 */2677 void CDomain::sendDistributionAttributes(CContextClient* client, const string& domainId)2678 TRY2679 {2680 string serverDomainId = domainId.empty() ? this->getId() : domainId ;2681 2682 int nbServer = client->serverSize;2683 std::vector<int> nGlobDomain(2);2684 nGlobDomain[0] = this->ni_glo;2685 nGlobDomain[1] = this->nj_glo;2686 2687 CServerDistributionDescription serverDescription(nGlobDomain, nbServer);2688 if (isUnstructed_) serverDescription.computeServerDistribution(false, 0);2689 else serverDescription.computeServerDistribution(false, 1);2690 2691 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin();2692 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();2693 2694 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT);2695 if (client->isServerLeader())2696 {2697 std::list<CMessage> msgs;2698 2699 const std::list<int>& ranks = client->getRanksServerLeader();2700 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)2701 {2702 // Use const int to ensure CMessage holds a copy of the value instead of just a reference2703 const int ibegin_srv = serverIndexBegin[*itRank][0];2704 const int jbegin_srv = serverIndexBegin[*itRank][1];2705 const int ni_srv = serverDimensionSizes[*itRank][0];2706 const int nj_srv = serverDimensionSizes[*itRank][1];2707 2708 msgs.push_back(CMessage());2709 CMessage& msg = msgs.back();2710 msg << serverDomainId ;2711 msg << isUnstructed_;2712 msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv;2713 msg << ni_glo.getValue() << nj_glo.getValue();2714 msg << isCompressible_;2715 2716 event.push(*itRank,1,msg);2717 }2718 client->sendEvent(event);2719 }2720 else client->sendEvent(event);2721 }2722 CATCH_DUMP_ATTR2723 2724 /*!2725 Send area from client to connected client(s)2726 */2727 void CDomain::sendArea(CContextClient* client, const string& domainId)2728 TRY2729 {2730 if (!hasArea) return;2731 string serverDomainId = domainId.empty() ? this->getId() : domainId ;2732 2733 int ns, n, i, j, ind, nv, idx;2734 int serverSize = client->serverSize;2735 2736 // send area for each connected server2737 CEventClient eventArea(getType(), EVENT_ID_AREA);2738 2739 list<CMessage> list_msgsArea;2740 list<CArray<double,1> > list_area;2741 2742 std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap;2743 iteMap = indSrv_[serverSize].end();2744 for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k)2745 {2746 int nbData = 0;2747 int rank = connectedServerRank_[serverSize][k];2748 it = indSrv_[serverSize].find(rank);2749 if (iteMap != it)2750 nbData = it->second.size();2751 list_area.push_back(CArray<double,1>(nbData));2752 2753 const std::vector<size_t>& temp = it->second;2754 for (n = 0; n < nbData; ++n)2755 {2756 idx = static_cast<int>(it->second[n]);2757 list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]);2758 }2759 2760 list_msgsArea.push_back(CMessage());2761 list_msgsArea.back() <<serverDomainId << hasArea;2762 list_msgsArea.back() << list_area.back();2763 eventArea.push(rank, nbSenders[serverSize][rank], list_msgsArea.back());2764 }2765 client->sendEvent(eventArea);2766 }2767 CATCH_DUMP_ATTR2768 2769 /*!2770 Send longitude and latitude from client to servers2771 Each client send long and lat information to corresponding connected clients(s).2772 Because longitude and latitude are optional, this function only called if latitude and longitude exist2773 */2774 void CDomain::sendLonLat(CContextClient* client, const string& domainId)2775 TRY2776 {2777 if (!hasLonLat) return;2778 string serverDomainId = domainId.empty() ? this->getId() : domainId ;2779 2780 int ns, n, i, j, ind, nv, idx;2781 int serverSize = client->serverSize;2782 2783 // send lon lat for each connected server2784 CEventClient eventLon(getType(), EVENT_ID_LON);2785 CEventClient eventLat(getType(), EVENT_ID_LAT);2786 2787 list<CMessage> list_msgsLon, list_msgsLat;2788 list<CArray<double,1> > list_lon, list_lat;2789 list<CArray<double,2> > list_boundslon, list_boundslat;2790 2791 std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap;2792 iteMap = indSrv_[serverSize].end();2793 for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k)2794 {2795 int nbData = 0;2796 int rank = connectedServerRank_[serverSize][k];2797 it = indSrv_[serverSize].find(rank);2798 if (iteMap != it)2799 nbData = it->second.size();2800 2801 list_lon.push_back(CArray<double,1>(nbData));2802 list_lat.push_back(CArray<double,1>(nbData));2803 2804 if (hasBounds)2805 {2806 list_boundslon.push_back(CArray<double,2>(nvertex, nbData));2807 list_boundslat.push_back(CArray<double,2>(nvertex, nbData));2808 }2809 2810 CArray<double,1>& lon = list_lon.back();2811 CArray<double,1>& lat = list_lat.back();2812 const std::vector<size_t>& temp = it->second;2813 for (n = 0; n < nbData; ++n)2814 {2815 idx = static_cast<int>(it->second[n]);2816 int localInd = globalLocalIndexMap_[idx];2817 lon(n) = lonvalue(localInd);2818 lat(n) = latvalue(localInd);2819 2820 if (hasBounds)2821 {2822 CArray<double,2>& boundslon = list_boundslon.back();2823 CArray<double,2>& boundslat = list_boundslat.back();2824 2825 for (nv = 0; nv < nvertex; ++nv)2826 {2827 boundslon(nv, n) = bounds_lonvalue(nv, localInd);2828 boundslat(nv, n) = bounds_latvalue(nv, localInd);2829 }2830 }2831 }2832 2833 list_msgsLon.push_back(CMessage());2834 list_msgsLat.push_back(CMessage());2835 2836 list_msgsLon.back() << serverDomainId << hasLonLat;2837 if (hasLonLat)2838 list_msgsLon.back() << list_lon.back();2839 list_msgsLon.back() << hasBounds;2840 if (hasBounds)2841 {2842 list_msgsLon.back() << list_boundslon.back();2843 }2844 2845 list_msgsLat.back() << serverDomainId << hasLonLat;2846 if (hasLonLat)2847 list_msgsLat.back() << list_lat.back();2848 list_msgsLat.back() << hasBounds;2849 if (hasBounds)2850 {2851 list_msgsLat.back() << list_boundslat.back();2852 }2853 2854 eventLon.push(rank, nbSenders[serverSize][rank], list_msgsLon.back());2855 eventLat.push(rank, nbSenders[serverSize][rank], list_msgsLat.back());2856 }2857 client->sendEvent(eventLon);2858 client->sendEvent(eventLat);2859 }2860 CATCH_DUMP_ATTR2861 2862 /*!2863 Send data index to corresponding connected clients.2864 Data index can be compressed however, we always send decompressed data index2865 and they will be compressed on receiving.2866 The compressed index are represented with 1 and others are represented with -12867 */2868 void CDomain::sendDataIndex(CContextClient* client, const string& domainId)2869 TRY2870 {2871 string serverDomainId = domainId.empty() ? this->getId() : domainId ;2872 2873 int ns, n, i, j, ind, nv, idx;2874 int serverSize = client->serverSize;2875 2876 // send area for each connected server2877 CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX);2878 2879 list<CMessage> list_msgsDataIndex;2880 list<CArray<int,1> > list_data_i_index, list_data_j_index;2881 2882 int nbIndex = i_index.numElements();2883 int niByIndex = max(i_index) - min(i_index) + 1;2884 int njByIndex = max(j_index) - min(j_index) + 1;2885 int dataIindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : niByIndex;2886 int dataJindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : njByIndex;2887 2888 2889 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex);2890 dataIIndex = -1;2891 dataJIndex = -1;2892 ind = 0;2893 2894 for (idx = 0; idx < data_i_index.numElements(); ++idx)2895 {2896 int dataIidx = data_i_index(idx) + data_ibegin;2897 int dataJidx = data_j_index(idx) + data_jbegin;2898 if ((0 <= dataIidx) && (dataIidx < dataIindexBound) &&2899 (0 <= dataJidx) && (dataJidx < dataJindexBound))2900 {2901 dataIIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //i_index(dataIidx);//dataIidx;2902 dataJIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //j_index(dataJidx);//2903 }2904 }2905 2906 std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap;2907 iteMap = indSrv_[serverSize].end();2908 for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k)2909 {2910 int nbData = 0;2911 int rank = connectedServerRank_[serverSize][k];2912 it = indSrv_[serverSize].find(rank);2913 if (iteMap != it)2914 nbData = it->second.size();2915 list_data_i_index.push_back(CArray<int,1>(nbData));2916 list_data_j_index.push_back(CArray<int,1>(nbData));2917 2918 const std::vector<size_t>& temp = it->second;2919 for (n = 0; n < nbData; ++n)2920 {2921 idx = static_cast<int>(it->second[n]);2922 i = globalLocalIndexMap_[idx];2923 list_data_i_index.back()(n) = dataIIndex(i);2924 list_data_j_index.back()(n) = dataJIndex(i);2925 }2926 2927 list_msgsDataIndex.push_back(CMessage());2928 list_msgsDataIndex.back() << serverDomainId ;2929 list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back();2930 eventDataIndex.push(rank, nbSenders[serverSize][rank], list_msgsDataIndex.back());2931 }2932 client->sendEvent(eventDataIndex);2933 }2934 CATCH2935 2936 2122 bool CDomain::dispatchEvent(CEventServer& event) 2937 2123 TRY … … 2942 2128 switch(event.type) 2943 2129 { 2944 case EVENT_ID_SERVER_ATTRIBUT:2945 recvDistributionAttributes(event);2946 return true;2947 break;2948 case EVENT_ID_INDEX:2949 recvIndex(event);2950 return true;2951 break;2952 case EVENT_ID_LON:2953 recvLon(event);2954 return true;2955 break;2956 case EVENT_ID_LAT:2957 recvLat(event);2958 return true;2959 break;2960 case EVENT_ID_AREA:2961 recvArea(event);2962 return true;2963 break;2964 case EVENT_ID_DATA_INDEX:2965 recvDataIndex(event);2966 return true;2967 break;2968 2130 case EVENT_ID_DOMAIN_DISTRIBUTION: 2969 2131 recvDomainDistribution(event); … … 2983 2145 CATCH 2984 2146 2985 /*! 2986 Receive index event from clients(s) 2987 \param[in] event event contain info about rank and associated index 2988 */ 2989 void CDomain::recvIndex(CEventServer& event) 2990 TRY 2991 { 2992 string domainId; 2993 std::map<int, CBufferIn*> rankBuffers; 2994 2995 list<CEventServer::SSubEvent>::iterator it; 2996 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2997 { 2998 CBufferIn* buffer = it->buffer; 2999 *buffer >> domainId; 3000 rankBuffers[it->rank] = buffer; 3001 } 3002 get(domainId)->recvIndex(rankBuffers); 3003 } 3004 CATCH 3005 3006 /*! 3007 Receive index information from client(s). We use the global index for mapping index between 3008 sending clients and receiving clients. 3009 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 3010 */ 3011 void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) 3012 TRY 3013 { 3014 int nbReceived = rankBuffers.size(), i, ind, index, type_int, iIndex, jIndex; 3015 recvClientRanks_.resize(nbReceived); 3016 3017 std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); 3018 ind = 0; 3019 for (ind = 0; it != ite; ++it, ++ind) 3020 { 3021 recvClientRanks_[ind] = it->first; 3022 CBufferIn& buffer = *(it->second); 3023 buffer >> type_int >> isCurvilinear >> indGlob_[it->first]; 3024 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 3025 } 3026 int nbIndGlob = 0; 3027 for (i = 0; i < nbReceived; ++i) 3028 { 3029 nbIndGlob += indGlob_[recvClientRanks_[i]].numElements(); 3030 } 3031 3032 globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 3033 i_index.resize(nbIndGlob); 3034 j_index.resize(nbIndGlob); 3035 int nbIndexGlobMax = nbIndGlob, nbIndLoc; 3036 3037 nbIndGlob = 0; 3038 for (i = 0; i < nbReceived; ++i) 3039 { 3040 CArray<int,1>& tmp = indGlob_[recvClientRanks_[i]]; 3041 for (ind = 0; ind < tmp.numElements(); ++ind) 3042 { 3043 index = tmp(ind); 3044 if (0 == globalLocalIndexMap_.count(index)) 3045 { 3046 iIndex = (index%ni_glo)-ibegin; 3047 iIndex = (iIndex < 0) ? 0 : iIndex; 3048 jIndex = (index/ni_glo)-jbegin; 3049 jIndex = (jIndex < 0) ? 0 : jIndex; 3050 nbIndLoc = iIndex + ni * jIndex; 3051 i_index(nbIndGlob) = index % ni_glo; 3052 j_index(nbIndGlob) = index / ni_glo; 3053 globalLocalIndexMap_[index] = nbIndGlob; 3054 ++nbIndGlob; 3055 } 3056 } 3057 } 3058 3059 if (nbIndGlob==0) 3060 { 3061 i_index.resize(nbIndGlob); 3062 j_index.resize(nbIndGlob); 3063 } 3064 else 3065 { 3066 i_index.resizeAndPreserve(nbIndGlob); 3067 j_index.resizeAndPreserve(nbIndGlob); 3068 } 3069 3070 domainMask.resize(0); // Mask is not defined anymore on servers 3071 } 3072 CATCH 3073 3074 /*! 3075 Receive attributes event from clients(s) 3076 \param[in] event event contain info about rank and associated attributes 3077 */ 3078 void CDomain::recvDistributionAttributes(CEventServer& event) 3079 TRY 3080 { 3081 CBufferIn* buffer=event.subEvents.begin()->buffer; 3082 string domainId ; 3083 *buffer>>domainId ; 3084 get(domainId)->recvDistributionAttributes(*buffer); 3085 } 3086 CATCH 3087 3088 /*! 3089 Receive attributes from client(s) 3090 \param[in] rank rank of client source 3091 \param[in] buffer message containing attributes info 3092 */ 3093 void CDomain::recvDistributionAttributes(CBufferIn& buffer) 3094 TRY 3095 { 3096 int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 3097 int ni_glo_tmp, nj_glo_tmp; 3098 buffer >> isUnstructed_ >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp 3099 >> ni_glo_tmp >> nj_glo_tmp 3100 >> isCompressible_; 3101 3102 ni.setValue(ni_tmp); 3103 ibegin.setValue(ibegin_tmp); 3104 nj.setValue(nj_tmp); 3105 jbegin.setValue(jbegin_tmp); 3106 ni_glo.setValue(ni_glo_tmp); 3107 nj_glo.setValue(nj_glo_tmp); 3108 3109 } 3110 CATCH_DUMP_ATTR 3111 /*! 3112 Receive longitude event from clients(s) 3113 \param[in] event event contain info about rank and associated longitude 3114 */ 3115 void CDomain::recvLon(CEventServer& event) 3116 TRY 3117 { 3118 string domainId; 3119 std::map<int, CBufferIn*> rankBuffers; 3120 3121 list<CEventServer::SSubEvent>::iterator it; 3122 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 3123 { 3124 CBufferIn* buffer = it->buffer; 3125 *buffer >> domainId; 3126 rankBuffers[it->rank] = buffer; 3127 } 3128 get(domainId)->recvLon(rankBuffers); 3129 } 3130 CATCH 3131 3132 /*! 3133 Receive longitude information from client(s) 3134 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 3135 */ 3136 void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 3137 TRY 3138 { 3139 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 3140 if (nbReceived != recvClientRanks_.size()) 3141 ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", 3142 << "The number of sending clients is not correct." 3143 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 3144 3145 int nbLonInd = 0; 3146 vector<CArray<double,1> > recvLonValue(nbReceived); 3147 vector<CArray<double,2> > recvBoundsLonValue(nbReceived); 3148 for (i = 0; i < recvClientRanks_.size(); ++i) 3149 { 3150 int rank = recvClientRanks_[i]; 3151 CBufferIn& buffer = *(rankBuffers[rank]); 3152 buffer >> hasLonLat; 3153 if (hasLonLat) 3154 buffer >> recvLonValue[i]; 3155 buffer >> hasBounds; 3156 if (hasBounds) 3157 buffer >> recvBoundsLonValue[i]; 3158 } 3159 3160 if (hasLonLat) 3161 { 3162 for (i = 0; i < nbReceived; ++i) 3163 { 3164 nbLonInd += recvLonValue[i].numElements(); 3165 } 3166 3167 if (nbLonInd != globalLocalIndexMap_.size()) 3168 info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " 3169 << "something must be wrong with longitude index "<< std::endl; 3170 3171 nbLonInd = globalLocalIndexMap_.size(); 3172 lonvalue.resize(nbLonInd); 3173 if (hasBounds) 3174 { 3175 bounds_lonvalue.resize(nvertex,nbLonInd); 3176 bounds_lonvalue = 0.; 3177 } 3178 3179 nbLonInd = 0; 3180 for (i = 0; i < nbReceived; ++i) 3181 { 3182 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 3183 CArray<double,1>& tmp = recvLonValue[i]; 3184 for (ind = 0; ind < tmp.numElements(); ++ind) 3185 { 3186 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 3187 lonvalue(lInd) = tmp(ind); 3188 if (hasBounds) 3189 { 3190 for (int nv = 0; nv < nvertex; ++nv) 3191 bounds_lonvalue(nv, lInd) = recvBoundsLonValue[i](nv, ind); 3192 } 3193 } 3194 } 3195 } 3196 3197 // setup attribute depending the type of domain 3198 if (hasLonLat) 3199 { 3200 nbLonInd = globalLocalIndexMap_.size(); 3201 if (ni*nj != nbLonInd) 3202 ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", 3203 << "The number of index received is not coherent with the given resolution" 3204 << "nbLonInd=" << nbLonInd << ", ni=" << ni <<", nj"<<ni<<" ni*nj="<<ni*nj); 3205 3206 if (type == type_attr::rectilinear || type == type_attr::curvilinear) 3207 { 3208 lonvalue_2d.resize(ni,nj); 3209 for(int ij=0, j=0 ; j<nj ; j++) 3210 for(int i=0 ; i<ni; i++, ij++) lonvalue_2d(i,j) = lonvalue(ij) ; 3211 3212 if (hasBounds) 3213 { 3214 bounds_lon_2d.resize(nvertex, ni, nj) ; 3215 for(int ij=0, j=0 ; j<nj ; j++) 3216 for(int i=0 ; i<ni; i++, ij++) 3217 for(int nv=0; nv<nvertex; nv++) bounds_lon_2d(nv,i,j) = bounds_lonvalue(nv,ij) ; 3218 } 3219 } 3220 else if (type == type_attr::unstructured || type == type_attr::gaussian) 3221 { 3222 lonvalue_1d.resize(nbLonInd); 3223 lonvalue_1d = lonvalue ; 3224 if (hasBounds) 3225 { 3226 bounds_lon_1d.resize(nvertex, nbLonInd) ; 3227 bounds_lon_1d = bounds_lonvalue ; 3228 } 3229 } 3230 } 3231 } 3232 CATCH_DUMP_ATTR 3233 3234 /*! 3235 Receive latitude event from clients(s) 3236 \param[in] event event contain info about rank and associated latitude 3237 */ 3238 void CDomain::recvLat(CEventServer& event) 3239 TRY 3240 { 3241 string domainId; 3242 std::map<int, CBufferIn*> rankBuffers; 3243 3244 list<CEventServer::SSubEvent>::iterator it; 3245 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 3246 { 3247 CBufferIn* buffer = it->buffer; 3248 *buffer >> domainId; 3249 rankBuffers[it->rank] = buffer; 3250 } 3251 get(domainId)->recvLat(rankBuffers); 3252 } 3253 CATCH 3254 3255 /*! 3256 Receive latitude information from client(s) 3257 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 3258 */ 3259 void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 3260 TRY 3261 { 3262 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 3263 if (nbReceived != recvClientRanks_.size()) 3264 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 3265 << "The number of sending clients is not correct." 3266 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 3267 3268 vector<CArray<double,1> > recvLatValue(nbReceived); 3269 vector<CArray<double,2> > recvBoundsLatValue(nbReceived); 3270 for (i = 0; i < recvClientRanks_.size(); ++i) 3271 { 3272 int rank = recvClientRanks_[i]; 3273 CBufferIn& buffer = *(rankBuffers[rank]); 3274 buffer >> hasLonLat; 3275 if (hasLonLat) 3276 buffer >> recvLatValue[i]; 3277 buffer >> hasBounds; 3278 if (hasBounds) 3279 buffer >> recvBoundsLatValue[i]; 3280 } 3281 3282 int nbLatInd = 0; 3283 if (hasLonLat) 3284 { 3285 for (i = 0; i < nbReceived; ++i) 3286 { 3287 nbLatInd += recvLatValue[i].numElements(); 3288 } 3289 3290 if (nbLatInd != globalLocalIndexMap_.size()) 3291 info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " 3292 << "something must be wrong with latitude index "<< std::endl; 3293 3294 nbLatInd = globalLocalIndexMap_.size(); 3295 latvalue.resize(nbLatInd); 3296 if (hasBounds) 3297 { 3298 bounds_latvalue.resize(nvertex,nbLatInd); 3299 bounds_latvalue = 0. ; 3300 } 3301 3302 nbLatInd = 0; 3303 for (i = 0; i < nbReceived; ++i) 3304 { 3305 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 3306 CArray<double,1>& tmp = recvLatValue[i]; 3307 for (ind = 0; ind < tmp.numElements(); ++ind) 3308 { 3309 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 3310 latvalue(lInd) = tmp(ind); 3311 if (hasBounds) 3312 { 3313 CArray<double,2>& boundslat = recvBoundsLatValue[i]; 3314 for (int nv = 0; nv < nvertex; ++nv) 3315 bounds_latvalue(nv, lInd) = boundslat(nv, ind); 3316 } 3317 ++nbLatInd; 3318 } 3319 } 3320 } 3321 // setup attribute depending the type of domain 3322 if (hasLonLat) 3323 { 3324 nbLatInd = globalLocalIndexMap_.size(); 3325 3326 if (ni*nj != nbLatInd) 3327 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 3328 << "The number of index received is not coherent with the given resolution" 3329 << "nbLonInd=" << nbLatInd << ", ni=" << ni <<", nj"<<ni<<" ni*nj="<<ni*nj); 3330 3331 if (type == type_attr::rectilinear || type == type_attr::curvilinear) 3332 { 3333 { 3334 latvalue_2d.resize(ni,nj); 3335 for(int ij=0, j=0 ; j<nj ; j++) 3336 for(int i=0 ; i<ni; i++, ij++) latvalue_2d(i,j) = latvalue(ij) ; 3337 3338 if (hasBounds) 3339 { 3340 bounds_lat_2d.resize(nvertex, ni, nj) ; 3341 for(int ij=0, j=0 ; j<nj ; j++) 3342 for(int i=0 ; i<ni; i++, ij++) 3343 for(int nv=0; nv<nvertex; nv++) bounds_lat_2d(nv,i,j) = bounds_latvalue(nv,ij) ; 3344 } 3345 } 3346 } 3347 else if (type == type_attr::unstructured || type == type_attr::gaussian) 3348 { 3349 if (hasLonLat) 3350 { 3351 latvalue_1d.resize(nbLatInd); 3352 latvalue_1d = latvalue ; 3353 if (hasBounds) 3354 { 3355 bounds_lat_1d.resize(nvertex, nbLatInd) ; 3356 bounds_lat_1d = bounds_latvalue ; 3357 } 3358 } 3359 } 3360 } 3361 } 3362 CATCH_DUMP_ATTR 3363 3364 /*! 3365 Receive area event from clients(s) 3366 \param[in] event event contain info about rank and associated area 3367 */ 3368 void CDomain::recvArea(CEventServer& event) 3369 TRY 3370 { 3371 string domainId; 3372 std::map<int, CBufferIn*> rankBuffers; 3373 3374 list<CEventServer::SSubEvent>::iterator it; 3375 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 3376 { 3377 CBufferIn* buffer = it->buffer; 3378 *buffer >> domainId; 3379 rankBuffers[it->rank] = buffer; 3380 } 3381 get(domainId)->recvArea(rankBuffers); 3382 } 3383 CATCH 3384 3385 /*! 3386 Receive area information from client(s) 3387 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 3388 */ 3389 void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 3390 TRY 3391 { 3392 int nbReceived = rankBuffers.size(), i, ind, index, lInd; 3393 if (nbReceived != recvClientRanks_.size()) 3394 ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", 3395 << "The number of sending clients is not correct." 3396 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 3397 3398 vector<CArray<double,1> > recvAreaValue(nbReceived); 3399 for (i = 0; i < recvClientRanks_.size(); ++i) 3400 { 3401 int rank = recvClientRanks_[i]; 3402 CBufferIn& buffer = *(rankBuffers[rank]); 3403 buffer >> hasArea; 3404 if (hasArea) 3405 buffer >> recvAreaValue[i]; 3406 } 3407 3408 if (hasArea) 3409 { 3410 int nbAreaInd = 0; 3411 for (i = 0; i < nbReceived; ++i) 3412 { 3413 nbAreaInd += recvAreaValue[i].numElements(); 3414 } 3415 3416 if (nbAreaInd != globalLocalIndexMap_.size()) 3417 info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " 3418 << "something must be wrong with area index "<< std::endl; 3419 3420 nbAreaInd = globalLocalIndexMap_.size(); 3421 areavalue.resize(nbAreaInd); 3422 nbAreaInd = 0; 3423 for (i = 0; i < nbReceived; ++i) 3424 { 3425 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 3426 CArray<double,1>& tmp = recvAreaValue[i]; 3427 for (ind = 0; ind < tmp.numElements(); ++ind) 3428 { 3429 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 3430 areavalue(lInd) = tmp(ind); 3431 } 3432 } 3433 3434 // fill the area attribute 3435 area.resize(ni,nj); 3436 for (int j = 0; j < nj; ++j) 3437 { 3438 for (int i = 0; i < ni; ++i) 3439 { 3440 int k = j * ni + i; 3441 area(i,j) = areavalue(k) ; 3442 } 3443 } 3444 } 3445 } 3446 CATCH_DUMP_ATTR 3447 2147 3448 2148 /*! 3449 2149 Compare two domain objects. … … 3479 2179 CATCH_DUMP_ATTR 3480 2180 3481 /*! 3482 Receive data index event from clients(s) 3483 \param[in] event event contain info about rank and associated index 3484 */ 3485 void CDomain::recvDataIndex(CEventServer& event) 3486 TRY 3487 { 3488 string domainId; 3489 std::map<int, CBufferIn*> rankBuffers; 3490 3491 list<CEventServer::SSubEvent>::iterator it; 3492 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 3493 { 3494 CBufferIn* buffer = it->buffer; 3495 *buffer >> domainId; 3496 rankBuffers[it->rank] = buffer; 3497 } 3498 get(domainId)->recvDataIndex(rankBuffers); 3499 } 3500 CATCH 3501 3502 /*! 3503 Receive data index information from client(s) 3504 A client receives data index from different clients to rebuild its own data index. 3505 Because we use global index + mask info to calculate the sending data to client(s), 3506 this data index must be updated with mask info (maybe it will change in the future) 3507 Because the data index is local, to rebuild data index of received client, we should use global index along with. 3508 3509 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 3510 */ 3511 void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 3512 TRY 3513 { 3514 int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd; 3515 if (nbReceived != recvClientRanks_.size()) 3516 ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", 3517 << "The number of sending clients is not correct." 3518 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 3519 3520 vector<CArray<int,1> > recvDataIIndex(nbReceived),recvDataJIndex(nbReceived); 3521 for (i = 0; i < recvClientRanks_.size(); ++i) 3522 { 3523 int rank = recvClientRanks_[i]; 3524 CBufferIn& buffer = *(rankBuffers[rank]); 3525 buffer >> recvDataIIndex[i]; 3526 buffer >> recvDataJIndex[i]; 3527 } 3528 3529 int nbIndex = i_index.numElements(); 3530 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 3531 dataIIndex = -1; dataJIndex = -1; 3532 3533 nbIndex = 0; 3534 for (i = 0; i < nbReceived; ++i) 3535 { 3536 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 3537 CArray<int,1>& tmpI = recvDataIIndex[i]; 3538 CArray<int,1>& tmpJ = recvDataJIndex[i]; 3539 if ((tmpI.numElements() != tmpInd.numElements()) || (tmpJ.numElements() != tmpInd.numElements())) 3540 ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", 3541 << "The number of global received index is not coherent with the number of received data index." 3542 << "Expected number of global index: " << tmpI.numElements() << " but received " << tmpInd.numElements()); 3543 3544 for (ind = 0; ind < tmpI.numElements(); ++ind) 3545 { 3546 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 3547 dataIIndex(lInd) = (-1 == dataIIndex(lInd)) ? tmpI(ind) : dataIIndex(lInd); // Only fill in dataIndex if there is no data 3548 dataJIndex(lInd) = (-1 == dataJIndex(lInd)) ? tmpJ(ind) : dataJIndex(lInd); 3549 } 3550 } 3551 3552 int nbCompressedData = 0; 3553 for (ind = 0; ind < dataIIndex.numElements(); ++ind) 3554 { 3555 indexI = dataIIndex(ind); indexJ = dataJIndex(ind); 3556 if ((0 <= indexI) && (0 <= indexJ)) 3557 ++nbCompressedData; 3558 } 3559 3560 data_i_index.resize(nbCompressedData); 3561 data_j_index.resize(nbCompressedData); 3562 3563 nbCompressedData = 0; 3564 for (ind = 0; ind < dataIIndex.numElements(); ++ind) 3565 { 3566 indexI = dataIIndex(ind); indexJ = dataJIndex(ind); 3567 if ((0 <= indexI) && (0 <= indexJ)) 3568 { 3569 data_i_index(nbCompressedData) = (1 == data_dim) ? ind : ind % ni; 3570 data_j_index(nbCompressedData) = (1 == data_dim) ? 0 : ind / ni; 3571 ++nbCompressedData; 3572 } 3573 } 3574 3575 // Reset data_ibegin, data_jbegin 3576 data_ibegin.setValue(0); 3577 data_jbegin.setValue(0); 3578 } 3579 CATCH_DUMP_ATTR 3580 2181 3581 2182 CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) 3582 2183 TRY -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp
r1956 r1974 54 54 enum EEventId 55 55 { 56 EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT,57 EVENT_ID_AREA,58 EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT,59 56 EVENT_ID_DOMAIN_DISTRIBUTION, EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE 60 57 } ; … … 84 81 void checkAttributes(void); 85 82 bool checkAttributes_done_ = false ; 86 87 void checkAttributesOnClient();88 void checkAttributesOnClientAfterTransformation();89 90 void sendCheckedAttributes();91 83 92 84 bool hasTransformation(); … … 102 94 bool isWrittenCompressed(const StdString& filename) const; 103 95 104 int getNumberWrittenIndexes(MPI_Comm writtenCom);105 int getTotalNumberWrittenIndexes(MPI_Comm writtenCom);106 int getOffsetWrittenIndexes(MPI_Comm writtenCom);107 CArray<int,1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);108 109 96 std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false); 110 97 … … 125 112 126 113 public : 127 std::vector<int> getNbGlob();128 114 bool isEqual(CDomain* domain); 129 115 … … 155 141 void addRelFileCompressed(const StdString& filename); 156 142 157 void computeWrittenIndex();158 void computeWrittenCompressedIndex(MPI_Comm);159 160 143 void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 161 144 CArray<double,1>& lon_g, CArray<double,1>& lat_g); … … 182 165 CArray<double, 1> areavalue; 183 166 184 CArray<int,1> localIndexToWriteOnServer;185 167 186 168 CArray<bool, 1> domainMask; // mask_1d, mask_2d -> domainMask … … 198 180 void computeLocalMask(void) ; 199 181 200 void computeConnectedClients(CContextClient* client);201 private: std::set<CContextClient*> computeConnectedClients_done_; public:202 182 /** The number of server of a context client. Avoid to re-compute indice computed in a previous computeConnectedClient */ 203 private: std::set<int> listNbServer_ ; public:183 private: std::set<int> listNbServer_ ; 204 184 205 185 private: … … 233 213 private: 234 214 235 void sendDomainDistribution(CContextClient* client, const string& domainId="") ; //for testing236 void sendAttributes(); // ym obsolete -> to be removed237 void sendIndex(CContextClient* client, const string& domainId="");238 void sendDistributionAttributes(CContextClient* client, const string& domainId="");239 void sendArea(CContextClient* client, const string& domainId="");240 void sendLonLat(CContextClient* client, const string& domainId="");241 void sendDataIndex(CContextClient* client, const string& domainId="");242 215 void convertLonLatValue(); 243 216 void fillInRectilinearLonLat(); 244 217 void fillInCurvilinearLonLat(); 245 218 void fillInUnstructuredLonLat(); 246 247 static void recvDistributionAttributes(CEventServer& event);248 static void recvIndex(CEventServer& event);249 static void recvLon(CEventServer& event);250 static void recvLat(CEventServer& event);251 static void recvArea(CEventServer& event);252 static void recvDataIndex(CEventServer& event);253 void recvDistributionAttributes(CBufferIn& buffer);254 void recvIndex(std::map<int, CBufferIn*>& rankBuffers);255 void recvLon(std::map<int, CBufferIn*>& rankBuffers);256 void recvLat(std::map<int, CBufferIn*>& rankBuffers);257 void recvArea(std::map<int, CBufferIn*>& rankBuffers);258 void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);259 260 219 void completeLonLatClient(void); 261 220 … … 267 226 std::set<CContextClient*> clientsSet; 268 227 269 bool isChecked , computedWrittenIndex_;228 bool isChecked ; 270 229 std::set<StdString> relFiles, relFilesCompressed; 271 bool isClientChecked; // Verify whether all attributes of domain on the client side are good272 bool isClientAfterTransformationChecked;273 274 /** global index of the domain on server side, sent by the clients. This is global index for lon, lat, mask elements (ie non masked elements)275 indGlobs_[rank] -> array of global index received from the client of rank "rank"276 indGlobs[rank](ind) -> global indices of the "ind" element sent.277 Defined only on server side278 */279 std::map<int, CArray<int,1> > indGlob_;280 281 /** only on client sided : defined the number of clients which participate to a message sent to a server for longitude, lat, area, etc. attributes282 nbSender[nbServers] --> first map is related to the server distribution (ie associated with the contextClient)283 nbSenders[nbServers][server_rank]-> return the number of participants of a message sent to the server of rank "server_rank"284 */285 std::map<int, map<int,int> > nbSenders;286 230 287 231 /** only on client side : Global index of each client sent to server: map<serverSize, map<serverRank, indexes>> … … 291 235 */ 292 236 std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; 293 294 /** make the mapping between the global index (the key) and the local index 295 globalLocalIndexMap_[global_index] --> get the local index 296 */ 297 std::unordered_map<size_t,size_t> globalLocalIndexMap_; 298 299 300 /** only on server side : get the rank of each clients which participate to a received message 301 * recvClientRanks_[num_receiver] : client rank of the receiver "num_receiver" 302 */ 303 std::vector<int> recvClientRanks_; 304 305 std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 306 std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer; 237 307 238 std::map<int, std::vector<int> > connectedServerRank_; 308 239 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
r1973 r1974 728 728 } 729 729 730 void CGrid::checkAttributesAfterTransformation() 731 TRY 732 { 733 setAxisList(); 734 std::vector<CAxis*> axisListP = this->getAxis(); 735 for (int i = 0; i < axisListP.size(); ++i) 736 axisListP[i]->checkAttributesOnClientAfterTransformation(getGlobalDimension(), getAxisPositionInGrid()[i]); 737 738 setDomainList(); 739 std::vector<CDomain*> domListP = this->getDomains(); 740 if (!domListP.empty()) 741 { 742 for (int i = 0; i < domListP.size(); ++i) 743 { 744 domListP[i]->checkAttributesOnClientAfterTransformation(); 745 } 746 } 747 } 748 CATCH_DUMP_ATTR 749 750 //--------------------------------------------------------------- 751 730 752 731 /*! 753 732 * Test whether the data defined on the grid can be outputted in a compressed way. … … 840 819 { 841 820 CContext* context = CContext::getCurrent(); 842 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 843 { 844 if (this->isChecked && doSendingIndex && !isIndexSent) 845 { 846 if (isScalarGrid()) /*sendIndexScalarGrid()*/; 847 else /*sendIndex()*/; 848 this->isIndexSent = true; 849 } 850 } 851 821 852 822 if (this->isChecked) return; 853 this->check AttributesAfterTransformation();823 this->checkElementsAttributes(); 854 824 855 825 if (!(this->hasTransform() && !this->isTransformed())) … … 897 867 std::vector<CDomain*> domListP = this->getDomains(); 898 868 if (!domListP.empty()) 899 { 900 for (int i = 0; i < domListP.size(); ++i) 901 { 902 if (sendAtt) domListP[i]->sendCheckedAttributes(); 903 else domListP[i]->checkAttributesOnClient(); 904 } 905 } 869 for (int i = 0; i < domListP.size(); ++i) domListP[i]->checkAttributes(); 906 870 } 907 871 CATCH_DUMP_ATTR … … 915 879 std::vector<CAxis*> axisListP = this->getAxis(); 916 880 if (!axisListP.empty()) 917 { 918 for (int i = 0; i < axisListP.size(); ++i) 919 { 920 if (sendAtt) 921 axisListP[i]->sendCheckedAttributes(getGlobalDimension(),getAxisPositionInGrid()[i]); 922 else 923 axisListP[i]->checkAttributesOnClient(); 924 } 925 } 881 for (int i = 0; i < axisListP.size(); ++i) axisListP[i]->checkAttributes(); 926 882 } 927 883 CATCH_DUMP_ATTR … … 935 891 std::vector<CScalar*> scalarListP = this->getScalars(); 936 892 if (!scalarListP.empty()) 937 { 938 for (int i = 0; i < scalarListP.size(); ++i) 939 { 940 /*Nothing to do for now */ 941 // if (sendAtt) scalarListP[i]->sendCheckedAttributes(); 942 // else scalarListP[i]->checkAttributesOnClient(); 943 } 944 } 893 for (int i = 0; i < scalarListP.size(); ++i) scalarListP[i]->checkAttributes() ; 945 894 } 946 895 CATCH_DUMP_ATTR … … 1944 1893 CATCH_DUMP_ATTR 1945 1894 1946 1947 1948 /*!1949 Send all attributes of domains from client to server1950 */1951 void CGrid::sendAllDomains(CContextClient* contextClient)1952 TRY1953 {1954 std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren();1955 for (auto domain : domList)1956 {1957 sendAddDomain(domain->getId(),contextClient);1958 domain->sendDomainToFileServer(contextClient);1959 }1960 }1961 CATCH_DUMP_ATTR1962 1963 /*!1964 Send all attributes of axis from client to server1965 */1966 void CGrid::sendAllAxis(CContextClient* contextClient)1967 TRY1968 {1969 std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren();1970 for (int i=0; i<aList.size() ; ++i)1971 {1972 sendAddAxis(aList[i]->getId(),contextClient);1973 aList[i]->sendAxisToFileServer(contextClient, getGlobalDimension(), getAxisPositionInGrid()[i]);1974 }1975 }1976 CATCH_DUMP_ATTR1977 1978 /*!1979 Send all attributes of scalars from client to server1980 */1981 void CGrid::sendAllScalars(CContextClient* contextClient)1982 TRY1983 {1984 std::vector<CScalar*> sList = this->getVirtualScalarGroup()->getAllChildren();1985 for (auto scalar : sList)1986 {1987 sendAddScalar(scalar->getId(),contextClient);1988 scalar->sendScalarToFileServer(contextClient);1989 }1990 }1991 CATCH_DUMP_ATTR1992 1993 1895 void CGrid::setContextClient(CContextClient* contextClient) 1994 1896 TRY -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp
r1973 r1974 179 179 void sendAddAxis(const std::string& id,CContextClient* contextClient); 180 180 void sendAddScalar(const std::string& id,CContextClient* contextClient); 181 void sendAllDomains(CContextClient* contextClient); 182 void sendAllAxis(CContextClient* contextClient); 183 void sendAllScalars(CContextClient* contextClient); 184 181 185 182 static void recvAddDomain(CEventServer& event); 186 183 void recvAddDomain(CBufferIn& buffer); … … 268 265 CScalarGroup* getVirtualScalarGroup() const; 269 266 270 void checkAttributesAfterTransformation();271 267 void setTransformationAlgorithms(); 272 268 int computeGridGlobalDimension(std::vector<int>& globalDim,
Note: See TracChangeset
for help on using the changeset viewer.