Changeset 1129 for XIOS/dev/dev_olga/src/node/domain.cpp
- Timestamp:
- 05/11/17 18:25:20 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/node/domain.cpp
r1099 r1129 26 26 namespace xios { 27 27 28 /// ////////////////////// D éfinitions ////////////////////// ///28 /// ////////////////////// Dfinitions ////////////////////// /// 29 29 30 30 CDomain::CDomain(void) 31 31 : CObjectTemplate<CDomain>(), CDomainAttributes() 32 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 32 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_() 33 33 , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 34 34 , isClientAfterTransformationChecked(false), hasLonLat(false) 35 35 , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 36 36 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 37 , globalLocalIndexMap_() 37 , globalLocalIndexMap_(), computedWrittenIndex_(false) 38 38 { 39 39 } … … 41 41 CDomain::CDomain(const StdString & id) 42 42 : CObjectTemplate<CDomain>(id), CDomainAttributes() 43 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 43 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_() 44 44 , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 45 45 , isClientAfterTransformationChecked(false), hasLonLat(false) 46 46 , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 47 47 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 48 , globalLocalIndexMap_() 48 , globalLocalIndexMap_(), computedWrittenIndex_(false) 49 49 { 50 50 } … … 1082 1082 //---------------------------------------------------------------- 1083 1083 1084 /* 1085 Fill in longitude and latitude value from clients (or models) into internal values lonvalue, latvalue which 1086 will be used by XIOS. 1087 */ 1084 1088 void CDomain::completeLonLatClient(void) 1085 1089 { … … 1181 1185 } 1182 1186 1187 /* 1188 Convert internal longitude latitude value used by XIOS to "lonvalue_*" which can be retrieved with Fortran interface 1189 */ 1190 void CDomain::convertLonLatValue(void) 1191 { 1192 bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 1193 if (!lonvalue_2d.isEmpty() && lonlatValueExisted) 1194 { 1195 lonvalue_2d.resize(ni,nj); 1196 latvalue_2d.resize(ni,nj); 1197 if (hasBounds) 1198 { 1199 bounds_lon_2d.resize(nvertex, ni, nj); 1200 bounds_lat_2d.resize(nvertex, ni, nj); 1201 } 1202 1203 for (int j = 0; j < nj; ++j) 1204 { 1205 for (int i = 0; i < ni; ++i) 1206 { 1207 int k = j * ni + i; 1208 1209 lonvalue_2d(i,j) = lonvalue(k); 1210 latvalue_2d(i,j) = latvalue(k); 1211 1212 if (hasBounds) 1213 { 1214 for (int n = 0; n < nvertex; ++n) 1215 { 1216 bounds_lon_2d(n,i,j) = bounds_lonvalue(n,k); 1217 bounds_lat_2d(n,i,j) = bounds_latvalue(n,k); 1218 } 1219 } 1220 } 1221 } 1222 } 1223 else if (!lonvalue_1d.isEmpty() && lonlatValueExisted) 1224 { 1225 if (type_attr::rectilinear == type) 1226 { 1227 if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) 1228 { 1229 lonvalue.resize(ni * nj); 1230 latvalue.resize(ni * nj); 1231 if (hasBounds) 1232 { 1233 bounds_lonvalue.resize(nvertex, ni * nj); 1234 bounds_latvalue.resize(nvertex, ni * nj); 1235 } 1236 1237 for (int j = 0; j < nj; ++j) 1238 { 1239 for (int i = 0; i < ni; ++i) 1240 { 1241 int k = j * ni + i; 1242 1243 lonvalue(k) = lonvalue_1d(i); 1244 latvalue(k) = latvalue_1d(j); 1245 1246 if (hasBounds) 1247 { 1248 for (int n = 0; n < nvertex; ++n) 1249 { 1250 bounds_lonvalue(n,k) = bounds_lon_1d(n,i); 1251 bounds_latvalue(n,k) = bounds_lat_1d(n,j); 1252 } 1253 } 1254 } 1255 } 1256 } 1257 else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements() && !lonlatValueExisted) 1258 { 1259 lonvalue.reference(lonvalue_1d); 1260 latvalue.reference(latvalue_1d); 1261 if (hasBounds) 1262 { 1263 bounds_lonvalue.reference(bounds_lon_1d); 1264 bounds_latvalue.reference(bounds_lat_1d); 1265 } 1266 } 1267 else 1268 ERROR("CDomain::completeLonClient(void)", 1269 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1270 << "'lonvalue_1d' and 'latvalue_1d' does not have the same size as the local domain." << std::endl 1271 << "'lonvalue_1d' size is " << lonvalue_1d.numElements() 1272 << " and 'latvalue_1d' size is " << latvalue_1d.numElements() << std::endl 1273 << " They should be correspondingly " << ni.getValue() << " and " << nj.getValue() << " or " << std::endl 1274 << i_index.numElements() << " and " << j_index.numElements() << "."); 1275 } 1276 else if (type == type_attr::curvilinear || type == type_attr::unstructured && !lonlatValueExisted) 1277 { 1278 lonvalue.reference(lonvalue_1d); 1279 latvalue.reference(latvalue_1d); 1280 if (hasBounds) 1281 { 1282 bounds_lonvalue.reference(bounds_lon_1d); 1283 bounds_latvalue.reference(bounds_lat_1d); 1284 } 1285 } 1286 } 1287 } 1288 1289 1183 1290 void CDomain::checkBounds(void) 1184 1291 { … … 1395 1502 1396 1503 if (context->hasClient && !context->hasServer) 1397 { // C ÃŽtéclient uniquement1504 { // Ct client uniquement 1398 1505 this->checkMask(); 1399 1506 this->checkDomainData(); … … 1402 1509 } 1403 1510 else 1404 { // C ÃŽtéserveur uniquement1511 { // Ct serveur uniquement 1405 1512 } 1406 1513 … … 1435 1542 1436 1543 if (context->hasClient) 1437 { // C ÃŽtéclient uniquement1544 { // Ct client uniquement 1438 1545 this->checkMask(); 1439 1546 this->checkDomainData(); … … 1443 1550 } 1444 1551 else 1445 { // C ÃŽtéserveur uniquement1552 { // Ct serveur uniquement 1446 1553 } 1447 1554 … … 1549 1656 for (i = 0; i < nbIndex; ++i) 1550 1657 globalLocalIndexMap_[globalIndexDomain(i)] = i; 1551 1552 1658 } 1553 1659 … … 1598 1704 zoom_nj = zoom_jend-zoom_jbegin+1; 1599 1705 } 1706 1707 // if (globalLocalIndexZoomMap_.empty()) 1708 // { 1709 // int nbIndexZoom = globalIndexDomainZoom.numElements(); 1710 // for (i = 0; i < nbIndex; ++i) 1711 // globalLocalIndexZoomMap_[globalIndexDomainZoom(i)] = i; 1712 // } 1600 1713 1601 1714 … … 1690 1803 for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 1691 1804 connectedServerRank_.push_back(it->first); 1692 // std::vector<size_t> vec = it->second;1693 // std::sort(vec.begin(), vec.end());1694 // indSrv_[it->first] = vec;1695 1805 } 1696 1806 … … 1700 1810 clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 1701 1811 CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 1702 // indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1703 std::vector<int> connectedServerZoomRank; //(indZoomSrv_.size()); 1704 // for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1705 // connectedServerZoomRank.push_back(it->first); 1706 for (it = globalIndexDomainZoomOnServer.begin(); it != globalIndexDomainZoomOnServer.end(); ++it) 1707 { 1708 connectedServerZoomRank.push_back(it->first); 1709 std::vector<size_t> vec = it->second; 1710 std::sort(vec.begin(), vec.end()); 1711 indZoomSrv_[it->first] = vec; 1712 } 1713 nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank); 1812 indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1813 1814 for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1815 connectedServerZoomRank_.push_back(it->first); 1816 1817 nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank_); 1714 1818 1715 1819 delete clientServerMap; … … 1721 1825 return indSrv_; 1722 1826 } 1827 1828 void CDomain::computeWrittenIndex() 1829 { 1830 if (computedWrittenIndex_) return; 1831 computedWrittenIndex_ = true; 1832 1833 CContext* context=CContext::getCurrent() ; 1834 CContextClient* client = context->client; 1835 1836 std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); 1837 nBegin[0] = zoom_ibegin; nBegin[1] = zoom_jbegin; 1838 nSize[0] = zoom_ni; nSize[1] = zoom_nj; 1839 nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; 1840 nGlob[0] = ni_glo; nGlob[1] = nj_glo; 1841 CDistributionServer srvDist(client->clientSize, nBegin, nSize, nBeginGlobal, nGlob); 1842 const CArray<size_t,1>& writtenGlobalIndex = srvDist.getGlobalIndex(); 1843 1844 size_t nbWritten = 0, indGlo; 1845 boost::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 1846 ite = globalLocalIndexMap_.end(), it; 1847 CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 1848 itSrve = writtenGlobalIndex.end(), itSrv; 1849 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 1850 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 1851 { 1852 indGlo = *itSrv; 1853 if (ite != globalLocalIndexMap_.find(indGlo)) 1854 { 1855 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 1856 ++nbWritten; 1857 } 1858 } 1859 } 1723 1860 1724 1861 /*! … … 1729 1866 { 1730 1867 sendDistributionAttributes(); 1731 sendIndex(); 1732 sendIndex();1868 sendIndex(); 1869 // sendIndexZoom(); 1733 1870 sendMask(); 1734 1871 sendLonLat(); … … 1757 1894 list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 1758 1895 1759 boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex , itZoom, iteZoom;1760 iteIndex = indSrv_.end(); iteZoom = indZoomSrv_.end();1896 boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; 1897 iteIndex = indSrv_.end(); 1761 1898 for (int k = 0; k < connectedServerRank_.size(); ++k) 1762 1899 { … … 1766 1903 if (iteIndex != itIndex) 1767 1904 nbIndGlob = itIndex->second.size(); 1768 int nbIndZoom = 0; 1769 itZoom = indZoomSrv_.find(rank); 1770 if (iteZoom != itZoom) 1771 nbIndZoom = itZoom->second.size(); 1772 1773 list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 1774 list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 1775 1776 CArray<int,1>& indZoom = list_indZoom.back(); 1905 1906 list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 1907 1777 1908 CArray<int,1>& indGlob = list_indGlob.back(); 1778 1909 for (n = 0; n < nbIndGlob; ++n) 1779 1910 { 1780 1911 indGlob(n) = static_cast<int>(itIndex->second[n]); 1781 }1782 1783 for (n = 0; n < nbIndZoom; ++n)1784 {1785 indZoom(n) = static_cast<int>(itZoom->second[n]);1786 1912 } 1787 1913 … … 1789 1915 list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 1790 1916 list_msgsIndex.back() << isCurvilinear; 1791 list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back(); 1792 if (!doZoomByIndex_) 1793 { 1794 //list_msgsIndex.back() << zoom_ni.getValue() << zoom_ibegin.getValue() << zoom_nj.getValue() << zoom_jbegin.getValue(); 1795 } 1917 list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); 1796 1918 1797 1919 // if (isCompressible_) … … 1811 1933 1812 1934 client->sendEvent(eventIndex); 1935 } 1936 } 1937 1938 /*! 1939 Send global index and zoom index from client to connected client(s) 1940 zoom index can be smaller than global index 1941 */ 1942 void CDomain::sendIndexZoom() 1943 { 1944 int ns, n, i, j, ind, nv, idx; 1945 CContext* context = CContext::getCurrent(); 1946 1947 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1948 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 1949 for (int p = 0; p < nbSrvPools; ++p) 1950 { 1951 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; 1952 CEventClient eventIndexZoom(getType(), EVENT_ID_INDEX_ZOOM); 1953 1954 list<CMessage> list_msgsIndex; 1955 list<CArray<int,1> > list_indZoom; 1956 1957 boost::unordered_map<int, vector<size_t> >::const_iterator itZoom, iteZoom; 1958 iteZoom = indZoomSrv_.end(); 1959 for (int k = 0; k < connectedServerZoomRank_.size(); ++k) 1960 { 1961 int nbIndGlob = 0; 1962 int rank = connectedServerZoomRank_[k]; 1963 int nbIndZoom = 0; 1964 itZoom = indZoomSrv_.find(rank); 1965 if (iteZoom != itZoom) 1966 nbIndZoom = itZoom->second.size(); 1967 1968 list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 1969 CArray<int,1>& indZoom = list_indZoom.back(); 1970 for (n = 0; n < nbIndZoom; ++n) 1971 { 1972 indZoom(n) = static_cast<int>(itZoom->second[n]); 1973 } 1974 1975 list_msgsIndex.push_back(CMessage()); 1976 list_msgsIndex.back() << this->getId(); // enum ne fonctionne pour les message => ToFix 1977 list_msgsIndex.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back 1978 1979 eventIndexZoom.push(rank, nbConnectedClientsZoom_[rank], list_msgsIndex.back()); 1980 } 1981 1982 client->sendEvent(eventIndexZoom); 1813 1983 } 1814 1984 } … … 2036 2206 list_msgsLat.push_back(CMessage()); 2037 2207 2038 list_msgsLon.back() << this->getId() << hasLonLat << list_lon.back() << hasBounds; 2039 list_msgsLat.back() << this->getId() << hasLonLat << list_lat.back() << hasBounds; 2040 2208 list_msgsLon.back() << this->getId() << hasLonLat; 2209 if (hasLonLat) 2210 list_msgsLon.back() << list_lon.back(); 2211 list_msgsLon.back() << hasBounds; 2041 2212 if (hasBounds) 2042 2213 { 2043 2214 list_msgsLon.back() << list_boundslon.back(); 2215 } 2216 2217 list_msgsLat.back() << this->getId() << hasLonLat; 2218 if (hasLonLat) 2219 list_msgsLat.back() << list_lat.back(); 2220 list_msgsLat.back() << hasBounds; 2221 if (hasBounds) 2222 { 2044 2223 list_msgsLat.back() << list_boundslat.back(); 2045 2224 } … … 2076 2255 2077 2256 int nbIndex = i_index.numElements(); 2257 int niByIndex = max(i_index) - min(i_index) + 1; 2258 int njByIndex = max(j_index) - min(j_index) + 1; 2259 int dataIindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : niByIndex; 2260 int dataJindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : njByIndex; 2261 2262 2078 2263 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 2079 dataIIndex = -1; dataJIndex = -1, ind = 0; 2264 dataIIndex = -1; 2265 dataJIndex = -1; 2266 ind = 0; 2267 2080 2268 for (idx = 0; idx < data_i_index.numElements(); ++idx) 2081 2269 { 2082 if ((0 <= data_i_index(idx)) && (data_i_index(idx) < ni) && (ind < nbIndex)) 2083 { 2084 dataIIndex(ind) = data_i_index(idx); 2085 dataJIndex(ind) = data_j_index(idx); 2086 ++ind; 2270 int dataIidx = data_i_index(idx) + data_ibegin; 2271 int dataJidx = data_j_index(idx) + data_jbegin; 2272 if ((0 <= dataIidx) && (dataIidx < dataIindexBound) && 2273 (0 <= dataJidx) && (dataJidx < dataJindexBound)) 2274 { 2275 dataIIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //i_index(dataIidx);//dataIidx; 2276 dataJIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //j_index(dataJidx);// 2087 2277 } 2088 2278 } … … 2131 2321 case EVENT_ID_INDEX: 2132 2322 recvIndex(event); 2323 return true; 2324 break; 2325 case EVENT_ID_INDEX_ZOOM: 2326 recvIndexZoom(event); 2133 2327 return true; 2134 2328 break; … … 2198 2392 { 2199 2393 int nbReceived = rankBuffers.size(), i, ind, index, type_int; 2200 recvClientRanks_.resize(nbReceived); 2201 vector<CArray<int,1> > recvZoomInd(nbReceived); 2202 int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp; 2394 recvClientRanks_.resize(nbReceived); 2203 2395 2204 2396 std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); … … 2208 2400 recvClientRanks_[ind] = it->first; 2209 2401 CBufferIn& buffer = *(it->second); 2210 buffer >> type_int >> isCurvilinear >> indGlob_[it->first] >> recvZoomInd[ind] >> doZoomByIndex_; 2211 if (!doZoomByIndex_) 2212 { 2213 //buffer >> ni_zoom_tmp >> ibegin_zoom_tmp >> nj_zoom_tmp >> jbegin_zoom_tmp; 2214 } 2402 buffer >> type_int >> isCurvilinear >> indGlob_[it->first]; 2215 2403 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 2216 2404 } … … 2224 2412 j_index.resize(nbIndGlob); 2225 2413 2414 globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 2226 2415 nbIndGlob = 0; 2227 2416 for (i = 0; i < nbReceived; ++i) … … 2233 2422 i_index(nbIndGlob) = index % ni_glo; 2234 2423 j_index(nbIndGlob) = index / ni_glo; 2424 globalLocalIndexMap_[index] = nbIndGlob; 2235 2425 ++nbIndGlob; 2236 2426 } 2237 } 2238 2239 int nbZoomInd = 0; 2240 for (i = 0; i < nbReceived; ++i) 2241 { 2242 nbZoomInd += recvZoomInd[i].numElements(); 2243 } 2244 2245 if (doZoomByIndex_) 2246 { 2247 zoom_i_index.resize(nbZoomInd); 2248 zoom_j_index.resize(nbZoomInd); 2249 2250 nbZoomInd = 0; 2251 for (i = 0; i < nbReceived; ++i) 2252 { 2253 CArray<int,1>& tmp = recvZoomInd[i]; 2254 for (ind = 0; ind < tmp.numElements(); ++ind) 2255 { 2256 index = tmp(ind); 2257 zoom_i_index(nbZoomInd) = index % ni_glo; 2258 zoom_j_index(nbZoomInd) = index / ni_glo; 2259 ++nbZoomInd; 2260 } 2261 } 2262 } 2263 else 2264 { 2265 // zoom_ni.setValue(ni_zoom_tmp); 2266 // zoom_ibegin.setValue(ibegin_zoom_tmp); 2267 // zoom_nj.setValue(nj_zoom_tmp); 2268 // zoom_jbegin.setValue(jbegin_zoom_tmp); 2269 // int nbZoom = ni_zoom_tmp * nj_zoom_tmp; 2270 // zoom_i_index.resize(nbZoom); 2271 // zoom_j_index.resize(nbZoom); 2272 // nbZoom = 0; 2273 // for (int j = 0; j < nj_zoom_tmp; ++j) 2274 // for (int i = 0; i < ni_zoom_tmp; ++i) 2275 // { 2276 // zoom_i_index(nbZoom) = ibegin_zoom_tmp + i; 2277 // zoom_j_index(nbZoom) = jbegin_zoom_tmp + j; 2278 // ++nbZoom; 2279 // } 2280 } 2281 2282 globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 2283 nbIndGlob = 0; 2284 for (int j = 0; j < nj; ++j) 2285 for (int i = 0; i < ni; ++i) 2286 { 2287 globalLocalIndexMap_[(i + ibegin) + (j + jbegin) * ni_glo] = nbIndGlob; 2288 ++nbIndGlob; 2289 } 2290 2291 2427 } 2292 2428 2293 2429 // { … … 2368 2504 2369 2505 /*! 2506 Receive index event from clients(s) 2507 \param[in] event event contain info about rank and associated index 2508 */ 2509 void CDomain::recvIndexZoom(CEventServer& event) 2510 { 2511 string domainId; 2512 std::map<int, CBufferIn*> rankBuffers; 2513 2514 list<CEventServer::SSubEvent>::iterator it; 2515 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2516 { 2517 CBufferIn* buffer = it->buffer; 2518 *buffer >> domainId; 2519 rankBuffers[it->rank] = buffer; 2520 } 2521 get(domainId)->recvIndexZoom(rankBuffers); 2522 } 2523 2524 /*! 2525 Receive index information from client(s) 2526 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 2527 */ 2528 void CDomain::recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers) 2529 { 2530 int nbReceived = rankBuffers.size(), i, ind, index, type_int; 2531 recvClientZoomRanks_.resize(nbReceived); 2532 int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp; 2533 2534 std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); 2535 ind = 0; 2536 for (ind = 0; it != ite; ++it, ++ind) 2537 { 2538 recvClientZoomRanks_[ind] = it->first; 2539 CBufferIn& buffer = *(it->second); 2540 buffer >> indGlobZoom_[it->first] >> doZoomByIndex_; 2541 } 2542 2543 int nbZoomInd = 0; 2544 for (i = 0; i < nbReceived; ++i) 2545 { 2546 nbZoomInd += indGlobZoom_[recvClientZoomRanks_[i]].numElements(); 2547 } 2548 2549 if (doZoomByIndex_) 2550 { 2551 zoom_i_index.resize(nbZoomInd); 2552 zoom_j_index.resize(nbZoomInd); 2553 2554 nbZoomInd = 0; 2555 for (i = 0; i < nbReceived; ++i) 2556 { 2557 CArray<int,1>& tmp = indGlobZoom_[recvClientRanks_[i]]; 2558 for (ind = 0; ind < tmp.numElements(); ++ind) 2559 { 2560 index = tmp(ind); 2561 zoom_i_index(nbZoomInd) = index % ni_glo; 2562 zoom_j_index(nbZoomInd) = index / ni_glo; 2563 ++nbZoomInd; 2564 } 2565 } 2566 } 2567 else 2568 { 2569 } 2570 2571 // globalLocalIndexZoomMap_.rehash(std::ceil(nbZoomInd/globalLocalIndexZoomMap_.max_load_factor())); 2572 // nbZoomInd = 0; 2573 // for (int j = 0; j < zoom_nj; ++j) 2574 // for (int i = 0; i < zoom_ni; ++i) 2575 // { 2576 // globalLocalIndexZoomMap_[(i + zoom_ibegin) + (j + zoom_jbegin) * ni_glo] = nbZoomInd; 2577 // ++nbZoomInd; 2578 // } 2579 } 2580 2581 /*! 2370 2582 Receive attributes event from clients(s) 2371 2583 \param[in] event event contain info about rank and associated attributes … … 2506 2718 void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 2507 2719 { 2508 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex ;2720 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 2509 2721 if (nbReceived != recvClientRanks_.size()) 2510 2722 ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", … … 2519 2731 CBufferIn& buffer = *(rankBuffers[rank]); 2520 2732 buffer >> hasLonLat; 2521 buffer >> recvLonValue[i]; 2733 if (hasLonLat) 2734 buffer >> recvLonValue[i]; 2522 2735 buffer >> hasBounds; 2523 2736 if (hasBounds) … … 2525 2738 } 2526 2739 2527 lonvalue.resize(zoom_ni*zoom_nj); 2528 lonvalue = 0; 2529 2530 if (hasBounds) 2740 if (hasLonLat) 2531 2741 { 2532 bounds_lonvalue.resize(nvertex,zoom_ni*zoom_nj); 2533 bounds_lonvalue = 0.; 2534 } 2742 int nbLonInd = 0; 2743 for (i = 0; i < nbReceived; ++i) 2744 { 2745 nbLonInd += recvLonValue[i].numElements(); 2746 } 2535 2747 2536 for (i = 0; i < nbReceived; ++i) 2537 { 2538 int rank = recvClientRanks_[i]; 2539 CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 2540 for (ind = 0; ind < indi.numElements(); ++ind) 2541 { 2542 iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 2543 index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 2544 lonvalue(index) = recvLonValue[i](ind); 2545 if (hasBounds) 2546 { 2547 for (int nv = 0; nv < nvertex; ++nv) 2548 bounds_lonvalue(nv, index) = recvBoundsLonValue[i](nv, ind); 2549 } 2550 } 2551 } 2748 if (nbLonInd != globalLocalIndexMap_.size()) 2749 info (0) << "Something wrong with longitude index "<< std::endl; 2750 2751 lonvalue.resize(nbLonInd); 2752 if (hasBounds) 2753 { 2754 bounds_lonvalue.resize(nvertex,nbLonInd); 2755 bounds_lonvalue = 0.; 2756 } 2757 2758 nbLonInd = 0; 2759 for (i = 0; i < nbReceived; ++i) 2760 { 2761 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 2762 CArray<double,1>& tmp = recvLonValue[i]; 2763 for (ind = 0; ind < tmp.numElements(); ++ind) 2764 { 2765 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 2766 lonvalue(lInd) = tmp(ind); 2767 if (hasBounds) 2768 { 2769 for (int nv = 0; nv < nvertex; ++nv) 2770 bounds_lonvalue(nv, lInd) = recvBoundsLonValue[i](nv, ind); 2771 } 2772 } 2773 } 2774 } 2775 2776 2777 2778 // lonvalue.resize(zoom_ni*zoom_nj); 2779 // lonvalue = 0; 2780 2781 // if (hasBounds) 2782 // { 2783 // bounds_lonvalue.resize(nvertex,zoom_ni*zoom_nj); 2784 // bounds_lonvalue = 0.; 2785 // } 2786 2787 // if (0 == lonvalue.numElements()) return; 2788 2789 // for (i = 0; i < nbReceived; ++i) 2790 // { 2791 // int rank = recvClientRanks_[i]; 2792 // CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 2793 // for (ind = 0; ind < indi.numElements(); ++ind) 2794 // { 2795 // iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 2796 // index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 2797 // lonvalue(index) = recvLonValue[i](ind); 2798 // if (hasBounds) 2799 // { 2800 // for (int nv = 0; nv < nvertex; ++nv) 2801 // bounds_lonvalue(nv, index) = recvBoundsLonValue[i](nv, ind); 2802 // } 2803 // } 2804 // } 2552 2805 } 2553 2806 … … 2577 2830 void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 2578 2831 { 2579 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex ;2832 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 2580 2833 if (nbReceived != recvClientRanks_.size()) 2581 2834 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", … … 2590 2843 CBufferIn& buffer = *(rankBuffers[rank]); 2591 2844 buffer >> hasLonLat; 2592 buffer >> recvLatValue[i]; 2845 if (hasLonLat) 2846 buffer >> recvLatValue[i]; 2593 2847 buffer >> hasBounds; 2594 2848 if (hasBounds) … … 2596 2850 } 2597 2851 2598 latvalue.resize(zoom_ni*zoom_nj); 2599 latvalue = 0; 2600 2601 if (hasBounds) 2852 if (hasLonLat) 2602 2853 { 2603 bounds_latvalue.resize(nvertex,zoom_ni*zoom_nj); 2604 bounds_latvalue = 0. ; 2605 } 2854 int nbLatInd = 0; 2855 for (i = 0; i < nbReceived; ++i) 2856 { 2857 nbLatInd += recvLatValue[i].numElements(); 2858 } 2606 2859 2607 for (i = 0; i < nbReceived; ++i) 2608 { 2609 int rank = recvClientRanks_[i]; 2610 CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 2611 CArray<double,1>& lat = recvLatValue[i]; 2612 for (ind = 0; ind < indi.numElements(); ++ind) 2613 { 2614 iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 2615 index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 2616 latvalue(index) = lat(ind); 2617 if (hasBounds) 2618 { 2619 CArray<double,2>& boundslat = recvBoundsLatValue[i]; 2620 for (int nv = 0; nv < nvertex; ++nv) 2621 bounds_latvalue(nv, index) = boundslat(nv, ind); 2622 } 2623 } 2860 if (nbLatInd != globalLocalIndexMap_.size()) 2861 info (0) << "Something wrong with latitude index "<< std::endl; 2862 2863 latvalue.resize(nbLatInd); 2864 if (hasBounds) 2865 { 2866 bounds_latvalue.resize(nvertex,nbLatInd); 2867 bounds_latvalue = 0. ; 2868 } 2869 2870 nbLatInd = 0; 2871 for (i = 0; i < nbReceived; ++i) 2872 { 2873 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 2874 CArray<double,1>& tmp = recvLatValue[i]; 2875 for (ind = 0; ind < tmp.numElements(); ++ind) 2876 { 2877 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 2878 latvalue(lInd) = tmp(ind); 2879 if (hasBounds) 2880 { 2881 CArray<double,2>& boundslat = recvBoundsLatValue[i]; 2882 for (int nv = 0; nv < nvertex; ++nv) 2883 bounds_latvalue(nv, lInd) = boundslat(nv, ind); 2884 } 2885 ++nbLatInd; 2886 } 2887 } 2624 2888 } 2625 2889 } … … 2651 2915 void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 2652 2916 { 2653 int nbReceived = rankBuffers.size(), i, ind, index ;2917 int nbReceived = rankBuffers.size(), i, ind, index, lInd; 2654 2918 if (nbReceived != recvClientRanks_.size()) 2655 2919 ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", … … 2669 2933 int nbAreaInd = 0; 2670 2934 for (i = 0; i < nbReceived; ++i) 2671 { 2672 if (hasArea) 2673 nbAreaInd += recvAreaValue[i].numElements(); 2935 { 2936 nbAreaInd += recvAreaValue[i].numElements(); 2674 2937 } 2675 2938 2676 areavalue.resize(nbAreaInd); 2677 nbAreaInd = 0; 2939 if (nbAreaInd != globalLocalIndexMap_.size()) 2940 info (0) << "Something wrong with latitude index "<< std::endl; 2941 2678 2942 if (hasArea) 2679 2943 { 2944 areavalue.resize(nbAreaInd); 2945 nbAreaInd = 0; 2680 2946 for (i = 0; i < nbReceived; ++i) 2681 2947 { 2948 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 2682 2949 CArray<double,1>& tmp = recvAreaValue[i]; 2683 2950 for (ind = 0; ind < tmp.numElements(); ++ind) 2684 2951 { 2685 area(nbAreaInd) = tmp(ind); 2686 ++nbAreaInd; 2687 } 2688 } 2952 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 2953 areavalue(lInd) = tmp(ind); 2954 } 2955 } 2956 2689 2957 } 2690 2958 } … … 2728 2996 void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 2729 2997 { 2730 int nbReceived = rankBuffers.size(), i, ind, index, indexI, type_int;2998 int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd; 2731 2999 if (nbReceived != recvClientRanks_.size()) 2732 ERROR("void CDomain::recv Lat(std::map<int, CBufferIn*>& rankBuffers)",3000 ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", 2733 3001 << "The number of sending clients is not correct." 2734 3002 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); … … 2743 3011 } 2744 3012 2745 int nbCompressedData = 0; 3013 int nbIndex = i_index.numElements(); 3014 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 3015 dataIIndex = -1; dataJIndex = -1; 3016 3017 nbIndex = 0; 2746 3018 for (i = 0; i < nbReceived; ++i) 3019 { 3020 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 3021 CArray<int,1>& tmpI = recvDataIIndex[i]; 3022 CArray<int,1>& tmpJ = recvDataJIndex[i]; 3023 if ((tmpI.numElements() != tmpInd.numElements()) || (tmpJ.numElements() != tmpInd.numElements())) 3024 ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", 3025 << "The number of global received index is not coherent with the number of received data index." 3026 << "Expected number of global index: " << tmpI.numElements() << " but received " << tmpInd.numElements()); 3027 3028 for (ind = 0; ind < tmpI.numElements(); ++ind) 3029 { 3030 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 3031 dataIIndex(lInd) = tmpI(ind); 3032 dataJIndex(lInd) = tmpJ(ind); 3033 } 3034 } 3035 3036 int nbCompressedData = 0; 3037 for (ind = 0; ind < dataIIndex.numElements(); ++ind) 2747 3038 { 2748 CArray<int,1>& tmp = recvDataIIndex[i]; 2749 for (ind = 0; ind < tmp.numElements(); ++ind) 2750 { 2751 index = tmp(ind); 2752 if (0 <= index) 2753 ++nbCompressedData; 2754 } 2755 } 2756 3039 indexI = dataIIndex(ind); indexJ = dataJIndex(ind); 3040 if ((0 <= indexI) && (0 <= indexJ)) 3041 ++nbCompressedData; 3042 } 3043 2757 3044 data_i_index.resize(nbCompressedData); 2758 3045 data_j_index.resize(nbCompressedData); 2759 3046 2760 nbCompressedData = 0; 2761 for (i = 0; i < nbReceived; ++i)3047 nbCompressedData = 0; 3048 for (ind = 0; ind < dataIIndex.numElements(); ++ind) 2762 3049 { 2763 CArray<int,1>& tmpI = recvDataIIndex[i]; 2764 CArray<int,1>& tmpIndex = indGlob_[recvClientRanks_[i]]; 2765 for (ind = 0; ind < tmpI.numElements(); ++ind) 2766 { 2767 indexI = tmpI(ind); 2768 index = tmpIndex(ind); 2769 if (0 <= indexI) 2770 { 2771 data_i_index(nbCompressedData) = index % ni_glo - ibegin; 2772 data_j_index(nbCompressedData) = index / ni_glo - jbegin; 2773 ++nbCompressedData; 2774 } 2775 } 2776 } 3050 indexI = dataIIndex(ind); indexJ = dataJIndex(ind); 3051 if ((0 <= indexI) && (0 <= indexJ)) 3052 { 3053 data_i_index(nbCompressedData) = (1 == data_dim) ? ind : i_index(ind) - i_index(0); 3054 data_j_index(nbCompressedData) = (1 == data_dim) ? 0 : j_index(ind) - j_index(0); 3055 ++nbCompressedData; 3056 } 3057 } 3058 3059 // Reset data_ibegin, data_jbegin 3060 data_ibegin.setValue(0); 3061 data_jbegin.setValue(0); 2777 3062 } 2778 3063
Note: See TracChangeset
for help on using the changeset viewer.