Changeset 1642 for XIOS/dev/branch_openmp/src/node
- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- Location:
- XIOS/dev/branch_openmp/src/node
- Files:
-
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/node/axis.cpp
r1545 r1642 14 14 #include "distribution_client.hpp" 15 15 16 using namespace ep_lib;17 18 16 namespace xios { 19 17 … … 28 26 , transformationMap_(), hasValue(false), hasLabel(false) 29 27 , computedWrittenIndex_(false) 30 28 , clients() 31 29 { 32 30 } … … 40 38 , transformationMap_(), hasValue(false), hasLabel(false) 41 39 , computedWrittenIndex_(false) 42 40 , clients() 43 41 { 44 42 } … … 47 45 { /* Ne rien faire de plus */ } 48 46 49 std::map<StdString, ETranformationType> *CAxis::transformationMapList_ptr = 0;50 47 std::map<StdString, ETranformationType> CAxis::transformationMapList_ = std::map<StdString, ETranformationType>(); 48 bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_); 51 49 bool CAxis::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 50 TRY 52 51 { 53 52 m["zoom_axis"] = TRANS_ZOOM_AXIS; 54 53 m["interpolate_axis"] = TRANS_INTERPOLATE_AXIS; 54 m["extract_axis"] = TRANS_EXTRACT_AXIS; 55 55 m["inverse_axis"] = TRANS_INVERSE_AXIS; 56 56 m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_AXIS; … … 59 59 m["temporal_splitting"] = TRANS_TEMPORAL_SPLITTING; 60 60 m["duplicate_scalar"] = TRANS_DUPLICATE_SCALAR_TO_AXIS; 61 } 62 63 bool CAxis::initializeTransformationMap() 64 { 65 if(CAxis::transformationMapList_ptr == 0) CAxis::transformationMapList_ptr = new std::map<StdString, ETranformationType>(); 66 (*CAxis::transformationMapList_ptr)["zoom_axis"] = TRANS_ZOOM_AXIS; 67 (*CAxis::transformationMapList_ptr)["interpolate_axis"] = TRANS_INTERPOLATE_AXIS; 68 (*CAxis::transformationMapList_ptr)["inverse_axis"] = TRANS_INVERSE_AXIS; 69 (*CAxis::transformationMapList_ptr)["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_AXIS; 70 (*CAxis::transformationMapList_ptr)["extract_domain"] = TRANS_EXTRACT_DOMAIN_TO_AXIS; 71 (*CAxis::transformationMapList_ptr)["reduce_axis"] = TRANS_REDUCE_AXIS_TO_AXIS; 72 (*CAxis::transformationMapList_ptr)["temporal_splitting"] = TRANS_TEMPORAL_SPLITTING; 73 (*CAxis::transformationMapList_ptr)["duplicate_scalar"] = TRANS_DUPLICATE_SCALAR_TO_AXIS; 74 } 61 62 } 63 CATCH 75 64 76 65 ///--------------------------------------------------------------- 77 66 78 67 const std::set<StdString> & CAxis::getRelFiles(void) const 68 TRY 79 69 { 80 70 return (this->relFiles); 81 71 } 72 CATCH 82 73 83 74 bool CAxis::IsWritten(const StdString & filename) const 75 TRY 84 76 { 85 77 return (this->relFiles.find(filename) != this->relFiles.end()); 86 78 } 79 CATCH 87 80 88 81 bool CAxis::isWrittenCompressed(const StdString& filename) const 82 TRY 89 83 { 90 84 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 91 85 } 86 CATCH 92 87 93 88 bool CAxis::isDistributed(void) const 89 TRY 94 90 { 95 91 bool distributed = (!this->begin.isEmpty() && !this->n.isEmpty() && (this->begin + this->n < this->n_glo)) || 96 92 (!this->n.isEmpty() && (this->n != this->n_glo)); 97 // A same stupidcondition to make sure that if there is only one client, axis93 // A condition to make sure that if there is only one client, axis 98 94 // should be considered to be distributed. This should be a temporary solution 99 95 distributed |= (1 == CContext::getCurrent()->client->clientSize); 100 96 return distributed; 101 97 } 98 CATCH 102 99 103 100 /*! … … 107 104 */ 108 105 bool CAxis::isCompressible(void) const 106 TRY 109 107 { 110 108 return isCompressible_; 111 109 } 110 CATCH 112 111 113 112 void CAxis::addRelFile(const StdString & filename) 113 TRY 114 114 { 115 115 this->relFiles.insert(filename); 116 116 } 117 CATCH_DUMP_ATTR 117 118 118 119 void CAxis::addRelFileCompressed(const StdString& filename) 120 TRY 119 121 { 120 122 this->relFilesCompressed.insert(filename); 121 123 } 124 CATCH_DUMP_ATTR 122 125 123 126 //---------------------------------------------------------------- … … 128 131 */ 129 132 int CAxis::getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 133 TRY 130 134 { 131 135 int writtenSize; … … 133 137 return numberWrittenIndexes_[writtenSize]; 134 138 } 139 CATCH_DUMP_ATTR 135 140 136 141 /*! … … 139 144 */ 140 145 int CAxis::getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 146 TRY 141 147 { 142 148 int writtenSize; … … 144 150 return totalNumberWrittenIndexes_[writtenSize]; 145 151 } 152 CATCH_DUMP_ATTR 146 153 147 154 /*! … … 150 157 */ 151 158 int CAxis::getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom) 159 TRY 152 160 { 153 161 int writtenSize; … … 155 163 return offsetWrittenIndexes_[writtenSize]; 156 164 } 165 CATCH_DUMP_ATTR 157 166 158 167 CArray<int, 1>& CAxis::getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom) 168 TRY 159 169 { 160 170 int writtenSize; … … 162 172 return compressedIndexToWriteOnServer[writtenSize]; 163 173 } 174 CATCH_DUMP_ATTR 175 164 176 //---------------------------------------------------------------- 165 177 … … 171 183 std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 172 184 CServerDistributionDescription::ServerDistributionType distType) 185 TRY 173 186 { 174 187 … … 234 247 } 235 248 } 236 237 249 return attributesSizes; 238 250 } 251 CATCH_DUMP_ATTR 239 252 240 253 //---------------------------------------------------------------- … … 247 260 248 261 CAxis* CAxis::createAxis() 262 TRY 249 263 { 250 264 CAxis* axis = CAxisGroup::get("axis_definition")->createChild(); 251 265 return axis; 252 266 } 267 CATCH 253 268 254 269 /*! … … 257 272 */ 258 273 void CAxis::checkAttributes(void) 259 { 260 if (this->n_glo.isEmpty()) 274 TRY 275 { 276 CContext* context=CContext::getCurrent(); 277 278 if (this->n_glo.isEmpty()) 261 279 ERROR("CAxis::checkAttributes(void)", 262 280 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " … … 298 316 } 299 317 300 // Remove this check because it doen't make sense in case of a hole or overlapping axes301 318 if (!this->value.isEmpty()) 302 319 { 303 // StdSize true_size = value.numElements(); 304 // if (this->n.getValue() != true_size) 305 // ERROR("CAxis::checkAttributes(void)", 306 // << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 307 // << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 320 // Avoid this check at writing because it fails in case of a hole 321 if (context->hasClient) 322 { 323 StdSize true_size = value.numElements(); 324 if (this->n.getValue() != true_size) 325 ERROR("CAxis::checkAttributes(void)", 326 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 327 << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size 328 << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 329 } 308 330 this->hasValue = true; 309 331 } … … 311 333 this->checkBounds(); 312 334 313 CContext* context=CContext::getCurrent();314 335 if (context->hasClient) 315 336 { 337 this->checkMask(); 316 338 this->checkData(); 317 this->checkZoom();318 this->checkMask();319 339 this->checkLabel(); 320 340 } 321 341 } 342 CATCH_DUMP_ATTR 322 343 323 344 /*! 324 Check the validity of data and fill in values if any.345 Check the validity of data, fill in values if any, and apply mask. 325 346 */ 326 347 void CAxis::checkData() 348 TRY 327 349 { 328 350 if (data_begin.isEmpty()) data_begin.setValue(0); … … 342 364 { 343 365 data_index.resize(data_n); 344 for (int i = 0; i < data_n; ++i) data_index(i) = i; 345 } 346 } 347 348 /*! 349 Check validity of zoom info and fill in values if any. 350 */ 351 void CAxis::checkZoom(void) 352 { 353 if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 354 if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 355 if (zoom_index.isEmpty()) 356 { 357 zoom_index.setValue(index.getValue()); 358 } 359 if (zoom_n.isEmpty()) zoom_n.setValue(n); 360 if (zoom_begin.isEmpty()) zoom_begin.setValue(begin); 361 } 366 for (int i = 0; i < data_n; ++i) 367 { 368 if ((i+data_begin) >= 0 && (i+data_begin<n)) 369 { 370 if (mask(i+data_begin)) 371 data_index(i) = i+data_begin; 372 else 373 data_index(i) = -1; 374 } 375 else 376 data_index(i) = -1; 377 } 378 } 379 else 380 { 381 if (data_index.numElements() != data_n) 382 { 383 ERROR("CAxis::checkData(void)", 384 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 385 << "The size of data_index = "<< data_index.numElements() << "is not equal to the data size data_n = " << data_n.getValue() << ")."); 386 } 387 for (int i = 0; i < data_n; ++i) 388 { 389 if ((i+data_begin) >= 0 && (i+data_begin<n) && !mask(i+data_begin)) 390 data_index(i) = -1; 391 } 392 } 393 394 } 395 CATCH_DUMP_ATTR 362 396 363 397 size_t CAxis::getGlobalWrittenSize(void) 364 398 { 365 if (zoomByIndex()) return global_zoom_index.numElements(); 366 else return global_zoom_n ; 399 return n_glo ; 367 400 } 368 401 … … 371 404 */ 372 405 void CAxis::checkMask() 406 TRY 373 407 { 374 408 if (!mask.isEmpty()) 375 409 { 376 377 ERROR("CAxis::checkMask(void)",378 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] "379 << "The mask does not have the same size as the local domain." << std::endl380 << "Local size is " << n.getValue() << "." << std::endl381 << "Mask size is " << mask.extent(0) << ".");382 }383 else // (mask.isEmpty())384 { // If no mask was defined, we create a default one without any masked point.385 mask.resize(n);386 for (int i = 0; i < n; ++i)387 {388 mask(i)= true;389 390 391 }410 if (mask.extent(0) != n) 411 { 412 ERROR("CAxis::checkMask(void)", 413 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 414 << "The mask does not have the same size as the local domain." << std::endl 415 << "Local size is " << n.getValue() << "." << std::endl 416 << "Mask size is " << mask.extent(0) << "."); 417 } 418 } 419 else 420 { 421 mask.resize(n); 422 mask = true; 423 } 424 } 425 CATCH_DUMP_ATTR 392 426 393 427 /*! … … 395 429 */ 396 430 void CAxis::checkBounds() 431 TRY 397 432 { 398 433 if (!bounds.isEmpty()) … … 407 442 else hasBounds = false; 408 443 } 444 CATCH_DUMP_ATTR 409 445 410 446 void CAxis::checkLabel() 447 TRY 411 448 { 412 449 if (!label.isEmpty()) … … 421 458 else hasLabel = false; 422 459 } 460 CATCH_DUMP_ATTR 423 461 424 462 /*! … … 426 464 */ 427 465 void CAxis::checkEligibilityForCompressedOutput() 466 TRY 428 467 { 429 468 // We don't check if the mask is valid here, just if a mask has been defined at this point. 430 469 isCompressible_ = !mask.isEmpty(); 431 470 } 432 433 /* 434 Check whether we do zooming by indexing 435 return true if do zooming by index 436 */ 437 bool CAxis::zoomByIndex() 438 { 439 return (!global_zoom_index.isEmpty() && (0 != global_zoom_index.numElements())); 440 } 471 CATCH_DUMP_ATTR 441 472 442 473 /*! … … 444 475 */ 445 476 bool CAxis::dispatchEvent(CEventServer& event) 477 TRY 446 478 { 447 479 if (SuperClass::dispatchEvent(event)) return true; … … 469 501 } 470 502 } 503 CATCH 471 504 472 505 /*! … … 474 507 */ 475 508 void CAxis::checkAttributesOnClient() 509 TRY 476 510 { 477 511 if (this->areClientAttributesChecked_) return; … … 482 516 this->areClientAttributesChecked_ = true; 483 517 } 518 CATCH_DUMP_ATTR 484 519 485 520 /* … … 489 524 void CAxis::checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, 490 525 CServerDistributionDescription::ServerDistributionType distType) 526 TRY 491 527 { 492 528 CContext* context=CContext::getCurrent() ; … … 502 538 this->isClientAfterTransformationChecked = true; 503 539 } 540 CATCH_DUMP_ATTR 504 541 505 542 /* … … 512 549 void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 513 550 CServerDistributionDescription::ServerDistributionType distType) 551 TRY 514 552 { 515 553 if (!this->areClientAttributesChecked_) checkAttributesOnClient(); … … 522 560 this->isChecked = true; 523 561 } 562 CATCH_DUMP_ATTR 524 563 525 564 /*! … … 530 569 void CAxis::sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 531 570 CServerDistributionDescription::ServerDistributionType distType) 571 TRY 532 572 { 533 573 sendDistributionAttribute(globalDim, orderPositionInGrid, distType); … … 544 584 } 545 585 } 586 CATCH_DUMP_ATTR 546 587 547 588 /* … … 555 596 void CAxis::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, 556 597 CServerDistributionDescription::ServerDistributionType distType) 598 TRY 557 599 { 558 600 CContext* context = CContext::getCurrent(); … … 574 616 size_t ni = this->n.getValue(); 575 617 size_t ibegin = this->begin.getValue(); 576 size_t global_zoom_end = global_zoom_begin+global_zoom_n-1;577 size_t nZoomCount = 0;578 618 size_t nbIndex = index.numElements(); 579 619 … … 588 628 589 629 // Calculate the compressed index if any 590 std::set<int> writtenInd; 591 if (isCompressible_) 592 { 593 for (int idx = 0; idx < data_index.numElements(); ++idx) 594 { 595 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 596 597 if (ind >= 0 && ind < ni && mask(ind)) 598 { 599 ind += ibegin; 600 if (ind >= global_zoom_begin && ind <= global_zoom_end) 601 writtenInd.insert(ind); 602 } 603 } 604 } 630 // std::set<int> writtenInd; 631 // if (isCompressible_) 632 // { 633 // for (int idx = 0; idx < data_index.numElements(); ++idx) 634 // { 635 // int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 636 // 637 // if (ind >= 0 && ind < ni && mask(ind)) 638 // { 639 // ind += ibegin; 640 // writtenInd.insert(ind); 641 // } 642 // } 643 // } 605 644 606 645 // Compute the global index of the current client (process) hold … … 635 674 636 675 CServerDistributionDescription serverDescription(nGlobAxis, nbServer, distType); 637 676 638 677 std::vector<int> serverZeroIndex; 639 678 serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0); … … 654 693 if (distType==CServerDistributionDescription::ROOT_DISTRIBUTION) 655 694 { 656 for(int i=1; i<nbServer; ++i) 657 { 658 indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ; 659 } 660 695 for(int i=1; i<nbServer; ++i) indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ; 661 696 serverZeroIndexLeader.clear() ; 662 697 } 663 698 664 699 CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_[nbServer].begin(), 665 700 ite = indSrv_[nbServer].end(); … … 675 710 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 676 711 677 712 nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 678 713 679 714 delete clientServerMap; … … 681 716 } 682 717 } 718 CATCH_DUMP_ATTR 683 719 684 720 /* … … 688 724 */ 689 725 void CAxis::computeWrittenIndex() 726 TRY 690 727 { 691 728 if (computedWrittenIndex_) return; … … 697 734 // We describe the distribution of client (server) on which data are written 698 735 std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 699 nBegin[0] = zoom_begin;700 nSize[0] = zoom_n;736 nBegin[0] = begin; 737 nSize[0] = n; 701 738 nBeginGlobal[0] = 0; 702 739 nGlob[0] = n_glo; … … 711 748 CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 712 749 itSrve = writtenGlobalIndex.end(), itSrv; 713 if (!zoomByIndex()) 714 { 715 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 716 { 717 indGlo = *itSrv; 718 if (ite != globalLocalIndexMap_.find(indGlo)) 719 { 720 ++nbWritten; 721 } 722 } 723 724 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 725 // localIndexToWriteOnServer.resize(nbWritten); 726 727 nbWritten = 0; 728 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 729 { 730 indGlo = *itSrv; 731 if (ite != globalLocalIndexMap_.find(indGlo)) 732 { 733 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 734 ++nbWritten; 735 } 736 } 737 } 738 else 739 { 740 nbWritten = 0; 741 std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 742 ite = globalLocalIndexMap_.end(), it; 743 for (int i = 0; i < zoom_index.numElements(); ++i) 744 { 745 if (ite != globalLocalIndexMap_.find(zoom_index(i))) 746 ++nbWritten; 747 } 748 749 localIndexToWriteOnServer.resize(nbWritten); 750 751 nbWritten = 0; 752 for (int i = 0; i < zoom_index.numElements(); ++i) 753 { 754 if (ite != globalLocalIndexMap_.find(zoom_index(i))) 755 { 756 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[zoom_index(i)]; 757 ++nbWritten; 758 } 759 } 760 } 761 762 } 750 751 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 752 nbWritten = 0; 753 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 754 { 755 indGlo = *itSrv; 756 if (ite != globalLocalIndexMap_.find(indGlo)) 757 { 758 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 759 } 760 else 761 { 762 localIndexToWriteOnServer(nbWritten) = -1; 763 } 764 ++nbWritten; 765 } 766 767 } 768 CATCH_DUMP_ATTR 763 769 764 770 void CAxis::computeWrittenCompressedIndex(ep_lib::MPI_Comm writtenComm) 771 TRY 765 772 { 766 773 int writtenCommSize; … … 777 784 // We describe the distribution of client (server) on which data are written 778 785 std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 779 nBegin[0] = zoom_begin;780 nSize[0] = zoom_n;786 nBegin[0] = 0; 787 nSize[0] = n; 781 788 nBeginGlobal[0] = 0; 782 789 nGlob[0] = n_glo; … … 798 805 } 799 806 } 807 // 808 // nbWritten = 0; 809 // for (int idx = 0; idx < data_index.numElements(); ++idx) 810 // { 811 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 812 // { 813 // ++nbWritten; 814 // } 815 // } 816 // 817 // compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); 818 // nbWritten = 0; 819 // for (int idx = 0; idx < data_index.numElements(); ++idx) 820 // { 821 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 822 // { 823 // compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)]; 824 // ++nbWritten; 825 // } 826 // } 800 827 801 828 nbWritten = 0; … … 823 850 { 824 851 825 ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm);826 ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm);852 ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 853 ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 827 854 offsetWrittenIndexes_[writtenCommSize] -= numberWrittenIndexes_[writtenCommSize]; 828 855 } … … 831 858 } 832 859 } 860 CATCH_DUMP_ATTR 833 861 834 862 /*! … … 841 869 void CAxis::sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid, 842 870 CServerDistributionDescription::ServerDistributionType distType) 871 TRY 843 872 { 844 873 std::list<CContextClient*>::iterator it; … … 865 894 const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 866 895 const int ni = serverDimensionSizes[*itRank][orderPositionInGrid]; 867 const int end = begin + ni - 1;868 896 869 897 msgs.push_back(CMessage()); 870 898 CMessage& msg = msgs.back(); 871 899 msg << this->getId(); 872 msg << ni << begin << end;900 msg << ni << begin; 873 901 msg << isCompressible_; 874 902 … … 880 908 } 881 909 } 910 CATCH_DUMP_ATTR 882 911 883 912 /* … … 886 915 */ 887 916 void CAxis::recvDistributionAttribute(CEventServer& event) 917 TRY 888 918 { 889 919 CBufferIn* buffer = event.subEvents.begin()->buffer; … … 892 922 get(axisId)->recvDistributionAttribute(*buffer); 893 923 } 924 CATCH 894 925 895 926 /* … … 898 929 */ 899 930 void CAxis::recvDistributionAttribute(CBufferIn& buffer) 900 { 901 int ni_srv, begin_srv, end_srv; 902 int global_zoom_end, zoom_end; 903 bool zoomIndex = zoomByIndex(); 904 905 std::vector<int> zoom_index_tmp; 906 std::vector<int>::iterator itZoomBegin, itZoomEnd, itZoom; 907 908 buffer >> ni_srv >> begin_srv >> end_srv; 931 TRY 932 { 933 int ni_srv, begin_srv; 934 buffer >> ni_srv >> begin_srv; 909 935 buffer >> isCompressible_; 910 936 … … 912 938 n.setValue(ni_srv); 913 939 begin.setValue(begin_srv); 914 915 // If we have zoom by index then process it 916 if (zoomIndex) 917 { 918 zoom_index_tmp.resize(global_zoom_index.numElements()); 919 std::copy(global_zoom_index.begin(), global_zoom_index.end(), zoom_index_tmp.begin()); 920 std::sort(zoom_index_tmp.begin(), zoom_index_tmp.end()); 921 itZoomBegin = std::lower_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), begin_srv); 922 itZoomEnd = std::upper_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), end_srv); 923 int sz = std::distance(itZoomBegin, itZoomEnd); 924 zoom_index.resize(sz); 925 itZoom = itZoomBegin; 926 for (int i = 0; i < sz; ++i, ++itZoom) 927 { 928 zoom_index(i) = *(itZoom); 929 } 930 } 931 932 global_zoom_begin = zoomIndex ? 0 : global_zoom_begin ; 933 global_zoom_n = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 934 global_zoom_end = global_zoom_begin + global_zoom_n - 1; 935 936 zoom_begin = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomBegin) 937 : global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 938 zoom_end = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomEnd) - 1 939 : global_zoom_end < end_srv ? global_zoom_end : end_srv ; 940 zoom_n = zoom_end - zoom_begin + 1; 941 942 if (zoom_n<=0) 943 { 944 zoom_n = 0; zoom_begin=global_zoom_begin; //0; zoom_begin = 0; 945 } 946 947 if (n_glo == n) 948 { 949 zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 950 : global_zoom_begin; 951 zoom_n = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 952 } 953 } 940 } 941 CATCH_DUMP_ATTR 954 942 955 943 /* … … 959 947 */ 960 948 void CAxis::sendNonDistributedAttributes() 949 TRY 961 950 { 962 951 std::list<CContextClient*>::iterator it; 963 952 for (it=clients.begin(); it!=clients.end(); ++it) 964 965 953 { 954 CContextClient* client = *it; 966 955 967 956 CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); … … 1012 1001 } 1013 1002 } 1003 CATCH_DUMP_ATTR 1014 1004 1015 1005 /* … … 1018 1008 */ 1019 1009 void CAxis::recvNonDistributedAttributes(CEventServer& event) 1010 TRY 1020 1011 { 1021 1012 list<CEventServer::SSubEvent>::iterator it; … … 1028 1019 } 1029 1020 } 1021 CATCH 1030 1022 1031 1023 /* … … 1035 1027 */ 1036 1028 void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer) 1029 TRY 1037 1030 { 1038 CArray<int,1> tmp_index, tmp_data_index , tmp_zoom_index;1031 CArray<int,1> tmp_index, tmp_data_index; 1039 1032 CArray<bool,1> tmp_mask; 1040 1033 CArray<double,1> tmp_val; … … 1076 1069 for (int idx = 0; idx < index.numElements(); ++idx) globalLocalIndexMap_[index(idx)] = idx; 1077 1070 } 1071 CATCH_DUMP_ATTR 1078 1072 1079 1073 /* 1080 Send a ttributes of axis from a group of client to other group of clients/servers1081 onsupposing that these attributes are distributed among the clients of the sending group1082 In thefuture, if new attributes are added, they should also be processed in this function1074 Send axis attributes from a group of clients to another group of clients/servers 1075 supposing that these attributes are distributed among the clients of the sending group 1076 In future, if new attributes are added, they should also be processed in this function 1083 1077 */ 1084 1078 void CAxis::sendDistributedAttributes(void) 1085 { 1086 int ns, n, i, j, ind, nv, idx; 1079 TRY 1080 { 1081 int ind, idx; 1087 1082 std::list<CContextClient*>::iterator it; 1088 1083 … … 1095 1090 1096 1091 list<CMessage> listData; 1097 list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd; 1098 list<CArray<bool,1> > list_mask; 1092 list<CArray<int,1> > list_indi, list_dataInd; 1099 1093 list<CArray<double,1> > list_val; 1100 1094 list<CArray<double,2> > list_bounds; 1101 1095 list<CArray<string,1> > list_label; 1102 1096 1097 // Cut off the ghost points 1103 1098 int nbIndex = index.numElements(); 1104 1099 CArray<int,1> dataIndex(nbIndex); … … 1107 1102 { 1108 1103 if (0 <= data_index(idx) && data_index(idx) < nbIndex) 1109 dataIndex( idx) = 1;1104 dataIndex(data_index(idx)) = 1; 1110 1105 } 1111 1106 … … 1114 1109 for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 1115 1110 { 1116 int nbData = 0 ;1111 int nbData = 0, nbDataCount = 0; 1117 1112 int rank = connectedServerRank_[nbServer][k]; 1118 1113 it = indSrv_[nbServer].find(rank); … … 1121 1116 1122 1117 list_indi.push_back(CArray<int,1>(nbData)); 1123 list_dataInd.push_back(CArray<int,1>(nbData)); 1124 list_mask.push_back(CArray<bool,1>(nbData)); 1118 list_dataInd.push_back(CArray<int,1>(nbData)); 1125 1119 1126 1120 if (hasValue) … … 1134 1128 1135 1129 CArray<int,1>& indi = list_indi.back(); 1136 CArray<int,1>& dataIndi = list_dataInd.back(); 1137 CArray<bool,1>& maskIndi = list_mask.back();1138 1139 for ( n = 0; n < nbData; ++n)1130 CArray<int,1>& dataIndi = list_dataInd.back(); 1131 dataIndi = -1; 1132 1133 for (int n = 0; n < nbData; ++n) 1140 1134 { 1141 1135 idx = static_cast<int>(it->second[n]); … … 1144 1138 ind = globalLocalIndexMap_[idx]; 1145 1139 dataIndi(n) = dataIndex(ind); 1146 maskIndi(n) = mask(ind);1147 1140 1148 1141 if (hasValue) … … 1168 1161 listData.push_back(CMessage()); 1169 1162 listData.back() << this->getId() 1170 << list_indi.back() << list_dataInd.back() << list_mask.back();1163 << list_indi.back() << list_dataInd.back(); 1171 1164 1172 1165 listData.back() << hasValue; … … 1188 1181 } 1189 1182 } 1183 CATCH_DUMP_ATTR 1190 1184 1191 1185 /* … … 1194 1188 */ 1195 1189 void CAxis::recvDistributedAttributes(CEventServer& event) 1190 TRY 1196 1191 { 1197 1192 string axisId; … … 1209 1204 get(axisId)->recvDistributedAttributes(ranks, buffers); 1210 1205 } 1206 CATCH 1211 1207 1212 1208 /* … … 1216 1212 */ 1217 1213 void CAxis::recvDistributedAttributes(vector<int>& ranks, vector<CBufferIn*> buffers) 1214 TRY 1218 1215 { 1219 1216 int nbReceived = ranks.size(), idx, ind, gloInd, locInd; 1220 vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived), vec_zoomInd(nbReceived); 1221 vector<CArray<bool,1> > vec_mask(nbReceived); 1217 vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived); 1222 1218 vector<CArray<double,1> > vec_val(nbReceived); 1223 1219 vector<CArray<double,2> > vec_bounds(nbReceived); … … 1229 1225 buffer >> vec_indi[idx]; 1230 1226 buffer >> vec_dataInd[idx]; 1231 buffer >> vec_mask[idx];1232 1227 1233 1228 buffer >> hasValue; … … 1256 1251 globalLocalIndexMap_.rehash(std::ceil(index.numElements()/globalLocalIndexMap_.max_load_factor())); 1257 1252 nbIndexGlob = 0; 1253 int nbIndLoc = 0; 1258 1254 for (idx = 0; idx < nbReceived; ++idx) 1259 1255 { … … 1262 1258 { 1263 1259 gloInd = tmp(ind); 1260 nbIndLoc = (gloInd % n_glo)-begin; 1264 1261 if (0 == globalLocalIndexMap_.count(gloInd)) 1265 1262 { 1266 index(nbIndexGlob) = gloInd % n_glo; 1267 globalLocalIndexMap_[gloInd] = nbIndexGlob; 1263 index(nbIndexGlob) = gloInd % n_glo; 1264 globalLocalIndexMap_[gloInd] = nbIndexGlob; 1268 1265 ++nbIndexGlob; 1269 1266 } … … 1278 1275 CArray<int,1> nonCompressedData(nbData); 1279 1276 nonCompressedData = -1; 1280 mask.resize(nbData); 1277 // Mask is incorporated into data_index and is not sent/received anymore 1278 mask.resize(0); 1281 1279 if (hasValue) 1282 1280 value.resize(nbData); … … 1291 1289 CArray<int,1>& indi = vec_indi[idx]; 1292 1290 CArray<int,1>& dataIndi = vec_dataInd[idx]; 1293 CArray<bool,1>& maskIndi = vec_mask[idx];1294 1291 int nb = indi.numElements(); 1295 1292 for (int n = 0; n < nb; ++n) … … 1299 1296 nonCompressedData(locInd) = (-1 == nonCompressedData(locInd)) ? dataIndi(n) : nonCompressedData(locInd); 1300 1297 1301 if (!mask(locInd)) // Only rewrite mask if it's not true1302 mask(locInd) = maskIndi(n);1303 1304 1298 if (hasValue) 1305 1299 value(locInd) = vec_val[idx](n); … … 1316 1310 } 1317 1311 1318 int nbCompressedData = 0; 1312 int nbCompressedData = 0; 1319 1313 for (idx = 0; idx < nonCompressedData.numElements(); ++idx) 1320 1314 { 1321 1315 if (0 <= nonCompressedData(idx)) 1322 ++nbCompressedData; 1316 ++nbCompressedData; 1323 1317 } 1324 1318 … … 1330 1324 { 1331 1325 data_index(nbCompressedData) = idx % n; 1332 ++nbCompressedData; 1326 ++nbCompressedData; 1333 1327 } 1334 1328 } 1335 1329 1336 1330 data_begin.setValue(0); 1337 } 1331 data_n.setValue(data_index.numElements()); 1332 } 1333 CATCH_DUMP_ATTR 1338 1334 1339 1335 /*! … … 1345 1341 */ 1346 1342 bool CAxis::isEqual(CAxis* obj) 1343 TRY 1347 1344 { 1348 1345 vector<StdString> excludedAttr; … … 1368 1365 return objEqual; 1369 1366 } 1367 CATCH_DUMP_ATTR 1370 1368 1371 1369 /* … … 1375 1373 */ 1376 1374 CTransformation<CAxis>* CAxis::addTransformation(ETranformationType transType, const StdString& id) 1375 TRY 1377 1376 { 1378 1377 transformationMap_.push_back(std::make_pair(transType, CTransformation<CAxis>::createTransformation(transType,id))); 1379 1378 return transformationMap_.back().second; 1380 1379 } 1380 CATCH_DUMP_ATTR 1381 1381 1382 1382 /* … … 1384 1384 */ 1385 1385 bool CAxis::hasTransformation() 1386 TRY 1386 1387 { 1387 1388 return (!transformationMap_.empty()); 1388 1389 } 1390 CATCH_DUMP_ATTR 1389 1391 1390 1392 /* … … 1393 1395 */ 1394 1396 void CAxis::setTransformations(const TransMapTypes& axisTrans) 1397 TRY 1395 1398 { 1396 1399 transformationMap_ = axisTrans; 1397 1400 } 1401 CATCH_DUMP_ATTR 1398 1402 1399 1403 /* … … 1402 1406 */ 1403 1407 CAxis::TransMapTypes CAxis::getAllTransformations(void) 1408 TRY 1404 1409 { 1405 1410 return transformationMap_; 1406 1411 } 1412 CATCH_DUMP_ATTR 1407 1413 1408 1414 /* … … 1411 1417 */ 1412 1418 void CAxis::duplicateTransformation(CAxis* src) 1419 TRY 1413 1420 { 1414 1421 if (src->hasTransformation()) … … 1417 1424 } 1418 1425 } 1426 CATCH_DUMP_ATTR 1419 1427 1420 1428 /*! … … 1422 1430 */ 1423 1431 void CAxis::solveInheritanceTransformation() 1432 TRY 1424 1433 { 1425 1434 if (hasTransformation() || !hasDirectAxisReference()) … … 1438 1447 refAxis[i]->setTransformations(axis->getAllTransformations()); 1439 1448 } 1449 CATCH_DUMP_ATTR 1440 1450 1441 1451 void CAxis::setContextClient(CContextClient* contextClient) 1452 TRY 1442 1453 { 1443 1454 if (clientsSet.find(contextClient)==clientsSet.end()) … … 1446 1457 clientsSet.insert(contextClient); 1447 1458 } 1448 } 1459 } 1460 CATCH_DUMP_ATTR 1449 1461 1450 1462 void CAxis::parse(xml::CXMLNode & node) 1463 TRY 1451 1464 { 1452 1465 SuperClass::parse(node); … … 1462 1475 1463 1476 nodeElementName = node.getElementName(); 1464 1465 if(transformationMapList_ptr == 0) initializeTransformationMap(); 1466 std::map<StdString, ETranformationType>::const_iterator ite = (*CAxis::transformationMapList_ptr).end(), it; 1467 it = (*CAxis::transformationMapList_ptr).find(nodeElementName); 1477 std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 1478 it = transformationMapList_.find(nodeElementName); 1468 1479 if (ite != it) 1469 1480 { … … 1481 1492 } 1482 1493 } 1494 CATCH_DUMP_ATTR 1483 1495 1484 1496 DEFINE_REF_FUNC(Axis,axis) -
XIOS/dev/branch_openmp/src/node/axis.hpp
r1545 r1642 17 17 #include "transformation_enum.hpp" 18 18 19 #include "mpi_std.hpp"20 21 19 namespace xios { 22 20 /// ////////////////////// Déclarations ////////////////////// /// … … 31 29 BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) 32 30 # include "axis_attribute.conf" 33 # include "axis_attribute_private.conf"34 31 END_DECLARE_ATTRIBUTE_MAP(CAxis) 35 32 … … 123 120 CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); 124 121 bool isEqual(CAxis* axis); 125 bool zoomByIndex();126 122 127 123 public: 128 124 bool hasValue; 129 CArray<size_t,1> localIndexToWriteOnServer; 125 bool hasBounds; 126 bool hasLabel; 127 128 CArray<int,1> localIndexToWriteOnServer; 130 129 131 130 private: 132 131 void checkData(); 133 132 void checkMask(); 134 void checkZoom();135 133 void checkBounds(); 136 134 void checkLabel(); … … 175 173 std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer; 176 174 std::map<int, std::vector<int> > connectedServerRank_; 177 bool hasBounds;178 bool hasLabel;179 175 bool computedWrittenIndex_; 180 176 181 177 private: 182 178 static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 183 static bool initializeTransformationMap(); 184 static std::map<StdString, ETranformationType> *transformationMapList_ptr; 185 #pragma omp threadprivate(transformationMapList_ptr) 179 static std::map<StdString, ETranformationType> transformationMapList_; 186 180 static bool dummyTransformationMapList_; 187 #pragma omp threadprivate(dummyTransformationMapList_)188 181 189 182 DECLARE_REF_FUNC(Axis,axis) -
XIOS/dev/branch_openmp/src/node/compute_connectivity_domain.hpp
r1331 r1642 60 60 static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CComputeConnectivityDomain 64 63 -
XIOS/dev/branch_openmp/src/node/context.cpp
r1545 r1642 21 21 #include "distribute_file_server2.hpp" 22 22 23 using namespace ep_lib;24 25 23 namespace xios { 26 24 27 std::shared_ptr<CContextGroup> * CContext::root_ptr = 0;25 std::shared_ptr<CContextGroup> CContext::root; 28 26 29 27 /// ////////////////////// Définitions ////////////////////// /// … … 35 33 , idServer_(), client(0), server(0) 36 34 , allProcessed(false), countChildCtx_(0) 35 37 36 { /* Ne rien faire de plus */ } 38 37 … … 67 66 */ 68 67 CContextGroup* CContext::getRoot(void) 69 { 70 if(root_ptr == 0) root_ptr = new std::shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 71 return root_ptr->get(); 72 } 68 TRY 69 { 70 if (root.get()==NULL) root=std::shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())); 71 return root.get(); 72 } 73 CATCH 73 74 74 75 //---------------------------------------------------------------- … … 79 80 */ 80 81 std::shared_ptr<CCalendar> CContext::getCalendar(void) const 82 TRY 81 83 { 82 84 return (this->calendar); 83 85 } 86 CATCH 84 87 85 88 //---------------------------------------------------------------- … … 90 93 */ 91 94 void CContext::setCalendar(std::shared_ptr<CCalendar> newCalendar) 95 TRY 92 96 { 93 97 this->calendar = newCalendar; 94 98 } 99 CATCH_DUMP_ATTR 95 100 96 101 //---------------------------------------------------------------- … … 100 105 */ 101 106 void CContext::parse(xml::CXMLNode & node) 107 TRY 102 108 { 103 109 CContext::SuperClass::parse(node); … … 154 160 } 155 161 } 162 CATCH_DUMP_ATTR 156 163 157 164 //---------------------------------------------------------------- 158 165 //! Show tree structure of context 159 166 void CContext::ShowTree(StdOStream & out) 167 TRY 160 168 { 161 169 StdString currentContextId = CContext::getCurrent() -> getId(); … … 178 186 CContext::setCurrent(currentContextId); 179 187 } 180 188 CATCH 181 189 182 190 //---------------------------------------------------------------- … … 184 192 //! Convert context object into string (to print) 185 193 StdString CContext::toString(void) const 194 TRY 186 195 { 187 196 StdOStringStream oss; … … 203 212 204 213 } 205 206 214 oss << "</" << CContext::GetName() << " >"; 207 208 215 return (oss.str()); 209 216 } 217 CATCH 210 218 211 219 //---------------------------------------------------------------- … … 218 226 */ 219 227 void CContext::solveDescInheritance(bool apply, const CAttributeMap * const UNUSED(parent)) 228 TRY 220 229 { 221 230 #define DECLARE_NODE(Name_, name_) \ … … 225 234 #include "node_type.conf" 226 235 } 236 CATCH_DUMP_ATTR 227 237 228 238 //---------------------------------------------------------------- … … 230 240 //! Verify if all root definition in the context have child. 231 241 bool CContext::hasChild(void) const 242 TRY 232 243 { 233 244 return ( … … 238 249 false); 239 250 } 251 CATCH 240 252 241 253 //---------------------------------------------------------------- 242 254 243 255 void CContext::CleanTree(void) 256 TRY 244 257 { 245 258 #define DECLARE_NODE(Name_, name_) C##Name_##Definition::ClearAllAttributes(); … … 247 260 #include "node_type.conf" 248 261 } 262 CATCH 263 249 264 ///--------------------------------------------------------------- 250 265 251 266 //! Initialize client side 252 267 void CContext::initClient(ep_lib::MPI_Comm intraComm, ep_lib::MPI_Comm interComm, CContext* cxtServer /*= 0*/) 268 TRY 253 269 { 254 270 … … 257 273 258 274 259 if (CServer::serverLevel != 1) // initClient is called by client 275 if (CServer::serverLevel != 1) 276 // initClient is called by client 260 277 { 261 278 client = new CContextClient(this, intraComm, interComm, cxtServer); … … 288 305 server = new CContextServer(this, intraCommServer, interCommServer); 289 306 } 290 291 else// initClient is called by primary server307 else 308 // initClient is called by primary server 292 309 { 293 310 clientPrimServer.push_back(new CContextClient(this, intraComm, interComm)); … … 299 316 } 300 317 } 318 CATCH_DUMP_ATTR 301 319 302 320 /*! … … 307 325 */ 308 326 void CContext::setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting) 327 TRY 309 328 { 310 329 // Estimated minimum event size for small events (10 is an arbitrary constant just for safety) … … 353 372 } 354 373 contextClient->setBufferSize(bufferSize, maxEventSize); 355 356 }374 } 375 CATCH_DUMP_ATTR 357 376 358 377 //! Verify whether a context is initialized 359 378 bool CContext::isInitialized(void) 379 TRY 360 380 { 361 381 return hasClient; 362 382 } 383 CATCH_DUMP_ATTR 363 384 364 385 void CContext::initServer(ep_lib::MPI_Comm intraComm, ep_lib::MPI_Comm interComm, CContext* cxtClient /*= 0*/) 386 TRY 365 387 { 366 388 hasServer=true; … … 395 417 client = new CContextClient(this,intraCommClient,interCommClient, cxtClient); 396 418 } 419 CATCH_DUMP_ATTR 397 420 398 421 //! Try to send the buffers and receive possible answers 399 422 bool CContext::checkBuffersAndListen(bool enableEventsProcessing /*= true*/) 423 TRY 400 424 { 401 425 bool clientReady, serverFinished; … … 435 459 } 436 460 } 461 CATCH_DUMP_ATTR 437 462 438 463 //! Terminate a context 439 464 void CContext::finalize(void) 465 TRY 440 466 { 441 467 if (hasClient && !hasServer) // For now we only use server level 1 to read data … … 480 506 comms.clear(); 481 507 482 #pragma omp critical (_output)483 508 info(20)<<"CContext: Context <"<<getId()<<"> is finalized."<<endl; 484 509 } … … 496 521 { 497 522 // Blocking send of context finalize message to its client (e.g. primary server or model) 498 #pragma omp critical (_output)499 523 info(100)<<"DEBUG: context "<<getId()<<" Send client finalize<<"<<endl ; 500 524 client->finalize(); … … 524 548 comms.clear(); 525 549 526 #pragma omp critical (_output)527 550 info(20)<<"CContext: Context <"<<getId()<<"> is finalized."<<endl; 528 551 } … … 531 554 } 532 555 } 556 CATCH_DUMP_ATTR 533 557 534 558 //! Free internally allocated communicators 535 559 void CContext::freeComms(void) 560 TRY 536 561 { 537 562 for (std::list<ep_lib::MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) … … 539 564 comms.clear(); 540 565 } 566 CATCH_DUMP_ATTR 541 567 542 568 //! Deallocate buffers allocated by clientContexts 543 569 void CContext::releaseClientBuffers(void) 570 TRY 544 571 { 545 572 client->releaseBuffers(); … … 547 574 clientPrimServer[i]->releaseBuffers(); 548 575 } 576 CATCH_DUMP_ATTR 549 577 550 578 void CContext::postProcessingGlobalAttributes() 579 TRY 551 580 { 552 581 if (allProcessed) return; … … 612 641 allProcessed = true; 613 642 } 643 CATCH_DUMP_ATTR 614 644 615 645 void CContext::sendPostProcessingGlobalAttributes() 646 TRY 616 647 { 617 648 // Use correct context client to send message … … 638 669 } 639 670 } 671 CATCH_DUMP_ATTR 640 672 641 673 void CContext::recvPostProcessingGlobalAttributes(CEventServer& event) 674 TRY 642 675 { 643 676 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 646 679 get(id)->recvPostProcessingGlobalAttributes(*buffer); 647 680 } 681 CATCH 648 682 649 683 void CContext::recvPostProcessingGlobalAttributes(CBufferIn& buffer) 684 TRY 650 685 { 651 686 postProcessingGlobalAttributes(); 652 687 } 688 CATCH_DUMP_ATTR 653 689 654 690 /*! … … 661 697 and the active fields (fields will be written onto active files) 662 698 */ 699 663 700 void CContext::closeDefinition(void) 701 TRY 664 702 { 665 703 CTimer::get("Context : close definition").resume() ; … … 692 730 CTimer::get("Context : close definition").suspend() ; 693 731 } 732 CATCH_DUMP_ATTR 694 733 695 734 void CContext::findAllEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles) 735 TRY 696 736 { 697 737 for (unsigned int i = 0; i < activeFiles.size(); i++) 698 738 (void)activeFiles[i]->getEnabledFields(); 699 739 } 740 CATCH_DUMP_ATTR 700 741 701 742 void CContext::readAttributesOfEnabledFieldsInReadModeFiles() 743 TRY 702 744 { 703 745 for (unsigned int i = 0; i < this->enabledReadModeFiles.size(); ++i) 704 746 (void)this->enabledReadModeFiles[i]->readAttributesOfEnabledFieldsInReadMode(); 705 747 } 748 CATCH_DUMP_ATTR 706 749 707 750 void CContext::sendGridComponentEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles) 751 TRY 708 752 { 709 753 int size = activeFiles.size(); … … 713 757 } 714 758 } 759 CATCH_DUMP_ATTR 715 760 716 761 /*! … … 719 764 */ 720 765 void CContext::sendGridEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles) 766 TRY 721 767 { 722 768 int size = activeFiles.size(); … … 726 772 } 727 773 } 774 CATCH_DUMP_ATTR 728 775 729 776 void CContext::checkGridEnabledFields() 777 TRY 730 778 { 731 779 int size = enabledFiles.size(); … … 735 783 } 736 784 } 785 CATCH_DUMP_ATTR 737 786 738 787 /*! … … 741 790 */ 742 791 void CContext::checkGridEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles) 792 TRY 743 793 { 744 794 int size = activeFiles.size(); … … 748 798 } 749 799 } 800 CATCH_DUMP_ATTR 750 801 751 802 /*! … … 755 806 */ 756 807 void CContext::solveOnlyRefOfEnabledFields(bool sendToServer) 808 TRY 757 809 { 758 810 int size = this->enabledFiles.size(); … … 767 819 } 768 820 } 821 CATCH_DUMP_ATTR 769 822 770 823 /*! … … 775 828 */ 776 829 void CContext::solveAllRefOfEnabledFieldsAndTransform(bool sendToServer) 830 TRY 777 831 { 778 832 int size = this->enabledFiles.size(); … … 782 836 } 783 837 } 838 CATCH_DUMP_ATTR 784 839 785 840 void CContext::buildFilterGraphOfEnabledFields() 841 TRY 786 842 { 787 843 int size = this->enabledFiles.size(); … … 791 847 } 792 848 } 849 CATCH_DUMP_ATTR 793 850 794 851 void CContext::postProcessFilterGraph() 852 TRY 795 853 { 796 854 int size = enabledFiles.size(); … … 800 858 } 801 859 } 860 CATCH_DUMP_ATTR 802 861 803 862 void CContext::startPrefetchingOfEnabledReadModeFiles() 863 TRY 804 864 { 805 865 int size = enabledReadModeFiles.size(); … … 809 869 } 810 870 } 871 CATCH_DUMP_ATTR 811 872 812 873 void CContext::doPreTimestepOperationsForEnabledReadModeFiles() 874 TRY 813 875 { 814 876 int size = enabledReadModeFiles.size(); … … 818 880 } 819 881 } 882 CATCH_DUMP_ATTR 820 883 821 884 void CContext::doPostTimestepOperationsForEnabledReadModeFiles() 885 TRY 822 886 { 823 887 int size = enabledReadModeFiles.size(); … … 827 891 } 828 892 } 893 CATCH_DUMP_ATTR 829 894 830 895 void CContext::findFieldsWithReadAccess(void) 896 TRY 831 897 { 832 898 fieldsWithReadAccess.clear(); … … 842 908 } 843 909 } 910 CATCH_DUMP_ATTR 844 911 845 912 void CContext::solveAllRefOfFieldsWithReadAccess() 913 TRY 846 914 { 847 915 for (size_t i = 0; i < fieldsWithReadAccess.size(); ++i) 848 916 fieldsWithReadAccess[i]->solveAllReferenceEnabledField(false); 849 917 } 918 CATCH_DUMP_ATTR 850 919 851 920 void CContext::buildFilterGraphOfFieldsWithReadAccess() 921 TRY 852 922 { 853 923 for (size_t i = 0; i < fieldsWithReadAccess.size(); ++i) 854 924 fieldsWithReadAccess[i]->buildFilterGraph(garbageCollector, true); 855 925 } 926 CATCH_DUMP_ATTR 856 927 857 928 void CContext::solveAllInheritance(bool apply) 929 TRY 858 930 { 859 931 // Résolution des héritages descendants (cà d des héritages de groupes) … … 878 950 879 951 } 952 CATCH_DUMP_ATTR 880 953 881 954 void CContext::findEnabledFiles(void) 955 TRY 882 956 { 883 957 const std::vector<CFile*> allFiles = CFile::getAll(); … … 928 1002 929 1003 } 1004 CATCH_DUMP_ATTR 930 1005 931 1006 void CContext::distributeFiles(void) 1007 TRY 932 1008 { 933 1009 bool distFileMemory=false ; … … 937 1013 else distributeFileOverBandwith() ; 938 1014 } 939 1015 CATCH_DUMP_ATTR 940 1016 941 1017 void CContext::distributeFileOverBandwith(void) 1018 TRY 942 1019 { 943 1020 double eps=std::numeric_limits<double>::epsilon()*10 ; … … 1006 1083 } 1007 1084 1008 for (std::multimap<double,int>:: iterator it=poolDataSize.begin() ; it!=poolDataSize.end(); ++it) 1009 { 1010 #pragma omp critical (_output) 1011 info(30)<<"Load Balancing for servers (perfect=1) : "<<it->second<<" : ratio "<<it->first*1./dataPerPool<<endl ; 1012 } 1013 1085 for (std::multimap<double,int>:: iterator it=poolDataSize.begin() ; it!=poolDataSize.end(); ++it) info(30)<<"Load Balancing for servers (perfect=1) : "<<it->second<<" : ratio "<<it->first*1./dataPerPool<<endl ; 1086 1014 1087 for (int i = 0; i < this->enabledReadModeFiles.size(); ++i) 1015 1088 { … … 1023 1096 } 1024 1097 } 1098 CATCH_DUMP_ATTR 1025 1099 1026 1100 void CContext::distributeFileOverMemoryBandwith(void) 1101 TRY 1027 1102 { 1028 1103 // If primary server … … 1099 1174 } 1100 1175 1101 for (int i = 0; i < nbPools; ++i) 1102 { 1103 #pragma omp critical (_output) 1104 info(100)<<"Pool server level2 "<<i<<" assigned file bandwith "<<bandwithSize[i]*86400.*4./1024/1024.<<" Mb / days"<<endl ; 1105 } 1106 for (int i = 0; i < nbPools; ++i) 1107 { 1108 #pragma omp critical (_output) 1109 info(100)<<"Pool server level2 "<<i<<" assigned grid memory "<<memorySize[i]*100/1024./1024.<<" Mb"<<endl ; 1110 } 1176 for (int i = 0; i < nbPools; ++i) info(100)<<"Pool server level2 "<<i<<" assigned file bandwith "<<bandwithSize[i]*86400.*4./1024/1024.<<" Mb / days"<<endl ; 1177 for (int i = 0; i < nbPools; ++i) info(100)<<"Pool server level2 "<<i<<" assigned grid memory "<<memorySize[i]*100/1024./1024.<<" Mb"<<endl ; 1178 1111 1179 1112 1180 for (int i = 0; i < this->enabledReadModeFiles.size(); ++i) … … 1122 1190 } 1123 1191 } 1124 1125 1192 CATCH_DUMP_ATTR 1126 1193 1127 1194 /*! … … 1129 1196 */ 1130 1197 void CContext::findEnabledWriteModeFiles(void) 1198 TRY 1131 1199 { 1132 1200 int size = this->enabledFiles.size(); … … 1138 1206 } 1139 1207 } 1208 CATCH_DUMP_ATTR 1140 1209 1141 1210 /*! … … 1143 1212 */ 1144 1213 void CContext::findEnabledReadModeFiles(void) 1214 TRY 1145 1215 { 1146 1216 int size = this->enabledFiles.size(); … … 1151 1221 } 1152 1222 } 1223 CATCH_DUMP_ATTR 1153 1224 1154 1225 void CContext::closeAllFile(void) 1226 TRY 1155 1227 { 1156 1228 std::vector<CFile*>::const_iterator … … 1159 1231 for (; it != end; it++) 1160 1232 { 1161 #pragma omp critical (_output)1162 1233 info(30)<<"Closing File : "<<(*it)->getId()<<endl; 1163 1234 (*it)->close(); 1164 1235 } 1165 1236 } 1237 CATCH_DUMP_ATTR 1166 1238 1167 1239 /*! … … 1173 1245 */ 1174 1246 bool CContext::dispatchEvent(CEventServer& event) 1247 TRY 1175 1248 { 1176 1249 … … 1214 1287 } 1215 1288 } 1289 CATCH 1216 1290 1217 1291 //! Client side: Send a message to server to make it close 1218 1292 void CContext::sendCloseDefinition(void) 1293 TRY 1219 1294 { 1220 1295 // Use correct context client to send message … … 1239 1314 } 1240 1315 } 1316 CATCH_DUMP_ATTR 1241 1317 1242 1318 //! Server side: Receive a message of client announcing a context close 1243 1319 void CContext::recvCloseDefinition(CEventServer& event) 1320 TRY 1244 1321 { 1245 1322 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 1248 1325 get(id)->closeDefinition(); 1249 1326 } 1327 CATCH 1250 1328 1251 1329 //! Client side: Send a message to update calendar in each time step 1252 1330 void CContext::sendUpdateCalendar(int step) 1331 TRY 1253 1332 { 1254 1333 // Use correct context client to send message … … 1274 1353 } 1275 1354 } 1355 CATCH_DUMP_ATTR 1276 1356 1277 1357 //! Server side: Receive a message of client annoucing calendar update 1278 1358 void CContext::recvUpdateCalendar(CEventServer& event) 1359 TRY 1279 1360 { 1280 1361 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 1283 1364 get(id)->recvUpdateCalendar(*buffer); 1284 1365 } 1366 CATCH 1285 1367 1286 1368 //! Server side: Receive a message of client annoucing calendar update 1287 1369 void CContext::recvUpdateCalendar(CBufferIn& buffer) 1370 TRY 1288 1371 { 1289 1372 int step; … … 1295 1378 } 1296 1379 } 1380 CATCH_DUMP_ATTR 1297 1381 1298 1382 //! Client side: Send a message to create header part of netcdf file 1299 1383 void CContext::sendCreateFileHeader(void) 1384 TRY 1300 1385 { 1301 1386 // Use correct context client to send message … … 1322 1407 } 1323 1408 } 1409 CATCH_DUMP_ATTR 1324 1410 1325 1411 //! Server side: Receive a message of client annoucing the creation of header part of netcdf file 1326 1412 void CContext::recvCreateFileHeader(CEventServer& event) 1413 TRY 1327 1414 { 1328 1415 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 1331 1418 get(id)->recvCreateFileHeader(*buffer); 1332 1419 } 1420 CATCH 1333 1421 1334 1422 //! Server side: Receive a message of client annoucing the creation of header part of netcdf file 1335 1423 void CContext::recvCreateFileHeader(CBufferIn& buffer) 1424 TRY 1336 1425 { 1337 1426 if (!hasClient && hasServer) 1338 1427 createFileHeader(); 1339 1428 } 1429 CATCH_DUMP_ATTR 1340 1430 1341 1431 //! Client side: Send a message to do some post processing on server 1342 1432 void CContext::sendProcessingGridOfEnabledFields() 1433 TRY 1343 1434 { 1344 1435 // Use correct context client to send message … … 1364 1455 } 1365 1456 } 1457 CATCH_DUMP_ATTR 1366 1458 1367 1459 //! Server side: Receive a message to do some post processing 1368 1460 void CContext::recvProcessingGridOfEnabledFields(CEventServer& event) 1461 TRY 1369 1462 { 1370 1463 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 1372 1465 *buffer>>id; 1373 1466 } 1467 CATCH 1374 1468 1375 1469 //! Client side: Send a message to do some post processing on server 1376 1470 void CContext::sendPostProcessing() 1471 TRY 1377 1472 { 1378 1473 // Use correct context client to send message … … 1398 1493 } 1399 1494 } 1495 CATCH_DUMP_ATTR 1400 1496 1401 1497 //! Server side: Receive a message to do some post processing 1402 1498 void CContext::recvPostProcessing(CEventServer& event) 1499 TRY 1403 1500 { 1404 1501 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 1407 1504 get(id)->recvPostProcessing(*buffer); 1408 1505 } 1506 CATCH 1409 1507 1410 1508 //! Server side: Receive a message to do some post processing 1411 1509 void CContext::recvPostProcessing(CBufferIn& buffer) 1510 TRY 1412 1511 { 1413 1512 CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar(); 1414 1513 postProcessing(); 1415 1514 } 1515 CATCH_DUMP_ATTR 1416 1516 1417 1517 const StdString& CContext::getIdServer() 1518 TRY 1418 1519 { 1419 1520 if (hasClient) … … 1425 1526 if (hasServer) return (this->getId()); 1426 1527 } 1528 CATCH_DUMP_ATTR 1427 1529 1428 1530 const StdString& CContext::getIdServer(const int i) 1531 TRY 1429 1532 { 1430 1533 idServer_ = this->getId(); … … 1433 1536 return idServer_; 1434 1537 } 1435 1538 CATCH_DUMP_ATTR 1436 1539 1437 1540 /*! … … 1442 1545 */ 1443 1546 void CContext::postProcessing() 1547 TRY 1444 1548 { 1445 1549 if (isPostProcessed) return; … … 1504 1608 isPostProcessed = true; 1505 1609 } 1610 CATCH_DUMP_ATTR 1506 1611 1507 1612 /*! … … 1514 1619 std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, 1515 1620 CContextClient* contextClient, bool bufferForWriting /*= "false"*/) 1621 TRY 1516 1622 { 1517 1623 // As calendar attributes are sent even if there are no active files or fields, maps are initialized according the size of calendar attributes … … 1545 1651 return attributesSize; 1546 1652 } 1653 CATCH_DUMP_ATTR 1547 1654 1548 1655 /*! … … 1555 1662 std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize, 1556 1663 CContextClient* contextClient, bool bufferForWriting /*= "false"*/) 1664 TRY 1557 1665 { 1558 1666 std::map<int, StdSize> dataSize; … … 1563 1671 for (size_t i = 0; i < numEnabledFiles; ++i) 1564 1672 { 1565 // CFile* file = this->enabledFiles[i];1566 1673 CFile* file = fileList[i]; 1567 1674 if (file->getContextClient() == contextClient) … … 1591 1698 return dataSize; 1592 1699 } 1700 CATCH_DUMP_ATTR 1593 1701 1594 1702 //! Client side: Send infomation of active files (files are enabled to write out) 1595 1703 void CContext::sendEnabledFiles(const std::vector<CFile*>& activeFiles) 1704 TRY 1596 1705 { 1597 1706 int size = activeFiles.size(); … … 1611 1720 } 1612 1721 } 1722 CATCH_DUMP_ATTR 1613 1723 1614 1724 //! Client side: Send information of active fields (ones are written onto files) 1615 1725 void CContext::sendEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles) 1726 TRY 1616 1727 { 1617 1728 int size = activeFiles.size(); … … 1621 1732 } 1622 1733 } 1734 CATCH_DUMP_ATTR 1623 1735 1624 1736 //! Client side: Check if the defined axis, domains and grids are eligible for compressed indexed output 1625 1737 void CContext::checkAxisDomainsGridsEligibilityForCompressedOutput() 1738 TRY 1626 1739 { 1627 1740 if (!hasClient) return; … … 1639 1752 (*it)->checkEligibilityForCompressedOutput(); 1640 1753 } 1754 CATCH_DUMP_ATTR 1641 1755 1642 1756 //! Client side: Prepare the timeseries by adding the necessary files 1643 1757 void CContext::prepareTimeseries() 1758 TRY 1644 1759 { 1645 1760 if (!hasClient) return; … … 1739 1854 } 1740 1855 } 1856 CATCH_DUMP_ATTR 1741 1857 1742 1858 //! Client side: Send information of reference grid of active fields 1743 1859 void CContext::sendRefGrid(const std::vector<CFile*>& activeFiles) 1860 TRY 1744 1861 { 1745 1862 std::set<StdString> gridIds; … … 1773 1890 } 1774 1891 } 1892 CATCH_DUMP_ATTR 1775 1893 1776 1894 //! Client side: Send information of reference domain, axis and scalar of active fields 1777 1895 void CContext::sendRefDomainsAxisScalars(const std::vector<CFile*>& activeFiles) 1896 TRY 1778 1897 { 1779 1898 std::set<StdString> domainIds, axisIds, scalarIds; … … 1834 1953 } 1835 1954 } 1955 CATCH_DUMP_ATTR 1836 1956 1837 1957 //! Update calendar in each time step 1838 1958 void CContext::updateCalendar(int step) 1959 TRY 1839 1960 { 1840 1961 int prevStep = calendar->getStep(); … … 1847 1968 } 1848 1969 1849 #pragma omp critical (_output)1850 1970 info(50) << "updateCalendar : before : " << calendar->getCurrentDate() << endl; 1851 1971 calendar->update(step); 1852 #pragma omp critical (_output)1853 1972 info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl; 1854 1973 #ifdef XIOS_MEMTRACK_LIGHT 1855 #pragma omp critical (_output)1856 1974 info(50) << " Current memory used by XIOS : "<< MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ; 1857 1975 #endif … … 1864 1982 } 1865 1983 else if (prevStep == step) 1866 {1867 #pragma omp critical (_output)1868 1984 info(50) << "updateCalendar: already at step " << step << ", no operation done." << endl; 1869 }1870 1985 else // if (prevStep > step) 1871 1986 ERROR("void CContext::updateCalendar(int step)", 1872 1987 << "Illegal calendar update: previous step was " << prevStep << ", new step " << step << "is in the past!") 1873 1988 } 1989 CATCH_DUMP_ATTR 1874 1990 1875 1991 void CContext::initReadFiles(void) 1992 TRY 1876 1993 { 1877 1994 vector<CFile*>::const_iterator it; … … 1882 1999 } 1883 2000 } 2001 CATCH_DUMP_ATTR 1884 2002 1885 2003 //! Server side: Create header of netcdf file 1886 2004 void CContext::createFileHeader(void) 2005 TRY 1887 2006 { 1888 2007 vector<CFile*>::const_iterator it; … … 1894 2013 } 1895 2014 } 2015 CATCH_DUMP_ATTR 1896 2016 1897 2017 //! Get current context 1898 2018 CContext* CContext::getCurrent(void) 2019 TRY 1899 2020 { 1900 2021 return CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()).get(); 1901 2022 } 2023 CATCH 1902 2024 1903 2025 /*! … … 1906 2028 */ 1907 2029 void CContext::setCurrent(const string& id) 2030 TRY 1908 2031 { 1909 2032 CObjectFactory::SetCurrentContextId(id); 1910 2033 CGroupFactory::SetCurrentContextId(id); 1911 2034 } 2035 CATCH 1912 2036 1913 2037 /*! … … 1917 2041 */ 1918 2042 CContext* CContext::create(const StdString& id) 2043 TRY 1919 2044 { 1920 2045 CContext::setCurrent(id); … … 1923 2048 CContext* context = CObjectFactory::CreateObject<CContext>(id).get(); 1924 2049 getRoot(); 1925 if (!hasctxt) CGroupFactory::AddChild( *root_ptr, context->getShared());2050 if (!hasctxt) CGroupFactory::AddChild(root, context->getShared()); 1926 2051 1927 2052 #define DECLARE_NODE(Name_, name_) \ … … 1932 2057 return (context); 1933 2058 } 1934 2059 CATCH 1935 2060 1936 2061 //! Server side: Receive a message to do some post processing 1937 2062 void CContext::recvRegistry(CEventServer& event) 2063 TRY 1938 2064 { 1939 2065 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 1942 2068 get(id)->recvRegistry(*buffer); 1943 2069 } 2070 CATCH 1944 2071 1945 2072 void CContext::recvRegistry(CBufferIn& buffer) 2073 TRY 1946 2074 { 1947 2075 if (server->intraCommRank==0) … … 1952 2080 } 1953 2081 } 2082 CATCH_DUMP_ATTR 1954 2083 1955 2084 void CContext::sendRegistry(void) 2085 TRY 1956 2086 { 1957 2087 registryOut->hierarchicalGatherRegistry() ; … … 1979 2109 } 1980 2110 } 2111 CATCH_DUMP_ATTR 1981 2112 1982 2113 /*! … … 1985 2116 */ 1986 2117 bool CContext::isFinalized(void) 2118 TRY 1987 2119 { 1988 2120 return finalized; 1989 2121 } 2122 CATCH_DUMP_ATTR 2123 ///-------------------------------------------------------------- 2124 StdString CContext::dumpClassAttributes(void) 2125 { 2126 StdString str; 2127 str.append("enabled files=\""); 2128 int size = this->enabledFiles.size(); 2129 for (int i = 0; i < size; ++i) 2130 { 2131 str.append(enabledFiles[i]->getId()); 2132 str.append(" "); 2133 } 2134 str.append("\""); 2135 return str; 2136 } 1990 2137 1991 2138 } // namespace xios -
XIOS/dev/branch_openmp/src/node/context.hpp
r1545 r1642 5 5 #include "xios_spl.hpp" 6 6 //#include "node_type.hpp" 7 #include "mpi_std.hpp"8 7 #include "calendar_wrapper.hpp" 9 8 … … 12 11 #include "garbage_collector.hpp" 13 12 #include "registry.hpp" 13 #include "mpi.hpp" 14 14 15 15 … … 91 91 void initServer(ep_lib::MPI_Comm intraComm, ep_lib::MPI_Comm interComm, CContext* cxtClient = 0); 92 92 bool isInitialized(void); 93 94 StdString dumpClassAttributes(void); 93 95 94 96 // Put sever or client into loop state … … 143 145 void distributeFileOverMemoryBandwith() ; 144 146 145 146 147 // Send context close definition 147 148 void sendCloseDefinition(void); … … 239 240 240 241 // Context root 241 static std::shared_ptr<CContextGroup> *root_ptr; 242 #pragma omp threadprivate(root_ptr) 242 static std::shared_ptr<CContextGroup> root; 243 243 244 244 // Determine context on client or not -
XIOS/dev/branch_openmp/src/node/domain.cpp
r1545 r1642 19 19 #include "client_server_mapping_distributed.hpp" 20 20 21 using namespace ep_lib;22 23 21 #include <algorithm> 24 22 … … 32 30 , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 33 31 , isClientAfterTransformationChecked(false), hasLonLat(false) 34 , isRedistributed_(false), hasPole(false) , doZoomByIndex_(false)32 , isRedistributed_(false), hasPole(false) 35 33 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 36 34 , globalLocalIndexMap_(), computedWrittenIndex_(false) 37 , clients() 35 , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 36 , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 38 37 { 39 38 } … … 44 43 , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 45 44 , isClientAfterTransformationChecked(false), hasLonLat(false) 46 , isRedistributed_(false), hasPole(false) , doZoomByIndex_(false)45 , isRedistributed_(false), hasPole(false) 47 46 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 48 47 , globalLocalIndexMap_(), computedWrittenIndex_(false) 49 , clients() 48 , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 49 , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 50 50 { 51 51 } … … 58 58 59 59 void CDomain::assignMesh(const StdString meshName, const int nvertex) 60 TRY 60 61 { 61 62 mesh = CMesh::getMesh(meshName, nvertex); 62 63 } 64 CATCH_DUMP_ATTR 63 65 64 66 CDomain* CDomain::createDomain() 67 TRY 65 68 { 66 69 CDomain* domain = CDomainGroup::get("domain_definition")->createChild(); 67 70 return domain; 68 71 } 69 70 std::map<StdString, ETranformationType> *CDomain::transformationMapList_ptr = 0; 72 CATCH 73 74 std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>(); 75 bool CDomain::_dummyTransformationMapList = CDomain::initializeTransformationMap(CDomain::transformationMapList_); 71 76 72 77 bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 78 TRY 73 79 { 74 80 m["zoom_domain"] = TRANS_ZOOM_DOMAIN; … … 78 84 m["expand_domain"] = TRANS_EXPAND_DOMAIN; 79 85 m["reorder_domain"] = TRANS_REORDER_DOMAIN; 80 } 81 82 bool CDomain::initializeTransformationMap() 83 { 84 CDomain::transformationMapList_ptr = new std::map<StdString, ETranformationType>(); 85 (*CDomain::transformationMapList_ptr)["zoom_domain"] = TRANS_ZOOM_DOMAIN; 86 (*CDomain::transformationMapList_ptr)["interpolate_domain"] = TRANS_INTERPOLATE_DOMAIN; 87 (*CDomain::transformationMapList_ptr)["generate_rectilinear_domain"] = TRANS_GENERATE_RECTILINEAR_DOMAIN; 88 (*CDomain::transformationMapList_ptr)["compute_connectivity_domain"] = TRANS_COMPUTE_CONNECTIVITY_DOMAIN; 89 (*CDomain::transformationMapList_ptr)["expand_domain"] = TRANS_EXPAND_DOMAIN; 90 (*CDomain::transformationMapList_ptr)["reorder_domain"] = TRANS_REORDER_DOMAIN; 91 } 86 m["extract_domain"] = TRANS_EXTRACT_DOMAIN; 87 } 88 CATCH 92 89 93 90 const std::set<StdString> & CDomain::getRelFiles(void) const 91 TRY 94 92 { 95 93 return (this->relFiles); 96 94 } 97 95 CATCH 98 96 99 97 /*! … … 102 100 */ 103 101 int CDomain::getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 102 TRY 104 103 { 105 104 int writtenSize; … … 107 106 return numberWrittenIndexes_[writtenSize]; 108 107 } 108 CATCH_DUMP_ATTR 109 109 110 110 /*! … … 113 113 */ 114 114 int CDomain::getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 115 TRY 115 116 { 116 117 int writtenSize; … … 118 119 return totalNumberWrittenIndexes_[writtenSize]; 119 120 } 121 CATCH_DUMP_ATTR 120 122 121 123 /*! … … 124 126 */ 125 127 int CDomain::getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom) 128 TRY 126 129 { 127 130 int writtenSize; … … 129 132 return offsetWrittenIndexes_[writtenSize]; 130 133 } 134 CATCH_DUMP_ATTR 131 135 132 136 CArray<int, 1>& CDomain::getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom) 137 TRY 133 138 { 134 139 int writtenSize; … … 136 141 return compressedIndexToWriteOnServer[writtenSize]; 137 142 } 143 CATCH_DUMP_ATTR 138 144 139 145 //---------------------------------------------------------------- … … 145 151 */ 146 152 std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/) 153 TRY 147 154 { 148 155 … … 172 179 // size estimation for sendIndex (and sendArea which is always smaller or equal) 173 180 size_t sizeIndexEvent = 2 * sizeof(size_t) + 2 * CArray<int,1>::size(idxCount); 174 // if (isCompressible_)175 // {176 // std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank);177 // size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0;178 // sizeIndexEvent += CArray<int,1>::size(writtenIdxCount);179 // }180 181 181 182 // size estimation for sendLonLat … … 191 192 return attributesSizes; 192 193 } 194 CATCH_DUMP_ATTR 193 195 194 196 //---------------------------------------------------------------- 195 197 196 198 bool CDomain::isEmpty(void) const 197 { 198 return ((this->zoom_i_index.isEmpty()) || (0 == this->zoom_i_index.numElements())); 199 200 } 199 TRY 200 { 201 return ((this->i_index.isEmpty()) || (0 == this->i_index.numElements())); 202 } 203 CATCH 201 204 202 205 //---------------------------------------------------------------- 203 206 204 207 bool CDomain::IsWritten(const StdString & filename) const 208 TRY 205 209 { 206 210 return (this->relFiles.find(filename) != this->relFiles.end()); 207 211 } 212 CATCH 208 213 209 214 bool CDomain::isWrittenCompressed(const StdString& filename) const 215 TRY 210 216 { 211 217 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 212 218 } 219 CATCH 213 220 214 221 //---------------------------------------------------------------- 215 222 216 223 bool CDomain::isDistributed(void) const 224 TRY 217 225 { 218 226 bool distributed = !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || … … 222 230 return distributed; 223 231 } 232 CATCH 224 233 225 234 //---------------------------------------------------------------- … … 231 240 */ 232 241 bool CDomain::isCompressible(void) const 242 TRY 233 243 { 234 244 return isCompressible_; 235 245 } 246 CATCH 236 247 237 248 void CDomain::addRelFile(const StdString & filename) 249 TRY 238 250 { 239 251 this->relFiles.insert(filename); 240 252 } 253 CATCH_DUMP_ATTR 241 254 242 255 void CDomain::addRelFileCompressed(const StdString& filename) 256 TRY 243 257 { 244 258 this->relFilesCompressed.insert(filename); 245 259 } 260 CATCH_DUMP_ATTR 246 261 247 262 StdString CDomain::GetName(void) { return (StdString("domain")); } … … 256 271 */ 257 272 bool CDomain::distributionAttributesHaveValue() const 273 TRY 258 274 { 259 275 bool hasValues = true; … … 267 283 return hasValues; 268 284 } 285 CATCH 269 286 270 287 /*! … … 276 293 */ 277 294 void CDomain::redistribute(int nbLocalDomain) 295 TRY 278 296 { 279 297 if (this->isRedistributed_) return; … … 438 456 checkDomain(); 439 457 } 458 CATCH_DUMP_ATTR 440 459 441 460 /*! … … 443 462 */ 444 463 void CDomain::fillInLonLat() 464 TRY 445 465 { 446 466 switch (type) … … 460 480 } 461 481 completeLonLatClient() ; 462 463 }482 } 483 CATCH_DUMP_ATTR 464 484 465 485 /*! … … 469 489 */ 470 490 void CDomain::fillInRectilinearLonLat() 471 { 472 if (!lonvalue_rectilinear_read_from_file.isEmpty()) 491 TRY 492 { 493 if (!lonvalue_rectilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) 473 494 { 474 495 lonvalue_1d.resize(ni); … … 478 499 lon_end.setValue(lonvalue_rectilinear_read_from_file(ni_glo-1)); 479 500 } 480 else 501 else if (!hasLonInReadFile_) 481 502 { 482 503 if (!lonvalue_2d.isEmpty()) lonvalue_2d.free(); … … 504 525 505 526 506 if (!latvalue_rectilinear_read_from_file.isEmpty() )527 if (!latvalue_rectilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty() && latvalue_1d.isEmpty()) 507 528 { 508 529 latvalue_1d.resize(nj); … … 512 533 lat_end.setValue(latvalue_rectilinear_read_from_file(nj_glo-1)); 513 534 } 514 else 535 else if (!hasLatInReadFile_) 515 536 { 516 537 if (!latvalue_2d.isEmpty()) latvalue_1d.free(); … … 537 558 } 538 559 } 560 CATCH_DUMP_ATTR 539 561 540 562 /* 541 Fill in longitude and latitude of curvilinear domain read from a file542 If there are already longitude and latitude defined by model. We just ig onore readingvalue.563 Fill in 2D longitude and latitude of curvilinear domain read from a file. 564 If there are already longitude and latitude defined by model. We just ignore read value. 543 565 */ 544 566 void CDomain::fillInCurvilinearLonLat() 545 { 546 if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty()) 567 TRY 568 { 569 if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) 547 570 { 548 571 lonvalue_2d.resize(ni,nj); … … 554 577 } 555 578 556 if (!latvalue_curvilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty() )579 if (!latvalue_curvilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty() && latvalue_1d.isEmpty()) 557 580 { 558 581 latvalue_2d.resize(ni,nj); … … 564 587 } 565 588 566 if (!bounds_lonvalue_curvilinear_read_from_file.isEmpty() && bounds_lon_2d.isEmpty() )589 if (!bounds_lonvalue_curvilinear_read_from_file.isEmpty() && bounds_lon_2d.isEmpty() && bounds_lon_1d.isEmpty()) 567 590 { 568 591 bounds_lon_2d.resize(nvertex,ni,nj); … … 575 598 } 576 599 577 if (!bounds_latvalue_curvilinear_read_from_file.isEmpty() && bounds_lat_2d.isEmpty() )600 if (!bounds_latvalue_curvilinear_read_from_file.isEmpty() && bounds_lat_2d.isEmpty() && bounds_lat_1d.isEmpty()) 578 601 { 579 602 bounds_lat_2d.resize(nvertex,ni,nj); … … 585 608 bounds_latvalue_curvilinear_read_from_file.free(); 586 609 } 587 588 }610 } 611 CATCH_DUMP_ATTR 589 612 590 613 /* … … 593 616 */ 594 617 void CDomain::fillInUnstructuredLonLat() 618 TRY 595 619 { 596 620 if (i_index.isEmpty()) … … 644 668 } 645 669 } 670 CATCH_DUMP_ATTR 646 671 647 672 /* … … 649 674 */ 650 675 void CDomain::AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, CArray<double,1>& lon_g, CArray<double,1>& lat_g) 676 TRY 651 677 { 652 678 CContext* context = CContext::getCurrent(); … … 664 690 int v ; 665 691 v=ibegin ; 666 ep_lib::MPI_Allgather(&v,1, MPI_INT,ibegin_g,1,MPI_INT,client->intraComm) ;692 ep_lib::MPI_Allgather(&v,1,EP_INT,ibegin_g,1,EP_INT,client->intraComm) ; 667 693 v=jbegin ; 668 ep_lib::MPI_Allgather(&v,1, MPI_INT,jbegin_g,1,MPI_INT,client->intraComm) ;694 ep_lib::MPI_Allgather(&v,1,EP_INT,jbegin_g,1,EP_INT,client->intraComm) ; 669 695 v=ni ; 670 ep_lib::MPI_Allgather(&v,1, MPI_INT,ni_g,1,MPI_INT,client->intraComm) ;696 ep_lib::MPI_Allgather(&v,1,EP_INT,ni_g,1,EP_INT,client->intraComm) ; 671 697 v=nj ; 672 ep_lib::MPI_Allgather(&v,1, MPI_INT,nj_g,1,MPI_INT,client->intraComm) ;673 674 ep_lib::MPI_Allgatherv(lon.dataFirst(),ni, MPI_DOUBLE,lon_g.dataFirst(),ni_g, ibegin_g,MPI_DOUBLE,client->intraComm) ;675 ep_lib::MPI_Allgatherv(lat.dataFirst(),nj, MPI_DOUBLE,lat_g.dataFirst(),nj_g, jbegin_g,MPI_DOUBLE,client->intraComm) ;698 ep_lib::MPI_Allgather(&v,1,EP_INT,nj_g,1,EP_INT,client->intraComm) ; 699 700 ep_lib::MPI_Allgatherv(lon.dataFirst(),ni,EP_DOUBLE,lon_g.dataFirst(),ni_g, ibegin_g,EP_DOUBLE,client->intraComm) ; 701 ep_lib::MPI_Allgatherv(lat.dataFirst(),nj,EP_DOUBLE,lat_g.dataFirst(),nj_g, jbegin_g,EP_DOUBLE,client->intraComm) ; 676 702 677 703 delete[] ibegin_g ; … … 680 706 delete[] nj_g ; 681 707 } 708 CATCH_DUMP_ATTR 682 709 683 710 void CDomain::fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 684 711 CArray<double,2>& boundsLon, CArray<double,2>& boundsLat) 685 { 712 TRY 713 { 686 714 int i,j,k; 687 715 … … 782 810 } 783 811 } 812 CATCH_DUMP_ATTR 784 813 785 814 /* … … 787 816 */ 788 817 void CDomain::checkDomain(void) 818 TRY 789 819 { 790 820 if (type.isEmpty()) … … 877 907 for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; 878 908 } 879 880 checkZoom(); 881 } 882 883 // Check global zoom of a domain 884 // If there is no zoom defined for the domain, zoom will have value of global doamin 885 void CDomain::checkZoom(void) 886 { 887 if (global_zoom_ibegin.isEmpty()) 888 global_zoom_ibegin.setValue(0); 889 if (global_zoom_ni.isEmpty()) 890 global_zoom_ni.setValue(ni_glo); 891 if (global_zoom_jbegin.isEmpty()) 892 global_zoom_jbegin.setValue(0); 893 if (global_zoom_nj.isEmpty()) 894 global_zoom_nj.setValue(nj_glo); 895 if (zoom_i_index.isEmpty()) zoom_i_index.setValue(i_index.getValue()); 896 if (zoom_j_index.isEmpty()) zoom_j_index.setValue(j_index.getValue()); 897 if (zoom_ibegin.isEmpty()) zoom_ibegin.setValue(ibegin); 898 if (zoom_ni.isEmpty()) zoom_ni.setValue(ni); 899 if (zoom_jbegin.isEmpty()) zoom_jbegin.setValue(jbegin); 900 if (zoom_nj.isEmpty()) zoom_nj.setValue(nj); 901 } 909 } 910 CATCH_DUMP_ATTR 902 911 903 912 size_t CDomain::getGlobalWrittenSize(void) 904 913 { 905 return global_zoom_ni*global_zoom_nj;914 return ni_glo*nj_glo ; 906 915 } 907 916 //---------------------------------------------------------------- … … 909 918 // Check validity of local domain on using the combination of 3 parameters: ibegin, ni and i_index 910 919 void CDomain::checkLocalIDomain(void) 920 TRY 911 921 { 912 922 // If ibegin and ni are provided then we use them to check the validity of local domain … … 967 977 } 968 978 } 979 CATCH_DUMP_ATTR 969 980 970 981 // Check validity of local domain on using the combination of 3 parameters: jbegin, nj and j_index 971 982 void CDomain::checkLocalJDomain(void) 983 TRY 972 984 { 973 985 // If jbegin and nj are provided then we use them to check the validity of local domain … … 1018 1030 } 1019 1031 } 1032 CATCH_DUMP_ATTR 1020 1033 1021 1034 //---------------------------------------------------------------- 1022 1035 1023 1036 void CDomain::checkMask(void) 1037 TRY 1024 1038 { 1025 1039 if (!mask_1d.isEmpty() && !mask_2d.isEmpty()) … … 1067 1081 } 1068 1082 } 1083 CATCH_DUMP_ATTR 1069 1084 1070 1085 //---------------------------------------------------------------- 1071 1086 1072 1087 void CDomain::checkDomainData(void) 1088 TRY 1073 1089 { 1074 1090 if (data_dim.isEmpty()) … … 1110 1126 } 1111 1127 } 1128 CATCH_DUMP_ATTR 1112 1129 1113 1130 //---------------------------------------------------------------- 1114 1131 1115 1132 void CDomain::checkCompression(void) 1116 { 1133 TRY 1134 { 1135 int i,j,ind; 1117 1136 if (!data_i_index.isEmpty()) 1118 1137 { … … 1135 1154 << "'data_j_index' must be defined when 'data_i_index' is set and 'data_dim' is 2."); 1136 1155 } 1156 for (int k=0; k<data_i_index.numElements(); ++k) 1157 { 1158 i = data_i_index(k)+data_ibegin ; 1159 j = data_j_index(k)+data_jbegin ; 1160 if (i>=0 && i<ni && j>=0 && j<nj) 1161 { 1162 ind=j*ni+i ; 1163 if (!domainMask(ind)) 1164 { 1165 data_i_index(k) = -1; 1166 data_j_index(k) = -1; 1167 } 1168 } 1169 else 1170 { 1171 data_i_index(k) = -1; 1172 data_j_index(k) = -1; 1173 } 1174 } 1137 1175 } 1138 1176 else // (1 == data_dim) … … 1141 1179 { 1142 1180 data_j_index.resize(data_ni); 1143 for (int j = 0; j < data_ni; ++j) data_j_index(j) = 0; 1181 data_j_index = 0; 1182 } 1183 for (int k=0; k<data_i_index.numElements(); ++k) 1184 { 1185 i=data_i_index(k)+data_ibegin ; 1186 if (i>=0 && i < domainMask.size()) 1187 { 1188 if (!domainMask(i)) data_i_index(k) = -1; 1189 } 1190 else 1191 data_i_index(k) = -1; 1192 1193 if (!domainMask(i)) data_i_index(k) = -1; 1144 1194 } 1145 1195 } … … 1156 1206 data_i_index.resize(data_ni); 1157 1207 data_j_index.resize(data_ni); 1158 1159 for (int i = 0; i < data_ni; ++i) 1208 data_j_index = 0; 1209 1210 for (int k = 0; k < data_ni; ++k) 1160 1211 { 1161 data_i_index(i) = i; 1162 data_j_index(i) = 0; 1212 i=k+data_ibegin ; 1213 if (i>=0 && i < domainMask.size()) 1214 { 1215 if (domainMask(i)) 1216 data_i_index(k) = k; 1217 else 1218 data_i_index(k) = -1; 1219 } 1220 else 1221 data_i_index(k) = -1; 1163 1222 } 1164 1223 } … … 1169 1228 data_j_index.resize(dsize); 1170 1229 1171 for(int count = 0, j = 0; j < data_nj; ++j)1230 for(int count = 0, kj = 0; kj < data_nj; ++kj) 1172 1231 { 1173 for(int i = 0; i < data_ni; ++i, ++count)1232 for(int ki = 0; ki < data_ni; ++ki, ++count) 1174 1233 { 1175 data_i_index(count) = i; 1176 data_j_index(count) = j; 1234 i = ki + data_ibegin; 1235 j = kj + data_jbegin; 1236 ind=j*ni+i ; 1237 if (i>=0 && i<ni && j>=0 && j<nj) 1238 { 1239 if (domainMask(ind)) 1240 { 1241 data_i_index(count) = ki; 1242 data_j_index(count) = kj; 1243 } 1244 else 1245 { 1246 data_i_index(count) = -1; 1247 data_j_index(count) = -1; 1248 } 1249 } 1250 else 1251 { 1252 data_i_index(count) = -1; 1253 data_j_index(count) = -1; 1254 } 1177 1255 } 1178 1256 } … … 1180 1258 } 1181 1259 } 1260 CATCH_DUMP_ATTR 1182 1261 1183 1262 //---------------------------------------------------------------- 1184 1263 void CDomain::computeLocalMask(void) 1264 TRY 1185 1265 { 1186 1266 localMask.resize(i_index.numElements()) ; … … 1214 1294 } 1215 1295 } 1296 CATCH_DUMP_ATTR 1216 1297 1217 1298 void CDomain::checkEligibilityForCompressedOutput(void) 1299 TRY 1218 1300 { 1219 1301 // We don't check if the mask or the indexes are valid here, just if they have been defined at this point. 1220 1302 isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !data_i_index.isEmpty(); 1221 1303 } 1304 CATCH_DUMP_ATTR 1222 1305 1223 1306 //---------------------------------------------------------------- 1224 1307 1225 1308 /* 1226 Fill in longitude and latitude value from clients (or models) into internal values lonvalue, latvalue which1227 w ill be used by XIOS.1309 Fill in longitude, latitude, bounds, and area into internal values (lonvalue, latvalue, bounds_lonvalue, bounds_latvalue, areavalue) 1310 which will be used by XIOS. 1228 1311 */ 1229 1312 void CDomain::completeLonLatClient(void) 1313 TRY 1230 1314 { 1231 1315 bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 1232 1316 checkBounds() ; 1317 checkArea() ; 1318 1233 1319 if (!lonvalue_2d.isEmpty() && !lonlatValueExisted) 1234 1320 { … … 1325 1411 } 1326 1412 } 1327 } 1413 1414 if (!area.isEmpty() && areavalue.isEmpty()) 1415 { 1416 areavalue.resize(ni*nj); 1417 for (int j = 0; j < nj; ++j) 1418 { 1419 for (int i = 0; i < ni; ++i) 1420 { 1421 int k = j * ni + i; 1422 areavalue(k) = area(i,j); 1423 } 1424 } 1425 } 1426 } 1427 CATCH_DUMP_ATTR 1328 1428 1329 1429 /* … … 1331 1431 */ 1332 1432 void CDomain::convertLonLatValue(void) 1433 TRY 1333 1434 { 1334 1435 bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); … … 1428 1529 } 1429 1530 } 1430 1531 CATCH_DUMP_ATTR 1431 1532 1432 1533 void CDomain::checkBounds(void) 1534 TRY 1433 1535 { 1434 1536 bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); … … 1467 1569 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1468 1570 << "'bounds_lon_1d' dimension is not compatible with 'nvertex'." << std::endl 1469 << "'bounds_lon_1d' dimension is " << bounds_lon_1d.extent( 1)1571 << "'bounds_lon_1d' dimension is " << bounds_lon_1d.extent(0) 1470 1572 << " but nvertex is " << nvertex.getValue() << "."); 1471 1573 … … 1474 1576 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1475 1577 << "'bounds_lon_2d' dimension is not compatible with 'nvertex'." << std::endl 1476 << "'bounds_lon_2d' dimension is " << bounds_lon_2d.extent( 2)1578 << "'bounds_lon_2d' dimension is " << bounds_lon_2d.extent(0) 1477 1579 << " but nvertex is " << nvertex.getValue() << "."); 1478 1580 … … 1491 1593 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1492 1594 << "'bounds_lat_1d' dimension is not compatible with 'nvertex'." << std::endl 1493 << "'bounds_lat_1d' dimension is " << bounds_lat_1d.extent( 1)1595 << "'bounds_lat_1d' dimension is " << bounds_lat_1d.extent(0) 1494 1596 << " but nvertex is " << nvertex.getValue() << "."); 1495 1597 … … 1498 1600 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1499 1601 << "'bounds_lat_2d' dimension is not compatible with 'nvertex'." << std::endl 1500 << "'bounds_lat_2d' dimension is " << bounds_lat_2d.extent( 2)1602 << "'bounds_lat_2d' dimension is " << bounds_lat_2d.extent(0) 1501 1603 << " but nvertex is " << nvertex.getValue() << "."); 1502 1604 … … 1522 1624 } 1523 1625 } 1626 CATCH_DUMP_ATTR 1524 1627 1525 1628 void CDomain::checkArea(void) 1629 TRY 1526 1630 { 1527 1631 bool hasAreaValue = (!areavalue.isEmpty() && 0 != areavalue.numElements()); … … 1537 1641 << "Area size is " << area.extent(0) << " x " << area.extent(1) << "."); 1538 1642 } 1539 if (areavalue.isEmpty()) 1540 { 1541 areavalue.resize(ni*nj); 1542 for (int j = 0; j < nj; ++j) 1543 { 1544 for (int i = 0; i < ni; ++i) 1545 { 1546 int k = j * ni + i; 1547 areavalue(k) = area(i,j); 1548 } 1549 } 1550 } 1551 } 1552 } 1643 // if (areavalue.isEmpty()) 1644 // { 1645 // areavalue.resize(ni*nj); 1646 // for (int j = 0; j < nj; ++j) 1647 // { 1648 // for (int i = 0; i < ni; ++i) 1649 // { 1650 // int k = j * ni + i; 1651 // areavalue(k) = area(i,j); 1652 // } 1653 // } 1654 // } 1655 } 1656 } 1657 CATCH_DUMP_ATTR 1553 1658 1554 1659 void CDomain::checkLonLat() 1660 TRY 1555 1661 { 1556 1662 if (!hasLonLat) hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || … … 1612 1718 } 1613 1719 } 1720 CATCH_DUMP_ATTR 1614 1721 1615 1722 void CDomain::checkAttributesOnClientAfterTransformation() 1723 TRY 1616 1724 { 1617 1725 CContext* context=CContext::getCurrent() ; … … 1628 1736 this->isClientAfterTransformationChecked = true; 1629 1737 } 1738 CATCH_DUMP_ATTR 1630 1739 1631 1740 //---------------------------------------------------------------- … … 1633 1742 // This function only checks all attributes of current domain 1634 1743 void CDomain::checkAttributesOnClient() 1744 TRY 1635 1745 { 1636 1746 if (this->isClientChecked) return; … … 1658 1768 this->isClientChecked = true; 1659 1769 } 1770 CATCH_DUMP_ATTR 1660 1771 1661 1772 // Send all checked attributes to server 1662 1773 void CDomain::sendCheckedAttributes() 1774 TRY 1663 1775 { 1664 1776 if (!this->isClientChecked) checkAttributesOnClient(); … … 1673 1785 this->isChecked = true; 1674 1786 } 1787 CATCH_DUMP_ATTR 1675 1788 1676 1789 void CDomain::checkAttributes(void) 1790 TRY 1677 1791 { 1678 1792 if (this->isChecked) return; … … 1704 1818 this->isChecked = true; 1705 1819 } 1820 CATCH_DUMP_ATTR 1706 1821 1707 1822 /*! … … 1712 1827 */ 1713 1828 void CDomain::computeConnectedClients() 1829 TRY 1714 1830 { 1715 1831 CContext* context=CContext::getCurrent() ; … … 1734 1850 if (indSrv_.find(nbServer) == indSrv_.end()) 1735 1851 { 1736 int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 1737 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 1738 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 1739 1740 // Precompute number of index 1741 int globalIndexCountZoom = 0; 1742 nbIndex = i_index.numElements(); 1743 1744 if (doZoomByIndex_) 1745 { 1746 globalIndexCountZoom = zoom_i_index.numElements(); 1747 } 1748 else 1749 { 1750 for (i = 0; i < nbIndex; ++i) 1751 { 1752 i_ind=i_index(i); 1753 j_ind=j_index(i); 1754 1755 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1756 { 1757 ++globalIndexCountZoom; 1758 } 1759 } 1760 } 1761 1762 // Fill in index 1763 CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 1764 CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 1765 CArray<size_t,1> globalIndexDomain(nbIndex); 1766 size_t globalIndex; 1767 int globalIndexCount = 0; 1768 1769 for (i = 0; i < nbIndex; ++i) 1770 { 1771 i_ind=i_index(i); 1772 j_ind=j_index(i); 1773 globalIndex = i_ind + j_ind * ni_glo; 1774 globalIndexDomain(i) = globalIndex; 1775 } 1776 1777 if (globalLocalIndexMap_.empty()) 1778 { 1779 for (i = 0; i < nbIndex; ++i) 1780 globalLocalIndexMap_[globalIndexDomain(i)] = i; 1781 } 1782 1783 globalIndexCountZoom = 0; 1784 if (doZoomByIndex_) 1785 { 1786 int nbIndexZoom = zoom_i_index.numElements(); 1787 1788 for (i = 0; i < nbIndexZoom; ++i) 1789 { 1790 i_ind=zoom_i_index(i); 1791 j_ind=zoom_j_index(i); 1792 globalIndex = i_ind + j_ind * ni_glo; 1793 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1794 ++globalIndexCountZoom; 1795 } 1796 } 1797 else 1798 { 1799 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 1800 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 1801 for (i = 0; i < nbIndex; ++i) 1802 { 1803 i_ind=i_index(i); 1804 j_ind=j_index(i); 1805 globalIndex = i_ind + j_ind * ni_glo; 1806 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1807 { 1808 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1809 ++globalIndexCountZoom; 1810 } 1811 } 1812 1813 int iend = ibegin + ni -1; 1814 int jend = jbegin + nj -1; 1815 zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin.getValue() : ibegin; 1816 int zoom_iend = global_zoom_iend < iend ? zoom_iend : iend ; 1817 zoom_ni = zoom_iend-zoom_ibegin+1 ; 1818 1819 zoom_jbegin = global_zoom_jbegin > jbegin ? global_zoom_jbegin.getValue() : jbegin ; 1820 int zoom_jend = global_zoom_jend < jend ? zoom_jend : jend; 1821 zoom_nj = zoom_jend-zoom_jbegin+1; 1822 } 1823 1824 size_t globalSizeIndex = 1, indexBegin, indexEnd; 1825 int range, clientSize = client->clientSize; 1826 std::vector<int> nGlobDomain(2); 1827 nGlobDomain[0] = this->ni_glo; 1828 nGlobDomain[1] = this->nj_glo; 1829 for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 1830 indexBegin = 0; 1831 if (globalSizeIndex <= clientSize) 1832 { 1833 indexBegin = rank%globalSizeIndex; 1834 indexEnd = indexBegin; 1835 } 1836 else 1837 { 1838 for (int i = 0; i < clientSize; ++i) 1839 { 1840 range = globalSizeIndex / clientSize; 1841 if (i < (globalSizeIndex%clientSize)) ++range; 1842 if (i == client->clientRank) break; 1843 indexBegin += range; 1844 } 1845 indexEnd = indexBegin + range - 1; 1846 } 1847 1848 // Even if servers have no index, they must received something from client 1849 // We only use several client to send "empty" message to these servers 1850 CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 1851 std::vector<int> serverZeroIndex; 1852 if (isUnstructed_) serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0); 1853 else serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 1); 1854 1855 std::list<int> serverZeroIndexLeader; 1856 std::list<int> serverZeroIndexNotLeader; 1857 CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader); 1858 for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 1859 *it = serverZeroIndex[*it]; 1860 1861 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), 1862 client->intraComm); 1863 clientServerMap->computeServerIndexMapping(globalIndexDomain, nbServer); 1864 CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 1865 1866 CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), 1852 int i,j,i_ind,j_ind, nbIndex=i_index.numElements(); 1853 int globalIndexCount = i_index.numElements(); 1854 // Fill in index 1855 CArray<size_t,1> globalIndexDomain(nbIndex); 1856 size_t globalIndex; 1857 1858 for (i = 0; i < nbIndex; ++i) 1859 { 1860 i_ind=i_index(i); 1861 j_ind=j_index(i); 1862 globalIndex = i_ind + j_ind * ni_glo; 1863 globalIndexDomain(i) = globalIndex; 1864 } 1865 1866 if (globalLocalIndexMap_.empty()) 1867 { 1868 for (i = 0; i < nbIndex; ++i) 1869 globalLocalIndexMap_[globalIndexDomain(i)] = i; 1870 } 1871 1872 size_t globalSizeIndex = 1, indexBegin, indexEnd; 1873 int range, clientSize = client->clientSize; 1874 std::vector<int> nGlobDomain(2); 1875 nGlobDomain[0] = this->ni_glo; 1876 nGlobDomain[1] = this->nj_glo; 1877 for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 1878 indexBegin = 0; 1879 if (globalSizeIndex <= clientSize) 1880 { 1881 indexBegin = rank%globalSizeIndex; 1882 indexEnd = indexBegin; 1883 } 1884 else 1885 { 1886 for (int i = 0; i < clientSize; ++i) 1887 { 1888 range = globalSizeIndex / clientSize; 1889 if (i < (globalSizeIndex%clientSize)) ++range; 1890 if (i == client->clientRank) break; 1891 indexBegin += range; 1892 } 1893 indexEnd = indexBegin + range - 1; 1894 } 1895 1896 // Even if servers have no index, they must received something from client 1897 // We only use several client to send "empty" message to these servers 1898 CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 1899 std::vector<int> serverZeroIndex; 1900 if (isUnstructed_) serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0); 1901 else serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 1); 1902 1903 std::list<int> serverZeroIndexLeader; 1904 std::list<int> serverZeroIndexNotLeader; 1905 CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader); 1906 for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 1907 *it = serverZeroIndex[*it]; 1908 1909 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 1910 clientServerMap->computeServerIndexMapping(globalIndexDomain, nbServer); 1911 CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 1912 1913 CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), 1867 1914 ite = globalIndexDomainOnServer.end(); 1868 indSrv_[nbServer].swap(globalIndexDomainOnServer); 1869 connectedServerRank_[nbServer].clear(); 1870 for (it = indSrv_[nbServer].begin(); it != ite; ++it) 1871 connectedServerRank_[nbServer].push_back(it->first); 1872 1873 for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 1874 connectedServerRank_[nbServer].push_back(*it); 1875 1876 // Even if a client has no index, it must connect to at least one server and 1877 // send an "empty" data to this server 1878 if (connectedServerRank_[nbServer].empty()) 1879 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 1880 1881 nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 1882 delete clientServerMap; 1915 indSrv_[nbServer].swap(globalIndexDomainOnServer); 1916 connectedServerRank_[nbServer].clear(); 1917 for (it = indSrv_[nbServer].begin(); it != ite; ++it) 1918 connectedServerRank_[nbServer].push_back(it->first); 1919 1920 for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 1921 connectedServerRank_[nbServer].push_back(*it); 1922 1923 // Even if a client has no index, it must connect to at least one server and 1924 // send an "empty" data to this server 1925 if (connectedServerRank_[nbServer].empty()) 1926 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 1927 1928 // Now check if all servers have data to receive. If not, master client will send empty data. 1929 // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive. 1930 std::vector<int> counts (clientSize); 1931 std::vector<int> displs (clientSize); 1932 displs[0] = 0; 1933 int localCount = connectedServerRank_[nbServer].size() ; 1934 ep_lib::MPI_Gather(&localCount, 1, EP_INT, &counts[0], 1, EP_INT, 0, client->intraComm) ; 1935 for (int i = 0; i < clientSize-1; ++i) 1936 { 1937 displs[i+1] = displs[i] + counts[i]; 1938 } 1939 std::vector<int> allConnectedServers(displs[clientSize-1]+counts[clientSize-1]); 1940 ep_lib::MPI_Gatherv(&(connectedServerRank_[nbServer])[0], localCount, EP_INT, &allConnectedServers[0], &counts[0], &displs[0], EP_INT, 0, client->intraComm); 1941 1942 if ((allConnectedServers.size() != nbServer) && (rank == 0)) 1943 { 1944 std::vector<bool> isSrvConnected (nbServer, false); 1945 for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true; 1946 for (int i = 0; i < nbServer; ++i) 1947 { 1948 if (!isSrvConnected[i]) connectedServerRank_[nbServer].push_back(i); 1949 } 1950 } 1951 nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 1952 delete clientServerMap; 1883 1953 } 1884 1954 } 1885 1955 } 1886 1956 } 1957 CATCH_DUMP_ATTR 1887 1958 1888 1959 /*! … … 1892 1963 */ 1893 1964 void CDomain::computeWrittenIndex() 1965 TRY 1894 1966 { 1895 1967 if (computedWrittenIndex_) return; … … 1900 1972 1901 1973 std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); 1902 nBegin[0] = zoom_ibegin; nBegin[1] = zoom_jbegin;1903 nSize[0] = zoom_ni; nSize[1] = zoom_nj;1974 nBegin[0] = ibegin; nBegin[1] = jbegin; 1975 nSize[0] = ni; nSize[1] = nj; 1904 1976 nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; 1905 1977 nGlob[0] = ni_glo; nGlob[1] = nj_glo; … … 1913 1985 itSrve = writtenGlobalIndex.end(), itSrv; 1914 1986 1915 // for (itSrv = itSrvb; itSrv != itSrve; ++itSrv)1916 // {1917 // indGlo = *itSrv;1918 // if (ite != globalLocalIndexMap_.find(indGlo))1919 // {1920 // ++nbWritten;1921 // }1922 // }1923 1924 // localIndexToWriteOnServer.resize(nbWritten);1925 1987 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 1926 1927 1988 nbWritten = 0; 1928 1989 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) … … 1932 1993 { 1933 1994 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 1934 ++nbWritten;1935 1995 } 1936 1996 else 1937 1997 { 1938 localIndexToWriteOnServer(nbWritten) = 0; 1939 ++nbWritten; 1940 } 1941 } 1942 } 1998 localIndexToWriteOnServer(nbWritten) = -1; 1999 } 2000 ++nbWritten; 2001 } 2002 } 2003 CATCH_DUMP_ATTR 1943 2004 1944 2005 void CDomain::computeWrittenCompressedIndex(ep_lib::MPI_Comm writtenComm) 2006 TRY 1945 2007 { 1946 2008 int writtenCommSize; … … 1956 2018 1957 2019 std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); 1958 nBegin[0] = zoom_ibegin; nBegin[1] = zoom_jbegin;1959 nSize[0] = zoom_ni; nSize[1] = zoom_nj;2020 nBegin[0] = ibegin; nBegin[1] = jbegin; 2021 nSize[0] = ni; nSize[1] = nj; 1960 2022 nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; 1961 2023 nGlob[0] = ni_glo; nGlob[1] = nj_glo; … … 2002 2064 { 2003 2065 2004 ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm);2005 ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm);2066 ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 2067 ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 2006 2068 offsetWrittenIndexes_[writtenCommSize] -= numberWrittenIndexes_[writtenCommSize]; 2007 2069 } … … 2010 2072 } 2011 2073 } 2074 CATCH_DUMP_ATTR 2012 2075 2013 2076 /*! … … 2016 2079 */ 2017 2080 void CDomain::sendAttributes() 2081 TRY 2018 2082 { 2019 2083 sendDistributionAttributes(); 2020 2084 sendIndex(); 2021 sendMask();2022 2085 sendLonLat(); 2023 2086 sendArea(); 2024 2087 sendDataIndex(); 2025 2088 } 2026 2089 CATCH 2027 2090 /*! 2028 Send global index and zoom index from client to connected client(s) 2029 zoom index can be smaller than global index 2091 Send global index from client to connected client(s) 2030 2092 */ 2031 2093 void CDomain::sendIndex() 2094 TRY 2032 2095 { 2033 2096 int ns, n, i, j, ind, nv, idx; … … 2041 2104 2042 2105 list<CMessage> list_msgsIndex; 2043 list<CArray<int,1> > list_ind Zoom, list_writtenInd, list_indGlob;2106 list<CArray<int,1> > list_indGlob; 2044 2107 2045 2108 std::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; … … 2072 2135 } 2073 2136 } 2137 CATCH_DUMP_ATTR 2074 2138 2075 2139 /*! … … 2079 2143 */ 2080 2144 void CDomain::sendDistributionAttributes(void) 2145 TRY 2081 2146 { 2082 2147 std::list<CContextClient*>::iterator it; … … 2115 2180 msg << isUnstructed_; 2116 2181 msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; 2117 msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue();2182 msg << ni_glo.getValue() << nj_glo.getValue(); 2118 2183 msg << isCompressible_; 2119 2184 … … 2125 2190 } 2126 2191 } 2127 2128 /*! 2129 Send mask index from client to connected(s) clients 2130 */ 2131 void CDomain::sendMask() 2132 { 2133 int ns, n, i, j, ind, nv, idx; 2134 std::list<CContextClient*>::iterator it; 2135 for (it=clients.begin(); it!=clients.end(); ++it) 2136 { 2137 CContextClient* client = *it; 2138 int serverSize = client->serverSize; 2139 2140 // send area for each connected server 2141 CEventClient eventMask(getType(), EVENT_ID_MASK); 2142 2143 list<CMessage> list_msgsMask; 2144 list<CArray<bool,1> > list_mask; 2145 2146 std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 2147 iteMap = indSrv_[serverSize].end(); 2148 for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 2149 { 2150 int nbData = 0; 2151 int rank = connectedServerRank_[serverSize][k]; 2152 it = indSrv_[serverSize].find(rank); 2153 if (iteMap != it) 2154 nbData = it->second.size(); 2155 list_mask.push_back(CArray<bool,1>(nbData)); 2156 2157 const std::vector<size_t>& temp = it->second; 2158 for (n = 0; n < nbData; ++n) 2159 { 2160 idx = static_cast<int>(it->second[n]); 2161 list_mask.back()(n) = domainMask(globalLocalIndexMap_[idx]); 2162 } 2163 2164 list_msgsMask.push_back(CMessage()); 2165 list_msgsMask.back() << this->getId() << list_mask.back(); 2166 eventMask.push(rank, nbSenders[serverSize][rank], list_msgsMask.back()); 2167 } 2168 client->sendEvent(eventMask); 2169 } 2170 } 2192 CATCH_DUMP_ATTR 2171 2193 2172 2194 /*! … … 2174 2196 */ 2175 2197 void CDomain::sendArea() 2198 TRY 2176 2199 { 2177 2200 if (!hasArea) return; … … 2217 2240 } 2218 2241 } 2242 CATCH_DUMP_ATTR 2219 2243 2220 2244 /*! … … 2224 2248 */ 2225 2249 void CDomain::sendLonLat() 2250 TRY 2226 2251 { 2227 2252 if (!hasLonLat) return; … … 2312 2337 } 2313 2338 } 2339 CATCH_DUMP_ATTR 2314 2340 2315 2341 /*! … … 2320 2346 */ 2321 2347 void CDomain::sendDataIndex() 2348 TRY 2322 2349 { 2323 2350 int ns, n, i, j, ind, nv, idx; … … 2388 2415 } 2389 2416 } 2417 CATCH 2390 2418 2391 2419 bool CDomain::dispatchEvent(CEventServer& event) 2420 TRY 2392 2421 { 2393 2422 if (SuperClass::dispatchEvent(event)) return true; … … 2402 2431 case EVENT_ID_INDEX: 2403 2432 recvIndex(event); 2404 return true;2405 break;2406 case EVENT_ID_MASK:2407 recvMask(event);2408 2433 return true; 2409 2434 break; … … 2431 2456 } 2432 2457 } 2458 CATCH 2433 2459 2434 2460 /*! … … 2437 2463 */ 2438 2464 void CDomain::recvIndex(CEventServer& event) 2465 TRY 2439 2466 { 2440 2467 string domainId; … … 2450 2477 get(domainId)->recvIndex(rankBuffers); 2451 2478 } 2479 CATCH 2452 2480 2453 2481 /*! … … 2457 2485 */ 2458 2486 void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) 2487 TRY 2459 2488 { 2460 2489 int nbReceived = rankBuffers.size(), i, ind, index, type_int, iIndex, jIndex; … … 2495 2524 jIndex = (jIndex < 0) ? 0 : jIndex; 2496 2525 nbIndLoc = iIndex + ni * jIndex; 2497 if (nbIndLoc < nbIndexGlobMax) 2498 { 2499 i_index(nbIndLoc) = index % ni_glo; 2500 j_index(nbIndLoc) = index / ni_glo; 2501 globalLocalIndexMap_[index] = nbIndLoc; 2502 ++nbIndGlob; 2503 } 2504 // i_index(nbIndGlob) = index % ni_glo; 2505 // j_index(nbIndGlob) = index / ni_glo; 2506 // globalLocalIndexMap_[index] = nbIndGlob; 2507 // ++nbIndGlob; 2526 i_index(nbIndGlob) = index % ni_glo; 2527 j_index(nbIndGlob) = index / ni_glo; 2528 globalLocalIndexMap_[index] = nbIndGlob; 2529 ++nbIndGlob; 2508 2530 } 2509 2531 } … … 2520 2542 j_index.resizeAndPreserve(nbIndGlob); 2521 2543 } 2544 2545 domainMask.resize(0); // Mask is not defined anymore on servers 2522 2546 } 2547 CATCH 2523 2548 2524 2549 /*! … … 2527 2552 */ 2528 2553 void CDomain::recvDistributionAttributes(CEventServer& event) 2554 TRY 2529 2555 { 2530 2556 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 2533 2559 get(domainId)->recvDistributionAttributes(*buffer); 2534 2560 } 2561 CATCH 2535 2562 2536 2563 /*! 2537 Receive attributes from client(s) : zoom info and begin and n of each server2564 Receive attributes from client(s) 2538 2565 \param[in] rank rank of client source 2539 2566 \param[in] buffer message containing attributes info 2540 2567 */ 2541 2568 void CDomain::recvDistributionAttributes(CBufferIn& buffer) 2569 TRY 2542 2570 { 2543 2571 int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 2544 int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp;2572 int ni_glo_tmp, nj_glo_tmp; 2545 2573 buffer >> isUnstructed_ >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp 2546 >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp2574 >> ni_glo_tmp >> nj_glo_tmp 2547 2575 >> isCompressible_; 2576 2548 2577 ni.setValue(ni_tmp); 2549 2578 ibegin.setValue(ibegin_tmp); 2550 2579 nj.setValue(nj_tmp); 2551 2580 jbegin.setValue(jbegin_tmp); 2552 2553 global_zoom_ni.setValue(global_zoom_ni_tmp); 2554 global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); 2555 global_zoom_nj.setValue(global_zoom_nj_tmp); 2556 global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); 2557 2558 int iend = ibegin + ni - 1; 2559 int jend = jbegin + nj - 1; 2560 int zoom_iend_glob = global_zoom_ibegin + global_zoom_ni - 1; 2561 int zoom_jend_glob = global_zoom_jbegin + global_zoom_nj - 1; 2562 2563 zoom_ibegin.setValue(global_zoom_ibegin > ibegin ? global_zoom_ibegin.getValue() : ibegin); 2564 int zoom_iend = zoom_iend_glob < iend ? zoom_iend_glob : iend ; 2565 zoom_ni.setValue(zoom_iend-zoom_ibegin+1); 2566 2567 zoom_jbegin.setValue(global_zoom_jbegin > jbegin ? global_zoom_jbegin.getValue() : jbegin); 2568 int zoom_jend = zoom_jend_glob < jend ? zoom_jend_glob : jend ; 2569 zoom_nj.setValue(zoom_jend-zoom_jbegin+1); 2570 2571 if (zoom_ni<=0 || zoom_nj<=0) 2572 { 2573 zoom_ni=0 ; zoom_ibegin=global_zoom_ibegin ; //=0; zoom_iend=0 ; 2574 zoom_nj=0 ; zoom_jbegin=global_zoom_jbegin ; //=0; zoom_jend=0 ; 2575 } 2581 ni_glo.setValue(ni_glo_tmp); 2582 nj_glo.setValue(nj_glo_tmp); 2576 2583 2577 2584 } 2578 2579 /*! 2580 Receive area event from clients(s) 2581 \param[in] event event contain info about rank and associated area 2582 */ 2583 void CDomain::recvMask(CEventServer& event) 2584 { 2585 string domainId; 2586 std::map<int, CBufferIn*> rankBuffers; 2587 2588 list<CEventServer::SSubEvent>::iterator it; 2589 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2590 { 2591 CBufferIn* buffer = it->buffer; 2592 *buffer >> domainId; 2593 rankBuffers[it->rank] = buffer; 2594 } 2595 get(domainId)->recvMask(rankBuffers); 2596 } 2597 2598 2599 /*! 2600 Receive mask information from client(s) 2601 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 2602 */ 2603 void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) 2604 { 2605 int nbReceived = rankBuffers.size(), i, ind, index, lInd; 2606 if (nbReceived != recvClientRanks_.size()) 2607 ERROR("void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers)", 2608 << "The number of sending clients is not correct." 2609 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2610 2611 vector<CArray<bool,1> > recvMaskValue(nbReceived); 2612 for (i = 0; i < recvClientRanks_.size(); ++i) 2613 { 2614 int rank = recvClientRanks_[i]; 2615 CBufferIn& buffer = *(rankBuffers[rank]); 2616 buffer >> recvMaskValue[i]; 2617 } 2618 2619 int nbMaskInd = 0; 2620 for (i = 0; i < nbReceived; ++i) 2621 { 2622 nbMaskInd += recvMaskValue[i].numElements(); 2623 } 2624 2625 if (nbMaskInd != globalLocalIndexMap_.size()) 2626 info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " 2627 << "something must be wrong with mask index "<< std::endl; 2628 2629 nbMaskInd = globalLocalIndexMap_.size(); 2630 mask_1d.resize(nbMaskInd); 2631 domainMask.resize(nbMaskInd); 2632 mask_1d = false; 2633 2634 for (i = 0; i < nbReceived; ++i) 2635 { 2636 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 2637 CArray<bool,1>& tmp = recvMaskValue[i]; 2638 for (ind = 0; ind < tmp.numElements(); ++ind) 2639 { 2640 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 2641 if (!mask_1d(lInd)) // Only rewrite mask_1d if it's not true 2642 mask_1d(lInd) = tmp(ind); 2643 } 2644 } 2645 domainMask=mask_1d ; 2646 } 2647 2585 CATCH_DUMP_ATTR 2648 2586 /*! 2649 2587 Receive longitude event from clients(s) … … 2651 2589 */ 2652 2590 void CDomain::recvLon(CEventServer& event) 2591 TRY 2653 2592 { 2654 2593 string domainId; … … 2664 2603 get(domainId)->recvLon(rankBuffers); 2665 2604 } 2605 CATCH 2666 2606 2667 2607 /*! … … 2670 2610 */ 2671 2611 void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 2612 TRY 2672 2613 { 2673 2614 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; … … 2729 2670 } 2730 2671 } 2672 CATCH_DUMP_ATTR 2731 2673 2732 2674 /*! … … 2735 2677 */ 2736 2678 void CDomain::recvLat(CEventServer& event) 2679 TRY 2737 2680 { 2738 2681 string domainId; … … 2748 2691 get(domainId)->recvLat(rankBuffers); 2749 2692 } 2693 CATCH 2750 2694 2751 2695 /*! … … 2754 2698 */ 2755 2699 void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 2700 TRY 2756 2701 { 2757 2702 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; … … 2815 2760 } 2816 2761 } 2762 CATCH_DUMP_ATTR 2817 2763 2818 2764 /*! … … 2821 2767 */ 2822 2768 void CDomain::recvArea(CEventServer& event) 2769 TRY 2823 2770 { 2824 2771 string domainId; … … 2834 2781 get(domainId)->recvArea(rankBuffers); 2835 2782 } 2783 CATCH 2836 2784 2837 2785 /*! … … 2840 2788 */ 2841 2789 void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 2790 TRY 2842 2791 { 2843 2792 int nbReceived = rankBuffers.size(), i, ind, index, lInd; … … 2885 2834 } 2886 2835 } 2836 CATCH_DUMP_ATTR 2887 2837 2888 2838 /*! … … 2894 2844 */ 2895 2845 bool CDomain::isEqual(CDomain* obj) 2846 TRY 2896 2847 { 2897 2848 vector<StdString> excludedAttr; … … 2916 2867 return objEqual; 2917 2868 } 2869 CATCH_DUMP_ATTR 2918 2870 2919 2871 /*! … … 2922 2874 */ 2923 2875 void CDomain::recvDataIndex(CEventServer& event) 2876 TRY 2924 2877 { 2925 2878 string domainId; … … 2935 2888 get(domainId)->recvDataIndex(rankBuffers); 2936 2889 } 2890 CATCH 2937 2891 2938 2892 /*! … … 2946 2900 */ 2947 2901 void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 2902 TRY 2948 2903 { 2949 2904 int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd; … … 2982 2937 dataIIndex(lInd) = (-1 == dataIIndex(lInd)) ? tmpI(ind) : dataIIndex(lInd); // Only fill in dataIndex if there is no data 2983 2938 dataJIndex(lInd) = (-1 == dataJIndex(lInd)) ? tmpJ(ind) : dataJIndex(lInd); 2984 2985 if (!domainMask(lInd)) // Include mask info into data index on the RECEIVE getServerDimensionSizes2986 {2987 dataIIndex(lInd) = dataJIndex(lInd) = -1;2988 }2989 2939 } 2990 2940 } … … 3017 2967 data_jbegin.setValue(0); 3018 2968 } 2969 CATCH_DUMP_ATTR 3019 2970 3020 2971 CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) 2972 TRY 3021 2973 { 3022 2974 transformationMap_.push_back(std::make_pair(transType, CTransformation<CDomain>::createTransformation(transType,id))); 3023 2975 return transformationMap_.back().second; 3024 2976 } 2977 CATCH_DUMP_ATTR 3025 2978 3026 2979 /*! … … 3029 2982 */ 3030 2983 bool CDomain::hasTransformation() 2984 TRY 3031 2985 { 3032 2986 return (!transformationMap_.empty()); 3033 2987 } 2988 CATCH_DUMP_ATTR 3034 2989 3035 2990 /*! … … 3038 2993 */ 3039 2994 void CDomain::setTransformations(const TransMapTypes& domTrans) 2995 TRY 3040 2996 { 3041 2997 transformationMap_ = domTrans; 3042 2998 } 2999 CATCH_DUMP_ATTR 3043 3000 3044 3001 /*! … … 3047 3004 */ 3048 3005 CDomain::TransMapTypes CDomain::getAllTransformations(void) 3006 TRY 3049 3007 { 3050 3008 return transformationMap_; 3051 3009 } 3010 CATCH_DUMP_ATTR 3052 3011 3053 3012 void CDomain::duplicateTransformation(CDomain* src) 3013 TRY 3054 3014 { 3055 3015 if (src->hasTransformation()) … … 3058 3018 } 3059 3019 } 3020 CATCH_DUMP_ATTR 3060 3021 3061 3022 /*! … … 3063 3024 */ 3064 3025 void CDomain::solveInheritanceTransformation() 3026 TRY 3065 3027 { 3066 3028 if (hasTransformation() || !hasDirectDomainReference()) … … 3079 3041 refDomains[i]->setTransformations(domain->getAllTransformations()); 3080 3042 } 3043 CATCH_DUMP_ATTR 3081 3044 3082 3045 void CDomain::setContextClient(CContextClient* contextClient) 3046 TRY 3083 3047 { 3084 3048 if (clientsSet.find(contextClient)==clientsSet.end()) … … 3088 3052 } 3089 3053 } 3054 CATCH_DUMP_ATTR 3090 3055 3091 3056 /*! … … 3095 3060 */ 3096 3061 void CDomain::parse(xml::CXMLNode & node) 3062 TRY 3097 3063 { 3098 3064 SuperClass::parse(node); … … 3108 3074 3109 3075 nodeElementName = node.getElementName(); 3110 if(transformationMapList_ptr == 0) initializeTransformationMap(); 3111 3112 std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_ptr->end(), it; 3113 3114 it = transformationMapList_ptr->find(nodeElementName); 3076 std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 3077 it = transformationMapList_.find(nodeElementName); 3115 3078 if (ite != it) 3116 3079 { … … 3128 3091 } 3129 3092 } 3093 CATCH_DUMP_ATTR 3130 3094 //---------------------------------------------------------------- 3131 3095 -
XIOS/dev/branch_openmp/src/node/domain.hpp
r1545 r1642 17 17 #include "transformation_enum.hpp" 18 18 #include "server_distribution_description.hpp" 19 #include "mpi_std.hpp"20 19 #include "mesh.hpp" 21 20 … … 50 49 { 51 50 EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 52 EVENT_ID_AREA, EVENT_ID_MASK,51 EVENT_ID_AREA, 53 52 EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT 54 53 } ; … … 143 142 CArray<double, 1> areavalue; 144 143 145 CArray< size_t,1> localIndexToWriteOnServer;144 CArray<int,1> localIndexToWriteOnServer; 146 145 147 146 CArray<bool, 1> domainMask; // mask_1d, mask_2d -> domainMask … … 152 151 bool hasLonLat; 153 152 bool hasPole ; 153 bool hasLatInReadFile_ ; // specify if latitude is defined on read file, so it can be read later when grid distribution will be defined 154 bool hasBoundsLatInReadFile_ ; // specify if latitude boundarues are defined on read file, so it can be read later when grid distribution will be defined 155 bool hasLonInReadFile_ ; // specify if longitude is defined on read file, so it can be read later when grid distribution will be defined 156 bool hasBoundsLonInReadFile_ ; // specify if longitude boundaries are defined on read file, so it can be read later when grid distribution will be defined 154 157 155 158 void computeLocalMask(void) ; … … 166 169 void checkArea(void); 167 170 void checkLonLat(); 168 void checkZoom(void);169 171 170 172 void setTransformations(const TransMapTypes&); … … 173 175 void sendIndex(); 174 176 void sendDistributionAttributes(); 175 void sendMask();176 177 void sendArea(); 177 178 void sendLonLat(); … … 184 185 static void recvDistributionAttributes(CEventServer& event); 185 186 static void recvIndex(CEventServer& event); 186 static void recvIndexZoom(CEventServer& event);187 static void recvMask(CEventServer& event);188 187 static void recvLon(CEventServer& event); 189 188 static void recvLat(CEventServer& event); … … 192 191 void recvDistributionAttributes(CBufferIn& buffer); 193 192 void recvIndex(std::map<int, CBufferIn*>& rankBuffers); 194 void recvMask(std::map<int, CBufferIn*>& rankBuffers);195 193 void recvLon(std::map<int, CBufferIn*>& rankBuffers); 196 194 void recvLat(std::map<int, CBufferIn*>& rankBuffers); … … 201 199 void computeConnectedClients(); 202 200 203 private: 201 private: 204 202 205 203 /** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */ … … 207 205 std::set<CContextClient*> clientsSet; 208 206 209 bool doZoomByIndex_;210 207 bool isChecked, computedWrittenIndex_; 211 208 std::set<StdString> relFiles, relFilesCompressed; … … 234 231 private: 235 232 static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 236 static bool initializeTransformationMap(); 237 static std::map<StdString, ETranformationType> *transformationMapList_ptr; 238 #pragma omp threadprivate(transformationMapList_ptr) 233 static std::map<StdString, ETranformationType> transformationMapList_; 239 234 static bool _dummyTransformationMapList; 240 #pragma omp threadprivate(_dummyTransformationMapList)241 235 242 236 DECLARE_REF_FUNC(Domain,domain) -
XIOS/dev/branch_openmp/src/node/duplicate_scalar_to_axis.hpp
r1460 r1642 60 60 static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CReduceAxisToAxis 64 63 -
XIOS/dev/branch_openmp/src/node/expand_domain.hpp
r1331 r1642 60 60 static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CExpandDomain 64 63 -
XIOS/dev/branch_openmp/src/node/extract_axis_to_scalar.hpp
r1331 r1642 60 60 static CTransformation<CScalar>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CExtractAxisToScalar 64 63 -
XIOS/dev/branch_openmp/src/node/extract_domain_to_axis.hpp
r1331 r1642 60 60 static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CExtractDomainToAxis 64 63 -
XIOS/dev/branch_openmp/src/node/field.cpp
r1545 r1642 71 71 72 72 void CField::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 73 TRY 73 74 { 74 75 this->vVariableGroup = newVVariableGroup; 75 76 } 77 CATCH 76 78 77 79 CVariableGroup* CField::getVirtualVariableGroup(void) const 80 TRY 78 81 { 79 82 return this->vVariableGroup; 80 83 } 84 CATCH 81 85 82 86 std::vector<CVariable*> CField::getAllVariables(void) const 87 TRY 83 88 { 84 89 return this->vVariableGroup->getAllChildren(); 85 90 } 91 CATCH 86 92 87 93 void CField::solveDescInheritance(bool apply, const CAttributeMap* const parent) 94 TRY 88 95 { 89 96 SuperClassAttribute::setAttributes(parent, apply); 90 97 this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 91 98 } 99 CATCH_DUMP_ATTR 92 100 93 101 //---------------------------------------------------------------- 94 102 95 103 bool CField::dispatchEvent(CEventServer& event) 104 TRY 96 105 { 97 106 if (SuperClass::dispatchEvent(event)) return true; … … 131 140 } 132 141 } 142 CATCH 133 143 134 144 void CField::sendUpdateData(const CArray<double,1>& data) 145 TRY 135 146 { 136 147 CTimer::get("Field : send data").resume(); … … 189 200 CTimer::get("Field : send data").suspend(); 190 201 } 202 CATCH_DUMP_ATTR 191 203 192 204 void CField::recvUpdateData(CEventServer& event) 205 TRY 193 206 { 194 207 std::map<int,CBufferIn*> rankBuffers; … … 207 220 CTimer::get("Field : recv data").suspend(); 208 221 } 222 CATCH 209 223 210 224 void CField::recvUpdateData(std::map<int,CBufferIn*>& rankBuffers) 225 TRY 211 226 { 212 227 CContext* context = CContext::getCurrent(); … … 249 264 recvDataSrv.reset() ; 250 265 } 266 CATCH_DUMP_ATTR 251 267 252 268 void CField::writeUpdateData(const CArray<double,1>& data) 269 TRY 253 270 { 254 271 CContext* context = CContext::getCurrent(); … … 277 294 } 278 295 } 296 CATCH_DUMP_ATTR 279 297 280 298 void CField::writeField(void) 299 TRY 281 300 { 282 301 if (!getRelFile()->isEmptyZone()) … … 290 309 } 291 310 } 311 CATCH_DUMP_ATTR 292 312 293 313 /* … … 299 319 */ 300 320 bool CField::sendReadDataRequest(const CDate& tsDataRequested) 321 TRY 301 322 { 302 323 CContext* context = CContext::getCurrent(); … … 330 351 return !isEOF; 331 352 } 353 CATCH_DUMP_ATTR 332 354 333 355 /*! … … 336 358 */ 337 359 bool CField::sendReadDataRequestIfNeeded(void) 360 TRY 338 361 { 339 362 const CDate& currentDate = CContext::getCurrent()->getCalendar()->getCurrentDate(); … … 343 366 while (currentDate >= lastDataRequestedFromServer) 344 367 { 345 #pragma omp critical (_output) 346 { 347 info(20) << "currentDate : " << currentDate << endl ; 348 info(20) << "lastDataRequestedFromServer : " << lastDataRequestedFromServer << endl ; 349 info(20) << "file->output_freq.getValue() : " << file->output_freq.getValue() << endl ; 350 info(20) << "lastDataRequestedFromServer + file->output_freq.getValue() : " << lastDataRequestedFromServer + file->output_freq << endl ; 351 } 368 info(20) << "currentDate : " << currentDate << endl ; 369 info(20) << "lastDataRequestedFromServer : " << lastDataRequestedFromServer << endl ; 370 info(20) << "file->output_freq.getValue() : " << file->output_freq.getValue() << endl ; 371 info(20) << "lastDataRequestedFromServer + file->output_freq.getValue() : " << lastDataRequestedFromServer + file->output_freq << endl ; 352 372 353 373 dataRequested |= sendReadDataRequest(lastDataRequestedFromServer + file->output_freq); … … 356 376 return dataRequested; 357 377 } 378 CATCH_DUMP_ATTR 358 379 359 380 void CField::recvReadDataRequest(CEventServer& event) 381 TRY 360 382 { 361 383 CBufferIn* buffer = event.subEvents.begin()->buffer; … … 364 386 get(fieldId)->recvReadDataRequest(); 365 387 } 388 CATCH 366 389 367 390 /*! … … 372 395 */ 373 396 void CField::recvReadDataRequest(void) 397 TRY 374 398 { 375 399 CContext* context = CContext::getCurrent(); … … 452 476 } 453 477 } 478 CATCH_DUMP_ATTR 454 479 455 480 /*! … … 459 484 */ 460 485 CField::EReadField CField::readField(void) 486 TRY 461 487 { 462 488 CContext* context = CContext::getCurrent(); … … 505 531 if (!nstepMaxRead) 506 532 { 507 MPI_Allreduce(&nstepMax, &nstepMax, 1, MPI_INT, MPI_MAX, context->server->intraComm); 533 #ifdef _usingMPI 534 MPI_Allreduce(MPI_IN_PLACE, &nstepMax, 1, MPI_INT, MPI_MAX, context->server->intraComm); 535 #elif _usingEP 536 ep_lib::MPI_Allreduce(&nstepMax, &nstepMax, 1, EP_INT, EP_MAX, context->server->intraComm); 537 #endif 508 538 nstepMaxRead = true; 509 539 } … … 511 541 return readState; 512 542 } 543 CATCH_DUMP_ATTR 513 544 514 545 /* … … 519 550 */ 520 551 void CField::recvReadDataReady(CEventServer& event) 552 TRY 521 553 { 522 554 string fieldId; … … 534 566 get(fieldId)->recvReadDataReady(ranks, buffers); 535 567 } 568 CATCH 536 569 537 570 /*! … … 541 574 */ 542 575 void CField::recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers) 576 TRY 543 577 { 544 578 CContext* context = CContext::getCurrent(); … … 577 611 serverSourceFilter->streamDataFromServer(lastDataReceivedFromServer, data); 578 612 } 613 CATCH_DUMP_ATTR 579 614 580 615 void CField::checkForLateDataFromServer(void) 616 TRY 581 617 { 582 618 CContext* context = CContext::getCurrent(); … … 610 646 } 611 647 } 648 CATCH_DUMP_ATTR 612 649 613 650 void CField::checkIfMustAutoTrigger(void) 651 TRY 614 652 { 615 653 mustAutoTrigger = serverSourceFilter ? serverSourceFilter->mustAutoTrigger() : false; 616 654 } 655 CATCH_DUMP_ATTR 617 656 618 657 void CField::autoTriggerIfNeeded(void) 658 TRY 619 659 { 620 660 if (mustAutoTrigger) 621 661 serverSourceFilter->trigger(CContext::getCurrent()->getCalendar()->getCurrentDate()); 622 662 } 663 CATCH_DUMP_ATTR 623 664 624 665 //---------------------------------------------------------------- 625 666 626 667 void CField::setRelFile(CFile* _file) 668 TRY 627 669 { 628 670 this->file = _file; 629 671 hasOutputFile = true; 630 672 } 673 CATCH_DUMP_ATTR 631 674 632 675 //---------------------------------------------------------------- … … 639 682 640 683 CGrid* CField::getRelGrid(void) const 684 TRY 641 685 { 642 686 return this->grid; 643 687 } 688 CATCH 644 689 645 690 //---------------------------------------------------------------- 646 691 647 692 CFile* CField::getRelFile(void) const 693 TRY 648 694 { 649 695 return this->file; 650 696 } 697 CATCH 651 698 652 699 int CField::getNStep(void) const 700 TRY 653 701 { 654 702 return this->nstep; 655 703 } 704 CATCH 656 705 657 706 func::CFunctor::ETimeType CField::getOperationTimeType() const 707 TRY 658 708 { 659 709 return operationTimeType; 660 710 } 711 CATCH 661 712 662 713 //---------------------------------------------------------------- 663 714 664 715 void CField::incrementNStep(void) 716 TRY 665 717 { 666 718 this->nstep++; 667 719 } 720 CATCH_DUMP_ATTR 668 721 669 722 void CField::resetNStep(int nstep /*= 0*/) 723 TRY 670 724 { 671 725 this->nstep = nstep; 672 726 } 727 CATCH_DUMP_ATTR 673 728 674 729 void CField::resetNStepMax(void) 730 TRY 675 731 { 676 732 this->nstepMax = 0; 677 733 nstepMaxRead = false; 678 734 } 735 CATCH_DUMP_ATTR 679 736 680 737 //---------------------------------------------------------------- 681 738 682 739 bool CField::isActive(bool atCurrentTimestep /*= false*/) const 740 TRY 683 741 { 684 742 if (clientSourceFilter) … … 692 750 return false; 693 751 } 752 CATCH 694 753 695 754 //---------------------------------------------------------------- 696 755 697 756 bool CField::wasWritten() const 757 TRY 698 758 { 699 759 return written; 700 760 } 761 CATCH 701 762 702 763 void CField::setWritten() 764 TRY 703 765 { 704 766 written = true; 705 767 } 768 CATCH_DUMP_ATTR 706 769 707 770 //---------------------------------------------------------------- 708 771 709 772 bool CField::getUseCompressedOutput() const 773 TRY 710 774 { 711 775 return useCompressedOutput; 712 776 } 777 CATCH 713 778 714 779 void CField::setUseCompressedOutput() 780 TRY 715 781 { 716 782 useCompressedOutput = true; 717 783 } 784 CATCH_DUMP_ATTR 718 785 719 786 //---------------------------------------------------------------- 720 787 721 788 std::shared_ptr<COutputPin> CField::getInstantDataFilter() 789 TRY 722 790 { 723 791 return instantDataFilter; 724 792 } 793 CATCH_DUMP_ATTR 725 794 726 795 //---------------------------------------------------------------- … … 731 800 */ 732 801 void CField::buildGridTransformationGraph() 802 TRY 733 803 { 734 804 CContext* context = CContext::getCurrent(); … … 741 811 } 742 812 } 813 CATCH_DUMP_ATTR 743 814 744 815 /*! … … 746 817 */ 747 818 void CField::generateNewTransformationGridDest() 819 TRY 748 820 { 749 821 CContext* context = CContext::getCurrent(); … … 800 872 } 801 873 } 874 CATCH_DUMP_ATTR 802 875 803 876 void CField::updateRef(CGrid* grid) 877 TRY 804 878 { 805 879 if (!grid_ref.isEmpty()) grid_ref.setValue(grid->getId()); … … 823 897 } 824 898 } 899 CATCH_DUMP_ATTR 825 900 826 901 /*! … … 829 904 */ 830 905 void CField::solveAllEnabledFieldsAndTransform() 906 TRY 831 907 { 832 908 CContext* context = CContext::getCurrent(); … … 865 941 } 866 942 } 943 CATCH_DUMP_ATTR 867 944 868 945 void CField::checkGridOfEnabledFields() 946 TRY 869 947 { 870 948 if (!isGridChecked) … … 874 952 } 875 953 } 954 CATCH_DUMP_ATTR 876 955 877 956 void CField::sendGridComponentOfEnabledFields() 957 TRY 878 958 { 879 959 solveGridDomainAxisRef(true); 880 960 // solveCheckMaskIndex(true); 881 961 } 962 CATCH_DUMP_ATTR 882 963 883 964 void CField::sendGridOfEnabledFields() 965 TRY 884 966 { 885 967 // solveGridDomainAxisRef(true); 886 968 solveCheckMaskIndex(true); 887 969 } 970 CATCH_DUMP_ATTR 888 971 889 972 void CField::solveOnlyReferenceEnabledField(bool doSending2Server) 973 TRY 890 974 { 891 975 CContext* context = CContext::getCurrent(); … … 913 997 } 914 998 } 915 999 CATCH_DUMP_ATTR 1000 916 1001 void CField::solveAllReferenceEnabledField(bool doSending2Server) 1002 TRY 917 1003 { 918 1004 CContext* context = CContext::getCurrent(); … … 922 1008 { 923 1009 areAllReferenceSolved = true; 924 1010 925 1011 if (context->hasClient && !context->hasServer) 926 1012 { … … 943 1029 solveCheckMaskIndex(doSending2Server); 944 1030 } 1031 CATCH_DUMP_ATTR 945 1032 946 1033 std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 1034 TRY 947 1035 { 948 1036 return grid->getAttributesBufferSize(client, bufferForWriting); 949 1037 } 1038 CATCH_DUMP_ATTR 950 1039 951 1040 std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 1041 TRY 952 1042 { 953 1043 return grid->getDataBufferSize(client, getId(), bufferForWriting); 954 1044 } 1045 CATCH_DUMP_ATTR 955 1046 956 1047 size_t CField::getGlobalWrittenSize() 1048 TRY 957 1049 { 958 1050 return grid->getGlobalWrittenSize(); 959 1051 } 1052 CATCH_DUMP_ATTR 960 1053 961 1054 //---------------------------------------------------------------- 962 1055 963 1056 void CField::solveServerOperation(void) 1057 TRY 964 1058 { 965 1059 CContext* context = CContext::getCurrent(); … … 1004 1098 operationTimeType = functor->timeType(); 1005 1099 } 1100 CATCH_DUMP_ATTR 1006 1101 1007 1102 //---------------------------------------------------------------- … … 1016 1111 */ 1017 1112 void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput) 1113 TRY 1018 1114 { 1019 1115 if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform(); … … 1030 1126 { 1031 1127 if (!instantDataFilter) 1032 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true));1128 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false)); 1033 1129 1034 1130 … … 1046 1142 { 1047 1143 if (!instantDataFilter) 1048 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true));1144 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, false)); 1049 1145 1050 1146 // If the field data is to be read by the client or/and written to a file … … 1092 1188 { 1093 1189 checkTimeAttributes(); 1094 instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, f req_offset, true,1190 instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true, 1095 1191 detectMissingValues, defaultValue)); 1096 1192 } … … 1098 1194 { 1099 1195 if (check_if_active.isEmpty()) check_if_active = false; 1100 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, NoneDu, false,1196 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, true, NoneDu, false, 1101 1197 detectMissingValues, defaultValue)); 1102 1198 } … … 1121 1217 } 1122 1218 } 1219 CATCH_DUMP_ATTR 1123 1220 1124 1221 /*! … … 1130 1227 */ 1131 1228 std::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc) 1229 TRY 1132 1230 { 1133 1231 if (instantDataFilter || field_ref.isEmpty()) … … 1153 1251 return filters.second; 1154 1252 } 1253 CATCH_DUMP_ATTR 1155 1254 1156 1255 /*! … … 1164 1263 */ 1165 1264 std::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc) 1265 TRY 1166 1266 { 1167 1267 if (instantDataFilter || !hasExpression()) … … 1179 1279 { 1180 1280 checkTimeAttributes(); 1181 serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, f req_offset, true,1281 serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true, 1182 1282 detectMissingValues, defaultValue)); 1183 1283 } … … 1196 1296 { 1197 1297 if (check_if_active.isEmpty()) check_if_active = false; 1198 clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, NoneDu, false,1298 clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, true, NoneDu, false, 1199 1299 detectMissingValues, defaultValue)); 1200 1300 } … … 1206 1306 return selfReferenceFilter; 1207 1307 } 1308 CATCH_DUMP_ATTR 1208 1309 1209 1310 /*! … … 1217 1318 */ 1218 1319 std::shared_ptr<COutputPin> CField::getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 1320 TRY 1219 1321 { 1220 1322 std::map<CDuration, std::shared_ptr<COutputPin> >::iterator it = temporalDataFilters.find(outFreq); … … 1240 1342 return it->second; 1241 1343 } 1344 CATCH_DUMP_ATTR 1242 1345 1243 1346 /*! … … 1251 1354 1252 1355 std::shared_ptr<COutputPin> CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 1356 TRY 1253 1357 { 1254 1358 if (instantDataFilter || !hasExpression()) … … 1281 1385 } 1282 1386 } 1387 CATCH_DUMP_ATTR 1283 1388 1284 1389 //---------------------------------------------------------------- … … 1299 1404 1300 1405 void CField::solveGridReference(void) 1406 TRY 1301 1407 { 1302 1408 if (grid_ref.isEmpty() && domain_ref.isEmpty() && axis_ref.isEmpty() && scalar_ref.isEmpty()) … … 1382 1488 } 1383 1489 } 1490 CATCH_DUMP_ATTR 1384 1491 1385 1492 void CField::solveGridDomainAxisRef(bool checkAtt) 1493 TRY 1386 1494 { 1387 1495 grid->solveDomainAxisRef(checkAtt); 1388 1496 } 1497 CATCH_DUMP_ATTR 1389 1498 1390 1499 void CField::solveCheckMaskIndex(bool doSendingIndex) 1500 TRY 1391 1501 { 1392 1502 grid->checkMaskIndex(doSendingIndex); 1393 1503 } 1504 CATCH_DUMP_ATTR 1394 1505 1395 1506 void CField::solveTransformedGrid() 1507 TRY 1396 1508 { 1397 1509 if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) … … 1442 1554 } 1443 1555 } 1556 CATCH_DUMP_ATTR 1444 1557 1445 1558 void CField::solveGenerateGrid() 1559 TRY 1446 1560 { 1447 1561 if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) … … 1450 1564 grid->completeGrid(); 1451 1565 } 1566 CATCH_DUMP_ATTR 1452 1567 1453 1568 void CField::solveGridDomainAxisBaseRef() 1569 TRY 1454 1570 { 1455 1571 grid->solveDomainAxisRef(false); 1456 1572 grid->solveDomainAxisBaseRef(); 1457 1573 } 1574 CATCH_DUMP_ATTR 1458 1575 1459 1576 ///------------------------------------------------------------------- … … 1461 1578 template <> 1462 1579 void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void) 1580 TRY 1463 1581 { 1464 1582 if (this->group_ref.isEmpty()) return; … … 1472 1590 CFieldGroup* group = CFieldGroup::get(gref); 1473 1591 CFieldGroup* owner = CFieldGroup::get(boost::polymorphic_downcast<CFieldGroup*>(this)); 1474 1592 owner->setAttributes(group); // inherite of attributes of group reference 1593 1475 1594 std::vector<CField*> allChildren = group->getAllChildren(); 1476 1595 std::vector<CField*>::iterator it = allChildren.begin(), end = allChildren.end(); … … 1483 1602 } 1484 1603 } 1604 CATCH_DUMP_ATTR 1485 1605 1486 1606 void CField::scaleFactorAddOffset(double scaleFactor, double addOffset) 1607 TRY 1487 1608 { 1488 1609 recvDataSrv = (recvDataSrv - addOffset) / scaleFactor; 1489 1610 } 1611 CATCH_DUMP_ATTR 1490 1612 1491 1613 void CField::invertScaleFactorAddOffset(double scaleFactor, double addOffset) 1614 TRY 1492 1615 { 1493 1616 recvDataSrv = recvDataSrv * scaleFactor + addOffset; 1494 1617 } 1618 CATCH_DUMP_ATTR 1495 1619 1496 1620 void CField::outputField(CArray<double,1>& fieldOut) 1621 TRY 1497 1622 { 1498 1623 CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; … … 1503 1628 } 1504 1629 } 1630 CATCH_DUMP_ATTR 1505 1631 1506 1632 void CField::inputField(CArray<double,1>& fieldIn) 1633 TRY 1507 1634 { 1508 1635 CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; … … 1512 1639 recvDataSrv(outIndexClient(idx)) = fieldIn(outIndexServer(idx)); 1513 1640 } 1514 1515 }1641 } 1642 CATCH_DUMP_ATTR 1516 1643 1517 1644 void CField::outputCompressedField(CArray<double,1>& fieldOut) 1645 TRY 1518 1646 { 1519 1647 CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; … … 1524 1652 } 1525 1653 } 1654 CATCH_DUMP_ATTR 1526 1655 1527 1656 ///------------------------------------------------------------------- 1528 1657 1529 1658 void CField::parse(xml::CXMLNode& node) 1659 TRY 1530 1660 { 1531 1661 string newContent ; … … 1542 1672 if (node.getContent(newContent)) content=newContent ; 1543 1673 } 1674 CATCH_DUMP_ATTR 1544 1675 1545 1676 /*! … … 1549 1680 */ 1550 1681 const std::vector<StdString>& CField::getRefDomainAxisIds() 1682 TRY 1551 1683 { 1552 1684 CGrid* cgPtr = getRelGrid(); … … 1577 1709 return (domAxisScalarIds_); 1578 1710 } 1711 CATCH_DUMP_ATTR 1579 1712 1580 1713 CVariable* CField::addVariable(const string& id) 1714 TRY 1581 1715 { 1582 1716 return vVariableGroup->createChild(id); 1583 1717 } 1718 CATCH 1584 1719 1585 1720 CVariableGroup* CField::addVariableGroup(const string& id) 1721 TRY 1586 1722 { 1587 1723 return vVariableGroup->createChildGroup(id); 1588 1724 } 1725 CATCH 1589 1726 1590 1727 void CField::setContextClient(CContextClient* contextClient) 1728 TRY 1591 1729 { 1592 1730 CContext* context = CContext::getCurrent(); … … 1604 1742 } 1605 1743 } 1744 CATCH_DUMP_ATTR 1606 1745 1607 1746 CContextClient* CField::getContextClient() 1747 TRY 1608 1748 { 1609 1749 return client; 1610 1750 } 1751 CATCH 1611 1752 1612 1753 void CField::sendAddAllVariables(CContextClient* client) 1754 TRY 1613 1755 { 1614 1756 std::vector<CVariable*> allVar = getAllVariables(); … … 1623 1765 } 1624 1766 } 1625 1767 CATCH_DUMP_ATTR 1626 1768 1627 1769 /*! … … 1631 1773 1632 1774 void CField::sendAllAttributesToServer(CContextClient* client) 1775 TRY 1633 1776 { 1634 1777 if (grid_ref.isEmpty()) … … 1640 1783 else SuperClass::sendAllAttributesToServer(client) ; 1641 1784 } 1785 CATCH_DUMP_ATTR 1642 1786 1643 1787 void CField::sendAddVariable(const string& id, CContextClient* client) 1788 TRY 1644 1789 { 1645 1790 sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE, client); 1646 1791 } 1792 CATCH_DUMP_ATTR 1647 1793 1648 1794 void CField::sendAddVariableGroup(const string& id, CContextClient* client) 1795 TRY 1649 1796 { 1650 1797 sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE_GROUP, client); 1651 1798 } 1799 CATCH_DUMP_ATTR 1652 1800 1653 1801 void CField::recvAddVariable(CEventServer& event) 1802 TRY 1654 1803 { 1655 1804 … … 1659 1808 get(id)->recvAddVariable(*buffer); 1660 1809 } 1810 CATCH 1661 1811 1662 1812 void CField::recvAddVariable(CBufferIn& buffer) 1813 TRY 1663 1814 { 1664 1815 string id; … … 1666 1817 addVariable(id); 1667 1818 } 1819 CATCH_DUMP_ATTR 1668 1820 1669 1821 void CField::recvAddVariableGroup(CEventServer& event) 1822 TRY 1670 1823 { 1671 1824 … … 1675 1828 get(id)->recvAddVariableGroup(*buffer); 1676 1829 } 1830 CATCH 1677 1831 1678 1832 void CField::recvAddVariableGroup(CBufferIn& buffer) 1833 TRY 1679 1834 { 1680 1835 string id; … … 1682 1837 addVariableGroup(id); 1683 1838 } 1839 CATCH_DUMP_ATTR 1684 1840 1685 1841 /*! … … 1687 1843 */ 1688 1844 void CField::checkTimeAttributes(CDuration* freqOp) 1845 TRY 1689 1846 { 1690 1847 bool isFieldRead = file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read; … … 1708 1865 freq_offset.setValue(isFieldRead ? NoneDu : (freq_op.getValue() - TimeStep)); 1709 1866 } 1867 CATCH_DUMP_ATTR 1710 1868 1711 1869 /*! … … 1714 1872 */ 1715 1873 const string& CField::getExpression(void) 1874 TRY 1716 1875 { 1717 1876 if (!expr.isEmpty() && content.empty()) … … 1723 1882 return content; 1724 1883 } 1884 CATCH_DUMP_ATTR 1725 1885 1726 1886 bool CField::hasExpression(void) const 1887 TRY 1727 1888 { 1728 1889 return (!expr.isEmpty() || !content.empty()); 1729 1890 } 1730 1891 CATCH 1892 1893 bool CField::hasGridMask(void) const 1894 TRY 1895 { 1896 return (this->grid->hasMask()); 1897 } 1898 CATCH 1731 1899 1732 1900 DEFINE_REF_FUNC(Field,field) -
XIOS/dev/branch_openmp/src/node/field.hpp
r1545 r1642 209 209 bool hasExpression(void) const; 210 210 211 bool hasGridMask(void) const; 212 211 213 public: 212 214 /// Propriétés privées /// -
XIOS/dev/branch_openmp/src/node/field_impl.hpp
r1460 r1642 17 17 template <int N> 18 18 void CField::setData(const CArray<double, N>& _data) 19 TRY 19 20 { 20 21 if (clientSourceFilter) … … 27 28 << "Impossible to receive data from the model for a field [ id = " << getId() << " ] with a reference or an arithmetic operation."); 28 29 } 30 CATCH_DUMP_ATTR 29 31 30 32 template <int N> 31 33 void CField::getData(CArray<double, N>& _data) const 34 TRY 32 35 { 33 36 if (storeFilter) … … 45 48 } 46 49 } 50 CATCH 47 51 } // namespace xios 48 52 -
XIOS/dev/branch_openmp/src/node/file.cpp
r1556 r1642 25 25 CFile::CFile(void) 26 26 : CObjectTemplate<CFile>(), CFileAttributes() 27 , vFieldGroup(), data_out(), enabledFields(), fileComm( MPI_COMM_NULL)27 , vFieldGroup(), data_out(), enabledFields(), fileComm(EP_COMM_NULL) 28 28 , isOpen(false), read_client(0), checkRead(false), allZoneEmpty(false) 29 29 { … … 34 34 CFile::CFile(const StdString & id) 35 35 : CObjectTemplate<CFile>(id), CFileAttributes() 36 , vFieldGroup(), data_out(), enabledFields(), fileComm( MPI_COMM_NULL)36 , vFieldGroup(), data_out(), enabledFields(), fileComm(EP_COMM_NULL) 37 37 , isOpen(false), read_client(0), checkRead(false), allZoneEmpty(false) 38 38 { … … 53 53 54 54 const StdString CFile::getFileOutputName(void) const 55 TRY 55 56 { 56 57 return (name.isEmpty() ? getId() : name) + (name_suffix.isEmpty() ? StdString("") : name_suffix.getValue()); 57 58 } 59 CATCH 58 60 59 61 //---------------------------------------------------------------- … … 65 67 */ 66 68 std::shared_ptr<CDataOutput> CFile::getDataOutput(void) const 69 TRY 67 70 { 68 71 return data_out; 69 72 } 73 CATCH 70 74 71 75 /*! … … 76 80 */ 77 81 std::shared_ptr<CDataInput> CFile::getDataInput(void) const 82 TRY 78 83 { 79 84 return data_in; 80 85 } 86 CATCH 81 87 82 88 /*! … … 88 94 */ 89 95 CFieldGroup* CFile::getVirtualFieldGroup(void) const 96 TRY 90 97 { 91 98 return (this->vFieldGroup); 92 99 } 100 CATCH 93 101 94 102 /*! … … 100 108 */ 101 109 CVariableGroup* CFile::getVirtualVariableGroup(void) const 110 TRY 102 111 { 103 112 return (this->vVariableGroup); 104 113 } 114 CATCH 105 115 106 116 //! Get all fields of a file 107 117 std::vector<CField*> CFile::getAllFields(void) const 118 TRY 108 119 { 109 120 return (this->vFieldGroup->getAllChildren()); 110 121 } 122 CATCH 111 123 112 124 //! Get all variables of a file 113 125 std::vector<CVariable*> CFile::getAllVariables(void) const 126 TRY 114 127 { 115 128 return (this->vVariableGroup->getAllChildren()); 116 129 } 130 CATCH 117 131 118 132 //---------------------------------------------------------------- … … 129 143 int default_level, 130 144 bool default_enabled) 145 TRY 131 146 { 132 147 if (!this->enabledFields.empty()) … … 145 160 { 146 161 if (! (*it)->enabled.getValue()) continue; 147 // { it--; this->enabledFields.erase(it+1); continue; }148 162 } 149 163 else // Si l'attribut 'enabled' n'est pas dfini ... 150 164 { 151 165 if (!default_enabled) continue; 152 // { it--; this->enabledFields.erase(it+1); continue; }153 166 } 154 167 … … 156 169 { 157 170 if ((*it)->level.getValue() > _outputlevel) continue; 158 // { it--; this->enabledFields.erase(it+1); continue; }159 171 } 160 172 else // Si l'attribut 'level' n'est pas dfini ... 161 173 { 162 174 if (default_level > _outputlevel) continue; 163 // { it--; this->enabledFields.erase(it+1); continue; }164 175 } 165 176 166 // CField* field_tmp=(*it).get();167 // shared_ptr<CField> sptfield=*it;168 // field_tmp->refObject.push_back(sptfield);169 177 newEnabledFields.push_back(*it); 170 // Le champ est finalement actif, on y ajoute sa propre reference.171 // (*it)->refObject.push_back(*it);172 178 // Le champ est finalement actif, on y ajoute la rfrence au champ de base. 173 179 (*it)->setRelFile(CFile::get(this)); … … 177 183 return (this->enabledFields); 178 184 } 185 CATCH_DUMP_ATTR 179 186 180 187 //---------------------------------------------------------------- 181 188 //! Change virtual field group to a new one 182 189 void CFile::setVirtualFieldGroup(CFieldGroup* newVFieldGroup) 190 TRY 183 191 { 184 192 this->vFieldGroup = newVFieldGroup; 185 193 } 194 CATCH_DUMP_ATTR 186 195 187 196 //! Change virtual variable group to new one 188 197 void CFile::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 198 TRY 189 199 { 190 200 this->vVariableGroup = newVVariableGroup; 191 201 } 202 CATCH_DUMP_ATTR 192 203 193 204 //---------------------------------------------------------------- 194 205 bool CFile::isSyncTime(void) 206 TRY 195 207 { 196 208 CContext* context = CContext::getCurrent(); … … 206 218 return false; 207 219 } 220 CATCH_DUMP_ATTR 208 221 209 222 //! Initialize a file in order to write into it 210 223 void CFile::initWrite(void) 224 TRY 211 225 { 212 226 CContext* context = CContext::getCurrent(); … … 261 275 if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 262 276 } 277 CATCH_DUMP_ATTR 263 278 264 279 //! Initialize a file in order to write into it 265 280 void CFile::initRead(void) 281 TRY 266 282 { 267 283 if (checkRead) return; … … 269 285 checkRead = true; 270 286 } 287 CATCH_DUMP_ATTR 271 288 272 289 /*! … … 274 291 */ 275 292 void CFile::createSubComFile() 293 TRY 276 294 { 277 295 CContext* context = CContext::getCurrent(); … … 292 310 if (allZoneEmpty) ep_lib::MPI_Comm_free(&fileComm); 293 311 } 312 CATCH_DUMP_ATTR 294 313 295 314 /* … … 299 318 */ 300 319 void CFile::checkWriteFile(void) 320 TRY 301 321 { 302 322 CContext* context = CContext::getCurrent(); … … 315 335 } 316 336 } 337 CATCH_DUMP_ATTR 317 338 318 339 /* … … 323 344 */ 324 345 void CFile::checkReadFile(void) 346 TRY 325 347 { 326 348 CContext* context = CContext::getCurrent(); … … 340 362 } 341 363 } 364 CATCH_DUMP_ATTR 342 365 343 366 /*! … … 346 369 */ 347 370 bool CFile::isEmptyZone() 371 TRY 348 372 { 349 373 return allZoneEmpty; 350 374 } 375 CATCH_DUMP_ATTR 351 376 352 377 /*! … … 357 382 */ 358 383 bool CFile::checkSync(void) 384 TRY 359 385 { 360 386 CContext* context = CContext::getCurrent(); … … 371 397 return false; 372 398 } 399 CATCH_DUMP_ATTR 373 400 374 401 /*! … … 379 406 */ 380 407 bool CFile::checkSplit(void) 408 TRY 381 409 { 382 410 CContext* context = CContext::getCurrent(); … … 402 430 return false; 403 431 } 432 CATCH_DUMP_ATTR 404 433 405 434 /*! … … 408 437 */ 409 438 void CFile::createHeader(void) 439 TRY 410 440 { 411 441 CContext* context = CContext::getCurrent(); … … 594 624 } 595 625 } 626 CATCH_DUMP_ATTR 596 627 597 628 /*! … … 599 630 */ 600 631 void CFile::openInReadMode() 632 TRY 601 633 { 602 634 CContext* context = CContext::getCurrent(); … … 675 707 } 676 708 } 709 CATCH_DUMP_ATTR 677 710 678 711 //! Close file 679 712 void CFile::close(void) 713 TRY 680 714 { 681 715 if (!allZoneEmpty) … … 688 722 isOpen = false; 689 723 } 690 //if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm); 691 } 724 if (fileComm != EP_COMM_NULL) ep_lib::MPI_Comm_free(&fileComm); 725 } 726 CATCH_DUMP_ATTR 727 692 728 //---------------------------------------------------------------- 693 729 694 730 void CFile::readAttributesOfEnabledFieldsInReadMode() 731 TRY 695 732 { 696 733 if (enabledFields.empty()) return; … … 713 750 714 751 // Read necessary value from file 715 #pragma omp critical (_func)716 752 this->data_in->readFieldAttributesValues(enabledFields[idx]); 717 753 … … 723 759 close(); 724 760 } 725 761 CATCH_DUMP_ATTR 726 762 727 763 /*! … … 730 766 */ 731 767 void CFile::parse(xml::CXMLNode & node) 768 TRY 732 769 { 733 770 SuperClass::parse(node); … … 742 779 node.goToParentElement(); 743 780 } 744 745 } 781 } 782 CATCH_DUMP_ATTR 783 746 784 //---------------------------------------------------------------- 747 785 … … 751 789 */ 752 790 StdString CFile::toString(void) const 791 TRY 753 792 { 754 793 StdOStringStream oss; … … 763 802 return (oss.str()); 764 803 } 804 CATCH 765 805 766 806 //---------------------------------------------------------------- … … 773 813 */ 774 814 void CFile::solveDescInheritance(bool apply, const CAttributeMap * const parent) 815 TRY 775 816 { 776 817 SuperClassAttribute::setAttributes(parent,apply); … … 778 819 this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 779 820 } 821 CATCH_DUMP_ATTR 780 822 781 823 //---------------------------------------------------------------- … … 790 832 */ 791 833 void CFile::solveOnlyRefOfEnabledFields(bool sendToServer) 834 TRY 792 835 { 793 836 int size = this->enabledFields.size(); … … 797 840 } 798 841 } 842 CATCH_DUMP_ATTR 799 843 800 844 void CFile::checkGridOfEnabledFields() 845 TRY 801 846 { 802 847 int size = this->enabledFields.size(); … … 806 851 } 807 852 } 853 CATCH_DUMP_ATTR 808 854 809 855 void CFile::sendGridComponentOfEnabledFields() 856 TRY 810 857 { 811 858 int size = this->enabledFields.size(); … … 815 862 } 816 863 } 864 CATCH_DUMP_ATTR 817 865 818 866 /*! … … 821 869 */ 822 870 void CFile::sortEnabledFieldsForUgrid() 871 TRY 823 872 { 824 873 int size = this->enabledFields.size(); … … 869 918 } 870 919 } 920 CATCH_DUMP_ATTR 871 921 872 922 void CFile::sendGridOfEnabledFields() 923 TRY 873 924 { 874 925 int size = this->enabledFields.size(); … … 878 929 } 879 930 } 931 CATCH_DUMP_ATTR 880 932 881 933 void CFile::generateNewTransformationGridDest() 934 TRY 882 935 { 883 936 int size = this->enabledFields.size(); … … 887 940 } 888 941 } 942 CATCH_DUMP_ATTR 889 943 890 944 /*! … … 897 951 */ 898 952 void CFile::solveAllRefOfEnabledFieldsAndTransform(bool sendToServer) 953 TRY 899 954 { 900 955 int size = this->enabledFields.size(); 901 956 for (int i = 0; i < size; ++i) 902 { 903 this->enabledFields[i]->solveAllEnabledFieldsAndTransform(); 904 } 905 } 957 { 958 this->enabledFields[i]->solveAllEnabledFieldsAndTransform(); 959 } 960 } 961 CATCH_DUMP_ATTR 906 962 907 963 /*! … … 911 967 */ 912 968 void CFile::buildFilterGraphOfEnabledFields(CGarbageCollector& gc) 969 TRY 913 970 { 914 971 int size = this->enabledFields.size(); … … 918 975 } 919 976 } 977 CATCH_DUMP_ATTR 920 978 921 979 /*! … … 923 981 */ 924 982 void CFile::postProcessFilterGraph() 983 TRY 925 984 { 926 985 int size = this->enabledFields.size(); … … 930 989 } 931 990 } 991 CATCH_DUMP_ATTR 932 992 933 993 /*! … … 935 995 */ 936 996 void CFile::prefetchEnabledReadModeFields(void) 997 TRY 937 998 { 938 999 if (mode.isEmpty() || mode.getValue() != mode_attr::read) … … 943 1004 this->enabledFields[i]->sendReadDataRequest(CContext::getCurrent()->getCalendar()->getCurrentDate()); 944 1005 } 1006 CATCH_DUMP_ATTR 945 1007 946 1008 /*! … … 950 1012 */ 951 1013 void CFile::doPreTimestepOperationsForEnabledReadModeFields(void) 1014 TRY 952 1015 { 953 1016 if (mode.isEmpty() || mode.getValue() != mode_attr::read) … … 961 1024 } 962 1025 } 1026 CATCH_DUMP_ATTR 963 1027 964 1028 /*! … … 967 1031 */ 968 1032 void CFile::doPostTimestepOperationsForEnabledReadModeFields(void) 1033 TRY 969 1034 { 970 1035 if (mode.isEmpty() || mode.getValue() != mode_attr::read) … … 977 1042 } 978 1043 } 1044 CATCH_DUMP_ATTR 979 1045 980 1046 void CFile::solveFieldRefInheritance(bool apply) 1047 TRY 981 1048 { 982 1049 // Rsolution des hritages par rfrence de chacun des champs contenus dans le fichier. … … 985 1052 allF[i]->solveRefInheritance(apply); 986 1053 } 1054 CATCH_DUMP_ATTR 987 1055 988 1056 //---------------------------------------------------------------- … … 997 1065 */ 998 1066 CField* CFile::addField(const string& id) 1067 TRY 999 1068 { 1000 1069 return vFieldGroup->createChild(id); 1001 1070 } 1071 CATCH_DUMP_ATTR 1002 1072 1003 1073 /*! … … 1009 1079 */ 1010 1080 CFieldGroup* CFile::addFieldGroup(const string& id) 1081 TRY 1011 1082 { 1012 1083 return vFieldGroup->createChildGroup(id); 1013 1084 } 1085 CATCH_DUMP_ATTR 1014 1086 1015 1087 /*! … … 1024 1096 */ 1025 1097 CVariable* CFile::addVariable(const string& id) 1098 TRY 1026 1099 { 1027 1100 return vVariableGroup->createChild(id); 1028 1101 } 1102 CATCH_DUMP_ATTR 1029 1103 1030 1104 /*! … … 1036 1110 */ 1037 1111 CVariableGroup* CFile::addVariableGroup(const string& id) 1112 TRY 1038 1113 { 1039 1114 return vVariableGroup->createChildGroup(id); 1040 1115 } 1116 CATCH_DUMP_ATTR 1041 1117 1042 1118 void CFile::setContextClient(CContextClient* newContextClient) 1119 TRY 1043 1120 { 1044 1121 client = newContextClient; … … 1049 1126 } 1050 1127 } 1128 CATCH_DUMP_ATTR 1051 1129 1052 1130 CContextClient* CFile::getContextClient() 1131 TRY 1053 1132 { 1054 1133 return client; 1055 1134 } 1135 CATCH_DUMP_ATTR 1056 1136 1057 1137 void CFile::setReadContextClient(CContextClient* readContextclient) 1138 TRY 1058 1139 { 1059 1140 read_client = readContextclient; 1060 1141 } 1142 CATCH_DUMP_ATTR 1061 1143 1062 1144 CContextClient* CFile::getReadContextClient() 1145 TRY 1063 1146 { 1064 1147 return read_client; 1065 1148 } 1149 CATCH_DUMP_ATTR 1066 1150 1067 1151 /*! … … 1070 1154 */ 1071 1155 void CFile::sendAddField(const string& id, CContextClient* client) 1156 TRY 1072 1157 { 1073 1158 sendAddItem(id, EVENT_ID_ADD_FIELD, client); 1074 1159 } 1160 CATCH_DUMP_ATTR 1075 1161 1076 1162 /*! … … 1079 1165 */ 1080 1166 void CFile::sendAddFieldGroup(const string& id, CContextClient* client) 1167 TRY 1081 1168 { 1082 1169 sendAddItem(id, (int)EVENT_ID_ADD_FIELD_GROUP, client); 1083 1170 } 1171 CATCH_DUMP_ATTR 1084 1172 1085 1173 /*! … … 1088 1176 */ 1089 1177 void CFile::recvAddField(CEventServer& event) 1178 TRY 1090 1179 { 1091 1180 … … 1095 1184 get(id)->recvAddField(*buffer); 1096 1185 } 1186 CATCH 1097 1187 1098 1188 /*! … … 1101 1191 */ 1102 1192 void CFile::recvAddField(CBufferIn& buffer) 1193 TRY 1103 1194 { 1104 1195 string id; … … 1106 1197 addField(id); 1107 1198 } 1199 CATCH_DUMP_ATTR 1108 1200 1109 1201 /*! … … 1112 1204 */ 1113 1205 void CFile::recvAddFieldGroup(CEventServer& event) 1206 TRY 1114 1207 { 1115 1208 … … 1119 1212 get(id)->recvAddFieldGroup(*buffer); 1120 1213 } 1214 CATCH 1121 1215 1122 1216 /*! … … 1125 1219 */ 1126 1220 void CFile::recvAddFieldGroup(CBufferIn& buffer) 1221 TRY 1127 1222 { 1128 1223 string id; … … 1130 1225 addFieldGroup(id); 1131 1226 } 1227 CATCH_DUMP_ATTR 1132 1228 1133 1229 /*! … … 1138 1234 */ 1139 1235 void CFile::sendAddAllVariables(CContextClient* client) 1236 TRY 1140 1237 { 1141 1238 std::vector<CVariable*> allVar = getAllVariables(); … … 1150 1247 } 1151 1248 } 1249 CATCH_DUMP_ATTR 1152 1250 1153 1251 /*! … … 1157 1255 */ 1158 1256 void CFile::sendAddVariableGroup(const string& id, CContextClient* client) 1257 TRY 1159 1258 { 1160 1259 sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE_GROUP, client); 1161 1260 } 1261 CATCH_DUMP_ATTR 1162 1262 1163 1263 /* … … 1167 1267 */ 1168 1268 void CFile::sendAddVariable(const string& id, CContextClient* client) 1269 TRY 1169 1270 { 1170 1271 sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE, client); 1171 1272 } 1273 CATCH_DUMP_ATTR 1172 1274 1173 1275 /*! … … 1176 1278 */ 1177 1279 void CFile::recvAddVariable(CEventServer& event) 1178 {1179 1280 TRY 1281 { 1180 1282 CBufferIn* buffer = event.subEvents.begin()->buffer; 1181 1283 string id; … … 1183 1285 get(id)->recvAddVariable(*buffer); 1184 1286 } 1287 CATCH 1185 1288 1186 1289 /*! … … 1189 1292 */ 1190 1293 void CFile::recvAddVariable(CBufferIn& buffer) 1294 TRY 1191 1295 { 1192 1296 string id; … … 1194 1298 addVariable(id); 1195 1299 } 1300 CATCH_DUMP_ATTR 1196 1301 1197 1302 /*! … … 1200 1305 */ 1201 1306 void CFile::recvAddVariableGroup(CEventServer& event) 1307 TRY 1202 1308 { 1203 1309 … … 1207 1313 get(id)->recvAddVariableGroup(*buffer); 1208 1314 } 1315 CATCH 1209 1316 1210 1317 /*! … … 1213 1320 */ 1214 1321 void CFile::recvAddVariableGroup(CBufferIn& buffer) 1322 TRY 1215 1323 { 1216 1324 string id; … … 1218 1326 addVariableGroup(id); 1219 1327 } 1328 CATCH_DUMP_ATTR 1220 1329 1221 1330 /*! … … 1227 1336 */ 1228 1337 void CFile::sendEnabledFields(CContextClient* client) 1338 TRY 1229 1339 { 1230 1340 size_t size = this->enabledFields.size(); … … 1238 1348 } 1239 1349 } 1240 1350 CATCH_DUMP_ATTR 1241 1351 1242 1352 /*! … … 1248 1358 */ 1249 1359 bool CFile::dispatchEvent(CEventServer& event) 1360 TRY 1250 1361 { 1251 1362 if (SuperClass::dispatchEvent(event)) return true; … … 1279 1390 } 1280 1391 } 1281 1282 1283 1392 CATCH 1393 1394 ///-------------------------------------------------------------- 1395 /*! 1396 */ 1397 StdString CFile::dumpClassAttributes(void) 1398 { 1399 StdString str; 1400 CContext* context = CContext::getCurrent(); 1401 str.append("context=\""); 1402 str.append(context->getId()); 1403 str.append("\""); 1404 str.append(" enabled fields=\""); 1405 int size = this->enabledFields.size(); 1406 for (int i = 0; i < size; ++i) 1407 { 1408 str.append(this->enabledFields[i]->getId()); 1409 str.append(" "); 1410 } 1411 str.append("\""); 1412 return str; 1413 } 1284 1414 1285 1415 ///--------------------------------------------------------------- -
XIOS/dev/branch_openmp/src/node/file.hpp
r1545 r1642 4 4 /// XIOS headers /// 5 5 #include "xios_spl.hpp" 6 #include "mpi_std.hpp"7 6 #include "field.hpp" 8 7 #include "data_output.hpp" … … 13 12 #include "attribute_enum_impl.hpp" 14 13 #include "context_client.hpp" 15 14 #include "mpi.hpp" 16 15 17 16 namespace xios { … … 82 81 int default_level = 1, 83 82 bool default_enabled = true); 83 84 StdString dumpClassAttributes(void); 84 85 85 86 public : -
XIOS/dev/branch_openmp/src/node/generate_rectilinear_domain.hpp
r1331 r1642 60 60 static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CGenerateRectilinearDomain 64 63 -
XIOS/dev/branch_openmp/src/node/grid.cpp
r1545 r1642 82 82 83 83 StdSize CGrid::getDimension(void) 84 TRY 84 85 { 85 86 return getGlobalDimension().size(); 86 87 } 88 CATCH_DUMP_ATTR 87 89 88 90 //--------------------------------------------------------------- 89 91 90 92 StdSize CGrid::getDataSize(void) const 93 TRY 91 94 { 92 95 StdSize retvalue = 1; … … 98 101 return retvalue; 99 102 } 103 CATCH 100 104 101 105 /*! … … 106 110 */ 107 111 std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client, bool bufferForWriting) 112 TRY 108 113 { 109 114 std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client); … … 147 152 return attributesSizes; 148 153 } 154 CATCH_DUMP_ATTR 149 155 150 156 /*! … … 156 162 */ 157 163 std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/, bool bufferForWriting /*= "false"*/) 164 TRY 158 165 { 159 166 // The record index is sometimes sent along with the data but we always … … 180 187 return dataSizes; 181 188 } 189 CATCH_DUMP_ATTR 182 190 183 191 size_t CGrid::getGlobalWrittenSize(void) 192 TRY 184 193 { 185 194 std::vector<CDomain*> domainP = this->getDomains(); … … 191 200 return globalGridSize ; 192 201 } 193 202 CATCH_DUMP_ATTR 194 203 195 204 void CGrid::checkAttributesAfterTransformation() 205 TRY 196 206 { 197 207 setAxisList(); … … 228 238 } 229 239 } 240 CATCH_DUMP_ATTR 230 241 231 242 //--------------------------------------------------------------- … … 237 248 */ 238 249 bool CGrid::isCompressible(void) const 250 TRY 239 251 { 240 252 return isCompressible_; 241 253 } 254 CATCH 242 255 243 256 //--------------------------------------------------------------- 244 257 245 258 void CGrid::addRelFileCompressed(const StdString& filename) 259 TRY 246 260 { 247 261 this->relFilesCompressed.insert(filename); 248 262 } 263 CATCH_DUMP_ATTR 249 264 250 265 bool CGrid::isWrittenCompressed(const StdString& filename) const 266 TRY 251 267 { 252 268 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 253 269 } 270 CATCH 254 271 255 272 //--------------------------------------------------------------- … … 258 275 */ 259 276 void CGrid::solveDomainAxisRef(bool areAttributesChecked) 277 TRY 260 278 { 261 279 if (this->isDomainAxisChecked) return; … … 266 284 this->isDomainAxisChecked = areAttributesChecked; 267 285 } 286 CATCH_DUMP_ATTR 268 287 269 288 /* … … 272 291 */ 273 292 void CGrid::solveDomainAxisBaseRef() 293 TRY 274 294 { 275 295 if (this->hasDomainAxisBaseRef_) return; … … 297 317 this->hasDomainAxisBaseRef_ = true; 298 318 } 319 CATCH_DUMP_ATTR 299 320 300 321 void CGrid::checkEligibilityForCompressedOutput() 322 TRY 301 323 { 302 324 // We don't check if the mask is valid here, just if a mask has been defined at this point. 303 325 isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty(); 304 326 } 327 CATCH_DUMP_ATTR 305 328 306 329 void CGrid::checkMaskIndex(bool doSendingIndex) 330 TRY 307 331 { 308 332 CContext* context = CContext::getCurrent(); … … 339 363 this->isChecked = true; 340 364 } 365 CATCH_DUMP_ATTR 366 bool CGrid::hasMask() const 367 TRY 368 { 369 return (!mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty() || 370 !mask_4d.isEmpty() || !mask_5d.isEmpty() || !mask_6d.isEmpty() || !mask_7d.isEmpty()); 371 } 372 CATCH 341 373 342 374 /* … … 344 376 */ 345 377 void CGrid::createMask(void) 378 TRY 346 379 { 347 380 using namespace std; … … 381 414 } 382 415 } 416 CATCH_DUMP_ATTR 383 417 384 418 /* … … 386 420 */ 387 421 void CGrid::checkMask(void) 422 TRY 388 423 { 389 424 using namespace std; … … 423 458 } 424 459 } 425 426 427 /*! 428 A grid can have multiple dimension, so can its mask in the form of multi-dimension array. 429 It's not a good idea to store all multi-dimension arrays corresponding to each mask. 430 One of the ways is to convert this array into 1-dimension one and every process is taken place on it. 431 \param [in] multi-dimension array grid mask 432 */ 433 434 void CGrid::getLocalMask(CArray<bool,1>& localMask) 435 { 436 std::vector<CDomain*> domainP = this->getDomains(); 437 std::vector<CAxis*> axisP = this->getAxis(); 438 int dim = domainP.size() * 2 + axisP.size(); 439 440 switch (dim) 441 { 442 case 0: 443 getLocalMask(mask_0d, localMask); 444 break; 445 case 1: 446 getLocalMask(mask_1d, localMask); 447 break; 448 case 2: 449 getLocalMask(mask_2d, localMask); 450 break; 451 case 3: 452 getLocalMask(mask_3d, localMask); 453 break; 454 case 4: 455 getLocalMask(mask_4d, localMask); 456 break; 457 case 5: 458 getLocalMask(mask_5d, localMask); 459 break; 460 case 6: 461 getLocalMask(mask_6d, localMask); 462 break; 463 case 7: 464 getLocalMask(mask_7d, localMask); 465 break; 466 default: 467 break; 468 } 469 } 470 460 CATCH_DUMP_ATTR 461 471 462 /* 472 463 Modify value of mask in a certain index … … 476 467 */ 477 468 void CGrid::modifyMask(const CArray<int,1>& indexToModify, bool modifyValue) 469 TRY 478 470 { 479 471 using namespace std; … … 511 503 } 512 504 } 505 CATCH_DUMP_ATTR 513 506 514 507 /* … … 518 511 */ 519 512 void CGrid::modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue) 513 TRY 520 514 { 521 515 std::vector<CDomain*> domainP = this->getDomains(); … … 552 546 } 553 547 } 548 CATCH_DUMP_ATTR 554 549 555 550 //--------------------------------------------------------------- 556 551 557 552 void CGrid::solveDomainRef(bool sendAtt) 553 TRY 558 554 { 559 555 setDomainList(); … … 568 564 } 569 565 } 566 CATCH_DUMP_ATTR 570 567 571 568 //--------------------------------------------------------------- 572 569 573 570 void CGrid::solveAxisRef(bool sendAtt) 571 TRY 574 572 { 575 573 setAxisList(); … … 599 597 } 600 598 } 599 CATCH_DUMP_ATTR 601 600 602 601 //--------------------------------------------------------------- 603 602 604 603 void CGrid::solveScalarRef(bool sendAtt) 604 TRY 605 605 { 606 606 setScalarList(); … … 616 616 } 617 617 } 618 CATCH_DUMP_ATTR 618 619 619 620 /*! … … 621 622 */ 622 623 void CGrid::computeWrittenIndex() 624 TRY 623 625 { 624 626 if (computedWrittenIndex_) return; … … 659 661 { 660 662 CContextServer* server = CContext::getCurrent()->server; 661 MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm);662 MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm);663 ep_lib::MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, EP_INT, EP_SUM, server->intraComm); 664 ep_lib::MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, EP_INT, EP_SUM, server->intraComm); 663 665 offsetWrittenIndexes_ -= numberWrittenIndexes_; 664 666 } … … 680 682 } 681 683 } 684 CATCH_DUMP_ATTR 682 685 683 686 //--------------------------------------------------------------- … … 690 693 */ 691 694 void CGrid::computeClientIndex() 695 TRY 692 696 { 693 697 CContext* context = CContext::getCurrent(); 694 698 695 CContextClient* client = context->client; // Here it's not important which contextClient to recuperate699 CContextClient* client = context->client; 696 700 int rank = client->clientRank; 697 701 698 702 clientDistribution_ = new CDistributionClient(rank, this); 699 703 // Get local data index on client 700 storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 701 int nbStoreIndex = storeIndex_client.numElements(); 704 int nbStoreIndex = clientDistribution_->getLocalDataIndexOnClient().size(); 705 int nbStoreGridMask = clientDistribution_->getLocalMaskIndexOnClient().size(); 706 // nbStoreGridMask = nbStoreIndex if grid mask is defined, and 0 otherwise 707 storeIndex_client.resize(nbStoreIndex); 708 storeMask_client.resize(nbStoreGridMask); 702 709 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 710 for (int idx = 0; idx < nbStoreGridMask; ++idx) storeMask_client(idx) = (clientDistribution_->getLocalMaskIndexOnClient())[idx]; 703 711 704 712 if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); … … 746 754 } 747 755 } 756 CATCH_DUMP_ATTR 748 757 749 758 /*! … … 751 760 */ 752 761 void CGrid::computeConnectedClients() 762 TRY 753 763 { 754 764 CContext* context = CContext::getCurrent(); … … 840 850 connectedServerRank_[receiverSize].push_back(client->clientRank % client->serverSize); 841 851 852 // Now check if all servers have data to receive. If not, master client will send empty data. 853 // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive. 854 std::vector<int> counts (client->clientSize); 855 std::vector<int> displs (client->clientSize); 856 displs[0] = 0; 857 int localCount = connectedServerRank_[receiverSize].size() ; 858 ep_lib::MPI_Gather(&localCount, 1, EP_INT, &counts[0], 1, EP_INT, 0, client->intraComm) ; 859 for (int i = 0; i < client->clientSize-1; ++i) 860 { 861 displs[i+1] = displs[i] + counts[i]; 862 } 863 std::vector<int> allConnectedServers(displs[client->clientSize-1]+counts[client->clientSize-1]); 864 ep_lib::MPI_Gatherv(&(connectedServerRank_[receiverSize])[0], localCount, EP_INT, &allConnectedServers[0], &counts[0], &displs[0], EP_INT, 0, client->intraComm); 865 866 if ((allConnectedServers.size() != receiverSize) && (client->clientRank == 0)) 867 { 868 std::vector<bool> isSrvConnected (receiverSize, false); 869 for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true; 870 for (int i = 0; i < receiverSize; ++i) 871 { 872 if (!isSrvConnected[i]) connectedServerRank_[receiverSize].push_back(i); 873 } 874 } 875 842 876 nbSenders[receiverSize] = clientServerMap_->computeConnectedClients(receiverSize, client->clientSize, client->intraComm, connectedServerRank_[receiverSize]); 843 877 } 844 878 } 845 879 } 880 CATCH_DUMP_ATTR 846 881 847 882 /*! … … 853 888 */ 854 889 void CGrid::computeIndex(void) 890 TRY 855 891 { 856 892 CContext* context = CContext::getCurrent(); … … 879 915 } 880 916 } 917 CATCH_DUMP_ATTR 881 918 882 919 /*! … … 892 929 const CContextClient* client, 893 930 CClientServerMapping::GlobalIndexMap& globalIndexOnServer) 931 TRY 894 932 { 895 933 int serverSize = client->serverSize; … … 1058 1096 } 1059 1097 } 1060 //---------------------------------------------------------------- 1098 CATCH_DUMP_ATTR 1099 //---------------------------------------------------------------- 1061 1100 1062 1101 CGrid* CGrid::createGrid(CDomain* domain) 1102 TRY 1063 1103 { 1064 1104 std::vector<CDomain*> vecDom(1, domain); … … 1067 1107 return createGrid(vecDom, vecAxis); 1068 1108 } 1109 CATCH 1069 1110 1070 1111 CGrid* CGrid::createGrid(CDomain* domain, CAxis* axis) 1071 { 1112 TRY 1113 { 1072 1114 std::vector<CDomain*> vecDom(1, domain); 1073 1115 std::vector<CAxis*> vecAxis(1, axis); … … 1075 1117 return createGrid(vecDom, vecAxis); 1076 1118 } 1119 CATCH 1077 1120 1078 1121 CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 1079 1122 const CArray<int,1>& axisDomainOrder) 1123 TRY 1080 1124 { 1081 1125 std::vector<CScalar*> vecScalar; 1082 1126 return createGrid(generateId(domains, axis, vecScalar, axisDomainOrder), domains, axis, vecScalar, axisDomainOrder); 1083 1127 } 1128 CATCH 1084 1129 1085 1130 CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 1086 1131 const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 1132 TRY 1087 1133 { 1088 1134 return createGrid(generateId(domains, axis, scalars, axisDomainOrder), domains, axis, scalars, axisDomainOrder); 1089 1135 } 1136 CATCH 1090 1137 1091 1138 CGrid* CGrid::createGrid(StdString id, const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 1092 1139 const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 1140 TRY 1093 1141 { 1094 1142 if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size())) … … 1132 1180 return grid; 1133 1181 } 1182 CATCH 1134 1183 1135 1184 CGrid* CGrid::cloneGrid(const StdString& idNewGrid, CGrid* gridSrc) 1185 TRY 1136 1186 { 1137 1187 std::vector<CDomain*> domainSrcTmp = gridSrc->getDomains(), domainSrc; … … 1173 1223 return grid; 1174 1224 } 1225 CATCH 1175 1226 1176 1227 StdString CGrid::generateId(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 1177 1228 const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 1229 TRY 1178 1230 { 1179 1231 if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size())) … … 1216 1268 return id.str(); 1217 1269 } 1270 CATCH 1218 1271 1219 1272 StdString CGrid::generateId(const CGrid* gridSrc, const CGrid* gridDest) 1273 TRY 1220 1274 { 1221 1275 StdString idSrc = gridSrc->getId(); … … 1227 1281 return id.str(); 1228 1282 } 1283 CATCH 1229 1284 1230 1285 //---------------------------------------------------------------- 1231 1286 1232 1287 CDomainGroup* CGrid::getVirtualDomainGroup() const 1288 TRY 1233 1289 { 1234 1290 return this->vDomainGroup_; 1235 1291 } 1292 CATCH 1236 1293 1237 1294 CAxisGroup* CGrid::getVirtualAxisGroup() const 1295 TRY 1238 1296 { 1239 1297 return this->vAxisGroup_; 1240 1298 } 1299 CATCH 1241 1300 1242 1301 CScalarGroup* CGrid::getVirtualScalarGroup() const 1302 TRY 1243 1303 { 1244 1304 return this->vScalarGroup_; 1245 1305 } 1306 CATCH 1246 1307 1247 1308 /* … … 1279 1340 1280 1341 void CGrid::storeField_arr(const double* const data, CArray<double, 1>& stored) const 1342 TRY 1281 1343 { 1282 1344 const StdSize size = storeIndex_client.numElements(); … … 1285 1347 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 1286 1348 } 1349 CATCH 1287 1350 1288 1351 void CGrid::restoreField_arr(const CArray<double, 1>& stored, double* const data) const 1352 TRY 1289 1353 { 1290 1354 const StdSize size = storeIndex_client.numElements(); … … 1292 1356 for(StdSize i = 0; i < size; i++) data[storeIndex_client(i)] = stored(i); 1293 1357 } 1358 CATCH 1359 1360 void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) const 1361 { 1362 const StdSize size = storeIndex_client.numElements(); 1363 stored.resize(size); 1364 const double nanValue = std::numeric_limits<double>::quiet_NaN(); 1365 1366 if (storeMask_client.numElements() != 0) 1367 for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue; 1368 else 1369 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 1370 } 1294 1371 1295 1372 void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const 1373 TRY 1296 1374 { 1297 1375 const std::vector<int>& localMaskedDataIndex = clientDistribution_->getLocalMaskedDataIndexOnClient(); 1298 1376 const int size = localMaskedDataIndex.size(); 1299 1300 1377 for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i]; 1301 1378 } 1302 1379 CATCH 1303 1380 1304 1381 void CGrid::computeClientIndexScalarGrid() 1382 TRY 1305 1383 { 1306 1384 CContext* context = CContext::getCurrent(); 1307 // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; // This should be changed soon 1308 // for (int p = 0; p < nbSrvPools; ++p) 1309 { 1310 // CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[p] : context->client) 1311 // : context->client; 1385 { 1312 1386 CContextClient* client = context->client; 1313 1387 … … 1340 1414 } 1341 1415 } 1416 CATCH_DUMP_ATTR 1342 1417 1343 1418 void CGrid::computeConnectedClientsScalarGrid() 1419 TRY 1344 1420 { 1345 1421 CContext* context = CContext::getCurrent(); … … 1386 1462 } 1387 1463 } 1464 CATCH_DUMP_ATTR 1388 1465 1389 1466 void CGrid::sendIndexScalarGrid() 1467 TRY 1390 1468 { 1391 1469 CContext* context = CContext::getCurrent(); … … 1451 1529 } 1452 1530 } 1531 CATCH_DUMP_ATTR 1453 1532 1454 1533 void CGrid::sendIndex(void) 1534 TRY 1455 1535 { 1456 1536 CContext* context = CContext::getCurrent(); … … 1572 1652 } 1573 1653 } 1654 CATCH_DUMP_ATTR 1574 1655 1575 1656 void CGrid::recvIndex(CEventServer& event) 1657 TRY 1576 1658 { 1577 1659 string gridId; … … 1589 1671 get(gridId)->recvIndex(ranks, buffers); 1590 1672 } 1673 CATCH 1591 1674 1592 1675 void CGrid::recvIndex(vector<int> ranks, vector<CBufferIn*> buffers) 1676 TRY 1593 1677 { 1594 1678 CContext* context = CContext::getCurrent(); … … 1631 1715 std::vector<CDomain*> domainList = getDomains(); 1632 1716 std::vector<CAxis*> axisList = getAxis(); 1633 std::vector<int> n ZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize), nGlobElement(numElement);1634 std::vector<CArray<int,1> > global ZoomIndex(numElement);1717 std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize), nGlobElement(numElement); 1718 std::vector<CArray<int,1> > globalIndex(numElement); 1635 1719 for (int i = 0; i < numElement; ++i) 1636 1720 { … … 1638 1722 if (2 == axis_domain_order(i)) //domain 1639 1723 { 1640 n ZoomBegin[indexMap[i]] = domainList[domainId]->zoom_ibegin;1641 n ZoomSize[indexMap[i]] = domainList[domainId]->zoom_ni;1642 n ZoomBeginGlobal[indexMap[i]] = domainList[domainId]->global_zoom_ibegin;1724 nBegin[indexMap[i]] = domainList[domainId]->ibegin; 1725 nSize[indexMap[i]] = domainList[domainId]->ni; 1726 nBeginGlobal[indexMap[i]] = 0; 1643 1727 nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 1644 1728 1645 n ZoomBegin[indexMap[i] + 1] = domainList[domainId]->zoom_jbegin;1646 n ZoomSize[indexMap[i] + 1] = domainList[domainId]->zoom_nj;1647 n ZoomBeginGlobal[indexMap[i] + 1] = domainList[domainId]->global_zoom_jbegin;1729 nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin; 1730 nSize[indexMap[i] + 1] = domainList[domainId]->nj; 1731 nBeginGlobal[indexMap[i] + 1] = 0; 1648 1732 nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 1649 1733 1650 1734 { 1651 1735 int count = 0; 1652 global ZoomIndex[i].resize(nZoomSize[indexMap[i]]*nZoomSize[indexMap[i]+1]);1653 for (int jdx = 0; jdx < n ZoomSize[indexMap[i]+1]; ++jdx)1654 for (int idx = 0; idx < n ZoomSize[indexMap[i]]; ++idx)1736 globalIndex[i].resize(nSize[indexMap[i]]*nSize[indexMap[i]+1]); 1737 for (int jdx = 0; jdx < nSize[indexMap[i]+1]; ++jdx) 1738 for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 1655 1739 { 1656 global ZoomIndex[i](count) = (nZoomBegin[indexMap[i]] + idx) + (nZoomBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]];1740 globalIndex[i](count) = (nBegin[indexMap[i]] + idx) + (nBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]]; 1657 1741 ++count; 1658 1742 } … … 1663 1747 else if (1 == axis_domain_order(i)) // axis 1664 1748 { 1665 n ZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin;1666 n ZoomSize[indexMap[i]] = axisList[axisId]->zoom_n;1667 n ZoomBeginGlobal[indexMap[i]] = axisList[axisId]->global_zoom_begin;1749 nBegin[indexMap[i]] = axisList[axisId]->begin; 1750 nSize[indexMap[i]] = axisList[axisId]->n; 1751 nBeginGlobal[indexMap[i]] = 0; 1668 1752 nGlob[indexMap[i]] = axisList[axisId]->n_glo; 1669 if (axisList[axisId]->zoomByIndex()) 1670 { 1671 globalZoomIndex[i].reference(axisList[axisId]->zoom_index); 1672 } 1673 else 1674 { 1675 globalZoomIndex[i].resize(nZoomSize[indexMap[i]]); 1676 for (int idx = 0; idx < nZoomSize[indexMap[i]]; ++idx) 1677 globalZoomIndex[i](idx) = nZoomBegin[indexMap[i]] + idx; 1678 } 1753 globalIndex[i].resize(nSize[indexMap[i]]); 1754 for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 1755 globalIndex[i](idx) = nBegin[indexMap[i]] + idx; 1679 1756 1680 1757 ++axisId; … … 1682 1759 else // scalar 1683 1760 { 1684 n ZoomBegin[indexMap[i]] = 0;1685 n ZoomSize[indexMap[i]] = 1;1686 n ZoomBeginGlobal[indexMap[i]] = 0;1761 nBegin[indexMap[i]] = 0; 1762 nSize[indexMap[i]] = 1; 1763 nBeginGlobal[indexMap[i]] = 0; 1687 1764 nGlob[indexMap[i]] = 1; 1688 global ZoomIndex[i].resize(1);1689 global ZoomIndex[i](0) = 0;1765 globalIndex[i].resize(1); 1766 globalIndex[i](0) = 0; 1690 1767 ++scalarId; 1691 1768 } … … 1693 1770 dataSize = 1; 1694 1771 1695 for (int i = 0; i < n ZoomSize.size(); ++i)1696 dataSize *= n ZoomSize[i];1772 for (int i = 0; i < nSize.size(); ++i) 1773 dataSize *= nSize[i]; 1697 1774 serverDistribution_ = new CDistributionServer(server->intraCommRank, 1698 global ZoomIndex, axis_domain_order,1699 n ZoomBegin, nZoomSize, nZoomBeginGlobal, nGlob);1775 globalIndex, axis_domain_order, 1776 nBegin, nSize, nBeginGlobal, nGlob); 1700 1777 } 1701 1778 … … 1760 1837 nGlob.push_back(1); 1761 1838 } 1762 1763 modifyMaskSize(nSize, false);1764 1765 // These below codes are reserved for future1766 CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob);1767 map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(),1768 ite = outGlobalIndexFromClient.end(), it;1769 const CDistributionServer::GlobalLocalMap& globalLocalMask = srvDist.getGlobalLocalIndex();1770 CDistributionServer::GlobalLocalMap::const_iterator itSrv;1771 size_t nb = 0;1772 for (it = itb; it != ite; ++it)1773 {1774 CArray<size_t,1>& globalInd = it->second;1775 for (size_t idx = 0; idx < globalInd.numElements(); ++idx)1776 {1777 if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb;1778 }1779 }1780 1781 CArray<int,1> indexToModify(nb);1782 nb = 0;1783 for (it = itb; it != ite; ++it)1784 {1785 CArray<size_t,1>& globalInd = it->second;1786 for (size_t idx = 0; idx < globalInd.numElements(); ++idx)1787 {1788 itSrv = globalLocalMask.find(globalInd(idx));1789 if (globalLocalMask.end() != itSrv)1790 {1791 indexToModify(nb) = itSrv->second;1792 ++nb;1793 }1794 }1795 }1796 1797 modifyMask(indexToModify, true);1798 1839 } 1799 1840 … … 1803 1844 } 1804 1845 } 1846 CATCH_DUMP_ATTR 1805 1847 1806 1848 /* … … 1818 1860 const std::vector<CScalar*> scalars, 1819 1861 const CArray<int,1>& axisDomainOrder) 1820 { 1862 TRY 1863 { 1821 1864 // globalDim.resize(domains.size()*2+axis.size()+scalars.size()); 1822 1865 globalDim.resize(domains.size()*2+axis.size()); … … 1858 1901 return positionDimensionDistributed; 1859 1902 } 1903 CATCH_DUMP_ATTR 1860 1904 1861 1905 // Retrieve the global dimension of grid 1862 1906 std::vector<int> CGrid::getGlobalDimension() 1907 TRY 1863 1908 { 1864 1909 std::vector<int> globalDim; … … 1867 1912 return globalDim; 1868 1913 } 1914 CATCH_DUMP_ATTR 1869 1915 1870 1916 // Retrieve dimension on which we do distribution (Very often, it should be 2nd dimension) 1871 1917 int CGrid::getDistributedDimension() 1918 TRY 1872 1919 { 1873 1920 std::vector<int> globalDim; 1874 1921 return computeGridGlobalDimension(globalDim, getDomains(), getAxis(), getScalars(), axis_domain_order); 1875 1922 } 1923 CATCH_DUMP_ATTR 1876 1924 1877 1925 bool CGrid::isScalarGrid() const 1926 TRY 1878 1927 { 1879 1928 return (axisList_.empty() && domList_.empty()); 1880 1929 } 1930 CATCH 1881 1931 1882 1932 /*! … … 1886 1936 */ 1887 1937 bool CGrid::doGridHaveDataToWrite() 1938 TRY 1888 1939 { 1889 1940 return (0 != writtenDataSize_); 1890 1941 } 1942 CATCH_DUMP_ATTR 1891 1943 1892 1944 /*! … … 1897 1949 */ 1898 1950 size_t CGrid::getWrittenDataSize() const 1951 TRY 1899 1952 { 1900 1953 return writtenDataSize_; 1901 1954 } 1955 CATCH 1902 1956 1903 1957 /*! … … 1906 1960 */ 1907 1961 int CGrid::getNumberWrittenIndexes() const 1962 TRY 1908 1963 { 1909 1964 return numberWrittenIndexes_; 1910 1965 } 1966 CATCH 1911 1967 1912 1968 /*! … … 1915 1971 */ 1916 1972 int CGrid::getTotalNumberWrittenIndexes() const 1973 TRY 1917 1974 { 1918 1975 return totalNumberWrittenIndexes_; 1919 1976 } 1977 CATCH 1920 1978 1921 1979 /*! … … 1924 1982 */ 1925 1983 int CGrid::getOffsetWrittenIndexes() const 1984 TRY 1926 1985 { 1927 1986 return offsetWrittenIndexes_; 1928 1987 } 1988 CATCH 1929 1989 1930 1990 CDistributionServer* CGrid::getDistributionServer() 1991 TRY 1931 1992 { 1932 1993 return serverDistribution_; 1933 1994 } 1995 CATCH_DUMP_ATTR 1934 1996 1935 1997 CDistributionClient* CGrid::getDistributionClient() 1998 TRY 1936 1999 { 1937 2000 return clientDistribution_; 1938 2001 } 2002 CATCH_DUMP_ATTR 1939 2003 1940 2004 bool CGrid::doGridHaveDataDistributed(CContextClient* client) 2005 TRY 1941 2006 { 1942 2007 if (isScalarGrid()) return false; … … 1948 2013 return isDataDistributed_; 1949 2014 } 2015 CATCH_DUMP_ATTR 1950 2016 1951 2017 /*! … … 1957 2023 */ 1958 2024 bool CGrid::dispatchEvent(CEventServer& event) 2025 TRY 1959 2026 { 1960 2027 … … 1990 2057 } 1991 2058 } 2059 CATCH 1992 2060 1993 2061 ///--------------------------------------------------------------- 1994 2062 1995 2063 CDomain* CGrid::addDomain(const std::string& id) 2064 TRY 1996 2065 { 1997 2066 order_.push_back(2); … … 2000 2069 return vDomainGroup_->createChild(id); 2001 2070 } 2071 CATCH_DUMP_ATTR 2002 2072 2003 2073 CAxis* CGrid::addAxis(const std::string& id) 2074 TRY 2004 2075 { 2005 2076 order_.push_back(1); … … 2008 2079 return vAxisGroup_->createChild(id); 2009 2080 } 2081 CATCH_DUMP_ATTR 2010 2082 2011 2083 CScalar* CGrid::addScalar(const std::string& id) 2084 TRY 2012 2085 { 2013 2086 order_.push_back(0); … … 2016 2089 return vScalarGroup_->createChild(id); 2017 2090 } 2091 CATCH_DUMP_ATTR 2018 2092 2019 2093 //! Change virtual field group to a new one 2020 2094 void CGrid::setVirtualDomainGroup(CDomainGroup* newVDomainGroup) 2095 TRY 2021 2096 { 2022 2097 this->vDomainGroup_ = newVDomainGroup; 2023 2098 } 2099 CATCH_DUMP_ATTR 2024 2100 2025 2101 //! Change virtual variable group to new one 2026 2102 void CGrid::setVirtualAxisGroup(CAxisGroup* newVAxisGroup) 2103 TRY 2027 2104 { 2028 2105 this->vAxisGroup_ = newVAxisGroup; 2029 2106 } 2107 CATCH_DUMP_ATTR 2030 2108 2031 2109 //! Change virtual variable group to new one 2032 2110 void CGrid::setVirtualScalarGroup(CScalarGroup* newVScalarGroup) 2111 TRY 2033 2112 { 2034 2113 this->vScalarGroup_ = newVScalarGroup; 2035 2114 } 2115 CATCH_DUMP_ATTR 2036 2116 2037 2117 /*! … … 2040 2120 */ 2041 2121 void CGrid::sendAddDomain(const string& id) 2042 { 2122 TRY 2123 { 2043 2124 sendAddItem(id, (int)EVENT_ID_ADD_DOMAIN); 2044 2125 } 2126 CATCH_DUMP_ATTR 2045 2127 2046 2128 /*! … … 2049 2131 */ 2050 2132 void CGrid::sendAddAxis(const string& id) 2133 TRY 2051 2134 { 2052 2135 sendAddItem(id, (int)EVENT_ID_ADD_AXIS); 2053 2136 } 2137 CATCH_DUMP_ATTR 2054 2138 2055 2139 /*! … … 2058 2142 */ 2059 2143 void CGrid::sendAddScalar(const string& id) 2144 TRY 2060 2145 { 2061 2146 sendAddItem(id, (int)EVENT_ID_ADD_SCALAR); 2062 2147 } 2148 CATCH_DUMP_ATTR 2063 2149 2064 2150 /*! … … 2067 2153 */ 2068 2154 void CGrid::recvAddDomain(CEventServer& event) 2155 TRY 2069 2156 { 2070 2157 … … 2074 2161 get(id)->recvAddDomain(*buffer); 2075 2162 } 2163 CATCH 2076 2164 2077 2165 /*! … … 2080 2168 */ 2081 2169 void CGrid::recvAddDomain(CBufferIn& buffer) 2170 TRY 2082 2171 { 2083 2172 string id; … … 2085 2174 addDomain(id); 2086 2175 } 2176 CATCH_DUMP_ATTR 2087 2177 2088 2178 /*! … … 2091 2181 */ 2092 2182 void CGrid::recvAddAxis(CEventServer& event) 2183 TRY 2093 2184 { 2094 2185 … … 2098 2189 get(id)->recvAddAxis(*buffer); 2099 2190 } 2191 CATCH 2100 2192 2101 2193 /*! … … 2104 2196 */ 2105 2197 void CGrid::recvAddAxis(CBufferIn& buffer) 2198 TRY 2106 2199 { 2107 2200 string id; … … 2109 2202 addAxis(id); 2110 2203 } 2204 CATCH_DUMP_ATTR 2111 2205 2112 2206 /*! … … 2115 2209 */ 2116 2210 void CGrid::recvAddScalar(CEventServer& event) 2211 TRY 2117 2212 { 2118 2213 … … 2122 2217 get(id)->recvAddScalar(*buffer); 2123 2218 } 2219 CATCH 2124 2220 2125 2221 /*! … … 2128 2224 */ 2129 2225 void CGrid::recvAddScalar(CBufferIn& buffer) 2226 TRY 2130 2227 { 2131 2228 string id; … … 2133 2230 addScalar(id); 2134 2231 } 2232 CATCH_DUMP_ATTR 2135 2233 2136 2234 /*! … … 2141 2239 */ 2142 2240 void CGrid::solveDomainAxisRefInheritance(bool apply) 2241 TRY 2143 2242 { 2144 2243 CContext* context = CContext::getCurrent(); … … 2181 2280 } 2182 2281 } 2282 CATCH_DUMP_ATTR 2183 2283 2184 2284 bool CGrid::isTransformed() 2285 TRY 2185 2286 { 2186 2287 return isTransformed_; 2187 2288 } 2289 CATCH_DUMP_ATTR 2188 2290 2189 2291 void CGrid::setTransformed() 2292 TRY 2190 2293 { 2191 2294 isTransformed_ = true; 2192 2295 } 2296 CATCH_DUMP_ATTR 2193 2297 2194 2298 CGridTransformation* CGrid::getTransformations() 2299 TRY 2195 2300 { 2196 2301 return transformations_; 2197 2302 } 2303 CATCH_DUMP_ATTR 2198 2304 2199 2305 void CGrid::addTransGridSource(CGrid* gridSrc) 2306 TRY 2200 2307 { 2201 2308 if (gridSrc_.end() == gridSrc_.find(gridSrc)) 2202 2309 gridSrc_.insert(make_pair(gridSrc,make_pair(false,""))); 2203 2310 } 2311 CATCH_DUMP_ATTR 2204 2312 2205 2313 std::map<CGrid*,std::pair<bool,StdString> >& CGrid::getTransGridSource() 2314 TRY 2206 2315 { 2207 2316 return gridSrc_; 2208 2317 } 2318 CATCH_DUMP_ATTR 2209 2319 2210 2320 /*! … … 2213 2323 */ 2214 2324 void CGrid::completeGrid(CGrid* transformGridSrc) 2325 TRY 2215 2326 { 2216 2327 if (0 != transformGridSrc) … … 2231 2342 gridGenerate.completeGrid(); 2232 2343 } 2344 CATCH_DUMP_ATTR 2233 2345 2234 2346 bool CGrid::isGenerated() 2347 TRY 2235 2348 { 2236 2349 return isGenerated_; 2237 2350 } 2351 CATCH 2238 2352 2239 2353 void CGrid::setGenerated() 2354 TRY 2240 2355 { 2241 2356 isGenerated_ = true; 2242 2357 } 2358 CATCH_DUMP_ATTR 2243 2359 2244 2360 void CGrid::transformGrid(CGrid* transformGridSrc) 2361 TRY 2245 2362 { 2246 2363 if (!transformGridSrc) … … 2268 2385 transformGridSrc->checkMaskIndex(false); 2269 2386 } 2387 CATCH_DUMP_ATTR 2270 2388 2271 2389 bool CGrid::hasTransform() 2390 TRY 2272 2391 { 2273 2392 if (hasTransform_) return hasTransform_; … … 2283 2402 return hasTransform_; 2284 2403 } 2404 CATCH_DUMP_ATTR 2285 2405 2286 2406 /*! … … 2289 2409 */ 2290 2410 std::vector<CDomain*> CGrid::getDomains() 2411 TRY 2291 2412 { 2292 2413 std::vector<CDomain*> domList; … … 2297 2418 return domList; 2298 2419 } 2420 CATCH_DUMP_ATTR 2299 2421 2300 2422 /*! … … 2303 2425 */ 2304 2426 std::vector<CAxis*> CGrid::getAxis() 2427 TRY 2305 2428 { 2306 2429 std::vector<CAxis*> aList; … … 2310 2433 return aList; 2311 2434 } 2435 CATCH_DUMP_ATTR 2312 2436 2313 2437 /*! … … 2316 2440 */ 2317 2441 std::vector<CScalar*> CGrid::getScalars() 2442 TRY 2318 2443 { 2319 2444 std::vector<CScalar*> sList; … … 2323 2448 return sList; 2324 2449 } 2450 CATCH_DUMP_ATTR 2325 2451 2326 2452 /*! … … 2329 2455 */ 2330 2456 CDomain* CGrid::getDomain(int domainIndex) 2457 TRY 2331 2458 { 2332 2459 std::vector<CDomain*> domainListP = this->getDomains(); … … 2346 2473 return domainListP[domainIndex]; 2347 2474 } 2475 CATCH_DUMP_ATTR 2348 2476 2349 2477 /*! … … 2352 2480 */ 2353 2481 CAxis* CGrid::getAxis(int axisIndex) 2482 TRY 2354 2483 { 2355 2484 std::vector<CAxis*> axisListP = this->getAxis(); … … 2369 2498 return axisListP[axisIndex]; 2370 2499 } 2500 CATCH_DUMP_ATTR 2371 2501 2372 2502 /*! … … 2375 2505 */ 2376 2506 CScalar* CGrid::getScalar(int scalarIndex) 2507 TRY 2377 2508 { 2378 2509 std::vector<CScalar*> scalarListP = this->getScalars(); … … 2392 2523 return scalarListP[scalarIndex]; 2393 2524 } 2525 CATCH_DUMP_ATTR 2394 2526 2395 2527 /*! … … 2398 2530 */ 2399 2531 void CGrid::setDomainList(const std::vector<CDomain*> domains) 2532 TRY 2400 2533 { 2401 2534 if (isDomListSet) return; … … 2418 2551 isDomListSet = true; 2419 2552 } 2420 2421 }2553 } 2554 CATCH_DUMP_ATTR 2422 2555 2423 2556 /*! … … 2426 2559 */ 2427 2560 void CGrid::setAxisList(const std::vector<CAxis*> axis) 2561 TRY 2428 2562 { 2429 2563 if (isAxisListSet) return; … … 2447 2581 } 2448 2582 } 2583 CATCH_DUMP_ATTR 2449 2584 2450 2585 /*! … … 2453 2588 */ 2454 2589 void CGrid::setScalarList(const std::vector<CScalar*> scalars) 2590 TRY 2455 2591 { 2456 2592 if (isScalarListSet) return; … … 2474 2610 } 2475 2611 } 2612 CATCH_DUMP_ATTR 2476 2613 2477 2614 /*! … … 2480 2617 */ 2481 2618 std::vector<StdString> CGrid::getDomainList() 2619 TRY 2482 2620 { 2483 2621 setDomainList(); 2484 2622 return domList_; 2485 2623 } 2624 CATCH 2486 2625 2487 2626 /*! … … 2490 2629 */ 2491 2630 std::vector<StdString> CGrid::getAxisList() 2631 TRY 2492 2632 { 2493 2633 setAxisList(); 2494 2634 return axisList_; 2495 2635 } 2636 CATCH 2496 2637 2497 2638 /*! … … 2500 2641 */ 2501 2642 std::vector<StdString> CGrid::getScalarList() 2643 TRY 2502 2644 { 2503 2645 setScalarList(); 2504 2646 return scalarList_; 2505 2647 } 2648 CATCH 2506 2649 2507 2650 /*! … … 2509 2652 */ 2510 2653 void CGrid::sendAllDomains() 2654 TRY 2511 2655 { 2512 2656 std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren(); … … 2518 2662 } 2519 2663 } 2664 CATCH_DUMP_ATTR 2520 2665 2521 2666 /*! … … 2523 2668 */ 2524 2669 void CGrid::sendAllAxis() 2670 TRY 2525 2671 { 2526 2672 std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren(); … … 2533 2679 } 2534 2680 } 2681 CATCH_DUMP_ATTR 2535 2682 2536 2683 /*! … … 2538 2685 */ 2539 2686 void CGrid::sendAllScalars() 2687 TRY 2540 2688 { 2541 2689 std::vector<CScalar*> sList = this->getVirtualScalarGroup()->getAllChildren(); … … 2548 2696 } 2549 2697 } 2698 CATCH_DUMP_ATTR 2550 2699 2551 2700 void CGrid::setContextClient(CContextClient* contextClient) 2701 TRY 2552 2702 { 2553 2703 if (clientsSet.find(contextClient)==clientsSet.end()) … … 2561 2711 this->getAxis()[i]->setContextClient(contextClient); 2562 2712 } 2713 CATCH_DUMP_ATTR 2563 2714 2564 2715 /*! … … 2566 2717 */ 2567 2718 void CGrid::parse(xml::CXMLNode& node) 2719 TRY 2568 2720 { 2569 2721 SuperClass::parse(node); … … 2606 2758 setScalarList(); 2607 2759 } 2760 CATCH_DUMP_ATTR 2761 2608 2762 } // namespace xios -
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 -
XIOS/dev/branch_openmp/src/node/interpolate_axis.hpp
r1331 r1642 62 62 static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 63 63 static bool _dummyRegistered; 64 #pragma omp threadprivate(_dummyRegistered)65 64 }; // class CInterpolateAxis 66 65 -
XIOS/dev/branch_openmp/src/node/interpolate_domain.cpp
r1460 r1642 65 65 if (this->read_write_convention.isEmpty()) this->read_write_convention.setValue(read_write_convention_attr::fortran); 66 66 67 67 68 } 68 69 -
XIOS/dev/branch_openmp/src/node/interpolate_domain.hpp
r1331 r1642 60 60 static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CInterpolateDomain 64 63 -
XIOS/dev/branch_openmp/src/node/inverse_axis.hpp
r1331 r1642 59 59 static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 60 60 static bool _dummyRegistered; 61 #pragma omp threadprivate(_dummyRegistered)62 61 63 62 }; // class CInverseAxis -
XIOS/dev/branch_openmp/src/node/mesh.cpp
r1545 r1642 6 6 7 7 #include "mesh.hpp" 8 using namespace ep_lib;9 8 #include <boost/functional/hash.hpp> 9 //#include <unordered_map> 10 10 11 11 namespace xios { … … 33 33 } 34 34 35 std::map <StdString, CMesh> *CMesh::meshList_ptr = 0;36 std::map <StdString, vector<int> > *CMesh::domainList_ptr = 0;35 std::map <StdString, CMesh> CMesh::meshList = std::map <StdString, CMesh>(); 36 std::map <StdString, vector<int> > CMesh::domainList = std::map <StdString, vector<int> >(); 37 37 38 38 ///--------------------------------------------------------------- … … 45 45 CMesh* CMesh::getMesh (StdString meshName, int nvertex) 46 46 { 47 if(CMesh::domainList_ptr == NULL) CMesh::domainList_ptr = new std::map <StdString, vector<int> >(); 48 if(CMesh::meshList_ptr == NULL) CMesh::meshList_ptr = new std::map <StdString, CMesh>(); 49 50 CMesh::domainList_ptr->at(meshName).push_back(nvertex); 51 52 if ( CMesh::meshList_ptr->begin() != CMesh::meshList_ptr->end() ) 53 { 54 for (std::map<StdString, CMesh>::iterator it=CMesh::meshList_ptr->begin(); it!=CMesh::meshList_ptr->end(); ++it) 47 CMesh::domainList[meshName].push_back(nvertex); 48 49 if ( CMesh::meshList.begin() != CMesh::meshList.end() ) 50 { 51 for (std::map<StdString, CMesh>::iterator it=CMesh::meshList.begin(); it!=CMesh::meshList.end(); ++it) 55 52 { 56 53 if (it->first == meshName) 57 return &meshList _ptr->at(meshName);54 return &meshList[meshName]; 58 55 else 59 56 { 60 57 CMesh newMesh; 61 CMesh::meshList _ptr->insert( make_pair(meshName, newMesh) );62 return &meshList _ptr->at(meshName);58 CMesh::meshList.insert( make_pair(meshName, newMesh) ); 59 return &meshList[meshName]; 63 60 } 64 61 } … … 67 64 { 68 65 CMesh newMesh; 69 CMesh::meshList _ptr->insert( make_pair(meshName, newMesh) );70 return &meshList _ptr->at(meshName);66 CMesh::meshList.insert( make_pair(meshName, newMesh) ); 67 return &meshList[meshName]; 71 68 } 72 69 } … … 227 224 * \param [in] bounds_lat Array of boundary latitudes. Its size depends on the element type. 228 225 */ 226 // void CMesh::createMesh(const CArray<double, 1>& lonvalue, const CArray<double, 1>& latvalue, 227 // const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat) 228 // { 229 // int nvertex = (bounds_lon.numElements() == 0) ? 1 : bounds_lon.rows(); 230 // 231 // if (nvertex == 1) 232 // { 233 // nbNodes_ = lonvalue.numElements(); 234 // node_lon.resizeAndPreserve(nbNodes_); 235 // node_lat.resizeAndPreserve(nbNodes_); 236 // for (int nn = 0; nn < nbNodes_; ++nn) 237 // { 238 // if (map_nodes.find(make_pair (lonvalue(nn), latvalue(nn))) == map_nodes.end()) 239 // { 240 // map_nodes[make_pair (lonvalue(nn), latvalue(nn))] = nn ; 241 // node_lon(nn) = lonvalue(nn); 242 // node_lat(nn) = latvalue(nn); 243 // } 244 // } 245 // } 246 // else if (nvertex == 2) 247 // { 248 // nbEdges_ = bounds_lon.shape()[1]; 249 // 250 // // Create nodes and edge_node connectivity 251 // node_lon.resizeAndPreserve(nbEdges_*nvertex); // Max possible number of nodes 252 // node_lat.resizeAndPreserve(nbEdges_*nvertex); 253 // edge_nodes.resizeAndPreserve(nvertex, nbEdges_); 254 // 255 // for (int ne = 0; ne < nbEdges_; ++ne) 256 // { 257 // for (int nv = 0; nv < nvertex; ++nv) 258 // { 259 // if (map_nodes.find(make_pair (bounds_lon(nv, ne), bounds_lat(nv ,ne))) == map_nodes.end()) 260 // { 261 // map_nodes[make_pair (bounds_lon(nv, ne), bounds_lat(nv, ne))] = nbNodes_ ; 262 // edge_nodes(nv,ne) = nbNodes_ ; 263 // node_lon(nbNodes_) = bounds_lon(nv, ne); 264 // node_lat(nbNodes_) = bounds_lat(nv, ne); 265 // ++nbNodes_ ; 266 // } 267 // else 268 // edge_nodes(nv,ne) = map_nodes[make_pair (bounds_lon(nv, ne), bounds_lat(nv ,ne))]; 269 // } 270 // } 271 // node_lon.resizeAndPreserve(nbNodes_); 272 // node_lat.resizeAndPreserve(nbNodes_); 273 // 274 // // Create edges 275 // edge_lon.resizeAndPreserve(nbEdges_); 276 // edge_lat.resizeAndPreserve(nbEdges_); 277 // 278 // for (int ne = 0; ne < nbEdges_; ++ne) 279 // { 280 // if (map_edges.find(make_ordered_pair (edge_nodes(0,ne), edge_nodes(1,ne))) == map_edges.end()) 281 // { 282 // map_edges[make_ordered_pair ( edge_nodes(0,ne), edge_nodes(1,ne) )] = ne ; 283 // edge_lon(ne) = lonvalue(ne); 284 // edge_lat(ne) = latvalue(ne); 285 // } 286 // 287 // } 288 // edgesAreWritten = true; 289 // } 290 // else 291 // { 292 // nbFaces_ = bounds_lon.shape()[1]; 293 // 294 // // Create nodes and face_node connectivity 295 // node_lon.resizeAndPreserve(nbFaces_*nvertex); // Max possible number of nodes 296 // node_lat.resizeAndPreserve(nbFaces_*nvertex); 297 // face_nodes.resize(nvertex, nbFaces_); 298 // 299 // for (int nf = 0; nf < nbFaces_; ++nf) 300 // { 301 // for (int nv = 0; nv < nvertex; ++nv) 302 // { 303 // if (map_nodes.find(make_pair (bounds_lon(nv, nf), bounds_lat(nv ,nf))) == map_nodes.end()) 304 // { 305 // map_nodes[make_pair (bounds_lon(nv, nf), bounds_lat(nv, nf))] = nbNodes_ ; 306 // face_nodes(nv,nf) = nbNodes_ ; 307 // node_lon(nbNodes_) = bounds_lon(nv, nf); 308 // node_lat(nbNodes_) = bounds_lat(nv ,nf); 309 // ++nbNodes_ ; 310 // } 311 // else 312 // { 313 // face_nodes(nv,nf) = map_nodes[make_pair (bounds_lon(nv, nf), bounds_lat(nv ,nf))]; 314 // } 315 // } 316 // } 317 // node_lon.resizeAndPreserve(nbNodes_); 318 // node_lat.resizeAndPreserve(nbNodes_); 319 // 320 // // Create edges and edge_nodes connectivity 321 // edge_lon.resizeAndPreserve(nbFaces_*nvertex); // Max possible number of edges 322 // edge_lat.resizeAndPreserve(nbFaces_*nvertex); 323 // edge_nodes.resizeAndPreserve(2, nbFaces_*nvertex); 324 // edge_faces.resize(2, nbFaces_*nvertex); 325 // face_edges.resize(nvertex, nbFaces_); 326 // face_faces.resize(nvertex, nbFaces_); 327 // 328 // vector<int> countEdges(nbFaces_*nvertex); // needed in case if edges have been already generated 329 // vector<int> countFaces(nbFaces_); 330 // countEdges.assign(nbFaces_*nvertex, 0); 331 // countFaces.assign(nbFaces_, 0); 332 // int edge; 333 // for (int nf = 0; nf < nbFaces_; ++nf) 334 // { 335 // for (int nv1 = 0; nv1 < nvertex; ++nv1) 336 // { 337 // int nv = 0; 338 // int nv2 = (nv1 < nvertex -1 ) ? (nv1 + 1) : (nv1 + 1 - nvertex); // cyclic rotation 339 // if (map_edges.find(make_ordered_pair (face_nodes(nv1,nf), face_nodes(nv2,nf))) == map_edges.end()) 340 // { 341 // map_edges[make_ordered_pair (face_nodes(nv1,nf), face_nodes(nv2,nf))] = nbEdges_ ; 342 // face_edges(nv1,nf) = map_edges[make_ordered_pair (face_nodes(nv1,nf), face_nodes(nv2,nf))]; 343 // edge_faces(0,nbEdges_) = nf; 344 // edge_faces(1,nbEdges_) = -999; 345 // face_faces(nv1,nf) = 999999; 346 // edge_nodes(Range::all(),nbEdges_) = face_nodes(nv1,nf), face_nodes(nv2,nf); 347 // edge_lon(nbEdges_) = ( abs( node_lon(face_nodes(nv1,nf)) - node_lon(face_nodes(nv2,nf))) < 180.) ? 348 // (( node_lon(face_nodes(nv1,nf)) + node_lon(face_nodes(nv2,nf))) * 0.5) : 349 // (( node_lon(face_nodes(nv1,nf)) + node_lon(face_nodes(nv2,nf))) * 0.5 -180.); 350 // edge_lat(nbEdges_) = ( node_lat(face_nodes(nv1,nf)) + node_lat(face_nodes(nv2,nf)) ) * 0.5; 351 // ++nbEdges_; 352 // } 353 // else 354 // { 355 // edge = map_edges[make_ordered_pair (face_nodes(nv1,nf), face_nodes(nv2,nf))]; 356 // face_edges(nv1,nf) = edge; 357 // if (edgesAreWritten) 358 // { 359 // edge_faces(countEdges[edge], edge) = nf; 360 // if (countEdges[edge]==0) 361 // { 362 // face_faces(nv1,nf) = 999999; 363 // } 364 // else 365 // { 366 // int face1 = nf; // = edge_faces(1,edge) 367 // int face2 = edge_faces(0,edge); 368 // face_faces(countFaces[face1], face1) = face2; 369 // face_faces(countFaces[face2], face2) = face1; 370 // ++(countFaces[face1]); 371 // ++(countFaces[face2]); 372 // } 373 // } 374 // else 375 // { 376 // edge_faces(1,edge) = nf; 377 // int face1 = nf; // = edge_faces(1,edge) 378 // int face2 = edge_faces(0,edge); 379 // face_faces(countFaces[face1], face1) = face2; 380 // face_faces(countFaces[face2], face2) = face1; 381 // ++(countFaces[face1]); 382 // ++(countFaces[face2]); 383 // } 384 // ++(countEdges[edge]); 385 // } 386 // } 387 // } 388 // edge_nodes.resizeAndPreserve(2, nbEdges_); 389 // edge_faces.resizeAndPreserve(2, nbEdges_); 390 // edge_lon.resizeAndPreserve(nbEdges_); 391 // edge_lat.resizeAndPreserve(nbEdges_); 392 // 393 // // Create faces 394 // face_lon.resize(nbFaces_); 395 // face_lat.resize(nbFaces_); 396 // face_lon = lonvalue; 397 // face_lat = latvalue; 398 // facesAreWritten = true; 399 // 400 // } // nvertex > 2 401 // 402 // } // createMesh() 229 403 230 404 ///---------------------------------------------------------------- … … 240 414 * \param [in] bounds_lat Array of boundary latitudes. Its size depends on the element type. 241 415 */ 242 void CMesh::createMeshEpsilon(const MPI_Comm& comm,416 void CMesh::createMeshEpsilon(const ep_lib::MPI_Comm& comm, 243 417 const CArray<double, 1>& lonvalue, const CArray<double, 1>& latvalue, 244 418 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat) … … 247 421 int nvertex = (bounds_lon.numElements() == 0) ? 1 : bounds_lon.rows(); 248 422 int mpiRank, mpiSize; 249 MPI_Comm_rank(comm, &mpiRank);250 MPI_Comm_size(comm, &mpiSize);423 ep_lib::MPI_Comm_rank(comm, &mpiRank); 424 ep_lib::MPI_Comm_size(comm, &mpiSize); 251 425 double prec = 1e-11; // used in calculations of edge_lon/lat 252 426 … … 286 460 unsigned long nbEdgesOnProc = nbEdges_; 287 461 unsigned long nbEdgesAccum; 288 MPI_Scan(&nbEdgesOnProc, &nbEdgesAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);462 ep_lib::MPI_Scan(&nbEdgesOnProc, &nbEdgesAccum, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 289 463 nbEdgesAccum -= nbEdges_; 290 464 … … 416 590 unsigned long nodeCount = nodeIdx2Idx.size(); 417 591 unsigned long nodeStart, nbNodes; 418 MPI_Scan(&nodeCount, &nodeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);592 ep_lib::MPI_Scan(&nodeCount, &nodeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 419 593 int nNodes = nodeStart; 420 MPI_Bcast(&nNodes, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);594 ep_lib::MPI_Bcast(&nNodes, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 421 595 nbNodesGlo = nNodes; 422 596 … … 509 683 unsigned long nbFacesOnProc = nbFaces_; 510 684 unsigned long nbFacesAccum; 511 MPI_Scan(&nbFacesOnProc, &nbFacesAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);685 ep_lib::MPI_Scan(&nbFacesOnProc, &nbFacesAccum, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 512 686 nbFacesAccum -= nbFaces_; 513 687 … … 633 807 634 808 unsigned long edgeStart, nbEdges; 635 MPI_Scan(&edgeCount, &edgeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);809 ep_lib::MPI_Scan(&edgeCount, &edgeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 636 810 int nEdges = edgeStart; 637 MPI_Bcast(&nEdges, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);811 ep_lib::MPI_Bcast(&nEdges, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 638 812 nbEdgesGlo = nEdges; 639 813 … … 854 1028 unsigned long edgeCount = edgeIdx2Idx.size(); 855 1029 unsigned long edgeStart, nbEdges; 856 MPI_Scan(&edgeCount, &edgeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);1030 ep_lib::MPI_Scan(&edgeCount, &edgeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 857 1031 int nEdges = edgeStart; 858 MPI_Bcast(&nEdges, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);1032 ep_lib::MPI_Bcast(&nEdges, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 859 1033 nbEdgesGlo = nEdges; 860 1034 … … 1124 1298 unsigned long nodeCount = nodeIdx2Idx.size(); 1125 1299 unsigned long nodeStart, nbNodes; 1126 MPI_Scan(&nodeCount, &nodeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);1300 ep_lib::MPI_Scan(&nodeCount, &nodeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 1127 1301 int nNodes = nodeStart; 1128 MPI_Bcast(&nNodes, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);1302 ep_lib::MPI_Bcast(&nNodes, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 1129 1303 nbNodesGlo = nNodes; 1130 1304 … … 1244 1418 unsigned long edgeCount = edgeIdx2Idx.size(); 1245 1419 unsigned long edgeStart, nbEdges; 1246 MPI_Scan(&edgeCount, &edgeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);1420 ep_lib::MPI_Scan(&edgeCount, &edgeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 1247 1421 int nEdges = edgeStart; 1248 MPI_Bcast(&nEdges, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);1422 ep_lib::MPI_Bcast(&nEdges, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 1249 1423 nbEdgesGlo = nEdges; 1250 1424 … … 1440 1614 */ 1441 1615 1442 void CMesh::getGloNghbFacesNodeType(const MPI_Comm& comm, const CArray<int, 1>& face_idx,1616 void CMesh::getGloNghbFacesNodeType(const ep_lib::MPI_Comm& comm, const CArray<int, 1>& face_idx, 1443 1617 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat, 1444 1618 CArray<int, 2>& nghbFaces) … … 1449 1623 1450 1624 int mpiRank, mpiSize; 1451 MPI_Comm_rank(comm, &mpiRank);1452 MPI_Comm_size(comm, &mpiSize);1625 ep_lib::MPI_Comm_rank(comm, &mpiRank); 1626 ep_lib::MPI_Comm_size(comm, &mpiSize); 1453 1627 1454 1628 // (1) Generating unique node indexes … … 1596 1770 */ 1597 1771 1598 void CMesh::getGloNghbFacesEdgeType(const MPI_Comm& comm, const CArray<int, 1>& face_idx,1772 void CMesh::getGloNghbFacesEdgeType(const ep_lib::MPI_Comm& comm, const CArray<int, 1>& face_idx, 1599 1773 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat, 1600 1774 CArray<int, 2>& nghbFaces) … … 1605 1779 1606 1780 int mpiRank, mpiSize; 1607 MPI_Comm_rank(comm, &mpiRank);1608 MPI_Comm_size(comm, &mpiSize);1781 ep_lib::MPI_Comm_rank(comm, &mpiRank); 1782 ep_lib::MPI_Comm_size(comm, &mpiSize); 1609 1783 1610 1784 // (1) Generating unique node indexes … … 1777 1951 */ 1778 1952 1779 void CMesh::getGlobalNghbFaces(const int nghbType, const MPI_Comm& comm,1953 void CMesh::getGlobalNghbFaces(const int nghbType, const ep_lib::MPI_Comm& comm, 1780 1954 const CArray<int, 1>& face_idx, 1781 1955 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat, -
XIOS/dev/branch_openmp/src/node/mesh.hpp
r1545 r1642 83 83 int nbFaces_; 84 84 85 static std::map <StdString, CMesh> *meshList_ptr; 86 #pragma omp threadprivate(meshList_ptr) 87 static std::map <StdString, vector<int> > *domainList_ptr; 88 #pragma omp threadprivate(domainList_ptr) 85 static std::map <StdString, CMesh> meshList; 86 static std::map <StdString, vector<int> > domainList; 89 87 CClientClientDHTSizet* pNodeGlobalIndex; // pointer to a map <nodeHash, nodeIdxGlo> 90 88 CClientClientDHTSizet* pEdgeGlobalIndex; // pointer to a map <edgeHash, edgeIdxGlo> -
XIOS/dev/branch_openmp/src/node/node_enum.hpp
r1460 r1642 23 23 eZoomAxis, 24 24 eInterpolateAxis, 25 eExtractAxis, 25 26 eZoomDomain, 26 27 eInterpolateDomain, … … 38 39 eDuplicateScalarToAxis, 39 40 eReduceScalarToScalar, 40 eReorderDomain 41 eReorderDomain, 42 eExtractDomain 41 43 } ENodeType; 42 44 -
XIOS/dev/branch_openmp/src/node/node_type.hpp
r1460 r1642 13 13 #include "zoom_axis.hpp" 14 14 #include "interpolate_axis.hpp" 15 #include "extract_axis.hpp" 15 16 #include "zoom_domain.hpp" 16 17 #include "interpolate_domain.hpp" … … 29 30 #include "reduce_scalar_to_scalar.hpp" 30 31 #include "reorder_domain.hpp" 32 #include "extract_domain.hpp" 31 33 32 34 -
XIOS/dev/branch_openmp/src/node/reduce_axis_to_axis.hpp
r1460 r1642 59 59 static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 60 60 static bool _dummyRegistered; 61 #pragma omp threadprivate(_dummyRegistered)62 61 }; // class CReduceAxisToAxis 63 62 -
XIOS/dev/branch_openmp/src/node/reduce_axis_to_scalar.hpp
r1331 r1642 59 59 static CTransformation<CScalar>* create(const StdString& id, xml::CXMLNode* node); 60 60 static bool _dummyRegistered; 61 #pragma omp threadprivate(_dummyRegistered)62 61 }; // class CReduceAxisToScalar 63 62 -
XIOS/dev/branch_openmp/src/node/reduce_domain_to_axis.hpp
r1331 r1642 60 60 static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CReduceDomainToAxis 64 63 -
XIOS/dev/branch_openmp/src/node/reduce_domain_to_scalar.hpp
r1331 r1642 60 60 static CTransformation<CScalar>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CReduceDomainToScalar 64 63 -
XIOS/dev/branch_openmp/src/node/reduce_scalar_to_scalar.hpp
r1460 r1642 59 59 static CTransformation<CScalar>* create(const StdString& id, xml::CXMLNode* node); 60 60 static bool _dummyRegistered; 61 #pragma omp threadprivate(_dummyRegistered)62 61 }; // class CReduceScalarToScalar 63 62 -
XIOS/dev/branch_openmp/src/node/reorder_domain.hpp
r1460 r1642 60 60 static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CReorderDomain 64 63 -
XIOS/dev/branch_openmp/src/node/scalar.cpp
r1545 r1642 27 27 { /* Ne rien faire de plus */ } 28 28 29 30 std::map<StdString, ETranformationType> *CScalar::transformationMapList_ptr = 0; 31 29 std::map<StdString, ETranformationType> CScalar::transformationMapList_ = std::map<StdString, ETranformationType>(); 30 bool CScalar::dummyTransformationMapList_ = CScalar::initializeTransformationMap(CScalar::transformationMapList_); 32 31 bool CScalar::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 33 32 { … … 36 35 m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_SCALAR; 37 36 m["reduce_scalar"] = TRANS_REDUCE_SCALAR_TO_SCALAR; 38 }39 40 bool CScalar::initializeTransformationMap()41 {42 CScalar::transformationMapList_ptr = new std::map<StdString, ETranformationType>();43 (*CScalar::transformationMapList_ptr)["reduce_axis"] = TRANS_REDUCE_AXIS_TO_SCALAR;44 (*CScalar::transformationMapList_ptr)["extract_axis"] = TRANS_EXTRACT_AXIS_TO_SCALAR;45 (*CScalar::transformationMapList_ptr)["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_SCALAR;46 (*CScalar::transformationMapList_ptr)["reduce_scalar"] = TRANS_REDUCE_SCALAR_TO_SCALAR;47 37 } 48 38 … … 175 165 176 166 nodeElementName = node.getElementName(); 177 if(CScalar::transformationMapList_ptr == 0) initializeTransformationMap(); 178 std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_ptr->end(), it; 179 it = transformationMapList_ptr->find(nodeElementName); 167 std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 168 it = transformationMapList_.find(nodeElementName); 180 169 if (ite != it) 181 170 { -
XIOS/dev/branch_openmp/src/node/scalar.hpp
r1460 r1642 83 83 TransMapTypes transformationMap_; 84 84 85 void setTransformations(const TransMapTypes&);85 void setTransformations(const TransMapTypes&); 86 86 87 87 private: 88 88 static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 89 static bool initializeTransformationMap(); 90 static std::map<StdString, ETranformationType> *transformationMapList_ptr; 91 #pragma omp threadprivate(transformationMapList_ptr) 89 static std::map<StdString, ETranformationType> transformationMapList_; 92 90 static bool dummyTransformationMapList_; 93 #pragma omp threadprivate(dummyTransformationMapList_)94 91 95 92 -
XIOS/dev/branch_openmp/src/node/temporal_splitting.hpp
r1460 r1642 59 59 static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 60 60 static bool _dummyRegistered; 61 #pragma omp threadprivate(_dummyRegistered)62 61 }; // class CTemporalSplitting 63 62 -
XIOS/dev/branch_openmp/src/node/transformation_enum.hpp
r1460 r1642 24 24 TRANS_DUPLICATE_SCALAR_TO_AXIS = 15, 25 25 TRANS_REDUCE_SCALAR_TO_SCALAR = 16, 26 TRANS_REORDER_DOMAIN = 17 26 TRANS_REORDER_DOMAIN = 17, 27 TRANS_EXTRACT_DOMAIN = 18, 28 TRANS_EXTRACT_AXIS = 19 27 29 } ETranformationType; 28 30 -
XIOS/dev/branch_openmp/src/node/zoom_axis.hpp
r1331 r1642 60 60 static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CZoomAxis 64 63 -
XIOS/dev/branch_openmp/src/node/zoom_domain.hpp
r1331 r1642 60 60 static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 61 61 static bool _dummyRegistered; 62 #pragma omp threadprivate(_dummyRegistered)63 62 }; // class CZoomDomain 64 63
Note: See TracChangeset
for help on using the changeset viewer.