[219] | 1 | #include "domain.hpp" |
---|
| 2 | |
---|
[352] | 3 | #include "attribute_template.hpp" |
---|
| 4 | #include "object_template.hpp" |
---|
| 5 | #include "group_template.hpp" |
---|
[219] | 6 | |
---|
[591] | 7 | #include "xios_spl.hpp" |
---|
[300] | 8 | #include "event_client.hpp" |
---|
| 9 | #include "event_server.hpp" |
---|
| 10 | #include "buffer_in.hpp" |
---|
[352] | 11 | #include "message.hpp" |
---|
| 12 | #include "type.hpp" |
---|
| 13 | #include "context.hpp" |
---|
| 14 | #include "context_client.hpp" |
---|
[676] | 15 | #include "context_server.hpp" |
---|
[369] | 16 | #include "array_new.hpp" |
---|
[676] | 17 | #include "distribution_client.hpp" |
---|
[553] | 18 | #include "server_distribution_description.hpp" |
---|
[569] | 19 | #include "client_server_mapping_distributed.hpp" |
---|
[274] | 20 | |
---|
[676] | 21 | #include <algorithm> |
---|
| 22 | |
---|
[335] | 23 | namespace xios { |
---|
[509] | 24 | |
---|
[1158] | 25 | /// ////////////////////// Définitions ////////////////////// /// |
---|
[219] | 26 | |
---|
| 27 | CDomain::CDomain(void) |
---|
| 28 | : CObjectTemplate<CDomain>(), CDomainAttributes() |
---|
[1236] | 29 | , isChecked(false), relFiles(), isClientChecked(false), nbSenders(), indSrv_(), connectedServerRank_() |
---|
[1143] | 30 | , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) |
---|
[665] | 31 | , isClientAfterTransformationChecked(false), hasLonLat(false) |
---|
[1099] | 32 | , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) |
---|
| 33 | , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() |
---|
[1129] | 34 | , globalLocalIndexMap_(), computedWrittenIndex_(false) |
---|
[1855] | 35 | , clients(),hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) |
---|
| 36 | , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) |
---|
[878] | 37 | { |
---|
[924] | 38 | } |
---|
[219] | 39 | |
---|
| 40 | CDomain::CDomain(const StdString & id) |
---|
| 41 | : CObjectTemplate<CDomain>(id), CDomainAttributes() |
---|
[1236] | 42 | , isChecked(false), relFiles(), isClientChecked(false), nbSenders(), indSrv_(), connectedServerRank_() |
---|
[1143] | 43 | , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) |
---|
[665] | 44 | , isClientAfterTransformationChecked(false), hasLonLat(false) |
---|
[1099] | 45 | , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) |
---|
| 46 | , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() |
---|
[1129] | 47 | , globalLocalIndexMap_(), computedWrittenIndex_(false) |
---|
[1855] | 48 | , clients(), hasBoundsLatInReadFile_(false) |
---|
| 49 | , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) |
---|
[878] | 50 | { |
---|
[1337] | 51 | } |
---|
[219] | 52 | |
---|
| 53 | CDomain::~CDomain(void) |
---|
[509] | 54 | { |
---|
[219] | 55 | } |
---|
| 56 | |
---|
| 57 | ///--------------------------------------------------------------- |
---|
| 58 | |
---|
[924] | 59 | void CDomain::assignMesh(const StdString meshName, const int nvertex) |
---|
[881] | 60 | { |
---|
[924] | 61 | mesh = CMesh::getMesh(meshName, nvertex); |
---|
[881] | 62 | } |
---|
| 63 | |
---|
[622] | 64 | CDomain* CDomain::createDomain() |
---|
| 65 | { |
---|
| 66 | CDomain* domain = CDomainGroup::get("domain_definition")->createChild(); |
---|
| 67 | return domain; |
---|
| 68 | } |
---|
| 69 | |
---|
[836] | 70 | std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>(); |
---|
| 71 | bool CDomain::_dummyTransformationMapList = CDomain::initializeTransformationMap(CDomain::transformationMapList_); |
---|
| 72 | |
---|
| 73 | bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) |
---|
| 74 | { |
---|
| 75 | m["zoom_domain"] = TRANS_ZOOM_DOMAIN; |
---|
| 76 | m["interpolate_domain"] = TRANS_INTERPOLATE_DOMAIN; |
---|
| 77 | m["generate_rectilinear_domain"] = TRANS_GENERATE_RECTILINEAR_DOMAIN; |
---|
[934] | 78 | m["compute_connectivity_domain"] = TRANS_COMPUTE_CONNECTIVITY_DOMAIN; |
---|
[935] | 79 | m["expand_domain"] = TRANS_EXPAND_DOMAIN; |
---|
[1457] | 80 | m["reorder_domain"] = TRANS_REORDER_DOMAIN; |
---|
[1850] | 81 | return true ; |
---|
[836] | 82 | } |
---|
| 83 | |
---|
[1158] | 84 | const std::set<StdString> & CDomain::getRelFiles(void) const |
---|
| 85 | { |
---|
| 86 | return (this->relFiles); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | |
---|
[676] | 90 | /*! |
---|
| 91 | Returns the number of indexes written by each server. |
---|
| 92 | \return the number of indexes written by each server |
---|
| 93 | */ |
---|
[1249] | 94 | int CDomain::getNumberWrittenIndexes(MPI_Comm writtenCom) |
---|
[676] | 95 | { |
---|
[1249] | 96 | int writtenSize; |
---|
| 97 | MPI_Comm_size(writtenCom, &writtenSize); |
---|
| 98 | return numberWrittenIndexes_[writtenSize]; |
---|
[676] | 99 | } |
---|
| 100 | |
---|
| 101 | /*! |
---|
| 102 | Returns the total number of indexes written by the servers. |
---|
| 103 | \return the total number of indexes written by the servers |
---|
| 104 | */ |
---|
[1249] | 105 | int CDomain::getTotalNumberWrittenIndexes(MPI_Comm writtenCom) |
---|
[676] | 106 | { |
---|
[1249] | 107 | int writtenSize; |
---|
| 108 | MPI_Comm_size(writtenCom, &writtenSize); |
---|
| 109 | return totalNumberWrittenIndexes_[writtenSize]; |
---|
[676] | 110 | } |
---|
| 111 | |
---|
| 112 | /*! |
---|
| 113 | Returns the offset of indexes written by each server. |
---|
| 114 | \return the offset of indexes written by each server |
---|
| 115 | */ |
---|
[1249] | 116 | int CDomain::getOffsetWrittenIndexes(MPI_Comm writtenCom) |
---|
[676] | 117 | { |
---|
[1249] | 118 | int writtenSize; |
---|
| 119 | MPI_Comm_size(writtenCom, &writtenSize); |
---|
| 120 | return offsetWrittenIndexes_[writtenSize]; |
---|
[676] | 121 | } |
---|
| 122 | |
---|
[1249] | 123 | CArray<int, 1>& CDomain::getCompressedIndexToWriteOnServer(MPI_Comm writtenCom) |
---|
| 124 | { |
---|
| 125 | int writtenSize; |
---|
| 126 | MPI_Comm_size(writtenCom, &writtenSize); |
---|
| 127 | return compressedIndexToWriteOnServer[writtenSize]; |
---|
| 128 | } |
---|
| 129 | |
---|
[676] | 130 | //---------------------------------------------------------------- |
---|
| 131 | |
---|
[731] | 132 | /*! |
---|
| 133 | * Compute the minimum buffer size required to send the attributes to the server(s). |
---|
| 134 | * |
---|
| 135 | * \return A map associating the server rank with its minimum buffer size. |
---|
| 136 | */ |
---|
[1330] | 137 | std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/) |
---|
[731] | 138 | { |
---|
| 139 | |
---|
[1330] | 140 | std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client); |
---|
[731] | 141 | |
---|
| 142 | if (client->isServerLeader()) |
---|
| 143 | { |
---|
[1025] | 144 | // size estimation for sendDistributionAttribut |
---|
[731] | 145 | size_t size = 11 * sizeof(size_t); |
---|
| 146 | |
---|
| 147 | const std::list<int>& ranks = client->getRanksServerLeader(); |
---|
| 148 | for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) |
---|
| 149 | { |
---|
| 150 | if (size > attributesSizes[*itRank]) |
---|
| 151 | attributesSizes[*itRank] = size; |
---|
| 152 | } |
---|
| 153 | } |
---|
| 154 | |
---|
[1337] | 155 | boost::unordered_map<int, vector<size_t> >::const_iterator itIndexEnd = indSrv_[client->serverSize].end(); |
---|
[1236] | 156 | // std::map<int, std::vector<int> >::const_iterator itWrittenIndexEnd = indWrittenSrv_.end(); |
---|
[1337] | 157 | for (size_t k = 0; k < connectedServerRank_[client->serverSize].size(); ++k) |
---|
[731] | 158 | { |
---|
[1337] | 159 | int rank = connectedServerRank_[client->serverSize][k]; |
---|
| 160 | boost::unordered_map<int, std::vector<size_t> >::const_iterator it = indSrv_[client->serverSize].find(rank); |
---|
[764] | 161 | size_t idxCount = (it != itIndexEnd) ? it->second.size() : 0; |
---|
| 162 | |
---|
[731] | 163 | // size estimation for sendIndex (and sendArea which is always smaller or equal) |
---|
[764] | 164 | size_t sizeIndexEvent = 2 * sizeof(size_t) + 2 * CArray<int,1>::size(idxCount); |
---|
[731] | 165 | |
---|
| 166 | // size estimation for sendLonLat |
---|
[764] | 167 | size_t sizeLonLatEvent = CArray<double,1>::size(idxCount); |
---|
[731] | 168 | if (hasBounds) |
---|
[764] | 169 | sizeLonLatEvent += CArray<double,2>::size(nvertex * idxCount); |
---|
[731] | 170 | |
---|
| 171 | size_t size = CEventClient::headerSize + getId().size() + sizeof(size_t) + std::max(sizeIndexEvent, sizeLonLatEvent); |
---|
[764] | 172 | if (size > attributesSizes[rank]) |
---|
| 173 | attributesSizes[rank] = size; |
---|
[731] | 174 | } |
---|
| 175 | |
---|
| 176 | return attributesSizes; |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | //---------------------------------------------------------------- |
---|
| 180 | |
---|
[219] | 181 | bool CDomain::isEmpty(void) const |
---|
| 182 | { |
---|
[1624] | 183 | return ((this->i_index.isEmpty()) || (0 == this->i_index.numElements())); |
---|
[219] | 184 | } |
---|
| 185 | |
---|
| 186 | //---------------------------------------------------------------- |
---|
[676] | 187 | |
---|
[219] | 188 | bool CDomain::IsWritten(const StdString & filename) const |
---|
| 189 | { |
---|
| 190 | return (this->relFiles.find(filename) != this->relFiles.end()); |
---|
| 191 | } |
---|
| 192 | |
---|
[676] | 193 | bool CDomain::isWrittenCompressed(const StdString& filename) const |
---|
| 194 | { |
---|
| 195 | return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); |
---|
| 196 | } |
---|
| 197 | |
---|
[219] | 198 | //---------------------------------------------------------------- |
---|
[676] | 199 | |
---|
[594] | 200 | bool CDomain::isDistributed(void) const |
---|
| 201 | { |
---|
[1158] | 202 | bool distributed = !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || |
---|
[1143] | 203 | (!i_index.isEmpty() && i_index.numElements() == ni_glo*nj_glo)); |
---|
[1158] | 204 | distributed |= (1 == CContext::getCurrent()->client->clientSize); |
---|
| 205 | |
---|
| 206 | return distributed; |
---|
[594] | 207 | } |
---|
| 208 | |
---|
| 209 | //---------------------------------------------------------------- |
---|
[676] | 210 | |
---|
| 211 | /*! |
---|
| 212 | * Test whether the data defined on the domain can be outputted in a compressed way. |
---|
[679] | 213 | * |
---|
[676] | 214 | * \return true if and only if a mask was defined for this domain |
---|
| 215 | */ |
---|
| 216 | bool CDomain::isCompressible(void) const |
---|
| 217 | { |
---|
| 218 | return isCompressible_; |
---|
| 219 | } |
---|
| 220 | |
---|
[219] | 221 | void CDomain::addRelFile(const StdString & filename) |
---|
| 222 | { |
---|
| 223 | this->relFiles.insert(filename); |
---|
| 224 | } |
---|
[895] | 225 | |
---|
[676] | 226 | void CDomain::addRelFileCompressed(const StdString& filename) |
---|
| 227 | { |
---|
| 228 | this->relFilesCompressed.insert(filename); |
---|
| 229 | } |
---|
[219] | 230 | |
---|
| 231 | StdString CDomain::GetName(void) { return (StdString("domain")); } |
---|
| 232 | StdString CDomain::GetDefName(void){ return (CDomain::GetName()); } |
---|
| 233 | ENodeType CDomain::GetType(void) { return (eDomain); } |
---|
| 234 | |
---|
| 235 | //---------------------------------------------------------------- |
---|
| 236 | |
---|
[687] | 237 | /*! |
---|
[1158] | 238 | Verify if all distribution information of a domain are available |
---|
| 239 | This checking verifies the definition of distribution attributes (ni, nj, ibegin, jbegin) |
---|
| 240 | */ |
---|
| 241 | bool CDomain::distributionAttributesHaveValue() const |
---|
| 242 | { |
---|
| 243 | bool hasValues = true; |
---|
| 244 | |
---|
| 245 | if (ni.isEmpty() && ibegin.isEmpty() && i_index.isEmpty()) |
---|
| 246 | { |
---|
| 247 | hasValues = false; |
---|
| 248 | return hasValues; |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | return hasValues; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | /*! |
---|
[1419] | 255 | Redistribute RECTILINEAR or CURVILINEAR domain with a number of local domains. |
---|
[687] | 256 | All attributes ni,nj,ibegin,jbegin (if defined) will be rewritten |
---|
| 257 | The optional attributes lonvalue, latvalue will be added. Because this function only serves (for now) |
---|
| 258 | for interpolation from unstructured domain to rectilinear one, range of latvalue is 0-360 and lonvalue is -90 - +90 |
---|
| 259 | \param [in] nbLocalDomain number of local domain on the domain destination |
---|
| 260 | */ |
---|
| 261 | void CDomain::redistribute(int nbLocalDomain) |
---|
| 262 | { |
---|
[715] | 263 | if (this->isRedistributed_) return; |
---|
[727] | 264 | |
---|
[783] | 265 | this->isRedistributed_ = true; |
---|
| 266 | CContext* context = CContext::getCurrent(); |
---|
[1054] | 267 | // For now the assumption is that secondary server pools consist of the same number of procs. |
---|
| 268 | // CHANGE the line below if the assumption changes. |
---|
| 269 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; |
---|
[783] | 270 | int rankClient = client->clientRank; |
---|
| 271 | int rankOnDomain = rankClient%nbLocalDomain; |
---|
[687] | 272 | |
---|
[783] | 273 | if (ni_glo.isEmpty() || ni_glo <= 0 ) |
---|
| 274 | { |
---|
| 275 | ERROR("CDomain::redistribute(int nbLocalDomain)", |
---|
| 276 | << "[ Id = " << this->getId() << " ] " |
---|
| 277 | << "The global domain is badly defined," |
---|
| 278 | << " check the \'ni_glo\' value !") |
---|
| 279 | } |
---|
[687] | 280 | |
---|
[783] | 281 | if (nj_glo.isEmpty() || nj_glo <= 0 ) |
---|
| 282 | { |
---|
| 283 | ERROR("CDomain::redistribute(int nbLocalDomain)", |
---|
| 284 | << "[ Id = " << this->getId() << " ] " |
---|
| 285 | << "The global domain is badly defined," |
---|
| 286 | << " check the \'nj_glo\' value !") |
---|
| 287 | } |
---|
[687] | 288 | |
---|
[783] | 289 | if ((type_attr::rectilinear == type) || (type_attr::curvilinear == type)) |
---|
| 290 | { |
---|
[687] | 291 | int globalDomainSize = ni_glo * nj_glo; |
---|
| 292 | if (globalDomainSize <= nbLocalDomain) |
---|
| 293 | { |
---|
| 294 | for (int idx = 0; idx < nbLocalDomain; ++idx) |
---|
| 295 | { |
---|
| 296 | if (rankOnDomain < globalDomainSize) |
---|
| 297 | { |
---|
| 298 | int iIdx = rankOnDomain % ni_glo; |
---|
| 299 | int jIdx = rankOnDomain / ni_glo; |
---|
| 300 | ibegin.setValue(iIdx); jbegin.setValue(jIdx); |
---|
| 301 | ni.setValue(1); nj.setValue(1); |
---|
| 302 | } |
---|
| 303 | else |
---|
| 304 | { |
---|
| 305 | ibegin.setValue(0); jbegin.setValue(0); |
---|
| 306 | ni.setValue(0); nj.setValue(0); |
---|
| 307 | } |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | else |
---|
| 311 | { |
---|
[688] | 312 | float njGlo = nj_glo.getValue(); |
---|
| 313 | float niGlo = ni_glo.getValue(); |
---|
| 314 | int nbProcOnX, nbProcOnY, range; |
---|
| 315 | |
---|
[687] | 316 | // Compute (approximately) number of segment on x and y axis |
---|
[688] | 317 | float yOverXRatio = njGlo/niGlo; |
---|
| 318 | |
---|
[687] | 319 | nbProcOnX = std::ceil(std::sqrt(nbLocalDomain/yOverXRatio)); |
---|
| 320 | nbProcOnY = std::ceil(((float)nbLocalDomain)/nbProcOnX); |
---|
| 321 | |
---|
| 322 | // Simple distribution: Sweep from top to bottom, left to right |
---|
| 323 | // Calculate local begin on x |
---|
| 324 | std::vector<int> ibeginVec(nbProcOnX,0), jbeginVec(nbProcOnY,0); |
---|
| 325 | std::vector<int> niVec(nbProcOnX), njVec(nbProcOnY); |
---|
| 326 | for (int i = 1; i < nbProcOnX; ++i) |
---|
| 327 | { |
---|
| 328 | range = ni_glo / nbProcOnX; |
---|
| 329 | if (i < (ni_glo%nbProcOnX)) ++range; |
---|
| 330 | niVec[i-1] = range; |
---|
| 331 | ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; |
---|
| 332 | } |
---|
| 333 | niVec[nbProcOnX-1] = ni_glo - ibeginVec[nbProcOnX-1]; |
---|
| 334 | |
---|
| 335 | // Calculate local begin on y |
---|
| 336 | for (int j = 1; j < nbProcOnY; ++j) |
---|
| 337 | { |
---|
| 338 | range = nj_glo / nbProcOnY; |
---|
| 339 | if (j < (nj_glo%nbProcOnY)) ++range; |
---|
| 340 | njVec[j-1] = range; |
---|
| 341 | jbeginVec[j] = jbeginVec[j-1] + njVec[j-1]; |
---|
| 342 | } |
---|
| 343 | njVec[nbProcOnY-1] = nj_glo - jbeginVec[nbProcOnY-1]; |
---|
| 344 | |
---|
| 345 | // Now assign value to ni, ibegin, nj, jbegin |
---|
| 346 | int iIdx = rankOnDomain % nbProcOnX; |
---|
| 347 | int jIdx = rankOnDomain / nbProcOnX; |
---|
| 348 | |
---|
| 349 | if (rankOnDomain != (nbLocalDomain-1)) |
---|
| 350 | { |
---|
| 351 | ibegin.setValue(ibeginVec[iIdx]); |
---|
| 352 | jbegin.setValue(jbeginVec[jIdx]); |
---|
| 353 | nj.setValue(njVec[jIdx]); |
---|
| 354 | ni.setValue(niVec[iIdx]); |
---|
| 355 | } |
---|
| 356 | else // just merge all the remaining rectangle into the last one |
---|
| 357 | { |
---|
| 358 | ibegin.setValue(ibeginVec[iIdx]); |
---|
| 359 | jbegin.setValue(jbeginVec[jIdx]); |
---|
| 360 | nj.setValue(njVec[jIdx]); |
---|
| 361 | ni.setValue(ni_glo - ibeginVec[iIdx]); |
---|
| 362 | } |
---|
[1158] | 363 | } |
---|
[687] | 364 | } |
---|
[783] | 365 | else // unstructured domain |
---|
| 366 | { |
---|
[785] | 367 | if (this->i_index.isEmpty()) |
---|
| 368 | { |
---|
| 369 | int globalDomainSize = ni_glo * nj_glo; |
---|
| 370 | if (globalDomainSize <= nbLocalDomain) |
---|
[783] | 371 | { |
---|
[785] | 372 | for (int idx = 0; idx < nbLocalDomain; ++idx) |
---|
[783] | 373 | { |
---|
[785] | 374 | if (rankOnDomain < globalDomainSize) |
---|
| 375 | { |
---|
| 376 | int iIdx = rankOnDomain % ni_glo; |
---|
| 377 | int jIdx = rankOnDomain / ni_glo; |
---|
| 378 | ibegin.setValue(iIdx); jbegin.setValue(jIdx); |
---|
| 379 | ni.setValue(1); nj.setValue(1); |
---|
| 380 | } |
---|
| 381 | else |
---|
| 382 | { |
---|
| 383 | ibegin.setValue(0); jbegin.setValue(0); |
---|
| 384 | ni.setValue(0); nj.setValue(0); |
---|
| 385 | } |
---|
[783] | 386 | } |
---|
[785] | 387 | } |
---|
| 388 | else |
---|
| 389 | { |
---|
| 390 | float njGlo = nj_glo.getValue(); |
---|
| 391 | float niGlo = ni_glo.getValue(); |
---|
| 392 | std::vector<int> ibeginVec(nbLocalDomain,0); |
---|
| 393 | std::vector<int> niVec(nbLocalDomain); |
---|
| 394 | for (int i = 1; i < nbLocalDomain; ++i) |
---|
[783] | 395 | { |
---|
[785] | 396 | int range = ni_glo / nbLocalDomain; |
---|
| 397 | if (i < (ni_glo%nbLocalDomain)) ++range; |
---|
| 398 | niVec[i-1] = range; |
---|
| 399 | ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; |
---|
[783] | 400 | } |
---|
[785] | 401 | niVec[nbLocalDomain-1] = ni_glo - ibeginVec[nbLocalDomain-1]; |
---|
| 402 | |
---|
| 403 | int iIdx = rankOnDomain % nbLocalDomain; |
---|
| 404 | ibegin.setValue(ibeginVec[iIdx]); |
---|
| 405 | jbegin.setValue(0); |
---|
| 406 | ni.setValue(niVec[iIdx]); |
---|
| 407 | nj.setValue(1); |
---|
[783] | 408 | } |
---|
[1158] | 409 | |
---|
| 410 | i_index.resize(ni); |
---|
| 411 | for(int idx = 0; idx < ni; ++idx) i_index(idx)=ibegin+idx; |
---|
[783] | 412 | } |
---|
| 413 | else |
---|
| 414 | { |
---|
[785] | 415 | ibegin.setValue(this->i_index(0)); |
---|
[783] | 416 | jbegin.setValue(0); |
---|
[785] | 417 | ni.setValue(this->i_index.numElements()); |
---|
[783] | 418 | nj.setValue(1); |
---|
| 419 | } |
---|
| 420 | } |
---|
[785] | 421 | |
---|
| 422 | checkDomain(); |
---|
[687] | 423 | } |
---|
| 424 | |
---|
| 425 | /*! |
---|
[1158] | 426 | Fill in longitude and latitude whose values are read from file |
---|
| 427 | */ |
---|
| 428 | void CDomain::fillInLonLat() |
---|
| 429 | { |
---|
| 430 | switch (type) |
---|
| 431 | { |
---|
| 432 | case type_attr::rectilinear: |
---|
| 433 | fillInRectilinearLonLat(); |
---|
| 434 | break; |
---|
| 435 | case type_attr::curvilinear: |
---|
| 436 | fillInCurvilinearLonLat(); |
---|
| 437 | break; |
---|
| 438 | case type_attr::unstructured: |
---|
| 439 | fillInUnstructuredLonLat(); |
---|
| 440 | break; |
---|
| 441 | |
---|
| 442 | default: |
---|
| 443 | break; |
---|
| 444 | } |
---|
[1305] | 445 | completeLonLatClient() ; |
---|
[1158] | 446 | |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | /*! |
---|
[687] | 450 | Fill in the values for lonvalue_1d and latvalue_1d of rectilinear domain |
---|
| 451 | Range of longitude value from 0 - 360 |
---|
| 452 | Range of latitude value from -90 - +90 |
---|
| 453 | */ |
---|
| 454 | void CDomain::fillInRectilinearLonLat() |
---|
| 455 | { |
---|
[1565] | 456 | if (!lonvalue_rectilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) |
---|
[775] | 457 | { |
---|
| 458 | lonvalue_1d.resize(ni); |
---|
| 459 | for (int idx = 0; idx < ni; ++idx) |
---|
| 460 | lonvalue_1d(idx) = lonvalue_rectilinear_read_from_file(idx+ibegin); |
---|
| 461 | lon_start.setValue(lonvalue_rectilinear_read_from_file(0)); |
---|
| 462 | lon_end.setValue(lonvalue_rectilinear_read_from_file(ni_glo-1)); |
---|
| 463 | } |
---|
[1855] | 464 | else if (!hasLonInReadFile_) |
---|
[775] | 465 | { |
---|
| 466 | if (!lonvalue_2d.isEmpty()) lonvalue_2d.free(); |
---|
| 467 | lonvalue_1d.resize(ni); |
---|
| 468 | double lonRange = lon_end - lon_start; |
---|
| 469 | double lonStep = (1 == ni_glo.getValue()) ? lonRange : lonRange/double(ni_glo.getValue()-1); |
---|
[688] | 470 | |
---|
[775] | 471 | // Assign lon value |
---|
| 472 | for (int i = 0; i < ni; ++i) |
---|
| 473 | { |
---|
| 474 | if (0 == (ibegin + i)) |
---|
| 475 | { |
---|
| 476 | lonvalue_1d(i) = lon_start; |
---|
| 477 | } |
---|
| 478 | else if (ni_glo == (ibegin + i + 1)) |
---|
| 479 | { |
---|
| 480 | lonvalue_1d(i) = lon_end; |
---|
| 481 | } |
---|
| 482 | else |
---|
| 483 | { |
---|
| 484 | lonvalue_1d(i) = (ibegin + i) * lonStep + lon_start; |
---|
| 485 | } |
---|
| 486 | } |
---|
| 487 | } |
---|
[687] | 488 | |
---|
[727] | 489 | |
---|
[1565] | 490 | if (!latvalue_rectilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty() && latvalue_1d.isEmpty()) |
---|
[687] | 491 | { |
---|
[775] | 492 | latvalue_1d.resize(nj); |
---|
| 493 | for (int idx = 0; idx < nj; ++idx) |
---|
| 494 | latvalue_1d(idx) = latvalue_rectilinear_read_from_file(idx+jbegin); |
---|
| 495 | lat_start.setValue(latvalue_rectilinear_read_from_file(0)); |
---|
| 496 | lat_end.setValue(latvalue_rectilinear_read_from_file(nj_glo-1)); |
---|
[687] | 497 | } |
---|
[1855] | 498 | else if (!hasLatInReadFile_) |
---|
[775] | 499 | { |
---|
| 500 | if (!latvalue_2d.isEmpty()) latvalue_1d.free(); |
---|
| 501 | latvalue_1d.resize(nj); |
---|
[687] | 502 | |
---|
[775] | 503 | double latRange = lat_end - lat_start; |
---|
| 504 | double latStep = (1 == nj_glo.getValue()) ? latRange : latRange/double(nj_glo.getValue()-1); |
---|
| 505 | |
---|
| 506 | for (int j = 0; j < nj; ++j) |
---|
[727] | 507 | { |
---|
[775] | 508 | if (0 == (jbegin + j)) |
---|
| 509 | { |
---|
| 510 | latvalue_1d(j) = lat_start; |
---|
| 511 | } |
---|
| 512 | else if (nj_glo == (jbegin + j + 1)) |
---|
| 513 | { |
---|
| 514 | latvalue_1d(j) = lat_end; |
---|
| 515 | } |
---|
| 516 | else |
---|
| 517 | { |
---|
| 518 | latvalue_1d(j) = (jbegin + j) * latStep + lat_start; |
---|
| 519 | } |
---|
[727] | 520 | } |
---|
[687] | 521 | } |
---|
| 522 | } |
---|
| 523 | |
---|
[1158] | 524 | /* |
---|
| 525 | Fill in longitude and latitude of curvilinear domain read from a file |
---|
| 526 | If there are already longitude and latitude defined by model. We just igonore reading value. |
---|
| 527 | */ |
---|
| 528 | void CDomain::fillInCurvilinearLonLat() |
---|
| 529 | { |
---|
[1565] | 530 | if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) |
---|
[1158] | 531 | { |
---|
| 532 | lonvalue_2d.resize(ni,nj); |
---|
| 533 | for (int jdx = 0; jdx < nj; ++jdx) |
---|
| 534 | for (int idx = 0; idx < ni; ++idx) |
---|
[1419] | 535 | lonvalue_2d(idx,jdx) = lonvalue_curvilinear_read_from_file(idx, jdx); |
---|
[809] | 536 | |
---|
[1158] | 537 | lonvalue_curvilinear_read_from_file.free(); |
---|
| 538 | } |
---|
[809] | 539 | |
---|
[1565] | 540 | if (!latvalue_curvilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty() && latvalue_1d.isEmpty()) |
---|
[1158] | 541 | { |
---|
| 542 | latvalue_2d.resize(ni,nj); |
---|
| 543 | for (int jdx = 0; jdx < nj; ++jdx) |
---|
| 544 | for (int idx = 0; idx < ni; ++idx) |
---|
[1419] | 545 | latvalue_2d(idx,jdx) = latvalue_curvilinear_read_from_file(idx, jdx); |
---|
[1158] | 546 | |
---|
| 547 | latvalue_curvilinear_read_from_file.free(); |
---|
| 548 | } |
---|
| 549 | |
---|
[1565] | 550 | if (!bounds_lonvalue_curvilinear_read_from_file.isEmpty() && bounds_lon_2d.isEmpty() && bounds_lon_1d.isEmpty()) |
---|
[1158] | 551 | { |
---|
| 552 | bounds_lon_2d.resize(nvertex,ni,nj); |
---|
| 553 | for (int jdx = 0; jdx < nj; ++jdx) |
---|
| 554 | for (int idx = 0; idx < ni; ++idx) |
---|
| 555 | for (int ndx = 0; ndx < nvertex; ++ndx) |
---|
[1419] | 556 | bounds_lon_2d(ndx,idx,jdx) = bounds_lonvalue_curvilinear_read_from_file(ndx,idx, jdx); |
---|
[1158] | 557 | |
---|
| 558 | bounds_lonvalue_curvilinear_read_from_file.free(); |
---|
| 559 | } |
---|
| 560 | |
---|
[1565] | 561 | if (!bounds_latvalue_curvilinear_read_from_file.isEmpty() && bounds_lat_2d.isEmpty() && bounds_lat_1d.isEmpty()) |
---|
[1158] | 562 | { |
---|
| 563 | bounds_lat_2d.resize(nvertex,ni,nj); |
---|
| 564 | for (int jdx = 0; jdx < nj; ++jdx) |
---|
| 565 | for (int idx = 0; idx < ni; ++idx) |
---|
| 566 | for (int ndx = 0; ndx < nvertex; ++ndx) |
---|
[1419] | 567 | bounds_lat_2d(ndx,idx,jdx) = bounds_latvalue_curvilinear_read_from_file(ndx,idx, jdx); |
---|
[1158] | 568 | |
---|
| 569 | bounds_latvalue_curvilinear_read_from_file.free(); |
---|
| 570 | } |
---|
| 571 | |
---|
| 572 | } |
---|
| 573 | |
---|
| 574 | /* |
---|
| 575 | Fill in longitude and latitude of unstructured domain read from a file |
---|
| 576 | If there are already longitude and latitude defined by model. We just igonore reading value. |
---|
| 577 | */ |
---|
| 578 | void CDomain::fillInUnstructuredLonLat() |
---|
| 579 | { |
---|
| 580 | if (i_index.isEmpty()) |
---|
| 581 | { |
---|
| 582 | i_index.resize(ni); |
---|
[1413] | 583 | for(int idx = 0; idx < ni; ++idx) i_index(idx)=ibegin+idx; |
---|
[1158] | 584 | } |
---|
| 585 | |
---|
| 586 | if (!lonvalue_unstructured_read_from_file.isEmpty() && lonvalue_1d.isEmpty()) |
---|
| 587 | { |
---|
| 588 | lonvalue_1d.resize(ni); |
---|
| 589 | for (int idx = 0; idx < ni; ++idx) |
---|
[1419] | 590 | lonvalue_1d(idx) = lonvalue_unstructured_read_from_file(idx); |
---|
[1158] | 591 | |
---|
| 592 | // We dont need these values anymore, so just delete them |
---|
| 593 | lonvalue_unstructured_read_from_file.free(); |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | if (!latvalue_unstructured_read_from_file.isEmpty() && latvalue_1d.isEmpty()) |
---|
| 597 | { |
---|
| 598 | latvalue_1d.resize(ni); |
---|
| 599 | for (int idx = 0; idx < ni; ++idx) |
---|
[1419] | 600 | latvalue_1d(idx) = latvalue_unstructured_read_from_file(idx); |
---|
[1158] | 601 | |
---|
| 602 | // We dont need these values anymore, so just delete them |
---|
| 603 | latvalue_unstructured_read_from_file.free(); |
---|
| 604 | } |
---|
| 605 | |
---|
| 606 | if (!bounds_lonvalue_unstructured_read_from_file.isEmpty() && bounds_lon_1d.isEmpty()) |
---|
| 607 | { |
---|
| 608 | int nbVertex = nvertex; |
---|
| 609 | bounds_lon_1d.resize(nbVertex,ni); |
---|
| 610 | for (int idx = 0; idx < ni; ++idx) |
---|
| 611 | for (int jdx = 0; jdx < nbVertex; ++jdx) |
---|
[1419] | 612 | bounds_lon_1d(jdx,idx) = bounds_lonvalue_unstructured_read_from_file(jdx, idx); |
---|
[1158] | 613 | |
---|
| 614 | // We dont need these values anymore, so just delete them |
---|
[1427] | 615 | bounds_lonvalue_unstructured_read_from_file.free(); |
---|
[1158] | 616 | } |
---|
| 617 | |
---|
| 618 | if (!bounds_latvalue_unstructured_read_from_file.isEmpty() && bounds_lat_1d.isEmpty()) |
---|
| 619 | { |
---|
| 620 | int nbVertex = nvertex; |
---|
| 621 | bounds_lat_1d.resize(nbVertex,ni); |
---|
| 622 | for (int idx = 0; idx < ni; ++idx) |
---|
| 623 | for (int jdx = 0; jdx < nbVertex; ++jdx) |
---|
[1419] | 624 | bounds_lat_1d(jdx,idx) = bounds_latvalue_unstructured_read_from_file(jdx, idx); |
---|
[1158] | 625 | |
---|
| 626 | // We dont need these values anymore, so just delete them |
---|
[1427] | 627 | bounds_latvalue_unstructured_read_from_file.free(); |
---|
[1158] | 628 | } |
---|
| 629 | } |
---|
| 630 | |
---|
| 631 | /* |
---|
| 632 | Get global longitude and latitude of rectilinear domain. |
---|
| 633 | */ |
---|
[809] | 634 | void CDomain::AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, CArray<double,1>& lon_g, CArray<double,1>& lat_g) |
---|
[688] | 635 | { |
---|
[1337] | 636 | CContext* context = CContext::getCurrent(); |
---|
[1054] | 637 | // For now the assumption is that secondary server pools consist of the same number of procs. |
---|
| 638 | // CHANGE the line below if the assumption changes. |
---|
| 639 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; |
---|
[1337] | 640 | lon_g.resize(ni_glo) ; |
---|
| 641 | lat_g.resize(nj_glo) ; |
---|
[815] | 642 | |
---|
| 643 | |
---|
[1337] | 644 | int* ibegin_g = new int[client->clientSize] ; |
---|
| 645 | int* jbegin_g = new int[client->clientSize] ; |
---|
| 646 | int* ni_g = new int[client->clientSize] ; |
---|
| 647 | int* nj_g = new int[client->clientSize] ; |
---|
| 648 | int v ; |
---|
| 649 | v=ibegin ; |
---|
| 650 | MPI_Allgather(&v,1,MPI_INT,ibegin_g,1,MPI_INT,client->intraComm) ; |
---|
| 651 | v=jbegin ; |
---|
| 652 | MPI_Allgather(&v,1,MPI_INT,jbegin_g,1,MPI_INT,client->intraComm) ; |
---|
| 653 | v=ni ; |
---|
| 654 | MPI_Allgather(&v,1,MPI_INT,ni_g,1,MPI_INT,client->intraComm) ; |
---|
| 655 | v=nj ; |
---|
| 656 | MPI_Allgather(&v,1,MPI_INT,nj_g,1,MPI_INT,client->intraComm) ; |
---|
[815] | 657 | |
---|
[1337] | 658 | MPI_Allgatherv(lon.dataFirst(),ni,MPI_DOUBLE,lon_g.dataFirst(),ni_g, ibegin_g,MPI_DOUBLE,client->intraComm) ; |
---|
| 659 | MPI_Allgatherv(lat.dataFirst(),nj,MPI_DOUBLE,lat_g.dataFirst(),nj_g, jbegin_g,MPI_DOUBLE,client->intraComm) ; |
---|
[815] | 660 | |
---|
[809] | 661 | delete[] ibegin_g ; |
---|
| 662 | delete[] jbegin_g ; |
---|
| 663 | delete[] ni_g ; |
---|
| 664 | delete[] nj_g ; |
---|
| 665 | } |
---|
| 666 | |
---|
| 667 | void CDomain::fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, |
---|
| 668 | CArray<double,2>& boundsLon, CArray<double,2>& boundsLat) |
---|
| 669 | { |
---|
[688] | 670 | int i,j,k; |
---|
[815] | 671 | |
---|
[688] | 672 | const int nvertexValue = 4; |
---|
[775] | 673 | boundsLon.resize(nvertexValue,ni*nj); |
---|
[688] | 674 | |
---|
[899] | 675 | if (ni_glo>1) |
---|
| 676 | { |
---|
| 677 | double lonStepStart = lon(1)-lon(0); |
---|
| 678 | bounds_lon_start=lon(0) - lonStepStart/2; |
---|
| 679 | double lonStepEnd = lon(ni_glo-1)-lon(ni_glo-2); |
---|
| 680 | bounds_lon_end=lon(ni_glo-1) + lonStepEnd/2; |
---|
| 681 | double errorBoundsLon = std::abs(360-std::abs(bounds_lon_end-bounds_lon_start)); |
---|
[810] | 682 | |
---|
[899] | 683 | // if errorBoundsLon is reasonably small (0.1 x cell size) consider it as closed in longitude |
---|
| 684 | if (errorBoundsLon < std::abs(lonStepStart)*1e-1 || errorBoundsLon < std::abs(lonStepEnd)*1e-1 ) |
---|
| 685 | { |
---|
| 686 | bounds_lon_start= (lon(0) + lon(ni_glo-1)-360)/2 ; |
---|
| 687 | bounds_lon_end= (lon(0) +360 + lon(ni_glo-1))/2 ; |
---|
| 688 | } |
---|
| 689 | } |
---|
| 690 | else |
---|
[810] | 691 | { |
---|
[899] | 692 | if (bounds_lon_start.isEmpty()) bounds_lon_start=-180. ; |
---|
| 693 | if (bounds_lon_end.isEmpty()) bounds_lon_end=180.-1e-8 ; |
---|
[810] | 694 | } |
---|
[906] | 695 | |
---|
[809] | 696 | for(j=0;j<nj;++j) |
---|
| 697 | for(i=0;i<ni;++i) |
---|
| 698 | { |
---|
| 699 | k=j*ni+i; |
---|
| 700 | boundsLon(0,k) = boundsLon(1,k) = (0 == (ibegin + i)) ? bounds_lon_start |
---|
| 701 | : (lon(ibegin + i)+lon(ibegin + i-1))/2; |
---|
| 702 | boundsLon(2,k) = boundsLon(3,k) = ((ibegin + i + 1) == ni_glo) ? bounds_lon_end |
---|
| 703 | : (lon(ibegin + i + 1)+lon(ibegin + i))/2; |
---|
| 704 | } |
---|
[727] | 705 | |
---|
[815] | 706 | |
---|
[809] | 707 | boundsLat.resize(nvertexValue,nj*ni); |
---|
[810] | 708 | bool isNorthPole=false ; |
---|
| 709 | bool isSouthPole=false ; |
---|
[809] | 710 | if (std::abs(90 - std::abs(lat(0))) < NumTraits<double>::epsilon()) isNorthPole = true; |
---|
| 711 | if (std::abs(90 - std::abs(lat(nj_glo-1))) < NumTraits<double>::epsilon()) isSouthPole = true; |
---|
[808] | 712 | |
---|
[810] | 713 | // lat boundaries beyond pole the assimilate it to pole |
---|
| 714 | // lat boundarie is relativelly close to pole (0.1 x cell size) assimilate it to pole |
---|
[899] | 715 | if (nj_glo>1) |
---|
[810] | 716 | { |
---|
[899] | 717 | double latStepStart = lat(1)-lat(0); |
---|
| 718 | if (isNorthPole) bounds_lat_start=lat(0); |
---|
| 719 | else |
---|
[810] | 720 | { |
---|
[899] | 721 | bounds_lat_start=lat(0)-latStepStart/2; |
---|
| 722 | if (bounds_lat_start >= 90 ) bounds_lat_start=90 ; |
---|
| 723 | else if (bounds_lat_start <= -90 ) bounds_lat_start=-90 ; |
---|
| 724 | else if (bounds_lat_start <= 90 && bounds_lat_start >= lat(0)) |
---|
| 725 | { |
---|
| 726 | if ( std::abs(90-bounds_lat_start) <= 0.1*std::abs(latStepStart)) bounds_lat_start=90 ; |
---|
| 727 | } |
---|
| 728 | else if (bounds_lat_start >= -90 && bounds_lat_start <= lat(0)) |
---|
| 729 | { |
---|
| 730 | if ( std::abs(-90 - bounds_lat_start) <= 0.1*std::abs(latStepStart)) bounds_lat_start=-90 ; |
---|
| 731 | } |
---|
[810] | 732 | } |
---|
[899] | 733 | |
---|
| 734 | double latStepEnd = lat(nj_glo-1)-lat(nj_glo-2); |
---|
| 735 | if (isSouthPole) bounds_lat_end=lat(nj_glo-1); |
---|
| 736 | else |
---|
[810] | 737 | { |
---|
[899] | 738 | bounds_lat_end=lat(nj_glo-1)+latStepEnd/2; |
---|
| 739 | |
---|
| 740 | if (bounds_lat_end >= 90 ) bounds_lat_end=90 ; |
---|
| 741 | else if (bounds_lat_end <= -90 ) bounds_lat_end=-90 ; |
---|
| 742 | else if (bounds_lat_end <= 90 && bounds_lat_end >= lat(nj_glo-1)) |
---|
| 743 | { |
---|
| 744 | if ( std::abs(90-bounds_lat_end) <= 0.1*std::abs(latStepEnd)) bounds_lat_end=90 ; |
---|
| 745 | } |
---|
| 746 | else if (bounds_lat_end >= -90 && bounds_lat_end <= lat(nj_glo-1)) |
---|
| 747 | { |
---|
| 748 | if ( std::abs(-90 - bounds_lat_end) <= 0.1*std::abs(latStepEnd)) bounds_lat_end=-90 ; |
---|
| 749 | } |
---|
[810] | 750 | } |
---|
| 751 | } |
---|
| 752 | else |
---|
| 753 | { |
---|
[1158] | 754 | if (bounds_lat_start.isEmpty()) bounds_lat_start=-90. ; |
---|
[899] | 755 | if (bounds_lat_end.isEmpty()) bounds_lat_end=90 ; |
---|
[815] | 756 | } |
---|
| 757 | |
---|
[809] | 758 | for(j=0;j<nj;++j) |
---|
| 759 | for(i=0;i<ni;++i) |
---|
| 760 | { |
---|
| 761 | k=j*ni+i; |
---|
| 762 | boundsLat(1,k) = boundsLat(2,k) = (0 == (jbegin + j)) ? bounds_lat_start |
---|
| 763 | : (lat(jbegin + j)+lat(jbegin + j-1))/2; |
---|
| 764 | boundsLat(0,k) = boundsLat(3,k) = ((jbegin + j +1) == nj_glo) ? bounds_lat_end |
---|
| 765 | : (lat(jbegin + j + 1)+lat(jbegin + j))/2; |
---|
| 766 | } |
---|
[688] | 767 | } |
---|
| 768 | |
---|
[1236] | 769 | /* |
---|
| 770 | General check of the domain to verify its mandatory attributes |
---|
| 771 | */ |
---|
[467] | 772 | void CDomain::checkDomain(void) |
---|
[219] | 773 | { |
---|
[664] | 774 | if (type.isEmpty()) |
---|
| 775 | { |
---|
| 776 | ERROR("CDomain::checkDomain(void)", |
---|
[679] | 777 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 778 | << "The domain type is mandatory, " |
---|
| 779 | << "please define the 'type' attribute.") |
---|
[664] | 780 | } |
---|
[969] | 781 | |
---|
[953] | 782 | if (type == type_attr::gaussian) |
---|
| 783 | { |
---|
[1337] | 784 | hasPole=true ; |
---|
| 785 | type.setValue(type_attr::unstructured) ; |
---|
| 786 | } |
---|
| 787 | else if (type == type_attr::rectilinear) hasPole=true ; |
---|
| 788 | |
---|
[679] | 789 | if (type == type_attr::unstructured) |
---|
[664] | 790 | { |
---|
[679] | 791 | if (ni_glo.isEmpty()) |
---|
[664] | 792 | { |
---|
[679] | 793 | ERROR("CDomain::checkDomain(void)", |
---|
| 794 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 795 | << "The global domain is badly defined, " |
---|
| 796 | << "the mandatory 'ni_glo' attribute is missing.") |
---|
[664] | 797 | } |
---|
[679] | 798 | else if (ni_glo <= 0) |
---|
| 799 | { |
---|
| 800 | ERROR("CDomain::checkDomain(void)", |
---|
| 801 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 802 | << "The global domain is badly defined, " |
---|
| 803 | << "'ni_glo' attribute should be strictly positive so 'ni_glo = " << ni_glo.getValue() << "' is invalid.") |
---|
| 804 | } |
---|
[664] | 805 | isUnstructed_ = true; |
---|
| 806 | nj_glo = 1; |
---|
| 807 | nj = 1; |
---|
| 808 | jbegin = 0; |
---|
[942] | 809 | if (!i_index.isEmpty()) ni = i_index.numElements(); |
---|
[664] | 810 | j_index.resize(ni); |
---|
| 811 | for(int i=0;i<ni;++i) j_index(i)=0; |
---|
[611] | 812 | |
---|
[664] | 813 | if (!area.isEmpty()) |
---|
| 814 | area.transposeSelf(1, 0); |
---|
| 815 | } |
---|
[679] | 816 | |
---|
| 817 | if (ni_glo.isEmpty()) |
---|
[664] | 818 | { |
---|
[679] | 819 | ERROR("CDomain::checkDomain(void)", |
---|
| 820 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 821 | << "The global domain is badly defined, " |
---|
| 822 | << "the mandatory 'ni_glo' attribute is missing.") |
---|
[664] | 823 | } |
---|
[679] | 824 | else if (ni_glo <= 0) |
---|
| 825 | { |
---|
| 826 | ERROR("CDomain::checkDomain(void)", |
---|
| 827 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 828 | << "The global domain is badly defined, " |
---|
| 829 | << "'ni_glo' attribute should be strictly positive so 'ni_glo = " << ni_glo.getValue() << "' is invalid.") |
---|
| 830 | } |
---|
[509] | 831 | |
---|
[679] | 832 | if (nj_glo.isEmpty()) |
---|
| 833 | { |
---|
| 834 | ERROR("CDomain::checkDomain(void)", |
---|
| 835 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 836 | << "The global domain is badly defined, " |
---|
| 837 | << "the mandatory 'nj_glo' attribute is missing.") |
---|
| 838 | } |
---|
| 839 | else if (nj_glo <= 0) |
---|
| 840 | { |
---|
| 841 | ERROR("CDomain::checkDomain(void)", |
---|
| 842 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 843 | << "The global domain is badly defined, " |
---|
| 844 | << "'nj_glo' attribute should be strictly positive so 'nj_glo = " << nj_glo.getValue() << "' is invalid.") |
---|
| 845 | } |
---|
| 846 | |
---|
[664] | 847 | checkLocalIDomain(); |
---|
| 848 | checkLocalJDomain(); |
---|
[509] | 849 | |
---|
[664] | 850 | if (i_index.isEmpty()) |
---|
| 851 | { |
---|
| 852 | i_index.resize(ni*nj); |
---|
| 853 | for (int j = 0; j < nj; ++j) |
---|
| 854 | for (int i = 0; i < ni; ++i) i_index(i+j*ni) = i+ibegin; |
---|
| 855 | } |
---|
[594] | 856 | |
---|
[664] | 857 | if (j_index.isEmpty()) |
---|
| 858 | { |
---|
| 859 | j_index.resize(ni*nj); |
---|
| 860 | for (int j = 0; j < nj; ++j) |
---|
| 861 | for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; |
---|
[1158] | 862 | } |
---|
| 863 | |
---|
[821] | 864 | checkZoom(); |
---|
| 865 | } |
---|
[663] | 866 | |
---|
[969] | 867 | // Check global zoom of a domain |
---|
| 868 | // If there is no zoom defined for the domain, zoom will have value of global doamin |
---|
[821] | 869 | void CDomain::checkZoom(void) |
---|
| 870 | { |
---|
| 871 | if (global_zoom_ibegin.isEmpty()) |
---|
| 872 | global_zoom_ibegin.setValue(0); |
---|
| 873 | if (global_zoom_ni.isEmpty()) |
---|
| 874 | global_zoom_ni.setValue(ni_glo); |
---|
| 875 | if (global_zoom_jbegin.isEmpty()) |
---|
| 876 | global_zoom_jbegin.setValue(0); |
---|
| 877 | if (global_zoom_nj.isEmpty()) |
---|
| 878 | global_zoom_nj.setValue(nj_glo); |
---|
[1025] | 879 | if (zoom_i_index.isEmpty()) zoom_i_index.setValue(i_index.getValue()); |
---|
| 880 | if (zoom_j_index.isEmpty()) zoom_j_index.setValue(j_index.getValue()); |
---|
[1099] | 881 | if (zoom_ibegin.isEmpty()) zoom_ibegin.setValue(ibegin); |
---|
| 882 | if (zoom_ni.isEmpty()) zoom_ni.setValue(ni); |
---|
| 883 | if (zoom_jbegin.isEmpty()) zoom_jbegin.setValue(jbegin); |
---|
| 884 | if (zoom_nj.isEmpty()) zoom_nj.setValue(nj); |
---|
[219] | 885 | } |
---|
| 886 | |
---|
[1215] | 887 | size_t CDomain::getGlobalWrittenSize(void) |
---|
| 888 | { |
---|
| 889 | return global_zoom_ni*global_zoom_nj ; |
---|
| 890 | } |
---|
[219] | 891 | //---------------------------------------------------------------- |
---|
| 892 | |
---|
[969] | 893 | // Check validity of local domain on using the combination of 3 parameters: ibegin, ni and i_index |
---|
[219] | 894 | void CDomain::checkLocalIDomain(void) |
---|
| 895 | { |
---|
[969] | 896 | // If ibegin and ni are provided then we use them to check the validity of local domain |
---|
| 897 | if (i_index.isEmpty() && !ibegin.isEmpty() && !ni.isEmpty()) |
---|
[219] | 898 | { |
---|
[969] | 899 | if ((ni.getValue() < 0 || ibegin.getValue() < 0) || ((ibegin.getValue() + ni.getValue()) > ni_glo.getValue())) |
---|
| 900 | { |
---|
| 901 | ERROR("CDomain::checkLocalIDomain(void)", |
---|
| 902 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 903 | << "The local domain is wrongly defined," |
---|
| 904 | << " check the attributes 'ni_glo' (" << ni_glo.getValue() << "), 'ni' (" << ni.getValue() << ") and 'ibegin' (" << ibegin.getValue() << ")"); |
---|
| 905 | } |
---|
| 906 | } |
---|
| 907 | |
---|
| 908 | // i_index has higher priority than ibegin and ni |
---|
| 909 | if (!i_index.isEmpty()) |
---|
| 910 | { |
---|
[975] | 911 | int minIIndex = (0 < i_index.numElements()) ? i_index(0) : 0; |
---|
[969] | 912 | if (ni.isEmpty()) |
---|
| 913 | { |
---|
| 914 | // No information about ni |
---|
| 915 | int minIndex = ni_glo - 1; |
---|
| 916 | int maxIndex = 0; |
---|
| 917 | for (int idx = 0; idx < i_index.numElements(); ++idx) |
---|
| 918 | { |
---|
| 919 | if (i_index(idx) < minIndex) minIndex = i_index(idx); |
---|
| 920 | if (i_index(idx) > maxIndex) maxIndex = i_index(idx); |
---|
| 921 | } |
---|
| 922 | ni = maxIndex - minIndex + 1; |
---|
| 923 | minIIndex = minIIndex; |
---|
| 924 | } |
---|
| 925 | |
---|
| 926 | // It's not so correct but if ibegin is not the first value of i_index |
---|
| 927 | // then data on local domain has user-defined distribution. In this case, ibegin, ni have no meaning. |
---|
| 928 | if (ibegin.isEmpty()) ibegin = minIIndex; |
---|
| 929 | } |
---|
| 930 | else if (ibegin.isEmpty() && ni.isEmpty()) |
---|
| 931 | { |
---|
[594] | 932 | ibegin = 0; |
---|
| 933 | ni = ni_glo; |
---|
| 934 | } |
---|
[971] | 935 | else if ((!ibegin.isEmpty() && ni.isEmpty()) || (ibegin.isEmpty() && !ni.isEmpty())) |
---|
[219] | 936 | { |
---|
[969] | 937 | ERROR("CDomain::checkLocalIDomain(void)", |
---|
| 938 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
[971] | 939 | << "The local domain is wrongly defined," << endl |
---|
| 940 | << "i_index is empty and either 'ni' or 'ibegin' is not defined. " |
---|
| 941 | << "If 'ni' and 'ibegin' are used to define a domain, both of them must not be empty."); |
---|
[219] | 942 | } |
---|
[969] | 943 | |
---|
[219] | 944 | |
---|
[969] | 945 | if ((ni.getValue() < 0 || ibegin.getValue() < 0)) |
---|
[594] | 946 | { |
---|
| 947 | ERROR("CDomain::checkLocalIDomain(void)", |
---|
[679] | 948 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
[594] | 949 | << "The local domain is wrongly defined," |
---|
[679] | 950 | << " check the attributes 'ni_glo' (" << ni_glo.getValue() << "), 'ni' (" << ni.getValue() << ") and 'ibegin' (" << ibegin.getValue() << ")"); |
---|
[594] | 951 | } |
---|
[219] | 952 | } |
---|
| 953 | |
---|
[969] | 954 | // Check validity of local domain on using the combination of 3 parameters: jbegin, nj and j_index |
---|
[219] | 955 | void CDomain::checkLocalJDomain(void) |
---|
| 956 | { |
---|
[969] | 957 | // If jbegin and nj are provided then we use them to check the validity of local domain |
---|
| 958 | if (j_index.isEmpty() && !jbegin.isEmpty() && !nj.isEmpty()) |
---|
[657] | 959 | { |
---|
[969] | 960 | if ((nj.getValue() < 0 || jbegin.getValue() < 0) || (jbegin.getValue() + nj.getValue()) > nj_glo.getValue()) |
---|
| 961 | { |
---|
| 962 | ERROR("CDomain::checkLocalJDomain(void)", |
---|
| 963 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 964 | << "The local domain is wrongly defined," |
---|
| 965 | << " check the attributes 'nj_glo' (" << nj_glo.getValue() << "), 'nj' (" << nj.getValue() << ") and 'jbegin' (" << jbegin.getValue() << ")"); |
---|
| 966 | } |
---|
[657] | 967 | } |
---|
[969] | 968 | |
---|
| 969 | if (!j_index.isEmpty()) |
---|
[657] | 970 | { |
---|
[975] | 971 | int minJIndex = (0 < j_index.numElements()) ? j_index(0) : 0; |
---|
[969] | 972 | if (nj.isEmpty()) |
---|
| 973 | { |
---|
| 974 | // No information about nj |
---|
| 975 | int minIndex = nj_glo - 1; |
---|
| 976 | int maxIndex = 0; |
---|
| 977 | for (int idx = 0; idx < j_index.numElements(); ++idx) |
---|
| 978 | { |
---|
| 979 | if (j_index(idx) < minIndex) minIndex = j_index(idx); |
---|
| 980 | if (j_index(idx) > maxIndex) maxIndex = j_index(idx); |
---|
| 981 | } |
---|
| 982 | nj = maxIndex - minIndex + 1; |
---|
| 983 | minJIndex = minIndex; |
---|
| 984 | } |
---|
| 985 | // It's the same as checkLocalIDomain. It's not so correct but if jbegin is not the first value of j_index |
---|
| 986 | // then data on local domain has user-defined distribution. In this case, jbegin has no meaning. |
---|
| 987 | if (jbegin.isEmpty()) jbegin = minJIndex; |
---|
[657] | 988 | } |
---|
[969] | 989 | else if (jbegin.isEmpty() && nj.isEmpty()) |
---|
| 990 | { |
---|
| 991 | jbegin = 0; |
---|
| 992 | nj = nj_glo; |
---|
| 993 | } |
---|
[219] | 994 | |
---|
[969] | 995 | |
---|
| 996 | if ((nj.getValue() < 0 || jbegin.getValue() < 0)) |
---|
| 997 | { |
---|
| 998 | ERROR("CDomain::checkLocalJDomain(void)", |
---|
[679] | 999 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
[594] | 1000 | << "The local domain is wrongly defined," |
---|
[679] | 1001 | << " check the attributes 'nj_glo' (" << nj_glo.getValue() << "), 'nj' (" << nj.getValue() << ") and 'jbegin' (" << jbegin.getValue() << ")"); |
---|
[969] | 1002 | } |
---|
[219] | 1003 | } |
---|
| 1004 | |
---|
| 1005 | //---------------------------------------------------------------- |
---|
[679] | 1006 | |
---|
[219] | 1007 | void CDomain::checkMask(void) |
---|
| 1008 | { |
---|
[664] | 1009 | if (!mask_1d.isEmpty() && !mask_2d.isEmpty()) |
---|
[657] | 1010 | ERROR("CDomain::checkMask(void)", |
---|
[679] | 1011 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1012 | << "Both mask_1d and mask_2d are defined but only one can be used at the same time." << std::endl |
---|
| 1013 | << "Please define only one mask: 'mask_1d' or 'mask_2d'."); |
---|
[657] | 1014 | |
---|
[664] | 1015 | if (!mask_1d.isEmpty() && mask_2d.isEmpty()) |
---|
[219] | 1016 | { |
---|
[664] | 1017 | if (mask_1d.numElements() != i_index.numElements()) |
---|
[657] | 1018 | ERROR("CDomain::checkMask(void)", |
---|
[679] | 1019 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1020 | << "'mask_1d' does not have the same size as the local domain." << std::endl |
---|
| 1021 | << "Local size is " << i_index.numElements() << "." << std::endl |
---|
| 1022 | << "Mask size is " << mask_1d.numElements() << "."); |
---|
[657] | 1023 | } |
---|
[509] | 1024 | |
---|
[664] | 1025 | if (mask_1d.isEmpty() && !mask_2d.isEmpty()) |
---|
[657] | 1026 | { |
---|
[679] | 1027 | if (mask_2d.extent(0) != ni || mask_2d.extent(1) != nj) |
---|
| 1028 | ERROR("CDomain::checkMask(void)", |
---|
| 1029 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1030 | << "The mask does not have the same size as the local domain." << std::endl |
---|
| 1031 | << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl |
---|
| 1032 | << "Mask size is " << mask_2d.extent(0) << " x " << mask_2d.extent(1) << "."); |
---|
[657] | 1033 | } |
---|
[509] | 1034 | |
---|
[664] | 1035 | if (!mask_2d.isEmpty()) |
---|
[657] | 1036 | { |
---|
[1311] | 1037 | domainMask.resize(mask_2d.extent(0) * mask_2d.extent(1)); |
---|
[657] | 1038 | for (int j = 0; j < nj; ++j) |
---|
[1311] | 1039 | for (int i = 0; i < ni; ++i) domainMask(i+j*ni) = mask_2d(i,j); |
---|
| 1040 | // mask_2d.reset(); |
---|
[657] | 1041 | } |
---|
[675] | 1042 | else if (mask_1d.isEmpty()) |
---|
[657] | 1043 | { |
---|
[1311] | 1044 | domainMask.resize(i_index.numElements()); |
---|
| 1045 | for (int i = 0; i < i_index.numElements(); ++i) domainMask(i) = true; |
---|
[657] | 1046 | } |
---|
[1325] | 1047 | else |
---|
| 1048 | { |
---|
[1337] | 1049 | domainMask.resize(mask_1d.numElements()); |
---|
| 1050 | domainMask=mask_1d ; |
---|
| 1051 | } |
---|
[219] | 1052 | } |
---|
| 1053 | |
---|
[676] | 1054 | //---------------------------------------------------------------- |
---|
[219] | 1055 | |
---|
| 1056 | void CDomain::checkDomainData(void) |
---|
[509] | 1057 | { |
---|
[679] | 1058 | if (data_dim.isEmpty()) |
---|
[219] | 1059 | { |
---|
[679] | 1060 | data_dim.setValue(1); |
---|
[219] | 1061 | } |
---|
[679] | 1062 | else if (!(data_dim.getValue() == 1 || data_dim.getValue() == 2)) |
---|
[219] | 1063 | { |
---|
[679] | 1064 | ERROR("CDomain::checkDomainData(void)", |
---|
| 1065 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1066 | << "The data dimension is invalid, 'data_dim' must be 1 or 2 not << " << data_dim.getValue() << "."); |
---|
[219] | 1067 | } |
---|
| 1068 | |
---|
| 1069 | if (data_ibegin.isEmpty()) |
---|
[679] | 1070 | data_ibegin.setValue(0); |
---|
[660] | 1071 | if (data_jbegin.isEmpty()) |
---|
[679] | 1072 | data_jbegin.setValue(0); |
---|
[219] | 1073 | |
---|
[679] | 1074 | if (data_ni.isEmpty()) |
---|
[219] | 1075 | { |
---|
[679] | 1076 | data_ni.setValue((data_dim == 1) ? (ni.getValue() * nj.getValue()) : ni.getValue()); |
---|
[219] | 1077 | } |
---|
[679] | 1078 | else if (data_ni.getValue() < 0) |
---|
[219] | 1079 | { |
---|
[679] | 1080 | ERROR("CDomain::checkDomainData(void)", |
---|
| 1081 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1082 | << "The data size cannot be negative ('data_ni' = " << data_ni.getValue() << ")."); |
---|
[219] | 1083 | } |
---|
| 1084 | |
---|
[679] | 1085 | if (data_nj.isEmpty()) |
---|
[219] | 1086 | { |
---|
[679] | 1087 | data_nj.setValue((data_dim.getValue() == 1) ? (ni.getValue() * nj.getValue()) : nj.getValue()); |
---|
[219] | 1088 | } |
---|
[679] | 1089 | else if (data_nj.getValue() < 0) |
---|
| 1090 | { |
---|
| 1091 | ERROR("CDomain::checkDomainData(void)", |
---|
| 1092 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1093 | << "The data size cannot be negative ('data_nj' = " << data_nj.getValue() << ")."); |
---|
| 1094 | } |
---|
[219] | 1095 | } |
---|
| 1096 | |
---|
| 1097 | //---------------------------------------------------------------- |
---|
[679] | 1098 | |
---|
[219] | 1099 | void CDomain::checkCompression(void) |
---|
| 1100 | { |
---|
| 1101 | if (!data_i_index.isEmpty()) |
---|
| 1102 | { |
---|
[664] | 1103 | if (!data_j_index.isEmpty() && |
---|
[678] | 1104 | data_j_index.numElements() != data_i_index.numElements()) |
---|
[664] | 1105 | { |
---|
[679] | 1106 | ERROR("CDomain::checkCompression(void)", |
---|
| 1107 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1108 | << "'data_i_index' and 'data_j_index' arrays must have the same size." << std::endl |
---|
| 1109 | << "'data_i_index' size = " << data_i_index.numElements() << std::endl |
---|
| 1110 | << "'data_j_index' size = " << data_j_index.numElements()); |
---|
[664] | 1111 | } |
---|
| 1112 | |
---|
[679] | 1113 | if (2 == data_dim) |
---|
| 1114 | { |
---|
[664] | 1115 | if (data_j_index.isEmpty()) |
---|
[660] | 1116 | { |
---|
[679] | 1117 | ERROR("CDomain::checkCompression(void)", |
---|
| 1118 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1119 | << "'data_j_index' must be defined when 'data_i_index' is set and 'data_dim' is 2."); |
---|
[660] | 1120 | } |
---|
[679] | 1121 | } |
---|
| 1122 | else // (1 == data_dim) |
---|
| 1123 | { |
---|
[664] | 1124 | if (data_j_index.isEmpty()) |
---|
| 1125 | { |
---|
[679] | 1126 | data_j_index.resize(data_ni); |
---|
| 1127 | for (int j = 0; j < data_ni; ++j) data_j_index(j) = 0; |
---|
[664] | 1128 | } |
---|
[679] | 1129 | } |
---|
[219] | 1130 | } |
---|
| 1131 | else |
---|
| 1132 | { |
---|
[679] | 1133 | if (data_dim == 2 && !data_j_index.isEmpty()) |
---|
| 1134 | ERROR("CDomain::checkCompression(void)", |
---|
| 1135 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1136 | << "'data_i_index' must be defined when 'data_j_index' is set and 'data_dim' is 2."); |
---|
[219] | 1137 | |
---|
[679] | 1138 | if (1 == data_dim) |
---|
| 1139 | { |
---|
| 1140 | data_i_index.resize(data_ni); |
---|
| 1141 | data_j_index.resize(data_ni); |
---|
[666] | 1142 | |
---|
[679] | 1143 | for (int i = 0; i < data_ni; ++i) |
---|
| 1144 | { |
---|
| 1145 | data_i_index(i) = i; |
---|
| 1146 | data_j_index(i) = 0; |
---|
| 1147 | } |
---|
| 1148 | } |
---|
| 1149 | else // (data_dim == 2) |
---|
| 1150 | { |
---|
| 1151 | const int dsize = data_ni * data_nj; |
---|
| 1152 | data_i_index.resize(dsize); |
---|
| 1153 | data_j_index.resize(dsize); |
---|
[509] | 1154 | |
---|
[679] | 1155 | for(int count = 0, j = 0; j < data_nj; ++j) |
---|
| 1156 | { |
---|
| 1157 | for(int i = 0; i < data_ni; ++i, ++count) |
---|
[219] | 1158 | { |
---|
[679] | 1159 | data_i_index(count) = i; |
---|
| 1160 | data_j_index(count) = j; |
---|
[219] | 1161 | } |
---|
[679] | 1162 | } |
---|
| 1163 | } |
---|
[219] | 1164 | } |
---|
| 1165 | } |
---|
| 1166 | |
---|
[666] | 1167 | //---------------------------------------------------------------- |
---|
[893] | 1168 | void CDomain::computeLocalMask(void) |
---|
| 1169 | { |
---|
[1429] | 1170 | localMask.resize(i_index.numElements()) ; |
---|
[893] | 1171 | localMask=false ; |
---|
[676] | 1172 | |
---|
[893] | 1173 | size_t dn=data_i_index.numElements() ; |
---|
| 1174 | int i,j ; |
---|
| 1175 | size_t k,ind ; |
---|
[906] | 1176 | |
---|
[893] | 1177 | for(k=0;k<dn;k++) |
---|
| 1178 | { |
---|
| 1179 | if (data_dim==2) |
---|
| 1180 | { |
---|
| 1181 | i=data_i_index(k)+data_ibegin ; |
---|
| 1182 | j=data_j_index(k)+data_jbegin ; |
---|
[1429] | 1183 | if (i>=0 && i<ni && j>=0 && j<nj) |
---|
| 1184 | { |
---|
| 1185 | ind=j*ni+i ; |
---|
[1431] | 1186 | localMask(ind)=domainMask(ind) ; |
---|
[1429] | 1187 | } |
---|
[893] | 1188 | } |
---|
| 1189 | else |
---|
| 1190 | { |
---|
[1429] | 1191 | i=data_i_index(k)+data_ibegin ; |
---|
| 1192 | if (i>=0 && i<i_index.numElements()) |
---|
| 1193 | { |
---|
| 1194 | ind=i ; |
---|
[1431] | 1195 | localMask(ind)=domainMask(ind) ; |
---|
[1429] | 1196 | } |
---|
[893] | 1197 | } |
---|
| 1198 | } |
---|
| 1199 | } |
---|
| 1200 | |
---|
[676] | 1201 | void CDomain::checkEligibilityForCompressedOutput(void) |
---|
| 1202 | { |
---|
| 1203 | // We don't check if the mask or the indexes are valid here, just if they have been defined at this point. |
---|
| 1204 | isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !data_i_index.isEmpty(); |
---|
| 1205 | } |
---|
| 1206 | |
---|
| 1207 | //---------------------------------------------------------------- |
---|
| 1208 | |
---|
[1129] | 1209 | /* |
---|
| 1210 | Fill in longitude and latitude value from clients (or models) into internal values lonvalue, latvalue which |
---|
| 1211 | will be used by XIOS. |
---|
| 1212 | */ |
---|
[666] | 1213 | void CDomain::completeLonLatClient(void) |
---|
[219] | 1214 | { |
---|
[1099] | 1215 | bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); |
---|
[1305] | 1216 | checkBounds() ; |
---|
[1099] | 1217 | if (!lonvalue_2d.isEmpty() && !lonlatValueExisted) |
---|
[664] | 1218 | { |
---|
[1025] | 1219 | lonvalue.resize(ni * nj); |
---|
| 1220 | latvalue.resize(ni * nj); |
---|
[761] | 1221 | if (hasBounds) |
---|
| 1222 | { |
---|
[1025] | 1223 | bounds_lonvalue.resize(nvertex, ni * nj); |
---|
| 1224 | bounds_latvalue.resize(nvertex, ni * nj); |
---|
[761] | 1225 | } |
---|
| 1226 | |
---|
| 1227 | for (int j = 0; j < nj; ++j) |
---|
| 1228 | { |
---|
| 1229 | for (int i = 0; i < ni; ++i) |
---|
| 1230 | { |
---|
| 1231 | int k = j * ni + i; |
---|
| 1232 | |
---|
[1025] | 1233 | lonvalue(k) = lonvalue_2d(i,j); |
---|
| 1234 | latvalue(k) = latvalue_2d(i,j); |
---|
[761] | 1235 | |
---|
| 1236 | if (hasBounds) |
---|
| 1237 | { |
---|
| 1238 | for (int n = 0; n < nvertex; ++n) |
---|
| 1239 | { |
---|
[1025] | 1240 | bounds_lonvalue(n,k) = bounds_lon_2d(n,i,j); |
---|
| 1241 | bounds_latvalue(n,k) = bounds_lat_2d(n,i,j); |
---|
[761] | 1242 | } |
---|
| 1243 | } |
---|
| 1244 | } |
---|
| 1245 | } |
---|
[664] | 1246 | } |
---|
[1099] | 1247 | else if (!lonvalue_1d.isEmpty() && !lonlatValueExisted) |
---|
[664] | 1248 | { |
---|
| 1249 | if (type_attr::rectilinear == type) |
---|
| 1250 | { |
---|
[679] | 1251 | if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) |
---|
[664] | 1252 | { |
---|
[1025] | 1253 | lonvalue.resize(ni * nj); |
---|
| 1254 | latvalue.resize(ni * nj); |
---|
[761] | 1255 | if (hasBounds) |
---|
| 1256 | { |
---|
[1025] | 1257 | bounds_lonvalue.resize(nvertex, ni * nj); |
---|
| 1258 | bounds_latvalue.resize(nvertex, ni * nj); |
---|
[761] | 1259 | } |
---|
| 1260 | |
---|
| 1261 | for (int j = 0; j < nj; ++j) |
---|
| 1262 | { |
---|
| 1263 | for (int i = 0; i < ni; ++i) |
---|
[664] | 1264 | { |
---|
[761] | 1265 | int k = j * ni + i; |
---|
| 1266 | |
---|
[1025] | 1267 | lonvalue(k) = lonvalue_1d(i); |
---|
| 1268 | latvalue(k) = latvalue_1d(j); |
---|
[761] | 1269 | |
---|
[664] | 1270 | if (hasBounds) |
---|
| 1271 | { |
---|
[679] | 1272 | for (int n = 0; n < nvertex; ++n) |
---|
[666] | 1273 | { |
---|
[1025] | 1274 | bounds_lonvalue(n,k) = bounds_lon_1d(n,i); |
---|
| 1275 | bounds_latvalue(n,k) = bounds_lat_1d(n,j); |
---|
[666] | 1276 | } |
---|
[664] | 1277 | } |
---|
| 1278 | } |
---|
[761] | 1279 | } |
---|
| 1280 | } |
---|
[1099] | 1281 | else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements() && !lonlatValueExisted) |
---|
[974] | 1282 | { |
---|
[1025] | 1283 | lonvalue.reference(lonvalue_1d); |
---|
| 1284 | latvalue.reference(latvalue_1d); |
---|
[974] | 1285 | if (hasBounds) |
---|
| 1286 | { |
---|
[1025] | 1287 | bounds_lonvalue.reference(bounds_lon_1d); |
---|
| 1288 | bounds_latvalue.reference(bounds_lat_1d); |
---|
[974] | 1289 | } |
---|
| 1290 | } |
---|
[761] | 1291 | else |
---|
| 1292 | ERROR("CDomain::completeLonClient(void)", |
---|
| 1293 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1294 | << "'lonvalue_1d' and 'latvalue_1d' does not have the same size as the local domain." << std::endl |
---|
[974] | 1295 | << "'lonvalue_1d' size is " << lonvalue_1d.numElements() |
---|
| 1296 | << " and 'latvalue_1d' size is " << latvalue_1d.numElements() << std::endl |
---|
| 1297 | << " They should be correspondingly " << ni.getValue() << " and " << nj.getValue() << " or " << std::endl |
---|
| 1298 | << i_index.numElements() << " and " << j_index.numElements() << "."); |
---|
[664] | 1299 | } |
---|
[1099] | 1300 | else if (type == type_attr::curvilinear || type == type_attr::unstructured && !lonlatValueExisted) |
---|
[664] | 1301 | { |
---|
[1025] | 1302 | lonvalue.reference(lonvalue_1d); |
---|
| 1303 | latvalue.reference(latvalue_1d); |
---|
[664] | 1304 | if (hasBounds) |
---|
| 1305 | { |
---|
[1025] | 1306 | bounds_lonvalue.reference(bounds_lon_1d); |
---|
| 1307 | bounds_latvalue.reference(bounds_lat_1d); |
---|
[664] | 1308 | } |
---|
| 1309 | } |
---|
| 1310 | } |
---|
| 1311 | } |
---|
| 1312 | |
---|
[1129] | 1313 | /* |
---|
| 1314 | Convert internal longitude latitude value used by XIOS to "lonvalue_*" which can be retrieved with Fortran interface |
---|
| 1315 | */ |
---|
| 1316 | void CDomain::convertLonLatValue(void) |
---|
| 1317 | { |
---|
| 1318 | bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); |
---|
| 1319 | if (!lonvalue_2d.isEmpty() && lonlatValueExisted) |
---|
| 1320 | { |
---|
| 1321 | lonvalue_2d.resize(ni,nj); |
---|
| 1322 | latvalue_2d.resize(ni,nj); |
---|
| 1323 | if (hasBounds) |
---|
| 1324 | { |
---|
| 1325 | bounds_lon_2d.resize(nvertex, ni, nj); |
---|
| 1326 | bounds_lat_2d.resize(nvertex, ni, nj); |
---|
| 1327 | } |
---|
| 1328 | |
---|
| 1329 | for (int j = 0; j < nj; ++j) |
---|
| 1330 | { |
---|
| 1331 | for (int i = 0; i < ni; ++i) |
---|
| 1332 | { |
---|
| 1333 | int k = j * ni + i; |
---|
| 1334 | |
---|
| 1335 | lonvalue_2d(i,j) = lonvalue(k); |
---|
| 1336 | latvalue_2d(i,j) = latvalue(k); |
---|
| 1337 | |
---|
| 1338 | if (hasBounds) |
---|
| 1339 | { |
---|
| 1340 | for (int n = 0; n < nvertex; ++n) |
---|
| 1341 | { |
---|
| 1342 | bounds_lon_2d(n,i,j) = bounds_lonvalue(n,k); |
---|
| 1343 | bounds_lat_2d(n,i,j) = bounds_latvalue(n,k); |
---|
| 1344 | } |
---|
| 1345 | } |
---|
| 1346 | } |
---|
| 1347 | } |
---|
| 1348 | } |
---|
| 1349 | else if (!lonvalue_1d.isEmpty() && lonlatValueExisted) |
---|
| 1350 | { |
---|
| 1351 | if (type_attr::rectilinear == type) |
---|
| 1352 | { |
---|
| 1353 | if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) |
---|
| 1354 | { |
---|
| 1355 | lonvalue.resize(ni * nj); |
---|
| 1356 | latvalue.resize(ni * nj); |
---|
| 1357 | if (hasBounds) |
---|
| 1358 | { |
---|
| 1359 | bounds_lonvalue.resize(nvertex, ni * nj); |
---|
| 1360 | bounds_latvalue.resize(nvertex, ni * nj); |
---|
| 1361 | } |
---|
| 1362 | |
---|
| 1363 | for (int j = 0; j < nj; ++j) |
---|
| 1364 | { |
---|
| 1365 | for (int i = 0; i < ni; ++i) |
---|
| 1366 | { |
---|
| 1367 | int k = j * ni + i; |
---|
| 1368 | |
---|
| 1369 | lonvalue(k) = lonvalue_1d(i); |
---|
| 1370 | latvalue(k) = latvalue_1d(j); |
---|
| 1371 | |
---|
| 1372 | if (hasBounds) |
---|
| 1373 | { |
---|
| 1374 | for (int n = 0; n < nvertex; ++n) |
---|
| 1375 | { |
---|
| 1376 | bounds_lonvalue(n,k) = bounds_lon_1d(n,i); |
---|
| 1377 | bounds_latvalue(n,k) = bounds_lat_1d(n,j); |
---|
| 1378 | } |
---|
| 1379 | } |
---|
| 1380 | } |
---|
| 1381 | } |
---|
| 1382 | } |
---|
| 1383 | else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements() && !lonlatValueExisted) |
---|
| 1384 | { |
---|
| 1385 | lonvalue.reference(lonvalue_1d); |
---|
| 1386 | latvalue.reference(latvalue_1d); |
---|
| 1387 | if (hasBounds) |
---|
| 1388 | { |
---|
| 1389 | bounds_lonvalue.reference(bounds_lon_1d); |
---|
| 1390 | bounds_latvalue.reference(bounds_lat_1d); |
---|
| 1391 | } |
---|
| 1392 | } |
---|
| 1393 | else |
---|
| 1394 | ERROR("CDomain::completeLonClient(void)", |
---|
| 1395 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1396 | << "'lonvalue_1d' and 'latvalue_1d' does not have the same size as the local domain." << std::endl |
---|
| 1397 | << "'lonvalue_1d' size is " << lonvalue_1d.numElements() |
---|
| 1398 | << " and 'latvalue_1d' size is " << latvalue_1d.numElements() << std::endl |
---|
| 1399 | << " They should be correspondingly " << ni.getValue() << " and " << nj.getValue() << " or " << std::endl |
---|
| 1400 | << i_index.numElements() << " and " << j_index.numElements() << "."); |
---|
| 1401 | } |
---|
| 1402 | else if (type == type_attr::curvilinear || type == type_attr::unstructured && !lonlatValueExisted) |
---|
| 1403 | { |
---|
| 1404 | lonvalue.reference(lonvalue_1d); |
---|
| 1405 | latvalue.reference(latvalue_1d); |
---|
| 1406 | if (hasBounds) |
---|
| 1407 | { |
---|
| 1408 | bounds_lonvalue.reference(bounds_lon_1d); |
---|
| 1409 | bounds_latvalue.reference(bounds_lat_1d); |
---|
| 1410 | } |
---|
| 1411 | } |
---|
| 1412 | } |
---|
| 1413 | } |
---|
| 1414 | |
---|
| 1415 | |
---|
[449] | 1416 | void CDomain::checkBounds(void) |
---|
| 1417 | { |
---|
[1099] | 1418 | bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); |
---|
| 1419 | if (!nvertex.isEmpty() && nvertex > 0 && !hasBoundValues) |
---|
[449] | 1420 | { |
---|
[664] | 1421 | if (!bounds_lon_1d.isEmpty() && !bounds_lon_2d.isEmpty()) |
---|
| 1422 | ERROR("CDomain::checkBounds(void)", |
---|
[679] | 1423 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1424 | << "Only one longitude boundary attribute can be used but both 'bounds_lon_1d' and 'bounds_lon_2d' are defined." << std::endl |
---|
| 1425 | << "Define only one longitude boundary attribute: 'bounds_lon_1d' or 'bounds_lon_2d'."); |
---|
[664] | 1426 | |
---|
| 1427 | if (!bounds_lat_1d.isEmpty() && !bounds_lat_2d.isEmpty()) |
---|
| 1428 | ERROR("CDomain::checkBounds(void)", |
---|
[679] | 1429 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1430 | << "Only one latitude boundary attribute can be used but both 'bounds_lat_1d' and 'bounds_lat_2d' are defined." << std::endl |
---|
| 1431 | << "Define only one latitude boundary attribute: 'bounds_lat_1d' or 'bounds_lat_2d'."); |
---|
[664] | 1432 | |
---|
| 1433 | if ((!bounds_lon_1d.isEmpty() && bounds_lat_1d.isEmpty()) || (bounds_lon_1d.isEmpty() && !bounds_lat_1d.isEmpty())) |
---|
| 1434 | { |
---|
| 1435 | ERROR("CDomain::checkBounds(void)", |
---|
[679] | 1436 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1437 | << "Only 'bounds_lon_1d' or 'bounds_lat_1d' is defined." << std::endl |
---|
| 1438 | << "Please define either both attributes or none."); |
---|
[664] | 1439 | } |
---|
| 1440 | |
---|
| 1441 | if ((!bounds_lon_2d.isEmpty() && bounds_lat_2d.isEmpty()) || (bounds_lon_2d.isEmpty() && !bounds_lat_2d.isEmpty())) |
---|
| 1442 | { |
---|
| 1443 | ERROR("CDomain::checkBounds(void)", |
---|
[679] | 1444 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1445 | << "Only 'bounds_lon_2d' or 'bounds_lat_2d' is defined." << std::endl |
---|
| 1446 | << "Please define either both attributes or none."); |
---|
[664] | 1447 | } |
---|
| 1448 | |
---|
[691] | 1449 | if (!bounds_lon_1d.isEmpty() && nvertex.getValue() != bounds_lon_1d.extent(0)) |
---|
[679] | 1450 | ERROR("CDomain::checkBounds(void)", |
---|
| 1451 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1452 | << "'bounds_lon_1d' dimension is not compatible with 'nvertex'." << std::endl |
---|
[1624] | 1453 | << "'bounds_lon_1d' dimension is " << bounds_lon_1d.extent(0) |
---|
[679] | 1454 | << " but nvertex is " << nvertex.getValue() << "."); |
---|
[664] | 1455 | |
---|
[691] | 1456 | if (!bounds_lon_2d.isEmpty() && nvertex.getValue() != bounds_lon_2d.extent(0)) |
---|
[679] | 1457 | ERROR("CDomain::checkBounds(void)", |
---|
| 1458 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1459 | << "'bounds_lon_2d' dimension is not compatible with 'nvertex'." << std::endl |
---|
[1624] | 1460 | << "'bounds_lon_2d' dimension is " << bounds_lon_2d.extent(0) |
---|
[679] | 1461 | << " but nvertex is " << nvertex.getValue() << "."); |
---|
[664] | 1462 | |
---|
| 1463 | if (!bounds_lon_1d.isEmpty() && lonvalue_1d.isEmpty()) |
---|
[679] | 1464 | ERROR("CDomain::checkBounds(void)", |
---|
| 1465 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1466 | << "Since 'bounds_lon_1d' is defined, 'lonvalue_1d' must be defined too." << std::endl); |
---|
[664] | 1467 | |
---|
| 1468 | if (!bounds_lon_2d.isEmpty() && lonvalue_2d.isEmpty()) |
---|
[679] | 1469 | ERROR("CDomain::checkBounds(void)", |
---|
| 1470 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1471 | << "Since 'bounds_lon_2d' is defined, 'lonvalue_2d' must be defined too." << std::endl); |
---|
[664] | 1472 | |
---|
[691] | 1473 | if (!bounds_lat_1d.isEmpty() && nvertex.getValue() != bounds_lat_1d.extent(0)) |
---|
[679] | 1474 | ERROR("CDomain::checkBounds(void)", |
---|
| 1475 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1476 | << "'bounds_lat_1d' dimension is not compatible with 'nvertex'." << std::endl |
---|
[1624] | 1477 | << "'bounds_lat_1d' dimension is " << bounds_lat_1d.extent(0) |
---|
[679] | 1478 | << " but nvertex is " << nvertex.getValue() << "."); |
---|
[664] | 1479 | |
---|
[691] | 1480 | if (!bounds_lat_2d.isEmpty() && nvertex.getValue() != bounds_lat_2d.extent(0)) |
---|
[679] | 1481 | ERROR("CDomain::checkBounds(void)", |
---|
| 1482 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1483 | << "'bounds_lat_2d' dimension is not compatible with 'nvertex'." << std::endl |
---|
[1624] | 1484 | << "'bounds_lat_2d' dimension is " << bounds_lat_2d.extent(0) |
---|
[679] | 1485 | << " but nvertex is " << nvertex.getValue() << "."); |
---|
[664] | 1486 | |
---|
| 1487 | if (!bounds_lat_1d.isEmpty() && latvalue_1d.isEmpty()) |
---|
[679] | 1488 | ERROR("CDomain::checkBounds(void)", |
---|
| 1489 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1490 | << "Since 'bounds_lat_1d' is defined, 'latvalue_1d' must be defined too." << std::endl); |
---|
[664] | 1491 | |
---|
| 1492 | if (!bounds_lat_2d.isEmpty() && latvalue_2d.isEmpty()) |
---|
[679] | 1493 | ERROR("CDomain::checkBounds(void)", |
---|
| 1494 | << "Since 'bounds_lat_2d' is defined, 'latvalue_2d' must be defined too." << std::endl); |
---|
| 1495 | |
---|
[1486] | 1496 | // In case of reading UGRID bounds values are not required |
---|
| 1497 | hasBounds = (!bounds_lat_1d.isEmpty() || !bounds_lat_2d.isEmpty() ); |
---|
[449] | 1498 | } |
---|
[1132] | 1499 | else if (hasBoundValues) |
---|
| 1500 | { |
---|
| 1501 | hasBounds = true; |
---|
| 1502 | } |
---|
[509] | 1503 | else |
---|
[449] | 1504 | { |
---|
[679] | 1505 | hasBounds = false; |
---|
[449] | 1506 | } |
---|
| 1507 | } |
---|
[509] | 1508 | |
---|
[611] | 1509 | void CDomain::checkArea(void) |
---|
| 1510 | { |
---|
[1249] | 1511 | bool hasAreaValue = (!areavalue.isEmpty() && 0 != areavalue.numElements()); |
---|
| 1512 | hasArea = !area.isEmpty(); |
---|
| 1513 | if (hasArea && !hasAreaValue) |
---|
[611] | 1514 | { |
---|
| 1515 | if (area.extent(0) != ni || area.extent(1) != nj) |
---|
| 1516 | { |
---|
[679] | 1517 | ERROR("CDomain::checkArea(void)", |
---|
| 1518 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1519 | << "The area does not have the same size as the local domain." << std::endl |
---|
| 1520 | << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl |
---|
| 1521 | << "Area size is " << area.extent(0) << " x " << area.extent(1) << "."); |
---|
[611] | 1522 | } |
---|
[1025] | 1523 | if (areavalue.isEmpty()) |
---|
| 1524 | { |
---|
| 1525 | areavalue.resize(ni*nj); |
---|
| 1526 | for (int j = 0; j < nj; ++j) |
---|
| 1527 | { |
---|
| 1528 | for (int i = 0; i < ni; ++i) |
---|
| 1529 | { |
---|
| 1530 | int k = j * ni + i; |
---|
| 1531 | areavalue(k) = area(i,j); |
---|
| 1532 | } |
---|
| 1533 | } |
---|
| 1534 | } |
---|
[611] | 1535 | } |
---|
| 1536 | } |
---|
| 1537 | |
---|
[665] | 1538 | void CDomain::checkLonLat() |
---|
| 1539 | { |
---|
[1284] | 1540 | if (!hasLonLat) hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || |
---|
| 1541 | (!latvalue_2d.isEmpty() && !lonvalue_2d.isEmpty()); |
---|
[1099] | 1542 | bool hasLonLatValue = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); |
---|
| 1543 | if (hasLonLat && !hasLonLatValue) |
---|
[666] | 1544 | { |
---|
| 1545 | if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) |
---|
[762] | 1546 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1547 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1548 | << "Only one longitude attribute can be used but both 'lonvalue_1d' and 'lonvalue_2d' are defined." << std::endl |
---|
| 1549 | << "Define only one longitude attribute: 'lonvalue_1d' or 'lonvalue_2d'."); |
---|
[666] | 1550 | |
---|
| 1551 | if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) |
---|
| 1552 | { |
---|
[687] | 1553 | if ((type_attr::rectilinear != type) && (lonvalue_1d.numElements() != i_index.numElements())) |
---|
[762] | 1554 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1555 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1556 | << "'lonvalue_1d' does not have the same size as the local domain." << std::endl |
---|
| 1557 | << "Local size is " << i_index.numElements() << "." << std::endl |
---|
| 1558 | << "'lonvalue_1d' size is " << lonvalue_1d.numElements() << "."); |
---|
[666] | 1559 | } |
---|
| 1560 | |
---|
| 1561 | if (lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) |
---|
| 1562 | { |
---|
[679] | 1563 | if (lonvalue_2d.extent(0) != ni || lonvalue_2d.extent(1) != nj) |
---|
[762] | 1564 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1565 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1566 | << "'lonvalue_2d' does not have the same size as the local domain." << std::endl |
---|
| 1567 | << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl |
---|
| 1568 | << "'lonvalue_2d' size is " << lonvalue_2d.extent(0) << " x " << lonvalue_2d.extent(1) << "."); |
---|
[666] | 1569 | } |
---|
| 1570 | |
---|
| 1571 | if (!latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) |
---|
[762] | 1572 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1573 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1574 | << "Only one latitude attribute can be used but both 'latvalue_1d' and 'latvalue_2d' are defined." << std::endl |
---|
| 1575 | << "Define only one latitude attribute: 'latvalue_1d' or 'latvalue_2d'."); |
---|
[666] | 1576 | |
---|
| 1577 | if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty()) |
---|
| 1578 | { |
---|
[687] | 1579 | if ((type_attr::rectilinear != type) && (latvalue_1d.numElements() != i_index.numElements())) |
---|
[762] | 1580 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1581 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1582 | << "'latvalue_1d' does not have the same size as the local domain." << std::endl |
---|
| 1583 | << "Local size is " << i_index.numElements() << "." << std::endl |
---|
| 1584 | << "'latvalue_1d' size is " << latvalue_1d.numElements() << "."); |
---|
[666] | 1585 | } |
---|
| 1586 | |
---|
| 1587 | if (latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) |
---|
| 1588 | { |
---|
[679] | 1589 | if (latvalue_2d.extent(0) != ni || latvalue_2d.extent(1) != nj) |
---|
[762] | 1590 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1591 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1592 | << "'latvalue_2d' does not have the same size as the local domain." << std::endl |
---|
| 1593 | << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl |
---|
| 1594 | << "'latvalue_2d' size is " << latvalue_2d.extent(0) << " x " << latvalue_2d.extent(1) << "."); |
---|
[666] | 1595 | } |
---|
| 1596 | } |
---|
[665] | 1597 | } |
---|
| 1598 | |
---|
[657] | 1599 | void CDomain::checkAttributesOnClientAfterTransformation() |
---|
| 1600 | { |
---|
| 1601 | CContext* context=CContext::getCurrent() ; |
---|
| 1602 | |
---|
| 1603 | if (this->isClientAfterTransformationChecked) return; |
---|
| 1604 | if (context->hasClient) |
---|
| 1605 | { |
---|
[1025] | 1606 | this->computeConnectedClients(); |
---|
[1054] | 1607 | if (hasLonLat) |
---|
| 1608 | if (!context->hasServer) |
---|
| 1609 | this->completeLonLatClient(); |
---|
[657] | 1610 | } |
---|
| 1611 | |
---|
| 1612 | this->isClientAfterTransformationChecked = true; |
---|
| 1613 | } |
---|
| 1614 | |
---|
[219] | 1615 | //---------------------------------------------------------------- |
---|
[667] | 1616 | // Divide function checkAttributes into 2 seperate ones |
---|
[509] | 1617 | // This function only checks all attributes of current domain |
---|
| 1618 | void CDomain::checkAttributesOnClient() |
---|
| 1619 | { |
---|
| 1620 | if (this->isClientChecked) return; |
---|
| 1621 | CContext* context=CContext::getCurrent(); |
---|
[219] | 1622 | |
---|
[1025] | 1623 | if (context->hasClient && !context->hasServer) |
---|
| 1624 | { |
---|
| 1625 | this->checkDomain(); |
---|
| 1626 | this->checkBounds(); |
---|
| 1627 | this->checkArea(); |
---|
| 1628 | this->checkLonLat(); |
---|
| 1629 | } |
---|
[509] | 1630 | |
---|
[1025] | 1631 | if (context->hasClient && !context->hasServer) |
---|
[1129] | 1632 | { // Ct client uniquement |
---|
[509] | 1633 | this->checkMask(); |
---|
| 1634 | this->checkDomainData(); |
---|
| 1635 | this->checkCompression(); |
---|
[893] | 1636 | this->computeLocalMask() ; |
---|
[509] | 1637 | } |
---|
| 1638 | else |
---|
[1129] | 1639 | { // Ct serveur uniquement |
---|
[509] | 1640 | } |
---|
| 1641 | |
---|
| 1642 | this->isClientChecked = true; |
---|
| 1643 | } |
---|
| 1644 | |
---|
| 1645 | // Send all checked attributes to server |
---|
| 1646 | void CDomain::sendCheckedAttributes() |
---|
| 1647 | { |
---|
| 1648 | if (!this->isClientChecked) checkAttributesOnClient(); |
---|
[657] | 1649 | if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(); |
---|
[509] | 1650 | CContext* context=CContext::getCurrent() ; |
---|
| 1651 | |
---|
| 1652 | if (this->isChecked) return; |
---|
| 1653 | if (context->hasClient) |
---|
| 1654 | { |
---|
[1025] | 1655 | sendAttributes(); |
---|
[509] | 1656 | } |
---|
| 1657 | this->isChecked = true; |
---|
| 1658 | } |
---|
| 1659 | |
---|
[219] | 1660 | void CDomain::checkAttributes(void) |
---|
| 1661 | { |
---|
| 1662 | if (this->isChecked) return; |
---|
[347] | 1663 | CContext* context=CContext::getCurrent() ; |
---|
[219] | 1664 | |
---|
[467] | 1665 | this->checkDomain(); |
---|
[665] | 1666 | this->checkLonLat(); |
---|
[449] | 1667 | this->checkBounds(); |
---|
[611] | 1668 | this->checkArea(); |
---|
[509] | 1669 | |
---|
[300] | 1670 | if (context->hasClient) |
---|
[1129] | 1671 | { // Ct client uniquement |
---|
[219] | 1672 | this->checkMask(); |
---|
| 1673 | this->checkDomainData(); |
---|
| 1674 | this->checkCompression(); |
---|
[893] | 1675 | this->computeLocalMask() ; |
---|
[666] | 1676 | |
---|
[219] | 1677 | } |
---|
| 1678 | else |
---|
[1129] | 1679 | { // Ct serveur uniquement |
---|
[219] | 1680 | } |
---|
[509] | 1681 | |
---|
[300] | 1682 | if (context->hasClient) |
---|
| 1683 | { |
---|
[1025] | 1684 | this->computeConnectedClients(); |
---|
[666] | 1685 | this->completeLonLatClient(); |
---|
[300] | 1686 | } |
---|
[509] | 1687 | |
---|
[219] | 1688 | this->isChecked = true; |
---|
| 1689 | } |
---|
[509] | 1690 | |
---|
[1025] | 1691 | /*! |
---|
[1144] | 1692 | Compute the connection of a client to other clients to determine which clients to send attributes to. |
---|
| 1693 | The sending clients are supposed to already know the distribution of receiving clients (In simple cases, it's band) |
---|
| 1694 | The connection among clients is calculated by using global index. |
---|
| 1695 | A client connects to other clients which holds the same global index as it. |
---|
[1025] | 1696 | */ |
---|
| 1697 | void CDomain::computeConnectedClients() |
---|
[657] | 1698 | { |
---|
[553] | 1699 | CContext* context=CContext::getCurrent() ; |
---|
[1236] | 1700 | |
---|
| 1701 | // This line should be changed soon. |
---|
| 1702 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
[1099] | 1703 | |
---|
[1236] | 1704 | nbSenders.clear(); |
---|
| 1705 | connectedServerRank_.clear(); |
---|
| 1706 | |
---|
[1054] | 1707 | for (int p = 0; p < nbSrvPools; ++p) |
---|
[1027] | 1708 | { |
---|
[1054] | 1709 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; |
---|
[1099] | 1710 | int nbServer = client->serverSize; |
---|
[1337] | 1711 | int nbClient = client->clientSize; |
---|
[1099] | 1712 | int rank = client->clientRank; |
---|
[1027] | 1713 | bool doComputeGlobalIndexServer = true; |
---|
[449] | 1714 | |
---|
[1346] | 1715 | if (connectedServerRank_.find(nbServer) == connectedServerRank_.end()) |
---|
[1099] | 1716 | { |
---|
| 1717 | |
---|
[1346] | 1718 | if (indSrv_.find(nbServer) == indSrv_.end()) |
---|
| 1719 | { |
---|
| 1720 | int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; |
---|
| 1721 | int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; |
---|
| 1722 | int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; |
---|
[1099] | 1723 | |
---|
[1346] | 1724 | // Precompute number of index |
---|
| 1725 | int globalIndexCountZoom = 0; |
---|
| 1726 | nbIndex = i_index.numElements(); |
---|
| 1727 | |
---|
| 1728 | if (doZoomByIndex_) |
---|
| 1729 | { |
---|
| 1730 | globalIndexCountZoom = zoom_i_index.numElements(); |
---|
| 1731 | } |
---|
| 1732 | else |
---|
| 1733 | { |
---|
| 1734 | for (i = 0; i < nbIndex; ++i) |
---|
| 1735 | { |
---|
[1337] | 1736 | i_ind=i_index(i); |
---|
| 1737 | j_ind=j_index(i); |
---|
[657] | 1738 | |
---|
[1337] | 1739 | if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 1740 | { |
---|
| 1741 | ++globalIndexCountZoom; |
---|
| 1742 | } |
---|
[1346] | 1743 | } |
---|
| 1744 | } |
---|
[509] | 1745 | |
---|
[1346] | 1746 | // Fill in index |
---|
| 1747 | CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); |
---|
| 1748 | CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); |
---|
| 1749 | CArray<size_t,1> globalIndexDomain(nbIndex); |
---|
| 1750 | size_t globalIndex; |
---|
| 1751 | int globalIndexCount = 0; |
---|
[1027] | 1752 | |
---|
[1346] | 1753 | for (i = 0; i < nbIndex; ++i) |
---|
| 1754 | { |
---|
| 1755 | i_ind=i_index(i); |
---|
| 1756 | j_ind=j_index(i); |
---|
| 1757 | globalIndex = i_ind + j_ind * ni_glo; |
---|
| 1758 | globalIndexDomain(i) = globalIndex; |
---|
| 1759 | } |
---|
[1099] | 1760 | |
---|
[1346] | 1761 | if (globalLocalIndexMap_.empty()) |
---|
| 1762 | { |
---|
| 1763 | for (i = 0; i < nbIndex; ++i) |
---|
[1337] | 1764 | globalLocalIndexMap_[globalIndexDomain(i)] = i; |
---|
[1346] | 1765 | } |
---|
[1337] | 1766 | |
---|
[1346] | 1767 | globalIndexCountZoom = 0; |
---|
| 1768 | if (doZoomByIndex_) |
---|
| 1769 | { |
---|
| 1770 | int nbIndexZoom = zoom_i_index.numElements(); |
---|
[1337] | 1771 | |
---|
[1346] | 1772 | for (i = 0; i < nbIndexZoom; ++i) |
---|
| 1773 | { |
---|
[1337] | 1774 | i_ind=zoom_i_index(i); |
---|
| 1775 | j_ind=zoom_j_index(i); |
---|
| 1776 | globalIndex = i_ind + j_ind * ni_glo; |
---|
| 1777 | globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; |
---|
| 1778 | ++globalIndexCountZoom; |
---|
[1346] | 1779 | } |
---|
| 1780 | } |
---|
| 1781 | else |
---|
| 1782 | { |
---|
| 1783 | int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; |
---|
| 1784 | int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; |
---|
| 1785 | for (i = 0; i < nbIndex; ++i) |
---|
| 1786 | { |
---|
[1337] | 1787 | i_ind=i_index(i); |
---|
| 1788 | j_ind=j_index(i); |
---|
| 1789 | globalIndex = i_ind + j_ind * ni_glo; |
---|
| 1790 | if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 1791 | { |
---|
| 1792 | globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; |
---|
| 1793 | ++globalIndexCountZoom; |
---|
| 1794 | } |
---|
[1346] | 1795 | } |
---|
[1027] | 1796 | |
---|
[1346] | 1797 | int iend = ibegin + ni -1; |
---|
| 1798 | int jend = jbegin + nj -1; |
---|
[1509] | 1799 | zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin.getValue() : ibegin; |
---|
[1346] | 1800 | int zoom_iend = global_zoom_iend < iend ? zoom_iend : iend ; |
---|
| 1801 | zoom_ni = zoom_iend-zoom_ibegin+1 ; |
---|
[1099] | 1802 | |
---|
[1509] | 1803 | zoom_jbegin = global_zoom_jbegin > jbegin ? global_zoom_jbegin.getValue() : jbegin ; |
---|
[1346] | 1804 | int zoom_jend = global_zoom_jend < jend ? zoom_jend : jend; |
---|
| 1805 | zoom_nj = zoom_jend-zoom_jbegin+1; |
---|
| 1806 | } |
---|
[1027] | 1807 | |
---|
[1346] | 1808 | size_t globalSizeIndex = 1, indexBegin, indexEnd; |
---|
| 1809 | int range, clientSize = client->clientSize; |
---|
| 1810 | std::vector<int> nGlobDomain(2); |
---|
| 1811 | nGlobDomain[0] = this->ni_glo; |
---|
| 1812 | nGlobDomain[1] = this->nj_glo; |
---|
| 1813 | for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; |
---|
| 1814 | indexBegin = 0; |
---|
| 1815 | if (globalSizeIndex <= clientSize) |
---|
| 1816 | { |
---|
| 1817 | indexBegin = rank%globalSizeIndex; |
---|
| 1818 | indexEnd = indexBegin; |
---|
| 1819 | } |
---|
| 1820 | else |
---|
| 1821 | { |
---|
| 1822 | for (int i = 0; i < clientSize; ++i) |
---|
| 1823 | { |
---|
[1337] | 1824 | range = globalSizeIndex / clientSize; |
---|
| 1825 | if (i < (globalSizeIndex%clientSize)) ++range; |
---|
| 1826 | if (i == client->clientRank) break; |
---|
| 1827 | indexBegin += range; |
---|
[1346] | 1828 | } |
---|
| 1829 | indexEnd = indexBegin + range - 1; |
---|
| 1830 | } |
---|
[676] | 1831 | |
---|
[1346] | 1832 | // Even if servers have no index, they must received something from client |
---|
| 1833 | // We only use several client to send "empty" message to these servers |
---|
| 1834 | CServerDistributionDescription serverDescription(nGlobDomain, nbServer); |
---|
| 1835 | std::vector<int> serverZeroIndex; |
---|
[1902] | 1836 | if (isUnstructed_) serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); |
---|
| 1837 | else serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); |
---|
[657] | 1838 | |
---|
[1346] | 1839 | std::list<int> serverZeroIndexLeader; |
---|
| 1840 | std::list<int> serverZeroIndexNotLeader; |
---|
| 1841 | CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader); |
---|
| 1842 | for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) |
---|
| 1843 | *it = serverZeroIndex[*it]; |
---|
[1232] | 1844 | |
---|
[1346] | 1845 | CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), |
---|
| 1846 | client->intraComm); |
---|
| 1847 | clientServerMap->computeServerIndexMapping(globalIndexDomain, nbServer); |
---|
| 1848 | CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); |
---|
[584] | 1849 | |
---|
[1346] | 1850 | CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), |
---|
| 1851 | ite = globalIndexDomainOnServer.end(); |
---|
| 1852 | indSrv_[nbServer].swap(globalIndexDomainOnServer); |
---|
| 1853 | connectedServerRank_[nbServer].clear(); |
---|
| 1854 | for (it = indSrv_[nbServer].begin(); it != ite; ++it) |
---|
| 1855 | connectedServerRank_[nbServer].push_back(it->first); |
---|
[584] | 1856 | |
---|
[1346] | 1857 | for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) |
---|
| 1858 | connectedServerRank_[nbServer].push_back(*it); |
---|
[1232] | 1859 | |
---|
[1346] | 1860 | // Even if a client has no index, it must connect to at least one server and |
---|
| 1861 | // send an "empty" data to this server |
---|
| 1862 | if (connectedServerRank_[nbServer].empty()) |
---|
| 1863 | connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); |
---|
[1232] | 1864 | |
---|
[1346] | 1865 | nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); |
---|
| 1866 | delete clientServerMap; |
---|
| 1867 | } |
---|
[1337] | 1868 | } |
---|
[1027] | 1869 | } |
---|
[300] | 1870 | } |
---|
[467] | 1871 | |
---|
[1144] | 1872 | /*! |
---|
| 1873 | Compute index to write data. We only write data on the zoomed region, therefore, there should |
---|
| 1874 | be a map between the complete grid and the reduced grid where we write data. |
---|
| 1875 | By using global index we can easily create this kind of mapping. |
---|
| 1876 | */ |
---|
[1129] | 1877 | void CDomain::computeWrittenIndex() |
---|
| 1878 | { |
---|
| 1879 | if (computedWrittenIndex_) return; |
---|
| 1880 | computedWrittenIndex_ = true; |
---|
| 1881 | |
---|
[1143] | 1882 | CContext* context=CContext::getCurrent(); |
---|
| 1883 | CContextServer* server = context->server; |
---|
[1129] | 1884 | |
---|
| 1885 | std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); |
---|
| 1886 | nBegin[0] = zoom_ibegin; nBegin[1] = zoom_jbegin; |
---|
| 1887 | nSize[0] = zoom_ni; nSize[1] = zoom_nj; |
---|
| 1888 | nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; |
---|
| 1889 | nGlob[0] = ni_glo; nGlob[1] = nj_glo; |
---|
[1143] | 1890 | CDistributionServer srvDist(server->intraCommSize, nBegin, nSize, nBeginGlobal, nGlob); |
---|
[1129] | 1891 | const CArray<size_t,1>& writtenGlobalIndex = srvDist.getGlobalIndex(); |
---|
| 1892 | |
---|
| 1893 | size_t nbWritten = 0, indGlo; |
---|
| 1894 | boost::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), |
---|
| 1895 | ite = globalLocalIndexMap_.end(), it; |
---|
| 1896 | CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), |
---|
| 1897 | itSrve = writtenGlobalIndex.end(), itSrv; |
---|
[1143] | 1898 | |
---|
[1390] | 1899 | localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); |
---|
[1143] | 1900 | nbWritten = 0; |
---|
| 1901 | for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) |
---|
| 1902 | { |
---|
| 1903 | indGlo = *itSrv; |
---|
| 1904 | if (ite != globalLocalIndexMap_.find(indGlo)) |
---|
[1129] | 1905 | { |
---|
| 1906 | localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; |
---|
[1390] | 1907 | } |
---|
| 1908 | else |
---|
| 1909 | { |
---|
[1624] | 1910 | localIndexToWriteOnServer(nbWritten) = -1; |
---|
[1390] | 1911 | } |
---|
[1624] | 1912 | ++nbWritten; |
---|
[1129] | 1913 | } |
---|
[1249] | 1914 | } |
---|
| 1915 | |
---|
| 1916 | void CDomain::computeWrittenCompressedIndex(MPI_Comm writtenComm) |
---|
| 1917 | { |
---|
| 1918 | int writtenCommSize; |
---|
| 1919 | MPI_Comm_size(writtenComm, &writtenCommSize); |
---|
| 1920 | if (compressedIndexToWriteOnServer.find(writtenCommSize) != compressedIndexToWriteOnServer.end()) |
---|
| 1921 | return; |
---|
| 1922 | |
---|
| 1923 | if (isCompressible()) |
---|
| 1924 | { |
---|
| 1925 | size_t nbWritten = 0, indGlo; |
---|
| 1926 | CContext* context=CContext::getCurrent(); |
---|
| 1927 | CContextServer* server = context->server; |
---|
| 1928 | |
---|
| 1929 | std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); |
---|
| 1930 | nBegin[0] = zoom_ibegin; nBegin[1] = zoom_jbegin; |
---|
| 1931 | nSize[0] = zoom_ni; nSize[1] = zoom_nj; |
---|
| 1932 | nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; |
---|
| 1933 | nGlob[0] = ni_glo; nGlob[1] = nj_glo; |
---|
| 1934 | CDistributionServer srvDist(server->intraCommSize, nBegin, nSize, nBeginGlobal, nGlob); |
---|
| 1935 | const CArray<size_t,1>& writtenGlobalIndex = srvDist.getGlobalIndex(); |
---|
| 1936 | |
---|
| 1937 | boost::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), |
---|
| 1938 | ite = globalLocalIndexMap_.end(), it; |
---|
| 1939 | CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), |
---|
| 1940 | itSrve = writtenGlobalIndex.end(), itSrv; |
---|
| 1941 | boost::unordered_map<size_t,size_t> localGlobalIndexMap; |
---|
| 1942 | for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) |
---|
[1143] | 1943 | { |
---|
[1249] | 1944 | indGlo = *itSrv; |
---|
| 1945 | if (ite != globalLocalIndexMap_.find(indGlo)) |
---|
[1143] | 1946 | { |
---|
[1249] | 1947 | localGlobalIndexMap[localIndexToWriteOnServer(nbWritten)] = indGlo; |
---|
| 1948 | ++nbWritten; |
---|
| 1949 | } |
---|
| 1950 | } |
---|
[1143] | 1951 | |
---|
[1249] | 1952 | nbWritten = 0; |
---|
| 1953 | for (int idx = 0; idx < data_i_index.numElements(); ++idx) |
---|
| 1954 | { |
---|
| 1955 | if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_i_index(idx))) |
---|
[1143] | 1956 | { |
---|
[1249] | 1957 | ++nbWritten; |
---|
[1143] | 1958 | } |
---|
[1249] | 1959 | } |
---|
[1143] | 1960 | |
---|
[1249] | 1961 | compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); |
---|
| 1962 | nbWritten = 0; |
---|
| 1963 | for (int idx = 0; idx < data_i_index.numElements(); ++idx) |
---|
| 1964 | { |
---|
| 1965 | if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_i_index(idx))) |
---|
[1143] | 1966 | { |
---|
[1249] | 1967 | compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_i_index(idx)]; |
---|
| 1968 | ++nbWritten; |
---|
[1143] | 1969 | } |
---|
[1249] | 1970 | } |
---|
[1143] | 1971 | |
---|
[1249] | 1972 | numberWrittenIndexes_[writtenCommSize] = nbWritten; |
---|
| 1973 | if (isDistributed()) |
---|
| 1974 | { |
---|
| 1975 | |
---|
| 1976 | MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm); |
---|
| 1977 | MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm); |
---|
| 1978 | offsetWrittenIndexes_[writtenCommSize] -= numberWrittenIndexes_[writtenCommSize]; |
---|
| 1979 | } |
---|
| 1980 | else |
---|
| 1981 | totalNumberWrittenIndexes_[writtenCommSize] = numberWrittenIndexes_[writtenCommSize]; |
---|
| 1982 | } |
---|
| 1983 | } |
---|
[1129] | 1984 | |
---|
[667] | 1985 | /*! |
---|
[1025] | 1986 | Send all attributes from client to connected clients |
---|
| 1987 | The attributes will be rebuilt on receiving side |
---|
[667] | 1988 | */ |
---|
[1025] | 1989 | void CDomain::sendAttributes() |
---|
| 1990 | { |
---|
[1054] | 1991 | sendDistributionAttributes(); |
---|
[1236] | 1992 | sendIndex(); |
---|
[1025] | 1993 | sendMask(); |
---|
| 1994 | sendLonLat(); |
---|
| 1995 | sendArea(); |
---|
| 1996 | sendDataIndex(); |
---|
| 1997 | } |
---|
| 1998 | |
---|
| 1999 | /*! |
---|
| 2000 | Send global index and zoom index from client to connected client(s) |
---|
| 2001 | zoom index can be smaller than global index |
---|
| 2002 | */ |
---|
[665] | 2003 | void CDomain::sendIndex() |
---|
[300] | 2004 | { |
---|
[610] | 2005 | int ns, n, i, j, ind, nv, idx; |
---|
[1353] | 2006 | std::list<CContextClient*>::iterator it; |
---|
[1345] | 2007 | for (it=clients.begin(); it!=clients.end(); ++it) |
---|
| 2008 | { |
---|
| 2009 | CContextClient* client = *it; |
---|
[1099] | 2010 | |
---|
[1337] | 2011 | int serverSize = client->serverSize; |
---|
[1027] | 2012 | CEventClient eventIndex(getType(), EVENT_ID_INDEX); |
---|
[665] | 2013 | |
---|
[1027] | 2014 | list<CMessage> list_msgsIndex; |
---|
| 2015 | list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; |
---|
[665] | 2016 | |
---|
[1129] | 2017 | boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; |
---|
[1337] | 2018 | iteIndex = indSrv_[serverSize].end(); |
---|
| 2019 | for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) |
---|
[1027] | 2020 | { |
---|
| 2021 | int nbIndGlob = 0; |
---|
[1337] | 2022 | int rank = connectedServerRank_[serverSize][k]; |
---|
| 2023 | itIndex = indSrv_[serverSize].find(rank); |
---|
[1027] | 2024 | if (iteIndex != itIndex) |
---|
| 2025 | nbIndGlob = itIndex->second.size(); |
---|
[665] | 2026 | |
---|
[1129] | 2027 | list_indGlob.push_back(CArray<int,1>(nbIndGlob)); |
---|
[665] | 2028 | |
---|
[1027] | 2029 | CArray<int,1>& indGlob = list_indGlob.back(); |
---|
| 2030 | for (n = 0; n < nbIndGlob; ++n) |
---|
| 2031 | { |
---|
| 2032 | indGlob(n) = static_cast<int>(itIndex->second[n]); |
---|
| 2033 | } |
---|
[665] | 2034 | |
---|
[1027] | 2035 | list_msgsIndex.push_back(CMessage()); |
---|
| 2036 | list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix |
---|
| 2037 | list_msgsIndex.back() << isCurvilinear; |
---|
[1129] | 2038 | list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); |
---|
[1099] | 2039 | |
---|
[1337] | 2040 | eventIndex.push(rank, nbSenders[serverSize][rank], list_msgsIndex.back()); |
---|
[1027] | 2041 | } |
---|
| 2042 | |
---|
| 2043 | client->sendEvent(eventIndex); |
---|
[665] | 2044 | } |
---|
| 2045 | } |
---|
| 2046 | |
---|
[667] | 2047 | /*! |
---|
[1099] | 2048 | Send distribution from client to other clients |
---|
| 2049 | Because a client in a level knows correctly the grid distribution of client on the next level |
---|
| 2050 | it calculates this distribution then sends it to the corresponding clients on the next level |
---|
| 2051 | */ |
---|
| 2052 | void CDomain::sendDistributionAttributes(void) |
---|
| 2053 | { |
---|
[1353] | 2054 | std::list<CContextClient*>::iterator it; |
---|
[1345] | 2055 | for (it=clients.begin(); it!=clients.end(); ++it) |
---|
[1099] | 2056 | { |
---|
[1345] | 2057 | CContextClient* client = *it; |
---|
| 2058 | int nbServer = client->serverSize; |
---|
[1099] | 2059 | std::vector<int> nGlobDomain(2); |
---|
| 2060 | nGlobDomain[0] = this->ni_glo; |
---|
| 2061 | nGlobDomain[1] = this->nj_glo; |
---|
| 2062 | |
---|
| 2063 | CServerDistributionDescription serverDescription(nGlobDomain, nbServer); |
---|
| 2064 | if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); |
---|
| 2065 | else serverDescription.computeServerDistribution(false, 1); |
---|
| 2066 | |
---|
| 2067 | std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); |
---|
| 2068 | std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); |
---|
| 2069 | |
---|
| 2070 | CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); |
---|
[1345] | 2071 | if (client->isServerLeader()) |
---|
[1099] | 2072 | { |
---|
| 2073 | std::list<CMessage> msgs; |
---|
| 2074 | |
---|
[1345] | 2075 | const std::list<int>& ranks = client->getRanksServerLeader(); |
---|
[1099] | 2076 | for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) |
---|
| 2077 | { |
---|
| 2078 | // Use const int to ensure CMessage holds a copy of the value instead of just a reference |
---|
| 2079 | const int ibegin_srv = serverIndexBegin[*itRank][0]; |
---|
| 2080 | const int jbegin_srv = serverIndexBegin[*itRank][1]; |
---|
| 2081 | const int ni_srv = serverDimensionSizes[*itRank][0]; |
---|
| 2082 | const int nj_srv = serverDimensionSizes[*itRank][1]; |
---|
| 2083 | |
---|
| 2084 | msgs.push_back(CMessage()); |
---|
| 2085 | CMessage& msg = msgs.back(); |
---|
| 2086 | msg << this->getId() ; |
---|
[1364] | 2087 | msg << isUnstructed_; |
---|
[1099] | 2088 | msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; |
---|
| 2089 | msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue(); |
---|
| 2090 | msg << isCompressible_; |
---|
| 2091 | |
---|
| 2092 | event.push(*itRank,1,msg); |
---|
| 2093 | } |
---|
[1345] | 2094 | client->sendEvent(event); |
---|
[1099] | 2095 | } |
---|
[1345] | 2096 | else client->sendEvent(event); |
---|
[1099] | 2097 | } |
---|
| 2098 | } |
---|
| 2099 | |
---|
| 2100 | /*! |
---|
[1144] | 2101 | Send mask index from client to connected(s) clients |
---|
[667] | 2102 | */ |
---|
[1025] | 2103 | void CDomain::sendMask() |
---|
| 2104 | { |
---|
| 2105 | int ns, n, i, j, ind, nv, idx; |
---|
[1353] | 2106 | std::list<CContextClient*>::iterator it; |
---|
[1345] | 2107 | for (it=clients.begin(); it!=clients.end(); ++it) |
---|
[1027] | 2108 | { |
---|
[1345] | 2109 | CContextClient* client = *it; |
---|
[1337] | 2110 | int serverSize = client->serverSize; |
---|
[1025] | 2111 | |
---|
[1027] | 2112 | // send area for each connected server |
---|
| 2113 | CEventClient eventMask(getType(), EVENT_ID_MASK); |
---|
[1025] | 2114 | |
---|
[1027] | 2115 | list<CMessage> list_msgsMask; |
---|
| 2116 | list<CArray<bool,1> > list_mask; |
---|
[1025] | 2117 | |
---|
[1027] | 2118 | boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; |
---|
[1337] | 2119 | iteMap = indSrv_[serverSize].end(); |
---|
| 2120 | for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) |
---|
[1027] | 2121 | { |
---|
| 2122 | int nbData = 0; |
---|
[1337] | 2123 | int rank = connectedServerRank_[serverSize][k]; |
---|
| 2124 | it = indSrv_[serverSize].find(rank); |
---|
[1027] | 2125 | if (iteMap != it) |
---|
| 2126 | nbData = it->second.size(); |
---|
| 2127 | list_mask.push_back(CArray<bool,1>(nbData)); |
---|
[1025] | 2128 | |
---|
[1027] | 2129 | const std::vector<size_t>& temp = it->second; |
---|
| 2130 | for (n = 0; n < nbData; ++n) |
---|
| 2131 | { |
---|
| 2132 | idx = static_cast<int>(it->second[n]); |
---|
[1311] | 2133 | list_mask.back()(n) = domainMask(globalLocalIndexMap_[idx]); |
---|
[1027] | 2134 | } |
---|
| 2135 | |
---|
| 2136 | list_msgsMask.push_back(CMessage()); |
---|
| 2137 | list_msgsMask.back() << this->getId() << list_mask.back(); |
---|
[1337] | 2138 | eventMask.push(rank, nbSenders[serverSize][rank], list_msgsMask.back()); |
---|
[1025] | 2139 | } |
---|
[1027] | 2140 | client->sendEvent(eventMask); |
---|
[1025] | 2141 | } |
---|
| 2142 | } |
---|
| 2143 | |
---|
| 2144 | /*! |
---|
| 2145 | Send area from client to connected client(s) |
---|
| 2146 | */ |
---|
[665] | 2147 | void CDomain::sendArea() |
---|
| 2148 | { |
---|
| 2149 | if (!hasArea) return; |
---|
| 2150 | |
---|
| 2151 | int ns, n, i, j, ind, nv, idx; |
---|
[1353] | 2152 | std::list<CContextClient*>::iterator it; |
---|
[1099] | 2153 | |
---|
[1345] | 2154 | for (it=clients.begin(); it!=clients.end(); ++it) |
---|
[1027] | 2155 | { |
---|
[1345] | 2156 | CContextClient* client = *it; |
---|
[1337] | 2157 | int serverSize = client->serverSize; |
---|
[665] | 2158 | |
---|
[1027] | 2159 | // send area for each connected server |
---|
| 2160 | CEventClient eventArea(getType(), EVENT_ID_AREA); |
---|
[665] | 2161 | |
---|
[1027] | 2162 | list<CMessage> list_msgsArea; |
---|
| 2163 | list<CArray<double,1> > list_area; |
---|
[665] | 2164 | |
---|
[1027] | 2165 | boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; |
---|
[1337] | 2166 | iteMap = indSrv_[serverSize].end(); |
---|
| 2167 | for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) |
---|
[1027] | 2168 | { |
---|
| 2169 | int nbData = 0; |
---|
[1337] | 2170 | int rank = connectedServerRank_[serverSize][k]; |
---|
| 2171 | it = indSrv_[serverSize].find(rank); |
---|
[1027] | 2172 | if (iteMap != it) |
---|
| 2173 | nbData = it->second.size(); |
---|
| 2174 | list_area.push_back(CArray<double,1>(nbData)); |
---|
[665] | 2175 | |
---|
[1027] | 2176 | const std::vector<size_t>& temp = it->second; |
---|
| 2177 | for (n = 0; n < nbData; ++n) |
---|
| 2178 | { |
---|
| 2179 | idx = static_cast<int>(it->second[n]); |
---|
| 2180 | list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]); |
---|
| 2181 | } |
---|
| 2182 | |
---|
| 2183 | list_msgsArea.push_back(CMessage()); |
---|
| 2184 | list_msgsArea.back() << this->getId() << hasArea; |
---|
| 2185 | list_msgsArea.back() << list_area.back(); |
---|
[1337] | 2186 | eventArea.push(rank, nbSenders[serverSize][rank], list_msgsArea.back()); |
---|
[665] | 2187 | } |
---|
[1027] | 2188 | client->sendEvent(eventArea); |
---|
[665] | 2189 | } |
---|
| 2190 | } |
---|
| 2191 | |
---|
[667] | 2192 | /*! |
---|
| 2193 | Send longitude and latitude from client to servers |
---|
[1144] | 2194 | Each client send long and lat information to corresponding connected clients(s). |
---|
[667] | 2195 | Because longitude and latitude are optional, this function only called if latitude and longitude exist |
---|
| 2196 | */ |
---|
[665] | 2197 | void CDomain::sendLonLat() |
---|
| 2198 | { |
---|
| 2199 | if (!hasLonLat) return; |
---|
| 2200 | |
---|
| 2201 | int ns, n, i, j, ind, nv, idx; |
---|
[1353] | 2202 | std::list<CContextClient*>::iterator it; |
---|
[1345] | 2203 | for (it=clients.begin(); it!=clients.end(); ++it) |
---|
[300] | 2204 | { |
---|
[1345] | 2205 | CContextClient* client = *it; |
---|
[1337] | 2206 | int serverSize = client->serverSize; |
---|
[584] | 2207 | |
---|
[1027] | 2208 | // send lon lat for each connected server |
---|
| 2209 | CEventClient eventLon(getType(), EVENT_ID_LON); |
---|
| 2210 | CEventClient eventLat(getType(), EVENT_ID_LAT); |
---|
[509] | 2211 | |
---|
[1027] | 2212 | list<CMessage> list_msgsLon, list_msgsLat; |
---|
| 2213 | list<CArray<double,1> > list_lon, list_lat; |
---|
| 2214 | list<CArray<double,2> > list_boundslon, list_boundslat; |
---|
[610] | 2215 | |
---|
[1027] | 2216 | boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; |
---|
[1337] | 2217 | iteMap = indSrv_[serverSize].end(); |
---|
| 2218 | for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) |
---|
[467] | 2219 | { |
---|
[1027] | 2220 | int nbData = 0; |
---|
[1337] | 2221 | int rank = connectedServerRank_[serverSize][k]; |
---|
| 2222 | it = indSrv_[serverSize].find(rank); |
---|
[1027] | 2223 | if (iteMap != it) |
---|
| 2224 | nbData = it->second.size(); |
---|
[509] | 2225 | |
---|
[1027] | 2226 | list_lon.push_back(CArray<double,1>(nbData)); |
---|
| 2227 | list_lat.push_back(CArray<double,1>(nbData)); |
---|
| 2228 | |
---|
[467] | 2229 | if (hasBounds) |
---|
[300] | 2230 | { |
---|
[1027] | 2231 | list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); |
---|
| 2232 | list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); |
---|
| 2233 | } |
---|
[610] | 2234 | |
---|
[1027] | 2235 | CArray<double,1>& lon = list_lon.back(); |
---|
| 2236 | CArray<double,1>& lat = list_lat.back(); |
---|
| 2237 | const std::vector<size_t>& temp = it->second; |
---|
| 2238 | for (n = 0; n < nbData; ++n) |
---|
| 2239 | { |
---|
| 2240 | idx = static_cast<int>(it->second[n]); |
---|
| 2241 | int localInd = globalLocalIndexMap_[idx]; |
---|
| 2242 | lon(n) = lonvalue(localInd); |
---|
| 2243 | lat(n) = latvalue(localInd); |
---|
| 2244 | |
---|
| 2245 | if (hasBounds) |
---|
[449] | 2246 | { |
---|
[1027] | 2247 | CArray<double,2>& boundslon = list_boundslon.back(); |
---|
| 2248 | CArray<double,2>& boundslat = list_boundslat.back(); |
---|
| 2249 | |
---|
| 2250 | for (nv = 0; nv < nvertex; ++nv) |
---|
| 2251 | { |
---|
| 2252 | boundslon(nv, n) = bounds_lonvalue(nv, localInd); |
---|
| 2253 | boundslat(nv, n) = bounds_latvalue(nv, localInd); |
---|
| 2254 | } |
---|
[449] | 2255 | } |
---|
[300] | 2256 | } |
---|
[509] | 2257 | |
---|
[1027] | 2258 | list_msgsLon.push_back(CMessage()); |
---|
| 2259 | list_msgsLat.push_back(CMessage()); |
---|
[518] | 2260 | |
---|
[1129] | 2261 | list_msgsLon.back() << this->getId() << hasLonLat; |
---|
| 2262 | if (hasLonLat) |
---|
| 2263 | list_msgsLon.back() << list_lon.back(); |
---|
| 2264 | list_msgsLon.back() << hasBounds; |
---|
[1027] | 2265 | if (hasBounds) |
---|
| 2266 | { |
---|
| 2267 | list_msgsLon.back() << list_boundslon.back(); |
---|
[1129] | 2268 | } |
---|
| 2269 | |
---|
| 2270 | list_msgsLat.back() << this->getId() << hasLonLat; |
---|
| 2271 | if (hasLonLat) |
---|
| 2272 | list_msgsLat.back() << list_lat.back(); |
---|
| 2273 | list_msgsLat.back() << hasBounds; |
---|
| 2274 | if (hasBounds) |
---|
| 2275 | { |
---|
[1027] | 2276 | list_msgsLat.back() << list_boundslat.back(); |
---|
| 2277 | } |
---|
| 2278 | |
---|
[1337] | 2279 | eventLon.push(rank, nbSenders[serverSize][rank], list_msgsLon.back()); |
---|
| 2280 | eventLat.push(rank, nbSenders[serverSize][rank], list_msgsLat.back()); |
---|
[518] | 2281 | } |
---|
[1027] | 2282 | client->sendEvent(eventLon); |
---|
| 2283 | client->sendEvent(eventLat); |
---|
[300] | 2284 | } |
---|
| 2285 | } |
---|
[509] | 2286 | |
---|
[667] | 2287 | /*! |
---|
[1025] | 2288 | Send data index to corresponding connected clients. |
---|
| 2289 | Data index can be compressed however, we always send decompressed data index |
---|
| 2290 | and they will be compressed on receiving. |
---|
[1144] | 2291 | The compressed index are represented with 1 and others are represented with -1 |
---|
[667] | 2292 | */ |
---|
[1025] | 2293 | void CDomain::sendDataIndex() |
---|
[665] | 2294 | { |
---|
[1025] | 2295 | int ns, n, i, j, ind, nv, idx; |
---|
[1353] | 2296 | std::list<CContextClient*>::iterator it; |
---|
[1345] | 2297 | for (it=clients.begin(); it!=clients.end(); ++it) |
---|
| 2298 | { |
---|
| 2299 | CContextClient* client = *it; |
---|
[1099] | 2300 | |
---|
[1337] | 2301 | int serverSize = client->serverSize; |
---|
[1025] | 2302 | |
---|
[1027] | 2303 | // send area for each connected server |
---|
| 2304 | CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); |
---|
[1025] | 2305 | |
---|
[1027] | 2306 | list<CMessage> list_msgsDataIndex; |
---|
| 2307 | list<CArray<int,1> > list_data_i_index, list_data_j_index; |
---|
[1025] | 2308 | |
---|
[1027] | 2309 | int nbIndex = i_index.numElements(); |
---|
[1129] | 2310 | int niByIndex = max(i_index) - min(i_index) + 1; |
---|
| 2311 | int njByIndex = max(j_index) - min(j_index) + 1; |
---|
| 2312 | int dataIindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : niByIndex; |
---|
| 2313 | int dataJindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : njByIndex; |
---|
| 2314 | |
---|
| 2315 | |
---|
[1027] | 2316 | CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); |
---|
[1129] | 2317 | dataIIndex = -1; |
---|
| 2318 | dataJIndex = -1; |
---|
| 2319 | ind = 0; |
---|
| 2320 | |
---|
[1027] | 2321 | for (idx = 0; idx < data_i_index.numElements(); ++idx) |
---|
[1025] | 2322 | { |
---|
[1129] | 2323 | int dataIidx = data_i_index(idx) + data_ibegin; |
---|
| 2324 | int dataJidx = data_j_index(idx) + data_jbegin; |
---|
| 2325 | if ((0 <= dataIidx) && (dataIidx < dataIindexBound) && |
---|
| 2326 | (0 <= dataJidx) && (dataJidx < dataJindexBound)) |
---|
[1027] | 2327 | { |
---|
[1129] | 2328 | dataIIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //i_index(dataIidx);//dataIidx; |
---|
| 2329 | dataJIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //j_index(dataJidx);// |
---|
[1027] | 2330 | } |
---|
[1025] | 2331 | } |
---|
| 2332 | |
---|
[1027] | 2333 | boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; |
---|
[1337] | 2334 | iteMap = indSrv_[serverSize].end(); |
---|
| 2335 | for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) |
---|
[1027] | 2336 | { |
---|
| 2337 | int nbData = 0; |
---|
[1337] | 2338 | int rank = connectedServerRank_[serverSize][k]; |
---|
| 2339 | it = indSrv_[serverSize].find(rank); |
---|
[1027] | 2340 | if (iteMap != it) |
---|
| 2341 | nbData = it->second.size(); |
---|
| 2342 | list_data_i_index.push_back(CArray<int,1>(nbData)); |
---|
| 2343 | list_data_j_index.push_back(CArray<int,1>(nbData)); |
---|
[1025] | 2344 | |
---|
[1027] | 2345 | const std::vector<size_t>& temp = it->second; |
---|
| 2346 | for (n = 0; n < nbData; ++n) |
---|
| 2347 | { |
---|
| 2348 | idx = static_cast<int>(it->second[n]); |
---|
| 2349 | i = globalLocalIndexMap_[idx]; |
---|
| 2350 | list_data_i_index.back()(n) = dataIIndex(i); |
---|
| 2351 | list_data_j_index.back()(n) = dataJIndex(i); |
---|
| 2352 | } |
---|
| 2353 | |
---|
| 2354 | list_msgsDataIndex.push_back(CMessage()); |
---|
| 2355 | list_msgsDataIndex.back() << this->getId(); |
---|
| 2356 | list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); |
---|
[1337] | 2357 | eventDataIndex.push(rank, nbSenders[serverSize][rank], list_msgsDataIndex.back()); |
---|
[1025] | 2358 | } |
---|
[1027] | 2359 | client->sendEvent(eventDataIndex); |
---|
[1025] | 2360 | } |
---|
[665] | 2361 | } |
---|
[1025] | 2362 | |
---|
[300] | 2363 | bool CDomain::dispatchEvent(CEventServer& event) |
---|
[610] | 2364 | { |
---|
| 2365 | if (SuperClass::dispatchEvent(event)) return true; |
---|
| 2366 | else |
---|
| 2367 | { |
---|
| 2368 | switch(event.type) |
---|
[300] | 2369 | { |
---|
[610] | 2370 | case EVENT_ID_SERVER_ATTRIBUT: |
---|
[1025] | 2371 | recvDistributionAttributes(event); |
---|
[610] | 2372 | return true; |
---|
| 2373 | break; |
---|
| 2374 | case EVENT_ID_INDEX: |
---|
| 2375 | recvIndex(event); |
---|
| 2376 | return true; |
---|
| 2377 | break; |
---|
[1025] | 2378 | case EVENT_ID_MASK: |
---|
| 2379 | recvMask(event); |
---|
| 2380 | return true; |
---|
| 2381 | break; |
---|
[610] | 2382 | case EVENT_ID_LON: |
---|
| 2383 | recvLon(event); |
---|
| 2384 | return true; |
---|
| 2385 | break; |
---|
| 2386 | case EVENT_ID_LAT: |
---|
| 2387 | recvLat(event); |
---|
| 2388 | return true; |
---|
| 2389 | break; |
---|
[611] | 2390 | case EVENT_ID_AREA: |
---|
| 2391 | recvArea(event); |
---|
| 2392 | return true; |
---|
[1025] | 2393 | break; |
---|
| 2394 | case EVENT_ID_DATA_INDEX: |
---|
| 2395 | recvDataIndex(event); |
---|
| 2396 | return true; |
---|
[611] | 2397 | break; |
---|
[610] | 2398 | default: |
---|
[762] | 2399 | ERROR("bool CDomain::dispatchEvent(CEventServer& event)", |
---|
[610] | 2400 | << "Unknown Event"); |
---|
| 2401 | return false; |
---|
| 2402 | } |
---|
| 2403 | } |
---|
| 2404 | } |
---|
[509] | 2405 | |
---|
[667] | 2406 | /*! |
---|
[1025] | 2407 | Receive index event from clients(s) |
---|
| 2408 | \param[in] event event contain info about rank and associated index |
---|
| 2409 | */ |
---|
| 2410 | void CDomain::recvIndex(CEventServer& event) |
---|
| 2411 | { |
---|
| 2412 | string domainId; |
---|
| 2413 | std::map<int, CBufferIn*> rankBuffers; |
---|
[821] | 2414 | |
---|
[1025] | 2415 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2416 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
| 2417 | { |
---|
| 2418 | CBufferIn* buffer = it->buffer; |
---|
| 2419 | *buffer >> domainId; |
---|
| 2420 | rankBuffers[it->rank] = buffer; |
---|
| 2421 | } |
---|
| 2422 | get(domainId)->recvIndex(rankBuffers); |
---|
| 2423 | } |
---|
[300] | 2424 | |
---|
[1025] | 2425 | /*! |
---|
[1144] | 2426 | Receive index information from client(s). We use the global index for mapping index between |
---|
| 2427 | sending clients and receiving clients. |
---|
[1025] | 2428 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
| 2429 | */ |
---|
| 2430 | void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) |
---|
| 2431 | { |
---|
[1249] | 2432 | int nbReceived = rankBuffers.size(), i, ind, index, type_int, iIndex, jIndex; |
---|
[1129] | 2433 | recvClientRanks_.resize(nbReceived); |
---|
[1025] | 2434 | |
---|
| 2435 | std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); |
---|
| 2436 | ind = 0; |
---|
| 2437 | for (ind = 0; it != ite; ++it, ++ind) |
---|
| 2438 | { |
---|
| 2439 | recvClientRanks_[ind] = it->first; |
---|
| 2440 | CBufferIn& buffer = *(it->second); |
---|
[1129] | 2441 | buffer >> type_int >> isCurvilinear >> indGlob_[it->first]; |
---|
[1025] | 2442 | type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix |
---|
| 2443 | } |
---|
| 2444 | int nbIndGlob = 0; |
---|
| 2445 | for (i = 0; i < nbReceived; ++i) |
---|
[300] | 2446 | { |
---|
[1025] | 2447 | nbIndGlob += indGlob_[recvClientRanks_[i]].numElements(); |
---|
[300] | 2448 | } |
---|
[1025] | 2449 | |
---|
[1202] | 2450 | globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); |
---|
[1624] | 2451 | // i_index.resize(nbIndGlob); |
---|
| 2452 | // j_index.resize(nbIndGlob); |
---|
| 2453 | i_index.resize(ni*nj); |
---|
| 2454 | j_index.resize(ni*nj); |
---|
| 2455 | i_index = -1; |
---|
| 2456 | j_index = -1; |
---|
[1249] | 2457 | int nbIndexGlobMax = nbIndGlob, nbIndLoc; |
---|
| 2458 | |
---|
[1025] | 2459 | nbIndGlob = 0; |
---|
| 2460 | for (i = 0; i < nbReceived; ++i) |
---|
[456] | 2461 | { |
---|
[1025] | 2462 | CArray<int,1>& tmp = indGlob_[recvClientRanks_[i]]; |
---|
| 2463 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2464 | { |
---|
| 2465 | index = tmp(ind); |
---|
[1202] | 2466 | if (0 == globalLocalIndexMap_.count(index)) |
---|
| 2467 | { |
---|
[1249] | 2468 | iIndex = (index%ni_glo)-ibegin; |
---|
| 2469 | iIndex = (iIndex < 0) ? 0 : iIndex; |
---|
| 2470 | jIndex = (index/ni_glo)-jbegin; |
---|
| 2471 | jIndex = (jIndex < 0) ? 0 : jIndex; |
---|
| 2472 | nbIndLoc = iIndex + ni * jIndex; |
---|
[1624] | 2473 | i_index(nbIndLoc) = index % ni_glo; |
---|
| 2474 | j_index(nbIndLoc) = index / ni_glo; |
---|
| 2475 | globalLocalIndexMap_[index] = nbIndLoc; |
---|
| 2476 | // i_index(nbIndGlob) = index % ni_glo; |
---|
| 2477 | // j_index(nbIndGlob) = index / ni_glo; |
---|
| 2478 | // globalLocalIndexMap_[index] = nbIndGlob; |
---|
| 2479 | ++nbIndGlob; |
---|
| 2480 | // if (nbIndLoc < nbIndexGlobMax) |
---|
| 2481 | // { |
---|
| 2482 | // i_index(nbIndLoc) = index % ni_glo; |
---|
| 2483 | // j_index(nbIndLoc) = index / ni_glo; |
---|
| 2484 | // globalLocalIndexMap_[index] = nbIndLoc; |
---|
| 2485 | // ++nbIndGlob; |
---|
| 2486 | // } |
---|
| 2487 | // // i_index(nbIndGlob) = index % ni_glo; |
---|
| 2488 | // // j_index(nbIndGlob) = index / ni_glo; |
---|
| 2489 | // // globalLocalIndexMap_[index] = nbIndGlob; |
---|
| 2490 | // // ++nbIndGlob; |
---|
[1202] | 2491 | } |
---|
[1025] | 2492 | } |
---|
[1144] | 2493 | } |
---|
[1202] | 2494 | |
---|
[1624] | 2495 | // if (nbIndGlob==0) |
---|
| 2496 | // { |
---|
| 2497 | // i_index.resize(nbIndGlob); |
---|
| 2498 | // j_index.resize(nbIndGlob); |
---|
| 2499 | // } |
---|
| 2500 | // else |
---|
| 2501 | // { |
---|
| 2502 | // i_index.resizeAndPreserve(nbIndGlob); |
---|
| 2503 | // j_index.resizeAndPreserve(nbIndGlob); |
---|
| 2504 | // } |
---|
[300] | 2505 | } |
---|
[509] | 2506 | |
---|
[667] | 2507 | /*! |
---|
[1099] | 2508 | Receive attributes event from clients(s) |
---|
| 2509 | \param[in] event event contain info about rank and associated attributes |
---|
| 2510 | */ |
---|
| 2511 | void CDomain::recvDistributionAttributes(CEventServer& event) |
---|
| 2512 | { |
---|
| 2513 | CBufferIn* buffer=event.subEvents.begin()->buffer; |
---|
| 2514 | string domainId ; |
---|
| 2515 | *buffer>>domainId ; |
---|
| 2516 | get(domainId)->recvDistributionAttributes(*buffer); |
---|
| 2517 | } |
---|
| 2518 | |
---|
| 2519 | /*! |
---|
| 2520 | Receive attributes from client(s): zoom info and begin and n of each server |
---|
| 2521 | \param[in] rank rank of client source |
---|
| 2522 | \param[in] buffer message containing attributes info |
---|
| 2523 | */ |
---|
| 2524 | void CDomain::recvDistributionAttributes(CBufferIn& buffer) |
---|
| 2525 | { |
---|
| 2526 | int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; |
---|
| 2527 | int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; |
---|
[1364] | 2528 | buffer >> isUnstructed_ >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp |
---|
[1099] | 2529 | >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp |
---|
| 2530 | >> isCompressible_; |
---|
| 2531 | ni.setValue(ni_tmp); |
---|
| 2532 | ibegin.setValue(ibegin_tmp); |
---|
| 2533 | nj.setValue(nj_tmp); |
---|
| 2534 | jbegin.setValue(jbegin_tmp); |
---|
| 2535 | |
---|
| 2536 | global_zoom_ni.setValue(global_zoom_ni_tmp); |
---|
| 2537 | global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); |
---|
| 2538 | global_zoom_nj.setValue(global_zoom_nj_tmp); |
---|
| 2539 | global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); |
---|
| 2540 | |
---|
| 2541 | int iend = ibegin + ni - 1; |
---|
| 2542 | int jend = jbegin + nj - 1; |
---|
| 2543 | int zoom_iend_glob = global_zoom_ibegin + global_zoom_ni - 1; |
---|
| 2544 | int zoom_jend_glob = global_zoom_jbegin + global_zoom_nj - 1; |
---|
| 2545 | |
---|
[1509] | 2546 | zoom_ibegin.setValue(global_zoom_ibegin > ibegin ? global_zoom_ibegin.getValue() : ibegin); |
---|
[1099] | 2547 | int zoom_iend = zoom_iend_glob < iend ? zoom_iend_glob : iend ; |
---|
| 2548 | zoom_ni.setValue(zoom_iend-zoom_ibegin+1); |
---|
| 2549 | |
---|
[1509] | 2550 | zoom_jbegin.setValue(global_zoom_jbegin > jbegin ? global_zoom_jbegin.getValue() : jbegin); |
---|
[1099] | 2551 | int zoom_jend = zoom_jend_glob < jend ? zoom_jend_glob : jend ; |
---|
| 2552 | zoom_nj.setValue(zoom_jend-zoom_jbegin+1); |
---|
| 2553 | |
---|
| 2554 | if (zoom_ni<=0 || zoom_nj<=0) |
---|
| 2555 | { |
---|
[1249] | 2556 | zoom_ni=0 ; zoom_ibegin=global_zoom_ibegin ; //=0; zoom_iend=0 ; |
---|
| 2557 | zoom_nj=0 ; zoom_jbegin=global_zoom_jbegin ; //=0; zoom_jend=0 ; |
---|
[1099] | 2558 | } |
---|
| 2559 | |
---|
| 2560 | } |
---|
| 2561 | |
---|
| 2562 | /*! |
---|
[1025] | 2563 | Receive area event from clients(s) |
---|
| 2564 | \param[in] event event contain info about rank and associated area |
---|
[667] | 2565 | */ |
---|
[1025] | 2566 | void CDomain::recvMask(CEventServer& event) |
---|
[610] | 2567 | { |
---|
[1025] | 2568 | string domainId; |
---|
| 2569 | std::map<int, CBufferIn*> rankBuffers; |
---|
[676] | 2570 | |
---|
[610] | 2571 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2572 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[1025] | 2573 | { |
---|
[610] | 2574 | CBufferIn* buffer = it->buffer; |
---|
| 2575 | *buffer >> domainId; |
---|
[1025] | 2576 | rankBuffers[it->rank] = buffer; |
---|
[610] | 2577 | } |
---|
[1025] | 2578 | get(domainId)->recvMask(rankBuffers); |
---|
| 2579 | } |
---|
[676] | 2580 | |
---|
| 2581 | |
---|
[667] | 2582 | /*! |
---|
[1025] | 2583 | Receive mask information from client(s) |
---|
| 2584 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
[667] | 2585 | */ |
---|
[1025] | 2586 | void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) |
---|
[610] | 2587 | { |
---|
[1202] | 2588 | int nbReceived = rankBuffers.size(), i, ind, index, lInd; |
---|
[1025] | 2589 | if (nbReceived != recvClientRanks_.size()) |
---|
[1202] | 2590 | ERROR("void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers)", |
---|
[1025] | 2591 | << "The number of sending clients is not correct." |
---|
| 2592 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
[676] | 2593 | |
---|
[1025] | 2594 | vector<CArray<bool,1> > recvMaskValue(nbReceived); |
---|
| 2595 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
[676] | 2596 | { |
---|
[1025] | 2597 | int rank = recvClientRanks_[i]; |
---|
| 2598 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2599 | buffer >> recvMaskValue[i]; |
---|
[676] | 2600 | } |
---|
[1025] | 2601 | |
---|
| 2602 | int nbMaskInd = 0; |
---|
| 2603 | for (i = 0; i < nbReceived; ++i) |
---|
| 2604 | { |
---|
| 2605 | nbMaskInd += recvMaskValue[i].numElements(); |
---|
| 2606 | } |
---|
| 2607 | |
---|
[1202] | 2608 | if (nbMaskInd != globalLocalIndexMap_.size()) |
---|
[1509] | 2609 | info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " |
---|
| 2610 | << "something must be wrong with mask index "<< std::endl; |
---|
[1202] | 2611 | |
---|
| 2612 | nbMaskInd = globalLocalIndexMap_.size(); |
---|
[1624] | 2613 | // mask_1d.resize(nbMaskInd); |
---|
| 2614 | // domainMask.resize(nbMaskInd); |
---|
| 2615 | mask_1d.resize(ni*nj); |
---|
| 2616 | domainMask.resize(ni*nj); |
---|
[1249] | 2617 | mask_1d = false; |
---|
[1202] | 2618 | |
---|
[1025] | 2619 | for (i = 0; i < nbReceived; ++i) |
---|
| 2620 | { |
---|
[1202] | 2621 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
[1025] | 2622 | CArray<bool,1>& tmp = recvMaskValue[i]; |
---|
| 2623 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2624 | { |
---|
[1202] | 2625 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
[1232] | 2626 | if (!mask_1d(lInd)) // Only rewrite mask_1d if it's not true |
---|
| 2627 | mask_1d(lInd) = tmp(ind); |
---|
[1025] | 2628 | } |
---|
[1311] | 2629 | } |
---|
| 2630 | domainMask=mask_1d ; |
---|
[610] | 2631 | } |
---|
| 2632 | |
---|
[667] | 2633 | /*! |
---|
| 2634 | Receive longitude event from clients(s) |
---|
| 2635 | \param[in] event event contain info about rank and associated longitude |
---|
| 2636 | */ |
---|
[518] | 2637 | void CDomain::recvLon(CEventServer& event) |
---|
[300] | 2638 | { |
---|
[1025] | 2639 | string domainId; |
---|
| 2640 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2641 | |
---|
[610] | 2642 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2643 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[1025] | 2644 | { |
---|
[610] | 2645 | CBufferIn* buffer = it->buffer; |
---|
| 2646 | *buffer >> domainId; |
---|
[1025] | 2647 | rankBuffers[it->rank] = buffer; |
---|
[300] | 2648 | } |
---|
[1025] | 2649 | get(domainId)->recvLon(rankBuffers); |
---|
[300] | 2650 | } |
---|
[509] | 2651 | |
---|
[667] | 2652 | /*! |
---|
| 2653 | Receive longitude information from client(s) |
---|
[1025] | 2654 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
[667] | 2655 | */ |
---|
[1025] | 2656 | void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) |
---|
[300] | 2657 | { |
---|
[1129] | 2658 | int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; |
---|
[1025] | 2659 | if (nbReceived != recvClientRanks_.size()) |
---|
| 2660 | ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 2661 | << "The number of sending clients is not correct." |
---|
| 2662 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
[518] | 2663 | |
---|
[1025] | 2664 | vector<CArray<double,1> > recvLonValue(nbReceived); |
---|
| 2665 | vector<CArray<double,2> > recvBoundsLonValue(nbReceived); |
---|
| 2666 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
| 2667 | { |
---|
| 2668 | int rank = recvClientRanks_[i]; |
---|
| 2669 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2670 | buffer >> hasLonLat; |
---|
[1129] | 2671 | if (hasLonLat) |
---|
| 2672 | buffer >> recvLonValue[i]; |
---|
[1025] | 2673 | buffer >> hasBounds; |
---|
| 2674 | if (hasBounds) |
---|
| 2675 | buffer >> recvBoundsLonValue[i]; |
---|
| 2676 | } |
---|
[924] | 2677 | |
---|
[1129] | 2678 | if (hasLonLat) |
---|
[518] | 2679 | { |
---|
[1129] | 2680 | int nbLonInd = 0; |
---|
| 2681 | for (i = 0; i < nbReceived; ++i) |
---|
| 2682 | { |
---|
| 2683 | nbLonInd += recvLonValue[i].numElements(); |
---|
| 2684 | } |
---|
[1099] | 2685 | |
---|
[1129] | 2686 | if (nbLonInd != globalLocalIndexMap_.size()) |
---|
[1509] | 2687 | info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " |
---|
| 2688 | << "something must be wrong with longitude index "<< std::endl; |
---|
[1129] | 2689 | |
---|
[1202] | 2690 | nbLonInd = globalLocalIndexMap_.size(); |
---|
[1624] | 2691 | // lonvalue.resize(nbLonInd); |
---|
| 2692 | lonvalue.resize(ni*nj); |
---|
| 2693 | lonvalue = -1.0; |
---|
[1129] | 2694 | if (hasBounds) |
---|
[518] | 2695 | { |
---|
[1624] | 2696 | // bounds_lonvalue.resize(nvertex,nbLonInd); |
---|
| 2697 | // bounds_lonvalue = 0.; |
---|
| 2698 | bounds_lonvalue.resize(nvertex,ni*nj); |
---|
| 2699 | bounds_lonvalue = -1.0; |
---|
[518] | 2700 | } |
---|
[1129] | 2701 | |
---|
| 2702 | nbLonInd = 0; |
---|
| 2703 | for (i = 0; i < nbReceived; ++i) |
---|
| 2704 | { |
---|
| 2705 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
| 2706 | CArray<double,1>& tmp = recvLonValue[i]; |
---|
| 2707 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2708 | { |
---|
| 2709 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
| 2710 | lonvalue(lInd) = tmp(ind); |
---|
| 2711 | if (hasBounds) |
---|
| 2712 | { |
---|
| 2713 | for (int nv = 0; nv < nvertex; ++nv) |
---|
| 2714 | bounds_lonvalue(nv, lInd) = recvBoundsLonValue[i](nv, ind); |
---|
| 2715 | } |
---|
| 2716 | } |
---|
| 2717 | } |
---|
[518] | 2718 | } |
---|
| 2719 | } |
---|
| 2720 | |
---|
[667] | 2721 | /*! |
---|
| 2722 | Receive latitude event from clients(s) |
---|
| 2723 | \param[in] event event contain info about rank and associated latitude |
---|
| 2724 | */ |
---|
[518] | 2725 | void CDomain::recvLat(CEventServer& event) |
---|
| 2726 | { |
---|
[1025] | 2727 | string domainId; |
---|
| 2728 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2729 | |
---|
[610] | 2730 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2731 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[1025] | 2732 | { |
---|
[610] | 2733 | CBufferIn* buffer = it->buffer; |
---|
| 2734 | *buffer >> domainId; |
---|
[1025] | 2735 | rankBuffers[it->rank] = buffer; |
---|
[518] | 2736 | } |
---|
[1025] | 2737 | get(domainId)->recvLat(rankBuffers); |
---|
[518] | 2738 | } |
---|
| 2739 | |
---|
[667] | 2740 | /*! |
---|
| 2741 | Receive latitude information from client(s) |
---|
[1025] | 2742 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
[667] | 2743 | */ |
---|
[1025] | 2744 | void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) |
---|
[518] | 2745 | { |
---|
[1129] | 2746 | int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; |
---|
[1025] | 2747 | if (nbReceived != recvClientRanks_.size()) |
---|
| 2748 | ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 2749 | << "The number of sending clients is not correct." |
---|
| 2750 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
[509] | 2751 | |
---|
[1025] | 2752 | vector<CArray<double,1> > recvLatValue(nbReceived); |
---|
| 2753 | vector<CArray<double,2> > recvBoundsLatValue(nbReceived); |
---|
| 2754 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
| 2755 | { |
---|
| 2756 | int rank = recvClientRanks_[i]; |
---|
| 2757 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2758 | buffer >> hasLonLat; |
---|
[1129] | 2759 | if (hasLonLat) |
---|
| 2760 | buffer >> recvLatValue[i]; |
---|
[1025] | 2761 | buffer >> hasBounds; |
---|
| 2762 | if (hasBounds) |
---|
| 2763 | buffer >> recvBoundsLatValue[i]; |
---|
| 2764 | } |
---|
[610] | 2765 | |
---|
[1129] | 2766 | if (hasLonLat) |
---|
[1025] | 2767 | { |
---|
[1129] | 2768 | int nbLatInd = 0; |
---|
| 2769 | for (i = 0; i < nbReceived; ++i) |
---|
| 2770 | { |
---|
| 2771 | nbLatInd += recvLatValue[i].numElements(); |
---|
| 2772 | } |
---|
[1025] | 2773 | |
---|
[1129] | 2774 | if (nbLatInd != globalLocalIndexMap_.size()) |
---|
[1509] | 2775 | info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " |
---|
| 2776 | << "something must be wrong with latitude index "<< std::endl; |
---|
[1129] | 2777 | |
---|
[1202] | 2778 | nbLatInd = globalLocalIndexMap_.size(); |
---|
[1624] | 2779 | // latvalue.resize(nbLatInd); |
---|
| 2780 | latvalue.resize(ni*nj); |
---|
[1129] | 2781 | if (hasBounds) |
---|
[1099] | 2782 | { |
---|
[1624] | 2783 | // bounds_latvalue.resize(nvertex,nbLatInd); |
---|
| 2784 | // bounds_latvalue = 0. ; |
---|
| 2785 | bounds_latvalue.resize(nvertex,ni*nj); |
---|
| 2786 | bounds_latvalue = -1. ; |
---|
[449] | 2787 | } |
---|
[1129] | 2788 | |
---|
| 2789 | nbLatInd = 0; |
---|
| 2790 | for (i = 0; i < nbReceived; ++i) |
---|
| 2791 | { |
---|
| 2792 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
| 2793 | CArray<double,1>& tmp = recvLatValue[i]; |
---|
| 2794 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2795 | { |
---|
| 2796 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
| 2797 | latvalue(lInd) = tmp(ind); |
---|
| 2798 | if (hasBounds) |
---|
| 2799 | { |
---|
| 2800 | CArray<double,2>& boundslat = recvBoundsLatValue[i]; |
---|
| 2801 | for (int nv = 0; nv < nvertex; ++nv) |
---|
| 2802 | bounds_latvalue(nv, lInd) = boundslat(nv, ind); |
---|
| 2803 | } |
---|
| 2804 | ++nbLatInd; |
---|
| 2805 | } |
---|
| 2806 | } |
---|
[300] | 2807 | } |
---|
| 2808 | } |
---|
[553] | 2809 | |
---|
[667] | 2810 | /*! |
---|
| 2811 | Receive area event from clients(s) |
---|
| 2812 | \param[in] event event contain info about rank and associated area |
---|
| 2813 | */ |
---|
[611] | 2814 | void CDomain::recvArea(CEventServer& event) |
---|
| 2815 | { |
---|
[1025] | 2816 | string domainId; |
---|
| 2817 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2818 | |
---|
[611] | 2819 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2820 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[1025] | 2821 | { |
---|
[611] | 2822 | CBufferIn* buffer = it->buffer; |
---|
| 2823 | *buffer >> domainId; |
---|
[1025] | 2824 | rankBuffers[it->rank] = buffer; |
---|
[611] | 2825 | } |
---|
[1025] | 2826 | get(domainId)->recvArea(rankBuffers); |
---|
[611] | 2827 | } |
---|
| 2828 | |
---|
[667] | 2829 | /*! |
---|
| 2830 | Receive area information from client(s) |
---|
[1025] | 2831 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
[667] | 2832 | */ |
---|
[1025] | 2833 | void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) |
---|
[611] | 2834 | { |
---|
[1129] | 2835 | int nbReceived = rankBuffers.size(), i, ind, index, lInd; |
---|
[1025] | 2836 | if (nbReceived != recvClientRanks_.size()) |
---|
| 2837 | ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 2838 | << "The number of sending clients is not correct." |
---|
| 2839 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
[611] | 2840 | |
---|
[1025] | 2841 | vector<CArray<double,1> > recvAreaValue(nbReceived); |
---|
| 2842 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
| 2843 | { |
---|
| 2844 | int rank = recvClientRanks_[i]; |
---|
| 2845 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2846 | buffer >> hasArea; |
---|
| 2847 | if (hasArea) |
---|
| 2848 | buffer >> recvAreaValue[i]; |
---|
| 2849 | } |
---|
[611] | 2850 | |
---|
[1025] | 2851 | if (hasArea) |
---|
| 2852 | { |
---|
[1202] | 2853 | int nbAreaInd = 0; |
---|
| 2854 | for (i = 0; i < nbReceived; ++i) |
---|
| 2855 | { |
---|
| 2856 | nbAreaInd += recvAreaValue[i].numElements(); |
---|
| 2857 | } |
---|
| 2858 | |
---|
| 2859 | if (nbAreaInd != globalLocalIndexMap_.size()) |
---|
[1509] | 2860 | info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " |
---|
| 2861 | << "something must be wrong with area index "<< std::endl; |
---|
[1202] | 2862 | |
---|
| 2863 | nbAreaInd = globalLocalIndexMap_.size(); |
---|
[1624] | 2864 | // areavalue.resize(nbAreaInd); |
---|
| 2865 | // nbAreaInd = 0; |
---|
| 2866 | areavalue.resize(ni*nj); |
---|
| 2867 | nbAreaInd = -1.0; |
---|
[1025] | 2868 | for (i = 0; i < nbReceived; ++i) |
---|
| 2869 | { |
---|
[1129] | 2870 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
[1025] | 2871 | CArray<double,1>& tmp = recvAreaValue[i]; |
---|
| 2872 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2873 | { |
---|
[1129] | 2874 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
| 2875 | areavalue(lInd) = tmp(ind); |
---|
[1025] | 2876 | } |
---|
| 2877 | } |
---|
[1129] | 2878 | |
---|
[1025] | 2879 | } |
---|
[611] | 2880 | } |
---|
| 2881 | |
---|
[1025] | 2882 | /*! |
---|
[1158] | 2883 | Compare two domain objects. |
---|
| 2884 | They are equal if only if they have identical attributes as well as their values. |
---|
| 2885 | Moreover, they must have the same transformations. |
---|
| 2886 | \param [in] domain Compared domain |
---|
| 2887 | \return result of the comparison |
---|
| 2888 | */ |
---|
| 2889 | bool CDomain::isEqual(CDomain* obj) |
---|
| 2890 | { |
---|
| 2891 | vector<StdString> excludedAttr; |
---|
| 2892 | excludedAttr.push_back("domain_ref"); |
---|
| 2893 | bool objEqual = SuperClass::isEqual(obj, excludedAttr); |
---|
| 2894 | if (!objEqual) return objEqual; |
---|
| 2895 | |
---|
| 2896 | TransMapTypes thisTrans = this->getAllTransformations(); |
---|
| 2897 | TransMapTypes objTrans = obj->getAllTransformations(); |
---|
| 2898 | |
---|
| 2899 | TransMapTypes::const_iterator it, itb, ite; |
---|
| 2900 | std::vector<ETranformationType> thisTransType, objTransType; |
---|
| 2901 | for (it = thisTrans.begin(); it != thisTrans.end(); ++it) |
---|
| 2902 | thisTransType.push_back(it->first); |
---|
| 2903 | for (it = objTrans.begin(); it != objTrans.end(); ++it) |
---|
| 2904 | objTransType.push_back(it->first); |
---|
| 2905 | |
---|
| 2906 | if (thisTransType.size() != objTransType.size()) return false; |
---|
| 2907 | for (int idx = 0; idx < thisTransType.size(); ++idx) |
---|
| 2908 | objEqual &= (thisTransType[idx] == objTransType[idx]); |
---|
| 2909 | |
---|
| 2910 | return objEqual; |
---|
| 2911 | } |
---|
| 2912 | |
---|
| 2913 | /*! |
---|
[1025] | 2914 | Receive data index event from clients(s) |
---|
| 2915 | \param[in] event event contain info about rank and associated index |
---|
| 2916 | */ |
---|
| 2917 | void CDomain::recvDataIndex(CEventServer& event) |
---|
| 2918 | { |
---|
| 2919 | string domainId; |
---|
| 2920 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2921 | |
---|
| 2922 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2923 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
| 2924 | { |
---|
| 2925 | CBufferIn* buffer = it->buffer; |
---|
| 2926 | *buffer >> domainId; |
---|
| 2927 | rankBuffers[it->rank] = buffer; |
---|
| 2928 | } |
---|
| 2929 | get(domainId)->recvDataIndex(rankBuffers); |
---|
| 2930 | } |
---|
| 2931 | |
---|
| 2932 | /*! |
---|
| 2933 | Receive data index information from client(s) |
---|
| 2934 | A client receives data index from different clients to rebuild its own data index. |
---|
[1249] | 2935 | Because we use global index + mask info to calculate the sending data to client(s), |
---|
| 2936 | this data index must be updated with mask info (maybe it will change in the future) |
---|
[1025] | 2937 | Because the data index is local, to rebuild data index of received client, we should use global index along with. |
---|
[1249] | 2938 | |
---|
[1025] | 2939 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
| 2940 | */ |
---|
| 2941 | void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) |
---|
| 2942 | { |
---|
[1129] | 2943 | int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd; |
---|
[1025] | 2944 | if (nbReceived != recvClientRanks_.size()) |
---|
[1129] | 2945 | ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", |
---|
[1025] | 2946 | << "The number of sending clients is not correct." |
---|
| 2947 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
| 2948 | |
---|
| 2949 | vector<CArray<int,1> > recvDataIIndex(nbReceived),recvDataJIndex(nbReceived); |
---|
| 2950 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
| 2951 | { |
---|
| 2952 | int rank = recvClientRanks_[i]; |
---|
| 2953 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2954 | buffer >> recvDataIIndex[i]; |
---|
| 2955 | buffer >> recvDataJIndex[i]; |
---|
| 2956 | } |
---|
| 2957 | |
---|
[1129] | 2958 | int nbIndex = i_index.numElements(); |
---|
| 2959 | CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); |
---|
| 2960 | dataIIndex = -1; dataJIndex = -1; |
---|
[1143] | 2961 | |
---|
[1129] | 2962 | nbIndex = 0; |
---|
[1025] | 2963 | for (i = 0; i < nbReceived; ++i) |
---|
[1129] | 2964 | { |
---|
| 2965 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
| 2966 | CArray<int,1>& tmpI = recvDataIIndex[i]; |
---|
| 2967 | CArray<int,1>& tmpJ = recvDataJIndex[i]; |
---|
| 2968 | if ((tmpI.numElements() != tmpInd.numElements()) || (tmpJ.numElements() != tmpInd.numElements())) |
---|
| 2969 | ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 2970 | << "The number of global received index is not coherent with the number of received data index." |
---|
| 2971 | << "Expected number of global index: " << tmpI.numElements() << " but received " << tmpInd.numElements()); |
---|
| 2972 | |
---|
| 2973 | for (ind = 0; ind < tmpI.numElements(); ++ind) |
---|
[1025] | 2974 | { |
---|
[1129] | 2975 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
[1202] | 2976 | dataIIndex(lInd) = (-1 == dataIIndex(lInd)) ? tmpI(ind) : dataIIndex(lInd); // Only fill in dataIndex if there is no data |
---|
[1249] | 2977 | dataJIndex(lInd) = (-1 == dataJIndex(lInd)) ? tmpJ(ind) : dataJIndex(lInd); |
---|
[1129] | 2978 | } |
---|
[1025] | 2979 | } |
---|
| 2980 | |
---|
[1129] | 2981 | int nbCompressedData = 0; |
---|
| 2982 | for (ind = 0; ind < dataIIndex.numElements(); ++ind) |
---|
| 2983 | { |
---|
| 2984 | indexI = dataIIndex(ind); indexJ = dataJIndex(ind); |
---|
| 2985 | if ((0 <= indexI) && (0 <= indexJ)) |
---|
| 2986 | ++nbCompressedData; |
---|
| 2987 | } |
---|
| 2988 | |
---|
[1025] | 2989 | data_i_index.resize(nbCompressedData); |
---|
| 2990 | data_j_index.resize(nbCompressedData); |
---|
| 2991 | |
---|
[1129] | 2992 | nbCompressedData = 0; |
---|
| 2993 | for (ind = 0; ind < dataIIndex.numElements(); ++ind) |
---|
[1025] | 2994 | { |
---|
[1129] | 2995 | indexI = dataIIndex(ind); indexJ = dataJIndex(ind); |
---|
| 2996 | if ((0 <= indexI) && (0 <= indexJ)) |
---|
| 2997 | { |
---|
[1130] | 2998 | data_i_index(nbCompressedData) = (1 == data_dim) ? ind : ind % ni; |
---|
| 2999 | data_j_index(nbCompressedData) = (1 == data_dim) ? 0 : ind / ni; |
---|
[1129] | 3000 | ++nbCompressedData; |
---|
| 3001 | } |
---|
[1025] | 3002 | } |
---|
[1129] | 3003 | |
---|
| 3004 | // Reset data_ibegin, data_jbegin |
---|
| 3005 | data_ibegin.setValue(0); |
---|
| 3006 | data_jbegin.setValue(0); |
---|
[1025] | 3007 | } |
---|
| 3008 | |
---|
[836] | 3009 | CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) |
---|
| 3010 | { |
---|
| 3011 | transformationMap_.push_back(std::make_pair(transType, CTransformation<CDomain>::createTransformation(transType,id))); |
---|
| 3012 | return transformationMap_.back().second; |
---|
| 3013 | } |
---|
| 3014 | |
---|
[667] | 3015 | /*! |
---|
| 3016 | Check whether a domain has transformation |
---|
| 3017 | \return true if domain has transformation |
---|
| 3018 | */ |
---|
[631] | 3019 | bool CDomain::hasTransformation() |
---|
| 3020 | { |
---|
| 3021 | return (!transformationMap_.empty()); |
---|
| 3022 | } |
---|
| 3023 | |
---|
[667] | 3024 | /*! |
---|
| 3025 | Set transformation for current domain. It's the method to move transformation in hierarchy |
---|
| 3026 | \param [in] domTrans transformation on domain |
---|
| 3027 | */ |
---|
[631] | 3028 | void CDomain::setTransformations(const TransMapTypes& domTrans) |
---|
| 3029 | { |
---|
| 3030 | transformationMap_ = domTrans; |
---|
| 3031 | } |
---|
| 3032 | |
---|
[667] | 3033 | /*! |
---|
| 3034 | Get all transformation current domain has |
---|
| 3035 | \return all transformation |
---|
| 3036 | */ |
---|
[631] | 3037 | CDomain::TransMapTypes CDomain::getAllTransformations(void) |
---|
| 3038 | { |
---|
| 3039 | return transformationMap_; |
---|
| 3040 | } |
---|
| 3041 | |
---|
[823] | 3042 | void CDomain::duplicateTransformation(CDomain* src) |
---|
| 3043 | { |
---|
| 3044 | if (src->hasTransformation()) |
---|
| 3045 | { |
---|
| 3046 | this->setTransformations(src->getAllTransformations()); |
---|
| 3047 | } |
---|
| 3048 | } |
---|
| 3049 | |
---|
[667] | 3050 | /*! |
---|
[747] | 3051 | * Go through the hierarchy to find the domain from which the transformations must be inherited |
---|
| 3052 | */ |
---|
[631] | 3053 | void CDomain::solveInheritanceTransformation() |
---|
| 3054 | { |
---|
[747] | 3055 | if (hasTransformation() || !hasDirectDomainReference()) |
---|
| 3056 | return; |
---|
[631] | 3057 | |
---|
[747] | 3058 | CDomain* domain = this; |
---|
| 3059 | std::vector<CDomain*> refDomains; |
---|
| 3060 | while (!domain->hasTransformation() && domain->hasDirectDomainReference()) |
---|
[631] | 3061 | { |
---|
[747] | 3062 | refDomains.push_back(domain); |
---|
| 3063 | domain = domain->getDirectDomainReference(); |
---|
[631] | 3064 | } |
---|
| 3065 | |
---|
[747] | 3066 | if (domain->hasTransformation()) |
---|
| 3067 | for (size_t i = 0; i < refDomains.size(); ++i) |
---|
| 3068 | refDomains[i]->setTransformations(domain->getAllTransformations()); |
---|
[631] | 3069 | } |
---|
| 3070 | |
---|
[1345] | 3071 | void CDomain::setContextClient(CContextClient* contextClient) |
---|
| 3072 | { |
---|
[1353] | 3073 | if (clientsSet.find(contextClient)==clientsSet.end()) |
---|
| 3074 | { |
---|
| 3075 | clients.push_back(contextClient) ; |
---|
| 3076 | clientsSet.insert(contextClient); |
---|
| 3077 | } |
---|
[1345] | 3078 | } |
---|
| 3079 | |
---|
[667] | 3080 | /*! |
---|
| 3081 | Parse children nodes of a domain in xml file. |
---|
| 3082 | Whenver there is a new transformation, its type and name should be added into this function |
---|
| 3083 | \param node child node to process |
---|
| 3084 | */ |
---|
[631] | 3085 | void CDomain::parse(xml::CXMLNode & node) |
---|
| 3086 | { |
---|
| 3087 | SuperClass::parse(node); |
---|
| 3088 | |
---|
| 3089 | if (node.goToChildElement()) |
---|
| 3090 | { |
---|
[836] | 3091 | StdString nodeElementName; |
---|
[631] | 3092 | do |
---|
| 3093 | { |
---|
[784] | 3094 | StdString nodeId(""); |
---|
| 3095 | if (node.getAttributes().end() != node.getAttributes().find("id")) |
---|
| 3096 | { nodeId = node.getAttributes()["id"]; } |
---|
| 3097 | |
---|
[836] | 3098 | nodeElementName = node.getElementName(); |
---|
| 3099 | std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; |
---|
| 3100 | it = transformationMapList_.find(nodeElementName); |
---|
| 3101 | if (ite != it) |
---|
[657] | 3102 | { |
---|
[836] | 3103 | transformationMap_.push_back(std::make_pair(it->second, CTransformation<CDomain>::createTransformation(it->second, |
---|
| 3104 | nodeId, |
---|
| 3105 | &node))); |
---|
[657] | 3106 | } |
---|
[968] | 3107 | else |
---|
| 3108 | { |
---|
| 3109 | ERROR("void CDomain::parse(xml::CXMLNode & node)", |
---|
| 3110 | << "The transformation " << nodeElementName << " has not been supported yet."); |
---|
| 3111 | } |
---|
[631] | 3112 | } while (node.goToNextElement()) ; |
---|
| 3113 | node.goToParentElement(); |
---|
| 3114 | } |
---|
| 3115 | } |
---|
[219] | 3116 | //---------------------------------------------------------------- |
---|
[509] | 3117 | |
---|
[540] | 3118 | DEFINE_REF_FUNC(Domain,domain) |
---|
[509] | 3119 | |
---|
[219] | 3120 | ///--------------------------------------------------------------- |
---|
| 3121 | |
---|
[335] | 3122 | } // namespace xios |
---|