Changeset 709
- Timestamp:
- 09/29/15 14:01:53 (9 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/bld.cfg
r691 r709 30 30 src::remap $PWD/extern/remap/src 31 31 bld::lib xios 32 bld::lib::remap mapper 33 bld::target libxios.a libmapper.a 32 bld::target libxios.a 34 33 #bld::target generate_fortran_interface.exe 35 34 bld::target xios_server.exe test_remap.exe 36 #bld::target test_new_features.exe test_unstruct_complete.exe35 bld::target test_new_features.exe test_unstruct_complete.exe 37 36 bld::target test_client.exe test_complete.exe 38 37 bld::exe_dep -
XIOS/trunk/inputs/REMAP/iodef.xml
r689 r709 13 13 14 14 15 <file_definition type=" multiple_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE.">15 <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 16 16 <file id="output" name="output"> 17 17 <field field_ref="src_field" name="field" /> … … 32 32 <domain id="src_domain" /> 33 33 <domain id="dst_domain" domain_src="src_domain"> 34 <interpolate_domain file="weight.nc"/> 34 <!-- <interpolate_domain file="weight.nc"/>--> 35 <interpolate_domain/> 35 36 </domain> 36 <domain id="dst_domain_regular" domain_src="src_domain" >37 <domain id="dst_domain_regular" domain_src="src_domain" ni_glo="180" nj_glo="90"> 37 38 <generate_rectilinear_domain /> 38 39 <interpolate_domain/> -
XIOS/trunk/src/filter/spatial_transform_filter.cpp
r690 r709 80 80 std::map<int, CArray<int,1> >::const_iterator itbSend = localIndexToSend.begin(), itSend, 81 81 iteSend = localIndexToSend.end(); 82 int sendBuffSize = 0; 83 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize = (sendBuffSize < itSend->second.numElements()) 84 ? itSend->second.numElements(): sendBuffSize; 85 double* sendBuff; 86 if (0 != sendBuffSize) sendBuff = new double[sendBuffSize]; 82 int idxSendBuff = 0; 83 std::vector<double*> sendBuff(localIndexToSend.size()); 84 for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 85 { 86 if (0 != itSend->second.numElements()) 87 sendBuff[idxSendBuff] = new double[itSend->second.numElements()]; 88 } 89 90 idxSendBuff = 0; 87 91 std::vector<MPI_Request> sendRequest; 88 for (itSend = itbSend; itSend != iteSend; ++itSend )92 for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 89 93 { 90 94 int destRank = itSend->first; … … 93 97 for (int idx = 0; idx < countSize; ++idx) 94 98 { 95 sendBuff[idx ] = dataSrc(localIndex_p(idx));99 sendBuff[idxSendBuff][idx] = dataSrc(localIndex_p(idx)); 96 100 } 97 101 sendRequest.push_back(MPI_Request()); 98 MPI_Isend(sendBuff , countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRequest.back());102 MPI_Isend(sendBuff[idxSendBuff], countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRequest.back()); 99 103 } 100 104 … … 113 117 int countSize = itRecv->second.size(); 114 118 MPI_Recv(recvBuff, recvBuffSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &status); 119 int countBuff = 0; 120 MPI_Get_count(&status, MPI_DOUBLE, &countBuff); 121 if (countBuff != countSize) 122 ERROR("CSpatialTransformFilterEngine::apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest)", 123 "Incoherent between the received size and expected size"); 115 124 for (int idx = 0; idx < countSize; ++idx) 116 125 { … … 119 128 for (int i = 0; i < numIndex; ++i) 120 129 { 121 // if (localIndex_p[i].first >= dataDest.numElements())122 130 dataDest(localIndex_p[i].first) += recvBuff[idx] * localIndex_p[i].second; 123 131 } … … 125 133 } 126 134 127 std::vector<MPI_Status> requestStatus(sendRequest.size()); 128 if (!sendRequest.empty()) MPI_Wait(&sendRequest[0], &requestStatus[0]); 129 if (0 != sendBuffSize) delete [] sendBuff; 135 136 if (!sendRequest.empty()) MPI_Waitall(sendRequest.size(), &sendRequest[0], MPI_STATUSES_IGNORE); 137 idxSendBuff = 0; 138 for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 139 { 140 if (0 != itSend->second.numElements()) 141 delete [] sendBuff[idxSendBuff]; 142 } 130 143 if (0 != recvBuffSize) delete [] recvBuff; 131 144 } -
XIOS/trunk/src/io/nc4_data_output.cpp
r707 r709 1625 1625 } 1626 1626 /* 1627 int ssize = nZoomBeginGlobal.size();1628 1627 for (int i = numElement - 1; i >= 0; --i) 1629 1628 1630 1629 1631 start.resize(ssize); 1632 count.resize(ssize); 1633 1634 for (int i = 0; i < ssize; ++i) 1630 start.reserve(nZoomBeginGlobal.size()); 1631 count.reserve(nZoomBeginGlobal.size()); 1632 1633 1634 for (int i = numElement - 1; i >= 0; --i) 1635 1635 { 1636 start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1]; 1637 count[i] = nZoomSizeServer[ssize - i - 1]; 1636 if (axisDomainOrder(i)) 1637 { 1638 CDomain* domain = CDomain::get(domainList[idxDomain]); 1639 1640 if (CDomain::type_attr::unstructured != domain->type) 1641 { 1642 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 1643 count.push_back(nZoomSizeServer[idx]); 1644 } 1645 --idx; 1646 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 1647 count.push_back(nZoomSizeServer[idx]); 1648 --idx; 1649 1650 --idxDomain; 1651 //idx -= 2; 1652 } 1653 else 1654 { 1655 CAxis* axis = CAxis::get(axisList[idxAxis]); 1656 1657 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 1658 count.push_back(nZoomSizeServer[idx]); 1659 1660 --idxAxis; 1661 --idx; 1662 } 1638 1663 } 1639 */ 1664 1665 // int ssize = nZoomBeginGlobal.size(); 1666 // 1667 // start.resize(ssize); 1668 // count.resize(ssize); 1669 // 1670 // for (int i = 0; i < ssize; ++i) 1671 // { 1672 // start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1]; 1673 // count[i] = nZoomSizeServer[ssize - i - 1]; 1674 // } 1640 1675 } 1641 1676 -
XIOS/trunk/src/test/test_remap.f90
r689 r709 119 119 bounds_lon_1D=dst_boundslon, bounds_lat_1D=dst_boundslat, nvertex=dst_nvertex) 120 120 121 CALL xios_set_domain_attr("dst_domain_regular", ni_glo=180, nj_glo=90,type="rectilinear")121 CALL xios_set_domain_attr("dst_domain_regular", type="rectilinear") 122 122 123 123 dtime%second = 3600 -
XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp
r689 r709 76 76 { 77 77 nVertexSrc = constNVertex; 78 domainSrc_->fillInRectilinearBoundLonLat(boundsLonSrc, boundsLatSrc); 78 79 } 79 80 … … 114 115 } 115 116 117 118 116 119 // Ok, now use mapper to calculate 117 120 int nSrcLocal = domainSrc_->i_index.numElements(); 118 121 int nDstLocal = domainDest_->i_index.numElements(); 122 long int * globalSrc = new long int [nSrcLocal]; 123 long int * globalDst = new long int [nDstLocal]; 124 125 long int globalIndex; 126 int i_ind, j_ind; 127 for (int idx = 0; idx < nSrcLocal; ++idx) 128 { 129 i_ind=domainSrc_->i_index(idx) ; 130 j_ind=domainSrc_->j_index(idx) ; 131 132 globalIndex = i_ind + j_ind * domainSrc_->ni_glo; 133 globalSrc[idx] = globalIndex; 134 } 135 136 for (int idx = 0; idx < nDstLocal; ++idx) 137 { 138 i_ind=domainDest_->i_index(idx) ; 139 j_ind=domainDest_->j_index(idx) ; 140 141 globalIndex = i_ind + j_ind * domainDest_->ni_glo; 142 globalDst[idx] = globalIndex; 143 } 144 145 146 // Calculate weight index 119 147 Mapper mapper(client->intraComm); 120 148 mapper.setVerbosity(PROGRESS) ; 121 mapper.setSourceMesh(boundsLonSrc.dataFirst(), boundsLatSrc.dataFirst(), nVertexSrc, nSrcLocal, &srcPole[0] );122 mapper.setTargetMesh(boundsLonDest.dataFirst(), boundsLatDest.dataFirst(), nVertexDest, nDstLocal, &dstPole[0] );149 mapper.setSourceMesh(boundsLonSrc.dataFirst(), boundsLatSrc.dataFirst(), nVertexSrc, nSrcLocal, &srcPole[0], globalSrc); 150 mapper.setTargetMesh(boundsLonDest.dataFirst(), boundsLatDest.dataFirst(), nVertexDest, nDstLocal, &dstPole[0], globalDst); 123 151 std::vector<double> timings = mapper.computeWeights(orderInterp); 124 152 153 std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 125 154 for (int idx = 0; idx < mapper.nWeights; ++idx) 126 155 { 127 transformationMapping_[mapper.targetWeightId[idx]].push_back(mapper.sourceWeightId[idx]); 128 transformationWeight_[mapper.targetWeightId[idx]].push_back(mapper.remapMatrix[idx]); 129 } 156 interpMapValue[mapper.targetWeightId[idx]].push_back(make_pair(mapper.sourceWeightId[idx],mapper.remapMatrix[idx])); 157 } 158 exchangeRemapInfo(interpMapValue); 159 160 delete [] globalSrc; 161 delete [] globalDst; 130 162 } 131 163 … … 141 173 } 142 174 175 void CDomainAlgorithmInterpolate::readRemapInfo() 176 { 177 CContext* context = CContext::getCurrent(); 178 CContextClient* client=context->client; 179 int clientRank = client->clientRank; 180 181 std::string filename = interpDomain_->file.getValue(); 182 std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 183 readInterpolationInfo(filename, interpMapValue); 184 185 exchangeRemapInfo(interpMapValue); 186 } 187 188 143 189 /*! 144 190 Read remap information from file then distribute it among clients 145 191 */ 146 void CDomainAlgorithmInterpolate:: readRemapInfo()192 void CDomainAlgorithmInterpolate::exchangeRemapInfo(const std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 147 193 { 148 194 CContext* context = CContext::getCurrent(); 149 195 CContextClient* client=context->client; 150 196 int clientRank = client->clientRank; 151 152 std::string filename = interpDomain_->file.getValue();153 std::map<int,std::vector<std::pair<int,double> > > interpMapValue;154 readInterpolationInfo(filename, interpMapValue);155 197 156 198 boost::unordered_map<size_t,int> globalIndexOfDomainDest; … … 189 231 int* sendBuff = new int[nbClient]; 190 232 int* recvBuff = new int[nbClient]; 191 for (int i = 0; i < nbClient; ++i) sendBuff[i] = 0; 233 for (int i = 0; i < nbClient; ++i) 234 { 235 sendBuff[i] = 0; 236 recvBuff[i] = 0; 237 } 192 238 int sendBuffSize = 0; 193 239 std::map<int, std::vector<size_t> >::const_iterator itbMap = globalIndexInterpSendToClient.begin(), itMap, … … 195 241 for (itMap = itbMap; itMap != iteMap; ++itMap) 196 242 { 243 const std::vector<size_t>& tmp = itMap->second; 197 244 int sizeIndex = 0, mapSize = (itMap->second).size(); 198 245 for (int idx = 0; idx < mapSize; ++idx) 199 246 { 200 sizeIndex += interpMapValue [(itMap->second)[idx]].size();247 sizeIndex += interpMapValue.at((itMap->second)[idx]).size(); 201 248 } 202 249 sendBuff[itMap->first] = sizeIndex; 203 250 sendBuffSize += sizeIndex; 204 251 } 252 205 253 206 254 MPI_Allreduce(sendBuff, recvBuff, nbClient, MPI_INT, MPI_SUM, client->intraComm); … … 211 259 212 260 std::vector<MPI_Request> sendRequest; 213 // Now send index and weight 214 int sendOffSet = 0 ;261 262 int sendOffSet = 0, l = 0; 215 263 for (itMap = itbMap; itMap != iteMap; ++itMap) 216 264 { 265 const std::vector<size_t>& indexToSend = itMap->second; 266 int mapSize = indexToSend.size(); 217 267 int k = 0; 218 int mapSize = (itMap->second).size();219 220 268 for (int idx = 0; idx < mapSize; ++idx) 221 269 { 222 std::vector<std::pair<int,double> >& interpMap = interpMapValue[(itMap->second)[idx]];270 const std::vector<std::pair<int,double> >& interpMap = interpMapValue.at(indexToSend[idx]); 223 271 for (int i = 0; i < interpMap.size(); ++i) 224 272 { 225 sendIndexDestBuff[ k] = (itMap->second)[idx];226 sendIndexSrcBuff[ k] = interpMap[i].first;227 sendWeightBuff[ k] = interpMap[i].second;273 sendIndexDestBuff[l] = indexToSend[idx]; 274 sendIndexSrcBuff[l] = interpMap[i].first; 275 sendWeightBuff[l] = interpMap[i].second; 228 276 ++k; 277 ++l; 229 278 } 230 279 } … … 303 352 304 353 std::vector<MPI_Status> requestStatus(sendRequest.size()); 305 MPI_Wait (&sendRequest[0], &requestStatus[0]);354 MPI_Waitall(sendRequest.size(), &sendRequest[0], MPI_STATUS_IGNORE); 306 355 307 356 delete [] sendIndexDestBuff; … … 322 371 */ 323 372 void CDomainAlgorithmInterpolate::readInterpolationInfo(std::string& filename, 324 373 std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 325 374 { 326 375 int ncid ; -
XIOS/trunk/src/transformation/domain_algorithm_interpolate.hpp
r689 r709 32 32 void computeRemap(); 33 33 void readRemapInfo(); 34 34 void exchangeRemapInfo(const std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); 35 35 private: 36 36 CInterpolateDomain* interpDomain_; -
XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp
r668 r709 32 32 std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexWeightFromDestToSource) 33 33 { 34 std::map<int, std::vector<int> >::const_iterator itbTransMap = transformationMapping_.begin(), 35 itTransMap = itbTransMap, 34 std::map<int, std::vector<int> >::const_iterator itbTransMap = transformationMapping_.begin(), itTransMap, 36 35 iteTransMap = transformationMapping_.end(); 37 36 std::map<int, std::vector<double> >::const_iterator itTransWeight = transformationWeight_.begin(); 38 std::map<size_t, std::vector<std::pair<size_t,double> > >::iterator iteWeight, itWeight;39 std::vector<int>::const_iterator itbVec, itVec, iteVec;40 37 std::vector<std::vector<size_t> > globalIndexSrcGrid; 41 38 CArray<size_t,1> globalIndexDestGrid;
Note: See TracChangeset
for help on using the changeset viewer.