Changeset 821 for XIOS/trunk/src
- Timestamp:
- 02/10/16 14:35:03 (8 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/config/domain_attribute_private.conf
r775 r821 13 13 DECLARE_ARRAY_PRIVATE(double, 1, lonvalue_rectilinear_read_from_file) 14 14 DECLARE_ARRAY_PRIVATE(double, 1, latvalue_rectilinear_read_from_file) 15 16 DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_ibegin) 17 DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_ni) 18 DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_jbegin) 19 DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_nj) -
XIOS/trunk/src/distribution_client.cpp
r818 r821 235 235 nBeginGlobal_.at(indexMap_[idx]) = axisList[axisIndex]->begin.getValue(); 236 236 nZoomBegin_.at((indexMap_[idx])) = axisList[axisIndex]->global_zoom_begin; 237 nZoomEnd_.at((indexMap_[idx])) = axisList[axisIndex]->global_zoom_begin + axisList[axisIndex]->global_zoom_ size-1;237 nZoomEnd_.at((indexMap_[idx])) = axisList[axisIndex]->global_zoom_begin + axisList[axisIndex]->global_zoom_n-1; 238 238 239 239 dataBegin_.at(indexMap_[idx]) = axisList[axisIndex]->data_begin.getValue(); -
XIOS/trunk/src/io/nc4_data_output.cpp
r819 r821 625 625 int zoom_begin_srv = axis->zoom_begin_srv; 626 626 int zoom_size = (MULTI_FILE == SuperClass::type) ? zoom_size_srv 627 : axis->global_zoom_ size;627 : axis->global_zoom_n; 628 628 int zoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv 629 629 : axis->global_zoom_begin; -
XIOS/trunk/src/mpi_tag.hpp
r720 r821 14 14 #define MPI_DHT_INFO_0 22 15 15 16 /* Tag for mpi communication to send and receive info of current grid source in grid transformation*/ 17 #define MPI_GRID_TRANSFORMATION_CURRENT_GRID_INDEX 31 18 19 /* Tag for mpi communication to send and receive info of current grid source in grid transformation*/ 20 #define MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_INDEX 32 21 22 /* Tag for mpi communication to send and receive info of current grid source in grid transformation*/ 23 #define MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_WEIGHT 33 24 25 /* Tag for mpi communication to send and receive info of DOMAIN in domain interpolation*/ 26 #define MPI_DOMAIN_INTERPOLATION_DEST_INDEX 7 27 28 /* Tag for mpi communication to send and receive info of DOMAIN in domain interpolation*/ 29 #define MPI_DOMAIN_INTERPOLATION_SRC_INDEX 8 30 31 /* Tag for mpi communication to send and receive info of DOMAIN in domain interpolation*/ 32 #define MPI_DOMAIN_INTERPOLATION_WEIGHT 9 33 16 34 #endif -
XIOS/trunk/src/node/axis.cpp
r817 r821 26 26 , isDistributed_(false), hasBounds_(false), isCompressible_(false) 27 27 , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 28 , transformationMap_(), global_zoom_begin(0), global_zoom_size(0),hasValue(false)28 , transformationMap_(), hasValue(false) 29 29 { 30 30 } … … 35 35 , isDistributed_(false), hasBounds_(false), isCompressible_(false) 36 36 , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 37 , transformationMap_(), global_zoom_begin(0), global_zoom_size(0),hasValue(false)37 , transformationMap_(), hasValue(false) 38 38 { 39 39 } … … 266 266 void CAxis::checkZoom(void) 267 267 { 268 if (0 == global_zoom_size) global_zoom_size = this->n_glo.getValue(); 268 if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 269 if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 269 270 } 270 271 … … 391 392 size_t ni = this->n.getValue(); 392 393 size_t ibegin = this->begin.getValue(); 393 size_t zoom_end = global_zoom_begin+global_zoom_ size-1;394 size_t zoom_end = global_zoom_begin+global_zoom_n-1; 394 395 size_t nZoomCount = 0; 395 396 size_t nbIndex = index.numElements(); … … 517 518 CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_VALUE); 518 519 519 int zoom_end = global_zoom_begin + global_zoom_ size- 1;520 int zoom_end = global_zoom_begin + global_zoom_n - 1; 520 521 int nb = 0; 521 522 for (size_t idx = 0; idx < n; ++idx) … … 830 831 msg << this->getId(); 831 832 msg << ni << begin << end; 832 msg << global_zoom_begin << global_zoom_size;833 msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 833 834 msg << isCompressible_; 834 835 … … 850 851 void CAxis::recvServerAttribut(CBufferIn& buffer) 851 852 { 852 int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_ size_tmp;853 int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_n_tmp; 853 854 854 855 buffer >> ni_srv >> begin_srv >> end_srv; 855 buffer >> global_zoom_begin_tmp >> global_zoom_ size_tmp;856 buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp; 856 857 buffer >> isCompressible_; 857 858 global_zoom_begin = global_zoom_begin_tmp; 858 global_zoom_ size = global_zoom_size_tmp;859 int global_zoom_end = global_zoom_begin + global_zoom_ size- 1;859 global_zoom_n = global_zoom_n_tmp; 860 int global_zoom_end = global_zoom_begin + global_zoom_n - 1; 860 861 861 862 zoom_begin_srv = global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; -
XIOS/trunk/src/node/axis.hpp
r816 r821 29 29 BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) 30 30 # include "axis_attribute.conf" 31 # include "axis_attribute_private.conf" 31 32 END_DECLARE_ATTRIBUTE_MAP(CAxis) 32 33 … … 116 117 int zoom_begin_srv, zoom_end_srv, zoom_size_srv; 117 118 int ni_srv, begin_srv, end_srv; 118 int global_zoom_begin, global_zoom_size; // The real global zoom begin and zoom size after axis is transformed (zoomed)119 119 CArray<double,1> value_srv; 120 120 CArray<double,2> bound_srv; -
XIOS/trunk/src/node/domain.cpp
r815 r821 32 32 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 33 33 , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 34 , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0)35 34 , isClientAfterTransformationChecked(false), hasLonLat(false) 36 35 , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() … … 42 41 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 43 42 , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 44 , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0)45 43 , isClientAfterTransformationChecked(false), hasLonLat(false) 46 44 , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() … … 663 661 } 664 662 computeNGlobDomain(); 665 666 if (0 == global_zoom_ni) global_zoom_ni = ni_glo; 667 if (0 == global_zoom_nj) global_zoom_nj = nj_glo; 663 checkZoom(); 664 } 665 666 void CDomain::checkZoom(void) 667 { 668 if (global_zoom_ibegin.isEmpty()) 669 global_zoom_ibegin.setValue(0); 670 if (global_zoom_ni.isEmpty()) 671 global_zoom_ni.setValue(ni_glo); 672 if (global_zoom_jbegin.isEmpty()) 673 global_zoom_jbegin.setValue(0); 674 if (global_zoom_nj.isEmpty()) 675 global_zoom_nj.setValue(nj_glo); 668 676 } 669 677 … … 1253 1261 msg << this->getId() ; 1254 1262 msg << ni_srv << ibegin_srv << iend_srv << nj_srv << jbegin_srv << jend_srv; 1255 msg << global_zoom_ni << global_zoom_ibegin << global_zoom_nj << global_zoom_jbegin;1263 msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue(); 1256 1264 msg << isCompressible_; 1257 1265 … … 1680 1688 void CDomain::recvServerAttribut(CBufferIn& buffer) 1681 1689 { 1690 int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; 1682 1691 buffer >> ni_srv >> ibegin_srv >> iend_srv >> nj_srv >> jbegin_srv >> jend_srv 1683 >> global_zoom_ni >> global_zoom_ibegin >> global_zoom_nj >> global_zoom_jbegin1692 >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp 1684 1693 >> isCompressible_; 1694 1695 global_zoom_ni.setValue(global_zoom_ni_tmp); 1696 global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); 1697 global_zoom_nj.setValue(global_zoom_nj_tmp); 1698 global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); 1685 1699 1686 1700 int zoom_iend = global_zoom_ibegin + global_zoom_ni - 1; -
XIOS/trunk/src/node/domain.hpp
r809 r821 95 95 bool isCompressible(void) const; 96 96 97 int global_zoom_ibegin, global_zoom_ni;98 int global_zoom_jbegin, global_zoom_nj;99 100 97 int ni_srv,ibegin_srv,iend_srv ; 101 98 int zoom_ni_srv,zoom_ibegin_srv,zoom_iend_srv ; … … 124 121 void sendLonLatArea(void); 125 122 void computeConnectedServer(void) ; 126 127 void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 123 124 void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 128 125 CArray<double,1>& lon_g, CArray<double,1>& lat_g); 129 130 void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 126 127 void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 131 128 CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); 132 129 void fillInRectilinearLonLat(); … … 170 167 void checkArea(void); 171 168 void checkLonLat(); 169 void checkZoom(void); 172 170 173 171 void checkTransformations(); -
XIOS/trunk/src/node/grid.cpp
r817 r821 262 262 } 263 263 this->isChecked = true; 264 } 265 266 void CGrid::createMask(void) 267 { 268 using namespace std; 269 std::vector<CDomain*> domainP = this->getDomains(); 270 std::vector<CAxis*> axisP = this->getAxis(); 271 int dim = domainP.size() * 2 + axisP.size(); 272 273 std::vector<CArray<bool,1>* > domainMasks(domainP.size()); 274 for (int i = 0; i < domainMasks.size(); ++i) domainMasks[i] = &(domainP[i]->mask_1d); 275 std::vector<CArray<bool,1>* > axisMasks(axisP.size()); 276 for (int i = 0; i < axisMasks.size(); ++i) axisMasks[i] = &(axisP[i]->mask); 277 278 switch (dim) { 279 case 1: 280 checkGridMask(mask_1d, domainMasks, axisMasks, axis_domain_order, true); 281 break; 282 case 2: 283 checkGridMask(mask_2d, domainMasks, axisMasks, axis_domain_order, true); 284 break; 285 case 3: 286 checkGridMask(mask_3d, domainMasks, axisMasks, axis_domain_order, true); 287 break; 288 default: 289 break; 290 } 264 291 } 265 292 -
XIOS/trunk/src/node/grid.hpp
r775 r821 206 206 map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient; 207 207 void checkMask(void); 208 void createMask(void); 208 209 void modifyMask(const CArray<int,1>& indexToModify); 209 210 … … 217 218 const std::vector<CArray<bool,1>* >& domainMasks, 218 219 const std::vector<CArray<bool,1>* >& axisMasks, 219 const CArray<bool,1>& axisDomainOrder); 220 const CArray<bool,1>& axisDomainOrder, 221 bool createMask = false); 220 222 template<int N> 221 223 void modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify); … … 295 297 const std::vector<CArray<bool,1>* >& domainMasks, 296 298 const std::vector<CArray<bool,1>* >& axisMasks, 297 const CArray<bool,1>& axisDomainOrder) 299 const CArray<bool,1>& axisDomainOrder, 300 bool createMask) 298 301 { 299 302 int idx = 0; … … 319 322 } 320 323 321 if (!gridMask.isEmpty() )324 if (!gridMask.isEmpty() && !createMask) 322 325 { 323 326 for (int i = 0; i < dim; ++i) -
XIOS/trunk/src/test/test_new_features.f90
r782 r821 17 17 INTEGER,PARAMETER :: ni_glo=100 18 18 INTEGER,PARAMETER :: nj_glo=100 19 INTEGER,PARAMETER :: llm= 220 INTEGER,PARAMETER :: llmInterPolated= 519 INTEGER,PARAMETER :: llm=5 20 INTEGER,PARAMETER :: llmInterPolated=4 21 21 DOUBLE PRECISION :: lval(llm)=1, tsTemp, lvalInterPolated(llmInterPolated)=1 22 22 TYPE(xios_field) :: field_hdl … … 45 45 46 46 !!! XIOS Initialization (get the local communicator) 47 48 47 CALL xios_initialize(id,return_comm=comm) 49 48 … … 147 146 CALL xios_set_axis_attr("axis_C", n_glo=llm, value=lval) 148 147 CALL xios_set_axis_attr("axis_D", n_glo=llm, begin=axisBegin, n=nAxis, value=lvaln) 149 CALL xios_set_axis_attr("axis_ G", n_glo=llmInterPolated, value=lvalnInterp, begin=axisterpBegin, n=nAxisinterp)148 CALL xios_set_axis_attr("axis_E", n_glo=llmInterPolated, value=lvalnInterp, begin=axisterpBegin, n=nAxisinterp) 150 149 CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 151 150 CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) … … 206 205 CALL xios_send_field("field_A",field_A) 207 206 CALL xios_send_field("field_Axis",field_Axis) 208 209 207 CALL xios_send_field("field_Two_Axis",field_Two_Axis) 210 208 CALL xios_send_field("field_All_Axis",field_All_Axis) -
XIOS/trunk/src/transformation/axis_algorithm_zoom.cpp
r787 r821 62 62 { 63 63 axisDest_->global_zoom_begin = zoomBegin_; 64 axisDest_->global_zoom_ size= zoomSize_;64 axisDest_->global_zoom_n = zoomSize_; 65 65 } 66 66 -
XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp
r809 r821 15 15 #include "netcdf.hpp" 16 16 #include "mapper.hpp" 17 #include "mpi_tag.hpp" 17 18 18 19 namespace xios { … … 95 96 double step=(domainSrc_->lon_end-domainSrc_->lon_start)/domainSrc_->ni_glo ; 96 97 for(int i=0; i<domainSrc_->ni_glo; ++i) lon_g(i)=domainSrc_->lon_start+i*step ; 97 step=(domainSrc_->lat_end-domainSrc_->lat_start)/domainSrc_->nj_glo ; 98 step=(domainSrc_->lat_end-domainSrc_->lat_start)/domainSrc_->nj_glo ; 98 99 for(int i=0; i<domainSrc_->ni_glo; ++i) lat_g(i)=domainSrc_->lat_start+i*step ; 99 100 } … … 160 161 double step=(domainDest_->lon_end-domainDest_->lon_start)/domainDest_->ni_glo ; 161 162 for(int i=0; i<domainDest_->ni_glo; ++i) lon_g(i)=domainDest_->lon_start+i*step ; 162 step=(domainDest_->lat_end-domainDest_->lat_start)/domainDest_->nj_glo ; 163 step=(domainDest_->lat_end-domainDest_->lat_start)/domainDest_->nj_glo ; 163 164 for(int i=0; i<domainDest_->ni_glo; ++i) lat_g(i)=domainDest_->lat_start+i*step ; 164 165 } … … 167 168 if (std::abs(poleValue - std::abs(lat_g(domainDest_->nj_glo-1))) < NumTraits<double>::epsilon()) isSouthPole = true; 168 169 169 170 171 170 171 172 172 173 if (isNorthPole && (0 == domainDest_->jbegin.getValue())) 173 174 { … … 469 470 MPI_INT, 470 471 itMap->first, 471 7,472 MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 472 473 client->intraComm, 473 474 &sendRequest.back()); … … 477 478 MPI_INT, 478 479 itMap->first, 479 8,480 MPI_DOMAIN_INTERPOLATION_SRC_INDEX, 480 481 client->intraComm, 481 482 &sendRequest.back()); … … 485 486 MPI_DOUBLE, 486 487 itMap->first, 487 9,488 MPI_DOMAIN_INTERPOLATION_WEIGHT, 488 489 client->intraComm, 489 490 &sendRequest.back()); … … 504 505 MPI_INT, 505 506 MPI_ANY_SOURCE, 506 7,507 MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 507 508 client->intraComm, 508 509 &recvStatus); … … 516 517 MPI_INT, 517 518 clientSrcRank, 518 8,519 MPI_DOMAIN_INTERPOLATION_SRC_INDEX, 519 520 client->intraComm, 520 521 &recvStatus); … … 524 525 MPI_DOUBLE, 525 526 clientSrcRank, 526 9,527 MPI_DOMAIN_INTERPOLATION_WEIGHT, 527 528 client->intraComm, 528 529 &recvStatus); -
XIOS/trunk/src/transformation/grid_transformation.cpp
r795 r821 18 18 #include "axis_algorithm_transformation.hpp" 19 19 #include "distribution_client.hpp" 20 #include "mpi_tag.hpp" 20 21 21 22 namespace xios { 22 23 CGridTransformation::CGridTransformation(CGrid* destination, CGrid* source) 23 24 : gridSource_(source), gridDestination_(destination), originalGridSource_(source), 24 globalIndexOfCurrentGridSource_(), globalIndexOfOriginalGridSource_(), weightOfGlobalIndexOfOriginalGridSource_(0), algoTypes_() 25 algoTypes_(), nbAlgos_(0), currentGridIndexToOriginalGridIndex_() 26 25 27 { 26 28 //Verify the compatibity between two grids … … 41 43 } 42 44 43 std::vector<CAxis*> axisSrcTmp = gridSource_->getAxis(), axisSrc;44 std::vector<CDomain*> domainSrcTmp = gridSource_->getDomains(), domainSrc;45 for (int idx = 0; idx < axisSrcTmp.size(); ++idx)46 {47 CAxis* axis = CAxis::createAxis();48 axis->axis_ref.setValue(axisSrcTmp[idx]->getId());49 axis->solveRefInheritance(true);50 axis->solveInheritanceTransformation();51 axis->checkAttributesOnClient();52 axisSrc.push_back(axis);53 }54 55 for (int idx = 0; idx < domainSrcTmp.size(); ++idx)56 {57 CDomain* domain = CDomain::createDomain();58 domain->domain_ref.setValue(domainSrcTmp[idx]->getId());59 domain->solveRefInheritance(true);60 domain->solveInheritanceTransformation();61 domain->checkAttributesOnClient();62 domainSrc.push_back(domain);63 }64 65 gridSource_ = CGrid::createGrid(domainSrc, axisSrc, gridDestination_->axis_domain_order);66 gridSource_->computeGridGlobalDimension(domainSrc, axisSrc, gridDestination_->axis_domain_order);45 // std::vector<CAxis*> axisSrcTmp = gridSource_->getAxis(), axisSrc; 46 // std::vector<CDomain*> domainSrcTmp = gridSource_->getDomains(), domainSrc; 47 // for (int idx = 0; idx < axisSrcTmp.size(); ++idx) 48 // { 49 // CAxis* axis = CAxis::createAxis(); 50 // axis->axis_ref.setValue(axisSrcTmp[idx]->getId()); 51 // axis->solveRefInheritance(true); 52 // axis->solveInheritanceTransformation(); 53 // axis->checkAttributesOnClient(); 54 // axisSrc.push_back(axis); 55 // } 56 // 57 // for (int idx = 0; idx < domainSrcTmp.size(); ++idx) 58 // { 59 // CDomain* domain = CDomain::createDomain(); 60 // domain->domain_ref.setValue(domainSrcTmp[idx]->getId()); 61 // domain->solveRefInheritance(true); 62 // domain->solveInheritanceTransformation(); 63 // domain->checkAttributesOnClient(); 64 // domainSrc.push_back(domain); 65 // } 66 // 67 // gridSource_ = CGrid::createGrid(domainSrc, axisSrc, gridDestination_->axis_domain_order); 68 // gridSource_->computeGridGlobalDimension(domainSrc, axisSrc, gridDestination_->axis_domain_order); 67 69 68 70 initializeMappingOfOriginalGridSource(); 69 initializeAlgorithms();71 // initializeAlgorithms(); 70 72 } 71 73 … … 81 83 CContextClient* client = context->client; 82 84 83 CDistributionClient distribution(client->clientRank, originalGridSource_); 84 const std::vector<size_t>& globalIndexGridSrcSendToServer = distribution.getGlobalDataIndexSendToServer(); 85 86 weightOfGlobalIndexOfOriginalGridSource_.resize(globalIndexGridSrcSendToServer.size()); 87 globalIndexOfCurrentGridSource_ = globalIndexGridSrcSendToServer; 88 globalIndexOfOriginalGridSource_ = globalIndexGridSrcSendToServer; 89 weightOfGlobalIndexOfOriginalGridSource_ = 1.0; 85 // Initialize algorithms 86 initializeAlgorithms(); 87 88 ListAlgoType::const_iterator itb = listAlgos_.begin(), 89 ite = listAlgos_.end(), it; 90 91 for (it = itb; it != ite; ++it) 92 { 93 ETranformationType transType = (it->second).first; 94 if (!isSpecialTransformation(transType)) ++nbAlgos_; 95 } 96 97 if (1<nbAlgos_) // Only when there are more than 1 algorithm, will we create temporary grid source 98 { 99 std::vector<CAxis*> axisSrcTmp = gridSource_->getAxis(), axisSrc; 100 std::vector<CDomain*> domainSrcTmp = gridSource_->getDomains(), domainSrc; 101 for (int idx = 0; idx < axisSrcTmp.size(); ++idx) 102 { 103 CAxis* axis = CAxis::createAxis(); 104 axis->axis_ref.setValue(axisSrcTmp[idx]->getId()); 105 axis->solveRefInheritance(true); 106 axis->solveInheritanceTransformation(); 107 axis->checkAttributesOnClient(); 108 axisSrc.push_back(axis); 109 } 110 111 for (int idx = 0; idx < domainSrcTmp.size(); ++idx) 112 { 113 CDomain* domain = CDomain::createDomain(); 114 domain->domain_ref.setValue(domainSrcTmp[idx]->getId()); 115 domain->solveRefInheritance(true); 116 domain->solveInheritanceTransformation(); 117 domain->checkAttributesOnClient(); 118 domainSrc.push_back(domain); 119 } 120 121 gridSource_ = CGrid::createGrid(domainSrc, axisSrc, gridDestination_->axis_domain_order); 122 gridSource_->computeGridGlobalDimension(domainSrc, axisSrc, gridDestination_->axis_domain_order); 123 } 90 124 } 91 125 … … 149 183 } 150 184 } 151 152 153 185 154 186 /*! … … 335 367 break; 336 368 } 369 gridSource_->createMask(); 370 gridSource_->computeGridGlobalDimension(domListSrcP, axisListSrcP, gridSource_->axis_domain_order); 337 371 } 338 372 … … 352 386 ListAlgoType::const_iterator itb = listAlgos_.begin(), 353 387 ite = listAlgos_.end(), it; 388 354 389 CGenericAlgorithmTransformation* algo = 0; 355 390 int nbAgloTransformation = 0; // Only count for executed transformation. Generate domain is a special one, not executed in the list … … 381 416 globaIndexWeightFromDestToSource); 382 417 383 // Compute transformation of global indexes among grids 384 computeTransformationFromOriginalGridSource(globaIndexWeightFromDestToSource); 385 386 // Now grid destination becomes grid source in a new transformation 387 setUpGrid(elementPositionInGrid, transType); 418 if (1 < nbAlgos_) 419 { 420 // Compute transformation of global indexes among grids 421 computeTransformationFromOriginalGridSource(globaIndexWeightFromDestToSource); 422 423 // Now grid destination becomes grid source in a new transformation 424 if (nbAgloTransformation != (nbAlgos_-1)) setUpGrid(elementPositionInGrid, transType); 425 } 426 else 427 { 428 currentGridIndexToOriginalGridIndex_.swap(globaIndexWeightFromDestToSource); 429 } 430 388 431 ++nbAgloTransformation; 389 432 } … … 416 459 iteArr = globalIndexOnClientDest.end(); 417 460 418 // Then find out which index became invalid (become masked after being applied the algorithms, or demande some masked points from grid source) 419 int num = globalIndexOfOriginalGridSource_.size(); 461 GlobalIndexMap::const_iterator iteGlobalMap = currentGridIndexToOriginalGridIndex_.end(); 420 462 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 421 463 int maskIndexNum = 0; 422 for (int idx = 0; idx < num; ++idx) 423 { 424 if (sfmax == globalIndexOfOriginalGridSource_[idx]) 425 { 426 size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_[idx]; 427 itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 428 if (iteArr != itArr) ++maskIndexNum; 464 for (itArr = itbArr; itArr != iteArr; ++itArr) 465 { 466 if (iteGlobalMap != currentGridIndexToOriginalGridIndex_.find(*itArr)) 467 { 468 const std::vector<std::pair<size_t,double> >& vecIndex = currentGridIndexToOriginalGridIndex_[*itArr]; 469 for (int idx = 0; idx < vecIndex.size(); ++idx) 470 { 471 if (sfmax == vecIndex[idx].first) 472 { 473 ++maskIndexNum; 474 break; 475 } 476 } 429 477 } 430 478 } … … 432 480 CArray<int,1> maskIndexToModify(maskIndexNum); 433 481 maskIndexNum = 0; 434 for (int idx = 0; idx < num; ++idx) 435 { 436 if (sfmax == globalIndexOfOriginalGridSource_[idx]) 437 { 438 size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_[idx]; 439 itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 440 if (iteArr != itArr) 482 for (itArr = itbArr; itArr != iteArr; ++itArr) 483 { 484 if (iteGlobalMap != currentGridIndexToOriginalGridIndex_.find(*itArr)) 485 { 486 const std::vector<std::pair<size_t,double> >& vecIndex = currentGridIndexToOriginalGridIndex_[*itArr]; 487 for (int idx = 0; idx < vecIndex.size(); ++idx) 441 488 { 442 int localIdx = std::distance(itbArr, itArr); 443 maskIndexToModify(maskIndexNum) = localMaskIndexOnClientDest[localIdx]; 444 ++maskIndexNum; 489 if (sfmax == vecIndex[idx].first) 490 { 491 int localIdx = std::distance(itbArr, itArr); 492 maskIndexToModify(maskIndexNum) = localMaskIndexOnClientDest[localIdx]; 493 ++maskIndexNum; 494 break; 495 } 445 496 } 446 497 } … … 460 511 CContextClient* client = context->client; 461 512 513 if (currentGridIndexToOriginalGridIndex_.empty()) 514 { 515 currentGridIndexToOriginalGridIndex_ = globaIndexMapFromDestToSource; 516 return; 517 } 518 462 519 CTransformationMapping transformationMap(gridDestination_, gridSource_); 463 520 … … 471 528 std::map<int,std::vector<size_t> >::const_iterator itbSend = globalIndexToSend.begin(), itSend, 472 529 iteSend = globalIndexToSend.end(); 473 std::vector<size_t>::const_iterator itbArr = globalIndexOfCurrentGridSource_.begin(), itArr,474 iteArr = globalIndexOfCurrentGridSource_.end();475 530 int sendBuffSize = 0; 476 531 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize += (itSend->second).size(); 532 // We use the first element of each block to send number of element in this block 533 sendBuffSize += globalIndexToSend.size(); 534 477 535 478 536 typedef unsigned long Scalar; 479 unsigned long* sendBuff, *currentSendBuff;480 if (0 != sendBuffSize) sendBuff = new unsigned long[sendBuffSize];537 Scalar* sendBuff, *currentSendBuff; 538 if (0 != sendBuffSize) sendBuff = new Scalar [sendBuffSize]; 481 539 for (StdSize idx = 0; idx < sendBuffSize; ++idx) sendBuff[idx] = NumTraits<Scalar>::sfmax(); 482 540 483 std::map<int, MPI_Request> requests; 484 485 std::vector<int> permutIndex(globalIndexOfCurrentGridSource_.size()); 486 typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 487 XIOSAlgorithms::fillInIndex(globalIndexOfCurrentGridSource_.size(), permutIndex); 488 XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(globalIndexOfCurrentGridSource_, permutIndex); 489 BinarySearch searchCurrentSrc(globalIndexOfCurrentGridSource_); 490 std::vector<int>::iterator itbIndex = permutIndex.begin(), itIndex, 491 iteIndex = permutIndex.end(); 492 493 // Find out local index on grid destination (received) 541 std::map<int, MPI_Request> requestsCurrentGrid, requestsOriginalGrid, requestsWeightGrid; 542 GlobalIndexMap::const_iterator iteGlobalIndex = currentGridIndexToOriginalGridIndex_.end(); 543 544 // Only send global index of original source corresponding to non-masked index 545 // Use first position of each block to specify the number of elemnt in this block 546 int globalIndexOriginalSrcSendBuffSize = 0; 494 547 int currentBuffPosition = 0; 495 548 for (itSend = itbSend; itSend != iteSend; ++itSend) … … 497 550 int destRank = itSend->first; 498 551 const std::vector<size_t>& globalIndexOfCurrentGridSourceToSend = itSend->second; 499 int countSize = globalIndexOfCurrentGridSourceToSend.size(); 500 for (int idx = 0; idx < (countSize); ++idx) 552 int countSize = globalIndexOfCurrentGridSourceToSend.size(); 553 size_t countBlock = 0; 554 for (int idx = 0; idx < countSize; ++idx) 501 555 { 502 if (searchCurrentSrc.search(itbIndex, iteIndex, globalIndexOfCurrentGridSourceToSend[idx], itIndex)) 556 size_t index = globalIndexOfCurrentGridSourceToSend[idx]; 557 if (iteGlobalIndex != currentGridIndexToOriginalGridIndex_.find(index))// searchCurrentSrc.search(itbIndex, iteIndex, globalIndexOfCurrentGridSourceToSend[idx], itIndex)) 503 558 { 504 sendBuff[idx+currentBuffPosition] = globalIndexOfOriginalGridSource_[*itIndex]; 559 globalIndexOriginalSrcSendBuffSize += currentGridIndexToOriginalGridIndex_[index].size() + 1; // 1 for number of elements in this block 560 sendBuff[idx+currentBuffPosition+1] = index; 561 countBlock += currentGridIndexToOriginalGridIndex_[index].size() + 1; 505 562 } 506 563 } 564 sendBuff[currentBuffPosition] = countBlock; 507 565 currentSendBuff = sendBuff + currentBuffPosition; 508 MPI_Isend(currentSendBuff, countSize , MPI_UNSIGNED_LONG, destRank, 14, client->intraComm, &requests[destRank]);509 currentBuffPosition += countSize ;566 MPI_Isend(currentSendBuff, countSize +1, MPI_UNSIGNED_LONG, destRank, MPI_GRID_TRANSFORMATION_CURRENT_GRID_INDEX, client->intraComm, &requestsCurrentGrid[destRank]); 567 currentBuffPosition += countSize + 1; 510 568 } 569 570 Scalar* sendOriginalIndexBuff, *currentOriginalIndexSendBuff; 571 if (0 != globalIndexOriginalSrcSendBuffSize) sendOriginalIndexBuff = new Scalar [globalIndexOriginalSrcSendBuffSize]; 572 double* sendOriginalWeightBuff, *currentOriginalWeightSendBuff; 573 if (0 != globalIndexOriginalSrcSendBuffSize) sendOriginalWeightBuff = new double [globalIndexOriginalSrcSendBuffSize]; 574 575 currentBuffPosition = 0; 576 for (itSend = itbSend; itSend != iteSend; ++itSend) 577 { 578 int destRank = itSend->first; 579 const std::vector<size_t>& globalIndexOfCurrentGridSourceToSend = itSend->second; 580 int countSize = globalIndexOfCurrentGridSourceToSend.size(); 581 int increaseStep = 0; 582 for (int idx = 0; idx < countSize; ++idx) 583 { 584 size_t index = globalIndexOfCurrentGridSourceToSend[idx]; 585 if (iteGlobalIndex != currentGridIndexToOriginalGridIndex_.find(index)) 586 { 587 size_t vectorSize = currentGridIndexToOriginalGridIndex_[index].size(); 588 sendOriginalIndexBuff[currentBuffPosition+increaseStep] = vectorSize; 589 sendOriginalWeightBuff[currentBuffPosition+increaseStep] = (double)vectorSize; 590 const std::vector<std::pair<size_t,double> >& indexWeightPair = currentGridIndexToOriginalGridIndex_[index]; 591 for (size_t i = 0; i < vectorSize; ++i) 592 { 593 ++increaseStep; 594 sendOriginalIndexBuff[currentBuffPosition+increaseStep] = indexWeightPair[i].first; 595 sendOriginalWeightBuff[currentBuffPosition+increaseStep] = indexWeightPair[i].second; 596 } 597 ++increaseStep; 598 } 599 } 600 601 currentOriginalIndexSendBuff = sendOriginalIndexBuff + currentBuffPosition; 602 currentOriginalWeightSendBuff = sendOriginalWeightBuff + currentBuffPosition; 603 if (0 != increaseStep) 604 { 605 MPI_Isend(currentOriginalIndexSendBuff, increaseStep, MPI_UNSIGNED_LONG, destRank, MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_INDEX, client->intraComm, &requestsOriginalGrid[destRank]); 606 MPI_Isend(currentOriginalWeightSendBuff, increaseStep, MPI_DOUBLE, destRank, MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_WEIGHT, client->intraComm, &requestsWeightGrid[destRank]); 607 } 608 currentBuffPosition += increaseStep; 609 } 610 511 611 512 612 // Receiving global index of grid source sending from current grid source … … 515 615 int recvBuffSize = 0; 516 616 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize += (itRecv->second).size(); 517 518 unsigned long* recvBuff, *currentRecvBuff; 519 if (0 != recvBuffSize) recvBuff = new unsigned long [recvBuffSize]; 617 recvBuffSize += globalIndexToReceive.size(); 618 619 Scalar* recvBuff, *currentRecvBuff; 620 if (0 != recvBuffSize) recvBuff = new Scalar [recvBuffSize]; 520 621 for (StdSize idx = 0; idx < recvBuffSize; ++idx) recvBuff[idx] = NumTraits<Scalar>::sfmax(); 521 622 623 std::map<int,int> countBlockMap; 624 int globalIndexOriginalSrcRecvBuffSize = 0; 522 625 int currentRecvBuffPosition = 0; 523 626 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) … … 527 630 int countSize = (itRecv->second).size(); 528 631 currentRecvBuff = recvBuff + currentRecvBuffPosition; 529 MPI_Recv(currentRecvBuff, countSize, MPI_UNSIGNED_LONG, srcRank, 14, client->intraComm, &status); 530 currentRecvBuffPosition += countSize; 632 MPI_Recv(currentRecvBuff, countSize +1, MPI_UNSIGNED_LONG, srcRank, MPI_GRID_TRANSFORMATION_CURRENT_GRID_INDEX, client->intraComm, &status); 633 globalIndexOriginalSrcRecvBuffSize += *currentRecvBuff; 634 countBlockMap[srcRank] = *currentRecvBuff; 635 currentRecvBuffPosition += countSize +1; 531 636 } 532 637 533 int nbCurrentGridSource = 0; 638 Scalar* recvOriginalIndexBuff, *currentOriginalIndexRecvBuff; 639 if (0 != globalIndexOriginalSrcRecvBuffSize) recvOriginalIndexBuff = new Scalar [globalIndexOriginalSrcRecvBuffSize]; 640 double* recvOriginalWeightBuff, *currentOriginalWeightRecvBuff; 641 if (0 != globalIndexOriginalSrcRecvBuffSize) recvOriginalWeightBuff = new double [globalIndexOriginalSrcRecvBuffSize]; 642 643 int countBlock = 0; 644 currentRecvBuffPosition = 0; 645 currentBuffPosition = 0; 534 646 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 535 647 { 536 int ssize = (itRecv->second).size(); 537 for (int idx = 0; idx < ssize; ++idx) 648 MPI_Status statusIndex, statusWeight; 649 int srcRank = itRecv->first; 650 countBlock = countBlockMap[srcRank]; 651 currentOriginalIndexRecvBuff = recvOriginalIndexBuff + currentBuffPosition; 652 currentOriginalWeightRecvBuff = recvOriginalWeightBuff + currentBuffPosition; 653 if (0 != countBlock) 538 654 { 539 nbCurrentGridSource += (itRecv->second)[idx].size(); 655 MPI_Recv(currentOriginalIndexRecvBuff, countBlock, MPI_UNSIGNED_LONG, srcRank, MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_INDEX, client->intraComm, &statusIndex); 656 MPI_Recv(currentOriginalWeightRecvBuff, countBlock, MPI_DOUBLE, srcRank, MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_WEIGHT, client->intraComm, &statusWeight); 657 } 658 currentBuffPosition += countBlock; 659 } 660 661 // We process everything in here, even case of masked index 662 // The way to process masked index needs discussing 663 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 664 GlobalIndexMap currentToOriginalTmp; 665 666 currentRecvBuffPosition = 0; 667 currentRecvBuff = recvBuff; 668 currentOriginalIndexRecvBuff = recvOriginalIndexBuff; 669 currentOriginalWeightRecvBuff = recvOriginalWeightBuff; 670 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 671 { 672 int countBlockRank = countBlockMap[itRecv->first]; 673 674 ++currentRecvBuff; // it's very subtle here, pay attention 675 int countSize = (itRecv->second).size(); 676 for (int idx = 0; idx < countSize; ++idx) 677 { 678 ++currentRecvBuff; 679 int ssize = (itRecv->second)[idx].size(); 680 if (sfmax != *currentRecvBuff) 681 { 682 if (0 != countBlockRank) 683 { 684 countBlock = *(currentOriginalIndexRecvBuff+currentRecvBuffPosition); 685 for (int i = 0; i < ssize; ++i) 686 { 687 for (int j = 0; j < countBlock; ++j) 688 { 689 size_t globalOriginalIndex = *(currentOriginalIndexRecvBuff+currentRecvBuffPosition+j+1); 690 double weightGlobal = *(currentOriginalWeightRecvBuff+currentRecvBuffPosition+j+1) * (itRecv->second)[idx][i].second; 691 currentToOriginalTmp[(itRecv->second)[idx][i].first].push_back(make_pair(globalOriginalIndex,weightGlobal)); 692 } 693 } 694 currentRecvBuffPosition += countBlock+1; 695 } 696 } 697 // else 698 // { 699 // for (int i = 0; i < ssize; ++i) 700 // { 701 // currentToOriginalTmp[(itRecv->second)[idx][i].first].push_back(make_pair(sfmax,1.0)); 702 // } 703 // } 540 704 } 541 705 } 542 706 543 if (globalIndexOfCurrentGridSource_.size() != nbCurrentGridSource) 544 { 545 globalIndexOfCurrentGridSource_.resize(nbCurrentGridSource); 546 globalIndexOfOriginalGridSource_.resize(nbCurrentGridSource); 547 weightOfGlobalIndexOfOriginalGridSource_.resize(nbCurrentGridSource); 548 } 549 550 int k = 0; 551 currentRecvBuff = recvBuff; 552 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 553 { 554 int countSize = (itRecv->second).size(); 555 for (int idx = 0; idx < countSize; ++idx, ++currentRecvBuff) 556 { 557 int ssize = (itRecv->second)[idx].size(); 558 for (int i = 0; i < ssize; ++i) 559 { 560 globalIndexOfCurrentGridSource_[k] = ((itRecv->second)[idx][i]).first; 561 weightOfGlobalIndexOfOriginalGridSource_(k) = ((itRecv->second)[idx][i]).second; 562 globalIndexOfOriginalGridSource_[k] = *currentRecvBuff; 563 ++k; 564 } 565 } 566 } 707 currentGridIndexToOriginalGridIndex_.swap(currentToOriginalTmp); 567 708 568 709 std::map<int, MPI_Request>::iterator itRequest; 569 for (itRequest = requests.begin(); itRequest != requests.end(); ++itRequest) 710 for (itRequest = requestsCurrentGrid.begin(); itRequest != requestsCurrentGrid.end(); ++itRequest) 711 MPI_Wait(&itRequest->second, MPI_STATUS_IGNORE); 712 for (itRequest = requestsOriginalGrid.begin(); itRequest != requestsOriginalGrid.end(); ++itRequest) 713 MPI_Wait(&itRequest->second, MPI_STATUS_IGNORE); 714 for (itRequest = requestsWeightGrid.begin(); itRequest != requestsWeightGrid.end(); ++itRequest) 570 715 MPI_Wait(&itRequest->second, MPI_STATUS_IGNORE); 571 716 572 717 if (0 != sendBuffSize) delete [] sendBuff; 573 718 if (0 != recvBuffSize) delete [] recvBuff; 719 if (0 != globalIndexOriginalSrcSendBuffSize) delete [] sendOriginalIndexBuff; 720 if (0 != globalIndexOriginalSrcSendBuffSize) delete [] sendOriginalWeightBuff; 721 if (0 != globalIndexOriginalSrcRecvBuffSize) delete [] recvOriginalIndexBuff; 722 if (0 != globalIndexOriginalSrcRecvBuffSize) delete [] recvOriginalWeightBuff; 574 723 } 575 724 … … 586 735 CTransformationMapping transformationMap(gridDestination_, originalGridSource_); 587 736 588 std::map<size_t, std::vector<std::pair<size_t,double> > > globaIndexWeightFromDestToSource; 589 int nb = globalIndexOfCurrentGridSource_.size(); 590 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 591 for (int idx = 0; idx < nb; ++idx) 592 { 593 if (sfmax != globalIndexOfOriginalGridSource_[idx]) 594 globaIndexWeightFromDestToSource[globalIndexOfCurrentGridSource_[idx]].push_back(make_pair(globalIndexOfOriginalGridSource_[idx], weightOfGlobalIndexOfOriginalGridSource_(idx))) ; 595 } 596 597 // Then compute transformation mapping among clients 598 transformationMap.computeTransformationMapping(globaIndexWeightFromDestToSource); 737 transformationMap.computeTransformationMapping(currentGridIndexToOriginalGridIndex_); 599 738 600 739 const std::map<int,std::vector<std::vector<std::pair<size_t,double> > > >& globalIndexToReceive = transformationMap.getGlobalIndexReceivedOnGridDestMapping(); … … 667 806 } 668 807 808 bool CGridTransformation::isSpecialTransformation(ETranformationType transType) 809 { 810 bool res; 811 switch (transType) 812 { 813 case TRANS_GENERATE_RECTILINEAR_DOMAIN: 814 res = true; 815 break; 816 default: 817 res = false; 818 break; 819 } 820 821 return res; 822 } 823 669 824 /*! 670 825 Local index of data which need sending from the grid source -
XIOS/trunk/src/transformation/grid_transformation.hpp
r790 r821 63 63 void computeTransformationFromOriginalGridSource(const std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexMapFromDestToSource); 64 64 void updateFinalGridDestination(); 65 bool isSpecialTransformation(ETranformationType transType); 65 66 66 67 protected: … … 77 78 //! List of algorithm types and their order 78 79 ListAlgoType listAlgos_; 80 81 //! Number of algorithm 82 int nbAlgos_; 83 84 typedef std::map<size_t, std::vector<std::pair<size_t,double> > > GlobalIndexMap; 85 79 86 // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_ 80 87 std::vector<bool> algoTypes_; … … 96 103 97 104 //! (Grid) Global index of grid source 98 std::vector<size_t> globalIndexOfCurrentGridSource_; 99 std::vector<size_t> globalIndexOfOriginalGridSource_; 100 CArray<double,1> weightOfGlobalIndexOfOriginalGridSource_; 105 GlobalIndexMap currentGridIndexToOriginalGridIndex_; 101 106 }; 102 107
Note: See TracChangeset
for help on using the changeset viewer.