Changeset 1642 for XIOS/dev/branch_openmp/src/node/domain.cpp
- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.