Changeset 1642 for XIOS/dev/branch_openmp/src/node/grid.hpp
- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/node/grid.hpp
r1545 r1642 19 19 namespace xios { 20 20 21 /// ////////////////////// D ᅵᅵclarations ////////////////////// ///21 /// ////////////////////// Declarations ////////////////////// /// 22 22 23 23 class CGridGroup; … … 91 91 StdSize getDataSize(void) const; 92 92 93 /// Entr ᅵᅵes-sorties de champs93 /// Entrees-sorties de champs 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; … … 203 205 bool hasTransform(); 204 206 size_t getGlobalWrittenSize(void) ; 205 void getLocalMask(CArray<bool,1>& localMask) ;206 template<int N>207 void getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask) ;208 207 public: 209 208 CArray<int, 1> storeIndex_client; 209 CArray<bool, 1> storeMask_client; 210 210 211 211 /** Map containing indexes that will be sent in sendIndex(). */ … … 247 247 CArray<size_t,1> indexFromClients; 248 248 249 bool hasMask(void) const; 249 250 void checkMask(void); 250 251 void createMask(void); … … 273 274 void restoreField_arr(const CArray<double, 1>& stored, double* const data) const; 274 275 void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const; 276 void maskField_arr(const double* const data, CArray<double, 1>& stored) const; 275 277 276 278 void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); … … 372 374 template <int n> 373 375 void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const 376 TRY 374 377 { 375 378 //#ifdef __XIOS_DEBUG … … 383 386 this->storeField_arr(field.dataFirst(), stored); 384 387 } 388 CATCH 389 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 } 385 403 386 404 template <int n> 387 405 void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const 406 TRY 388 407 { 389 408 //#ifdef __XIOS_DEBUG … … 397 416 this->restoreField_arr(stored, field.dataFirst()); 398 417 } 418 CATCH 399 419 400 420 /*! … … 406 426 template <int N> 407 427 void CGrid::uncompressField(const CArray<double,N>& data, CArray<double,1>& outData) const 428 TRY 408 429 { 409 430 uncompressField_arr(data.dataFirst(), outData); 410 431 } 432 CATCH 411 433 412 434 template<int N> … … 416 438 const CArray<int,1>& axisDomainOrder, 417 439 bool createMask) 440 TRY 418 441 { 419 442 int idx = 0; … … 510 533 ++idx; 511 534 } 512 513 }535 } 536 CATCH_DUMP_ATTR 514 537 515 538 template<int N> … … 517 540 const std::vector<int>& eachDimSize, 518 541 bool newValue) 542 TRY 519 543 { 520 544 if (N != eachDimSize.size()) … … 531 555 gridMask = newValue; 532 556 } 557 CATCH_DUMP_ATTR 533 558 534 559 … … 540 565 template<int N> 541 566 void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify) 567 TRY 542 568 { 543 569 int num = indexToModify.numElements(); … … 547 573 } 548 574 } 575 CATCH_DUMP_ATTR 576 549 577 ///-------------------------------------------------------------- 550 578 551 579 552 /*!553 A grid can have multiple dimension, so can its mask in the form of multi-dimension array.554 It's not a good idea to store all multi-dimension arrays corresponding to each mask.555 One of the ways is to convert this array into 1-dimension one and every process is taken place on it.556 \param [in] multi-dimension array grid mask557 */558 template<int N>559 void CGrid::getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask)560 {561 if (gridMask.isEmpty()) return ;562 int dim = gridMask.dimensions();563 std::vector<int> dimensionSizes(dim);564 for (int i = 0; i < dim; ++i) dimensionSizes[i] = gridMask.extent(i);565 566 std::vector<int> idxLoop(dim,0);567 int ssize = gridMask.numElements(), idx = 0;568 localMask.resize(ssize);569 while (idx < ssize)570 {571 for (int i = 0; i < dim-1; ++i)572 {573 if (idxLoop[i] == dimensionSizes[i])574 {575 idxLoop[i] = 0;576 ++idxLoop[i+1];577 }578 }579 580 int maskIndex = idxLoop[0];581 int mulDim = 1;582 for (int k = 1; k < dim; ++k)583 {584 mulDim *= dimensionSizes[k-1];585 maskIndex += idxLoop[k]*mulDim;586 }587 localMask(maskIndex) = *(gridMask.dataFirst()+maskIndex);588 589 ++idxLoop[0];590 ++idx;591 }592 }593 580 594 581 // Declare/Define CGridGroup and CGridDefinition
Note: See TracChangeset
for help on using the changeset viewer.