Changeset 1642 for XIOS/dev/branch_openmp/src/io/nc4_data_input.cpp
- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/io/nc4_data_input.cpp
r1545 r1642 29 29 30 30 StdSize CNc4DataInput::getFieldNbRecords_(CField* field) 31 TRY 31 32 { 32 33 StdString fieldId = field->getFieldOutputName(); … … 40 41 return 1; 41 42 } 43 CATCH 42 44 43 45 void CNc4DataInput::readFieldData_(CField* field) 46 TRY 44 47 { 45 48 CContext* context = CContext::getCurrent(); … … 55 58 CArray<double,1> fieldData(grid->getWrittenDataSize()); 56 59 if (!field->default_value.isEmpty()) fieldData = field->default_value; 57 #ifdef _usingEP 58 SuperClass::type = ONE_FILE; 59 printf("SuperClass::type = %d\n", SuperClass::type); 60 #endif 61 60 62 61 switch (SuperClass::type) 63 62 { … … 67 66 case ONE_FILE: 68 67 { 69 /*70 std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();71 std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();72 std::vector<int> nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer();73 74 int ssize = nZoomBeginGlobal.size();75 76 std::vector<StdSize> start(ssize);77 std::vector<StdSize> count(ssize);78 79 for (int i = 0; i < ssize; ++i)80 {81 start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1];82 count[i] = nZoomSizeServer[ssize - i - 1];83 }84 */85 86 std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();87 std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();88 std::vector<int> nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer();89 90 68 std::vector<StdSize> start, count; 91 69 … … 95 73 int numElement = axisDomainOrder.numElements(); 96 74 int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 97 int idx = nZoomBeginGlobal.size() - 1;98 99 start.reserve( nZoomBeginGlobal.size());100 count.reserve( nZoomBeginGlobal.size());75 int idx = domainList.size() * 2 + axisList.size() - 1; 76 77 start.reserve(idx+1); 78 count.reserve(idx+1); 101 79 102 80 for (int i = numElement - 1; i >= 0; --i) … … 107 85 if ((domain->type) != CDomain::type_attr::unstructured) 108 86 { 109 start.push_back( nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);110 count.push_back( nZoomSizeServer[idx]);87 start.push_back(domain->jbegin); 88 count.push_back(domain->nj); 111 89 } 112 --idx ; 113 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 114 count.push_back(nZoomSizeServer[idx]); 115 --idx ; 90 start.push_back(domain->ibegin); 91 count.push_back(domain->ni); 116 92 --idxDomain; 117 93 } 118 94 else if (1 == axisDomainOrder(i)) 119 95 { 120 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 121 count.push_back(nZoomSizeServer[idx]); 122 --idx; 96 CAxis* axis = CAxis::get(axisList[idxAxis]); 97 start.push_back(axis->begin); 98 count.push_back(axis->n); 99 --idxAxis ; 123 100 } 124 101 else … … 129 106 count.push_back(1); 130 107 } 131 --idx;132 108 } 133 109 } … … 148 124 } 149 125 } 126 CATCH 150 127 151 128 void CNc4DataInput::readFieldAttributes_(CField* field, bool readAttributeValues) 129 TRY 152 130 { 153 131 StdString fieldId = field->getFieldOutputName(); … … 166 144 // Verify the compatibility of dimension of declared grid and real grid in file 167 145 int realGridDim = 1; 168 bool isUnstructuredGrid = SuperClassWriter::isUnstructured(fieldId);146 bool isUnstructuredGrid = ((gridDim < 2) ? false : SuperClassWriter::isUnstructured(fieldId)); 169 147 std::map<StdString, StdSize> dimSizeMap = SuperClassWriter::getDimensions(&fieldId); 170 148 std::list<StdString> dimList = SuperClassWriter::getDimensionsList(&fieldId); … … 191 169 */ 192 170 193 for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 171 // if (!SuperClassWriter::isRectilinear(fieldId)) 172 if (true) 173 { 174 for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 194 175 listDimSize.push_front(*dimSizeMap.find(*it)); 176 } 177 else 178 { 179 std::list<StdString> coords = SuperClassWriter::getCoordinatesIdList(fieldId); 180 std::list<StdString>::const_iterator itCoord = coords.begin(); 181 for (; itCoord != coords.end(); itCoord++) 182 { 183 const StdString& coord = *itCoord; 184 if (SuperClassWriter::hasVariable(coord) && !SuperClassWriter::isTemporal(coord)) 185 { 186 std::map<StdString, StdSize> dimsTmp = SuperClassWriter::getDimensions(&coord); 187 StdString dimNameTmp = dimsTmp.begin()->first; 188 StdSize dimSizeTmp = dimsTmp.begin()->second; 189 listDimSize.push_front(make_pair(coord, dimSizeTmp)); 190 dimSizeMap.erase(dimNameTmp); 191 dimList.remove(dimNameTmp); 192 } 193 } 194 for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 195 listDimSize.push_front(*dimSizeMap.find(*it)); 196 } 195 197 196 198 // Now process domain and axis … … 251 253 } 252 254 } 255 CATCH 253 256 254 257 /*! … … 261 264 void CNc4DataInput::readDomainAttributeValueFromFile(CDomain* domain, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 262 265 int elementPosition, const StdString& fieldId) 266 TRY 263 267 { 264 268 // There are some optional attributes of a domain to retrieve from file // + lon lat? … … 439 443 domain->fillInLonLat(); 440 444 } 445 CATCH 441 446 442 447 /*! … … 449 454 void CNc4DataInput::readDomainAttributesFromFile(CDomain* domain, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 450 455 int elementPosition, const StdString& fieldId) 456 TRY 451 457 { 452 458 // There are some mandatory attributes of a domain to retrieve from file … … 497 503 domain->ni_glo.setValue(itMapNi->second); 498 504 } 499 } 505 506 // determine if coordinates values are present in file 507 if ((CDomain::type_attr::rectilinear == domain->type)) 508 { 509 // Ok, try to read some attributes such as longitude and latitude 510 domain->hasLatInReadFile_ = SuperClassWriter::hasVariable(itMapNj->first); 511 domain->hasLonInReadFile_ = SuperClassWriter::hasVariable(itMapNi->first); 512 } 513 else if ((CDomain::type_attr::curvilinear == domain->type) || (CDomain::type_attr::unstructured == domain->type) ) 514 { 515 StdString latName = this->getLatCoordName(fieldId); 516 domain->hasLatInReadFile_ = SuperClassWriter::hasVariable(latName) ; 517 StdString lonName = this->getLonCoordName(fieldId); 518 domain->hasLonInReadFile_ = SuperClassWriter::hasVariable(lonName) ; 519 StdString boundsLatName = this->getBoundsId(latName); 520 domain->hasBoundsLatInReadFile_ = SuperClassWriter::hasVariable(boundsLatName) ; 521 StdString boundsLonName = this->getBoundsId(lonName); 522 domain->hasBoundsLonInReadFile_ = SuperClassWriter::hasVariable(boundsLonName) ; 523 } 524 } 525 CATCH 500 526 501 527 /*! … … 508 534 void CNc4DataInput::readAxisAttributesFromFile(CAxis* axis, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 509 535 int elementPosition, const StdString& fieldId) 536 TRY 510 537 { 511 538 std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(), … … 524 551 axis->n_glo.setValue(itMapN->second); 525 552 } 553 CATCH 526 554 527 555 /*! … … 534 562 void CNc4DataInput::readAxisAttributeValueFromFile(CAxis* axis, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 535 563 int elementPosition, const StdString& fieldId) 564 TRY 536 565 { 537 566 std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(), … … 554 583 } 555 584 } 585 CATCH 556 586 557 587 /*! … … 582 612 583 613 void CNc4DataInput::closeFile_(void) 614 TRY 584 615 { 585 616 SuperClassWriter::close(); 586 617 } 618 CATCH 587 619 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.