- Timestamp:
- 08/28/18 16:38:30 (6 years ago)
- Location:
- XIOS/dev/dev_olga/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/distribution_client.cpp
r1564 r1568 36 36 GlobalLocalMap void2 ; 37 37 std::vector<int> void3 ; 38 std::vector< int> void4 ;38 std::vector<bool> void4 ; 39 39 40 40 globalLocalDataSendToServerMap_.swap(void1) ; … … 61 61 // Then check mask of grid 62 62 int gridDim = domList.size() * 2 + axisList.size(); 63 grid->checkMask();63 // grid->checkMask(); 64 64 switch (gridDim) { 65 65 case 0: … … 282 282 283 283 if ((iIdx >= nBeginLocal_[indexMap_[i]]) && (iIdx < nLocal_[indexMap_[i]]) && 284 (jIdx >= nBeginLocal_[indexMap_[i]+1]) && (jIdx < nLocal_[indexMap_[i]+1]) &&285 (domainMasks_[idxDomain](iIdx + jIdx*nLocal_[indexMap_[i]])))284 (jIdx >= nBeginLocal_[indexMap_[i]+1]) && (jIdx < nLocal_[indexMap_[i]+1]) 285 && (domainMasks_[idxDomain](iIdx + jIdx*nLocal_[indexMap_[i]]))) 286 286 { 287 287 ++count; … … 325 325 elementIndexData_[i].resize(dataNIndex_[i]); 326 326 elementIndexData_[i] = false; 327 int iIdx = 0, count = 0 , localIndex = 0;327 int iIdx = 0, count = 0; 328 328 for (int j = 0; j < dataNIndex_[i]; ++j) 329 329 { … … 438 438 currentIndex[0] = elementLocalIndex_[0](i); 439 439 440 // If defined, iterate on grid mask 441 if (!gridMask_.isEmpty()) 442 { 443 for (int k = 0; k < this->numElement_; ++k) 444 { 445 gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 446 } 447 if (gridMask_(gridMaskIndex)) ++indexLocalDataOnClientCount; 448 } 449 // If grid mask is not defined, iterate on elements' mask 450 else 451 { 452 bool maskTmp = true; 453 int idxDomain = 0, idxAxis = 0; 454 for (int elem = 0; elem < numElement_; ++elem) 455 { 456 if (2 == axisDomainOrder_(elem)) 457 { 458 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 459 ++idxDomain; 460 } 461 else if (1 == axisDomainOrder_(elem)) 462 { 463 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 464 ++idxAxis; 465 } 466 } 467 if (maskTmp) ++indexLocalDataOnClientCount; 468 } 469 440 bool maskTmp = true; 441 int idxDomain = 0, idxAxis = 0; 442 for (int elem = 0; elem < numElement_; ++elem) 443 { 444 if (2 == axisDomainOrder_(elem)) 445 { 446 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 447 ++idxDomain; 448 } 449 else if (1 == axisDomainOrder_(elem)) 450 { 451 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 452 ++idxAxis; 453 } 454 } 455 if (maskTmp) ++indexLocalDataOnClientCount; 470 456 } 471 457 idxLoop[0] += innerLoopSize; … … 535 521 if (isCurrentIndexDataCorrect) 536 522 { 537 int gridMaskIndex = 0; 538 for (int k = 0; k < this->numElement_; ++k) 523 bool maskTmp = true; 524 bool maskGridTmp = true; 525 526 // Domain or axis mask: only unmasked values will be sent 527 int idxDomain = 0, idxAxis = 0; 528 for (int elem = 0; elem < numElement_; ++elem) 539 529 { 540 gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 530 if (2 == axisDomainOrder_(elem)) 531 { 532 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 533 ++idxDomain; 534 } 535 else if (1 == axisDomainOrder_(elem)) 536 { 537 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 538 ++idxAxis; 539 } 541 540 } 542 541 543 bool maskTmp = true; 544 // If defined, apply grid mask 545 if (!gridMask_.isEmpty()) 542 // Grid mask: unmasked values will be replaces by NaN and then all values will be sent 543 if (!gridMask_.isEmpty()) 546 544 { 547 maskTmp = gridMask_(gridMaskIndex); 548 } 549 // If grid mask is not defined, apply elements' mask 550 else 551 { 552 int idxDomain = 0, idxAxis = 0; 553 for (int elem = 0; elem < numElement_; ++elem) 545 int gridMaskIndex = 0; 546 for (int k = 0; k < this->numElement_; ++k) 554 547 { 555 if (2 == axisDomainOrder_(elem)) 556 { 557 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 558 ++idxDomain; 559 } 560 else if (1 == axisDomainOrder_(elem)) 561 { 562 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 563 ++idxAxis; 564 } 548 gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 565 549 } 550 maskGridTmp = gridMask_(gridMaskIndex); 566 551 } 567 552 … … 575 560 globalDataIndex_[globalIndex] = indexLocalDataOnClientCount; 576 561 localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 562 if (maskGridTmp) 563 localMaskIndex_[indexLocalDataOnClientCount] = true; 564 else 565 localMaskIndex_[indexLocalDataOnClientCount] = false; 577 566 globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount; 578 localMaskIndex_[indexLocalDataOnClientCount] = gridMaskIndex;579 567 localMaskedDataIndex_[indexLocalDataOnClientCount] = indexLocalDataOnClientCount; 580 568 ++indexLocalDataOnClientCount; … … 641 629 return -1; 642 630 } 643 int tempI = dataIndex 631 int tempI = dataIndex; //+ dataBegin; 644 632 if ((tempI < 0) || (tempI > ni)) 645 633 return -1; … … 675 663 Return local mask index of client 676 664 */ 677 const std::vector< int>& CDistributionClient::getLocalMaskIndexOnClient()665 const std::vector<bool>& CDistributionClient::getLocalMaskIndexOnClient() 678 666 { 679 667 if (!isComputed_) createGlobalIndexSendToServer(); … … 691 679 692 680 } // namespace xios 681 -
XIOS/dev/dev_olga/src/distribution_client.hpp
r1562 r1568 33 33 34 34 public: 35 /** Default constructor */ 35 /** Default constructor */ 36 36 CDistributionClient(int rank, CGrid* grid); 37 37 … … 44 44 GlobalLocalDataMap& getGlobalLocalDataSendToServer(); 45 45 GlobalLocalDataMap& getGlobalDataIndexOnClient(); 46 const std::vector< int>& getLocalMaskIndexOnClient();46 const std::vector<bool>& getLocalMaskIndexOnClient(); 47 47 const std::vector<int>& getLocalMaskedDataIndexOnClient(); 48 48 … … 83 83 GlobalLocalDataMap globalLocalDataSendToServerMap_; 84 84 GlobalLocalDataMap globalDataIndex_; 85 86 /*! Array holding masked data indexes. 87 * It includes: 88 * masking on data (data_i/j_index or data_ni/nj and data_ibegin) 89 * masking on grid elements (domains, axes or scalars) 90 * It DOES NOT include grid mask. 91 * The array size defines the data size entering the workflow. It is used by source filter of client or server1. 92 */ 85 93 std::vector<int> localDataIndex_; 86 std::vector<int> localMaskIndex_; 94 95 /*! Array holding grid mask. 96 * It is used by source filter of client for replacing unmasked data by NaN. 97 */ 98 std::vector<bool> localMaskIndex_; 99 87 100 std::vector<int> localMaskedDataIndex_; 88 101 … … 172 185 } // namespace xios 173 186 #endif // __XIOS_DISTRIBUTIONCLIENT_HPP__ 187 -
XIOS/dev/dev_olga/src/filter/source_filter.cpp
r1250 r1568 7 7 namespace xios 8 8 { 9 CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid, bool compression, 9 CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid, 10 bool compression /*= true*/, bool mask /*= false*/, 10 11 const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/, 11 12 bool hasMissingValue /*= false*/, … … 14 15 , grid(grid) 15 16 , compression(compression) 17 , mask(mask) 16 18 , offset(offset) 17 19 , hasMissingValue(hasMissingValue), defaultValue(defaultValue) … … 40 42 } 41 43 else 42 grid->inputField(data, packet->data); 43 44 45 46 // if (compression) grid->inputField(data, packet->data) ; 47 // else 48 // { 49 // // just make a flat copy 50 // CArray<double, N> data_tmp(data.copy()) ; // supress const attribute 51 // CArray<double,1> dataTmp2(data_tmp.dataFirst(),shape(data.numElements()),neverDeleteData) ; 52 // packet->data = dataTmp2 ; 53 // } 44 { 45 if (mask) 46 grid->maskField(data, packet->data); 47 else 48 grid->inputField(data, packet->data); 49 } 54 50 // Convert missing values to NaN 55 51 if (hasMissingValue) -
XIOS/dev/dev_olga/src/filter/source_filter.hpp
r1241 r1568 21 21 * \param gc the garbage collector associated with this filter 22 22 * \param grid the grid to which the data is attached 23 * \param compression 24 * \param mask 23 25 * \param offset the offset applied to the timestamp of all packets 24 26 * \param manualTrigger whether the output should be triggered manually … … 27 29 */ 28 30 CSourceFilter(CGarbageCollector& gc, CGrid* grid, 29 bool compression=true, 31 bool compression = true, 32 bool mask = false, 30 33 const CDuration offset = NoneDu, bool manualTrigger = false, 31 34 bool hasMissingValue = false, … … 61 64 62 65 private: 63 CGrid* grid; //!< The grid attached to the data the filter can accept64 const CDuration offset; //!< The offset applied to the timestamp of all packets66 CGrid* grid; //!< The grid attached to the data the filter can accept 67 const CDuration offset; //!< The offset applied to the timestamp of all packets 65 68 const bool hasMissingValue; 66 69 const double defaultValue; 67 const bool compression ; //!< indicate if the data need to be compressed : on client size : true, on server side : false 70 const bool compression ; //!< indicates if data need to be compressed : on client side : true, on server side : false 71 const bool mask ; //!< indicates whether grid mask should be applied (true for clients, false for servers) 68 72 }; // class CSourceFilter 69 73 } // namespace xios -
XIOS/dev/dev_olga/src/node/axis.cpp
r1566 r1568 285 285 } 286 286 287 // Remove this check because it doen't make sense in case of a hole or overlapping axes288 287 if (!this->value.isEmpty()) 289 288 { 290 //StdSize true_size = value.numElements();291 //if (this->n.getValue() != true_size)292 //ERROR("CAxis::checkAttributes(void)",293 //<< "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] "294 //<< "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ").");289 StdSize true_size = value.numElements(); 290 if (this->n.getValue() != true_size) 291 ERROR("CAxis::checkAttributes(void)", 292 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 293 << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 295 294 this->hasValue = true; 296 295 } … … 310 309 Check the validity of data and fill in values if any. 311 310 */ 311 312 312 void CAxis::checkData() 313 313 { … … 328 328 { 329 329 data_index.resize(data_n); 330 for (int i = 0; i < data_n; ++i) data_index(i) = i; 331 } 330 for (int i = 0; i < data_n; ++i) 331 { 332 if ((i+data_begin) >= 0 && (i+data_begin<n)) 333 data_index(i) = i+data_begin; 334 else 335 data_index(i) = -1; 336 } 337 } 338 else 339 { 340 if (data_index.numElements() != data_n) 341 { 342 ERROR("CAxis::checkData(void)", 343 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 344 << "The size of data_index = "<< data_index.numElements() << "is not equal to the data size data_n = " << data_n.getValue() << ")."); 345 } 346 data_index.resize(data_n); 347 for (int i = 0; i < data_n; ++i) 348 { 349 if ((i+data_begin) >= 0 && (i+data_begin<n)) 350 data_index(i) = data_index(i); 351 else 352 data_index(i) = -1; 353 } 354 } 355 332 356 } 333 357 … … 344 368 if (!mask.isEmpty()) 345 369 { 346 if (mask.extent(0) != n) 347 ERROR("CAxis::checkMask(void)", 348 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 349 << "The mask does not have the same size as the local domain." << std::endl 350 << "Local size is " << n.getValue() << "." << std::endl 351 << "Mask size is " << mask.extent(0) << "."); 352 } 353 else // (mask.isEmpty()) 354 { // If no mask was defined, we create a default one without any masked point. 355 mask.resize(n); 356 for (int i = 0; i < n; ++i) 357 { 358 mask(i) = true; 359 } 370 if (mask.extent(0) != n) 371 { 372 ERROR("CAxis::checkMask(void)", 373 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 374 << "The mask does not have the same size as the local domain." << std::endl 375 << "Local size is " << n.getValue() << "." << std::endl 376 << "Mask size is " << mask.extent(0) << "."); 377 } 378 } 379 else 380 { 381 mask.resize(n); 382 mask = true; 360 383 } 361 384 } … … 547 570 548 571 // Calculate the compressed index if any 549 std::set<int> writtenInd;550 if (isCompressible_)551 {552 for (int idx = 0; idx < data_index.numElements(); ++idx)553 {554 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni);555 556 if (ind >= 0 && ind < ni && mask(ind))557 {558 ind += ibegin;559 writtenInd.insert(ind);560 }561 }562 }572 // std::set<int> writtenInd; 573 // if (isCompressible_) 574 // { 575 // for (int idx = 0; idx < data_index.numElements(); ++idx) 576 // { 577 // int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 578 // 579 // if (ind >= 0 && ind < ni && mask(ind)) 580 // { 581 // ind += ibegin; 582 // writtenInd.insert(ind); 583 // } 584 // } 585 // } 563 586 564 587 // Compute the global index of the current client (process) hold … … 725 748 } 726 749 } 750 // 751 // nbWritten = 0; 752 // for (int idx = 0; idx < data_index.numElements(); ++idx) 753 // { 754 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 755 // { 756 // ++nbWritten; 757 // } 758 // } 759 // 760 // compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); 761 // nbWritten = 0; 762 // for (int idx = 0; idx < data_index.numElements(); ++idx) 763 // { 764 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 765 // { 766 // compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)]; 767 // ++nbWritten; 768 // } 769 // } 727 770 728 771 nbWritten = 0; … … 959 1002 960 1003 /* 961 Send a ttributes of axis from a group of client to other group of clients/servers962 onsupposing that these attributes are distributed among the clients of the sending group963 In thefuture, if new attributes are added, they should also be processed in this function1004 Send axis attributes from a group of clients to another group of clients/servers 1005 supposing that these attributes are distributed among the clients of the sending group 1006 In future, if new attributes are added, they should also be processed in this function 964 1007 */ 965 1008 void CAxis::sendDistributedAttributes(void) 966 1009 { 967 int ns, n, i, j, ind, nv, idx;1010 int ind, idx; 968 1011 std::list<CContextClient*>::iterator it; 969 1012 … … 982 1025 list<CArray<string,1> > list_label; 983 1026 1027 // Cut off the ghost points 984 1028 int nbIndex = index.numElements(); 985 1029 CArray<int,1> dataIndex(nbIndex); … … 988 1032 { 989 1033 if (0 <= data_index(idx) && data_index(idx) < nbIndex) 990 dataIndex( idx) = 1;1034 dataIndex(data_index(idx)) = 1; 991 1035 } 992 1036 … … 995 1039 for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 996 1040 { 997 int nbData = 0 ;1041 int nbData = 0, nbDataCount = 0; 998 1042 int rank = connectedServerRank_[nbServer][k]; 999 1043 it = indSrv_[nbServer].find(rank); … … 1002 1046 1003 1047 list_indi.push_back(CArray<int,1>(nbData)); 1004 list_dataInd.push_back(CArray<int,1>(nbData)); 1048 list_dataInd.push_back(CArray<int,1>(nbData)); 1005 1049 list_mask.push_back(CArray<bool,1>(nbData)); 1006 1050 … … 1015 1059 1016 1060 CArray<int,1>& indi = list_indi.back(); 1017 CArray<int,1>& dataIndi = list_dataInd.back(); 1061 CArray<int,1>& dataIndi = list_dataInd.back(); 1062 dataIndi = -1; 1018 1063 CArray<bool,1>& maskIndi = list_mask.back(); 1019 1064 1020 for ( n = 0; n < nbData; ++n)1065 for (int n = 0; n < nbData; ++n) 1021 1066 { 1022 1067 idx = static_cast<int>(it->second[n]); … … 1162 1207 nonCompressedData = -1; 1163 1208 mask.resize(nbData); 1209 mask = true; 1164 1210 if (hasValue) 1165 1211 value.resize(nbData); … … 1199 1245 } 1200 1246 1201 int nbCompressedData = 0; 1247 int nbCompressedData = 0; 1202 1248 for (idx = 0; idx < nonCompressedData.numElements(); ++idx) 1203 1249 { 1204 1250 if (0 <= nonCompressedData(idx)) 1205 ++nbCompressedData; 1251 ++nbCompressedData; 1206 1252 } 1207 1253 … … 1213 1259 { 1214 1260 data_index(nbCompressedData) = idx % n; 1215 ++nbCompressedData; 1261 ++nbCompressedData; 1216 1262 } 1217 1263 } 1218 1264 1219 1265 data_begin.setValue(0); 1266 data_n.setValue(data_index.numElements()); 1220 1267 } 1221 1268 … … 1330 1377 clientsSet.insert(contextClient); 1331 1378 } 1332 }1379 } 1333 1380 1334 1381 void CAxis::parse(xml::CXMLNode & node) -
XIOS/dev/dev_olga/src/node/axis.hpp
r1562 r1568 126 126 bool hasLabel; 127 127 128 CArray<size_t,1> localIndexToWriteOnServer; 128 CArray<size_t,1> localIndexToWriteOnServer; 129 129 130 130 private: -
XIOS/dev/dev_olga/src/node/domain.cpp
r1565 r1568 2447 2447 { 2448 2448 iIndex = (index%ni_glo)-ibegin; 2449 iIndex = (iIndex < 0) ? 0 : iIndex; 2449 iIndex = (iIndex < 0) ? 0 : iIndex; // ?? 2450 2450 jIndex = (index/ni_glo)-jbegin; 2451 jIndex = (jIndex < 0) ? 0 : jIndex; 2451 jIndex = (jIndex < 0) ? 0 : jIndex; // ?? 2452 2452 nbIndLoc = iIndex + ni * jIndex; 2453 2453 if (nbIndLoc < nbIndexGlobMax) … … 2896 2896 buffer >> recvDataJIndex[i]; 2897 2897 } 2898 2898 2899 2899 int nbIndex = i_index.numElements(); 2900 2900 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 2901 2901 dataIIndex = -1; dataJIndex = -1; 2902 2902 2903 2903 nbIndex = 0; 2904 2904 for (i = 0; i < nbReceived; ++i) -
XIOS/dev/dev_olga/src/node/field.cpp
r1542 r1568 1027 1027 { 1028 1028 if (!instantDataFilter) 1029 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true));1029 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false)); 1030 1030 1031 1031 … … 1043 1043 { 1044 1044 if (!instantDataFilter) 1045 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true));1045 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, false)); 1046 1046 1047 1047 // If the field data is to be read by the client or/and written to a file … … 1089 1089 { 1090 1090 checkTimeAttributes(); 1091 instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, f req_offset, true,1091 instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true, 1092 1092 detectMissingValues, defaultValue)); 1093 1093 } … … 1095 1095 { 1096 1096 if (check_if_active.isEmpty()) check_if_active = false; 1097 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, NoneDu, false,1097 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, true, NoneDu, false, 1098 1098 detectMissingValues, defaultValue)); 1099 1099 } … … 1176 1176 { 1177 1177 checkTimeAttributes(); 1178 serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, f req_offset, true,1178 serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true, 1179 1179 detectMissingValues, defaultValue)); 1180 1180 } … … 1193 1193 { 1194 1194 if (check_if_active.isEmpty()) check_if_active = false; 1195 clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, NoneDu, false,1195 clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, true, NoneDu, false, 1196 1196 detectMissingValues, defaultValue)); 1197 1197 } -
XIOS/dev/dev_olga/src/node/grid.cpp
r1562 r1568 698 698 clientDistribution_ = new CDistributionClient(rank, this); 699 699 // Get local data index on client 700 storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 701 int nbStoreIndex = storeIndex_client.numElements(); 702 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 700 int nbStoreIndex = clientDistribution_->getLocalDataIndexOnClient().size(); 701 storeIndex_client.resize(nbStoreIndex); 702 storeMask_client.resize(nbStoreIndex); 703 for (int idx = 0; idx < nbStoreIndex; ++idx) 704 { 705 storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 706 storeMask_client(idx) = (clientDistribution_->getLocalMaskIndexOnClient())[idx]; 707 } 703 708 704 709 if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); … … 1293 1298 } 1294 1299 1300 void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) const 1301 { 1302 const StdSize size = storeIndex_client.numElements(); 1303 stored.resize(size); 1304 1305 const double nanValue = std::numeric_limits<double>::quiet_NaN(); 1306 for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue; 1307 } 1308 1295 1309 void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const 1296 1310 { … … 1749 1763 } 1750 1764 1751 modifyMaskSize(nSize, false); 1752 1753 // These below codes are reserved for future 1754 CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob); 1755 map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 1756 ite = outGlobalIndexFromClient.end(), it; 1757 const CDistributionServer::GlobalLocalMap& globalLocalMask = srvDist.getGlobalLocalIndex(); 1758 CDistributionServer::GlobalLocalMap::const_iterator itSrv; 1759 size_t nb = 0; 1760 for (it = itb; it != ite; ++it) 1761 { 1762 CArray<size_t,1>& globalInd = it->second; 1763 for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 1764 { 1765 if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb; 1766 } 1767 } 1768 1769 CArray<int,1> indexToModify(nb); 1770 nb = 0; 1771 for (it = itb; it != ite; ++it) 1772 { 1773 CArray<size_t,1>& globalInd = it->second; 1774 for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 1775 { 1776 itSrv = globalLocalMask.find(globalInd(idx)); 1777 if (globalLocalMask.end() != itSrv) 1778 { 1779 indexToModify(nb) = itSrv->second; 1780 ++nb; 1781 } 1782 } 1783 } 1784 1785 modifyMask(indexToModify, true); 1765 // modifyMaskSize(nSize, false); 1766 // modifyMaskSize(nSize, true); // Grid mask should be gone beyond client source filter 1767 // 1768 // // These below codes are reserved for future 1769 // CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob); 1770 // map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 1771 // ite = outGlobalIndexFromClient.end(), it; 1772 // const CDistributionServer::GlobalLocalMap& globalLocalMask = srvDist.getGlobalLocalIndex(); 1773 // CDistributionServer::GlobalLocalMap::const_iterator itSrv; 1774 // size_t nb = 0; 1775 // for (it = itb; it != ite; ++it) 1776 // { 1777 // CArray<size_t,1>& globalInd = it->second; 1778 // for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 1779 // { 1780 // if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb; 1781 // } 1782 // } 1783 // 1784 // CArray<int,1> indexToModify(nb); 1785 // nb = 0; 1786 // for (it = itb; it != ite; ++it) 1787 // { 1788 // CArray<size_t,1>& globalInd = it->second; 1789 // for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 1790 // { 1791 // itSrv = globalLocalMask.find(globalInd(idx)); 1792 // if (globalLocalMask.end() != itSrv) 1793 // { 1794 // indexToModify(nb) = itSrv->second; 1795 // ++nb; 1796 // } 1797 // } 1798 // } 1799 1800 // modifyMask(indexToModify, true); 1786 1801 } 1787 1802 -
XIOS/dev/dev_olga/src/node/grid.hpp
r1564 r1568 94 94 template <int n> 95 95 void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; 96 template <int n> 97 void maskField(const CArray<double,n>& field, CArray<double,1>& stored) const; 96 98 template <int n> 97 99 void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const; … … 208 210 public: 209 211 CArray<int, 1> storeIndex_client; 212 CArray<bool, 1> storeMask_client; 210 213 211 214 /** Map containing indexes that will be sent in sendIndex(). */ … … 273 276 void restoreField_arr(const CArray<double, 1>& stored, double* const data) const; 274 277 void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const; 278 void maskField_arr(const double* const data, CArray<double, 1>& stored) const; 275 279 276 280 void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); … … 385 389 386 390 template <int n> 391 void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const 392 { 393 //#ifdef __XIOS_DEBUG 394 if (this->getDataSize() != field.numElements()) 395 ERROR("void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const", 396 << "[ Awaiting data of size = " << this->getDataSize() << ", " 397 << "Received data size = " << field.numElements() << " ] " 398 << "The data array does not have the right size! " 399 << "Grid = " << this->getId()) 400 //#endif 401 this->maskField_arr(field.dataFirst(), stored); 402 } 403 404 template <int n> 387 405 void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const 388 406 { … … 417 435 bool createMask) 418 436 { 419 if (!gridMask.isEmpty() || createMask) 420 { 421 int idx = 0; 422 int numElement = axisDomainOrder.numElements(); 423 int dim = domainMasks.size() * 2 + axisMasks.size(); 424 std::vector<CDomain*> domainP = this->getDomains(); 425 std::vector<CAxis*> axisP = this->getAxis(); 426 427 std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); 428 std::vector<int> currentIndex(dim); 429 int idxDomain = 0, idxAxis = 0; 437 int idx = 0; 438 int numElement = axisDomainOrder.numElements(); 439 int dim = domainMasks.size() * 2 + axisMasks.size(); 440 std::vector<CDomain*> domainP = this->getDomains(); 441 std::vector<CAxis*> axisP = this->getAxis(); 442 443 std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); 444 std::vector<int> currentIndex(dim); 445 int idxDomain = 0, idxAxis = 0; 446 for (int i = 0; i < numElement; ++i) 447 { 448 indexMap[i] = idx; 449 if (2 == axisDomainOrder(i)) { 450 eachDimSize[indexMap[i]] = domainP[idxDomain]->ni; 451 eachDimSize[indexMap[i]+1] = domainP[idxDomain]->nj; 452 idx += 2; ++idxDomain; 453 } 454 else if (1 == axisDomainOrder(i)) { 455 // eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements(); 456 eachDimSize[indexMap[i]] = axisP[idxAxis]->n; 457 ++idx; ++idxAxis; 458 } 459 else {}; 460 } 461 462 if (!gridMask.isEmpty() && !createMask) 463 { 464 for (int i = 0; i < dim; ++i) 465 { 466 if (gridMask.extent(i) != eachDimSize[i]) 467 ERROR("CGrid::checkMask(void)", 468 << "The mask has one dimension whose size is different from the one of the local grid." << std::endl 469 << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl 470 << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl 471 << "Grid = " << this->getId()) 472 } 473 } 474 else { 475 CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); 476 gridMask = true; 477 } 478 479 int ssize = gridMask.numElements(); 480 idx = 0; 481 while (idx < ssize) 482 { 483 for (int i = 0; i < dim-1; ++i) 484 { 485 if (idxLoop[i] == eachDimSize[i]) 486 { 487 idxLoop[i] = 0; 488 ++idxLoop[i+1]; 489 } 490 } 491 492 // Find out outer index 493 idxDomain = idxAxis = 0; 494 bool maskValue = true; 430 495 for (int i = 0; i < numElement; ++i) 431 496 { 432 indexMap[i] = idx; 433 if (2 == axisDomainOrder(i)) { 434 eachDimSize[indexMap[i]] = domainP[idxDomain]->ni; 435 eachDimSize[indexMap[i]+1] = domainP[idxDomain]->nj; 436 idx += 2; ++idxDomain; 497 if (2 == axisDomainOrder(i)) 498 { 499 int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]]; 500 if (idxTmp < (*domainMasks[idxDomain]).numElements()) 501 maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp); 502 else 503 maskValue = false; 504 ++idxDomain; 437 505 } 438 else if (1 == axisDomainOrder(i)) { 439 // eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements(); 440 eachDimSize[indexMap[i]] = axisP[idxAxis]->n; 441 ++idx; ++idxAxis; 506 else if (1 == axisDomainOrder(i)) 507 { 508 int idxTmp = idxLoop[indexMap[i]]; 509 if (idxTmp < (*axisMasks[idxAxis]).numElements()) 510 maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp); 511 else 512 maskValue = false; 513 514 ++idxAxis; 442 515 } 443 else {};444 } 445 446 // if (!gridMask.isEmpty() && !createMask) 447 if (!createMask)516 } 517 518 int maskIndex = idxLoop[0]; 519 int mulDim = 1; 520 for (int k = 1; k < dim; ++k) 448 521 { 449 for (int i = 0; i < dim; ++i) 450 { 451 if (gridMask.extent(i) != eachDimSize[i]) 452 ERROR("CGrid::checkMask(void)", 453 << "The mask has one dimension whose size is different from the one of the local grid." << std::endl 454 << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl 455 << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl 456 << "Grid = " << this->getId()) 457 } 458 } 459 else { 460 CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); 461 gridMask = true; 462 } 463 464 int ssize = gridMask.numElements(); 465 idx = 0; 466 while (idx < ssize) 467 { 468 for (int i = 0; i < dim-1; ++i) 469 { 470 if (idxLoop[i] == eachDimSize[i]) 471 { 472 idxLoop[i] = 0; 473 ++idxLoop[i+1]; 474 } 475 } 476 477 // Find out outer index 478 idxDomain = idxAxis = 0; 479 bool maskValue = true; 480 for (int i = 0; i < numElement; ++i) 481 { 482 if (2 == axisDomainOrder(i)) 483 { 484 int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]]; 485 if (idxTmp < (*domainMasks[idxDomain]).numElements()) 486 maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp); 487 else 488 maskValue = false; 489 ++idxDomain; 490 } 491 else if (1 == axisDomainOrder(i)) 492 { 493 int idxTmp = idxLoop[indexMap[i]]; 494 if (idxTmp < (*axisMasks[idxAxis]).numElements()) 495 maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp); 496 else 497 maskValue = false; 498 499 ++idxAxis; 500 } 501 } 502 503 int maskIndex = idxLoop[0]; 504 int mulDim = 1; 505 for (int k = 1; k < dim; ++k) 506 { 507 mulDim *= eachDimSize[k-1]; 508 maskIndex += idxLoop[k]*mulDim; 509 } 510 *(gridMask.dataFirst()+maskIndex) &= maskValue; 511 512 ++idxLoop[0]; 513 ++idx; 514 } 515 } 522 mulDim *= eachDimSize[k-1]; 523 maskIndex += idxLoop[k]*mulDim; 524 } 525 *(gridMask.dataFirst()+maskIndex) &= maskValue; 526 527 ++idxLoop[0]; 528 ++idx; 529 } 516 530 } 517 531
Note: See TracChangeset
for help on using the changeset viewer.