Changeset 783 for XIOS/trunk/src/io/nc4_data_input.cpp
- Timestamp:
- 11/12/15 16:33:08 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/io/nc4_data_input.cpp
r782 r783 143 143 // Verify the compatibility of dimension of declared grid and real grid in file 144 144 int realGridDim = 1; 145 bool isUnstructuredGrid = SuperClassWriter::isUnstructured(fieldId); 145 146 std::map<StdString, StdSize> dimSizeMap = SuperClassWriter::getDimensions(&fieldId); 146 147 realGridDim = SuperClassWriter::isTemporal(fieldId) ? dimSizeMap.size() - 1 : dimSizeMap.size(); 148 if (isUnstructuredGrid) ++realGridDim; 147 149 148 150 if (gridDim != realGridDim) … … 154 156 if (SuperClassWriter::isTemporal(fieldId)) dimSizeMap.erase(SuperClassWriter::getUnlimitedDimensionName()); 155 157 int mapSize = dimSizeMap.size() - 1; 158 std::list<std::pair<StdString, StdSize> > listDimSize; 159 for (std::map<StdString, StdSize>::const_iterator itMap = dimSizeMap.begin(); itMap != dimSizeMap.end(); ++itMap) 160 listDimSize.push_front(*itMap); 156 161 157 162 // Now process domain and axis … … 169 174 { 170 175 it = readValueDomains_.insert(domainP[idxDomain]->getId()); 171 if (it.second) readDomainAttributeValueFromFile(domainP[idxDomain], dimSizeMap, mapSize - 1 -elementPosition, fieldId);176 if (it.second) readDomainAttributeValueFromFile(domainP[idxDomain], listDimSize, elementPosition, fieldId); 172 177 } 173 178 else 174 179 { 175 180 it = readMetaDataDomains_.insert(domainP[idxDomain]->getId()); 176 if (it.second) readDomainAttributesFromFile(domainP[idxDomain], dimSizeMap, mapSize - 1 -elementPosition, fieldId);181 if (it.second) readDomainAttributesFromFile(domainP[idxDomain], listDimSize, elementPosition, fieldId); 177 182 } 178 183 ++idxDomain; 179 elementPosition += 2; 184 if (isUnstructuredGrid) ++elementPosition; 185 else elementPosition += 2; 180 186 } 181 187 else … … 184 190 { 185 191 it = readValueAxis_.insert(axisP[idxAxis]->getId()); 186 if (it.second) readAxisAttributeValueFromFile(axisP[idxAxis], dimSizeMap, mapSize -elementPosition, fieldId);192 if (it.second) readAxisAttributeValueFromFile(axisP[idxAxis], listDimSize, elementPosition, fieldId); 187 193 } 188 194 else 189 195 { 190 196 it = readMetaDataAxis_.insert(axisP[idxAxis]->getId()); 191 if (it.second) readAxisAttributesFromFile(axisP[idxAxis], dimSizeMap, mapSize -elementPosition, fieldId);197 if (it.second) readAxisAttributesFromFile(axisP[idxAxis], listDimSize, elementPosition, fieldId); 192 198 } 193 199 ++idxAxis; … … 204 210 \param [in] fieldId id (or name) associated with the grid 205 211 */ 206 void CNc4DataInput::readDomainAttributeValueFromFile(CDomain* domain, std:: map<StdString, StdSize>& dimSizeMap,212 void CNc4DataInput::readDomainAttributeValueFromFile(CDomain* domain, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 207 213 int elementPosition, const StdString& fieldId) 208 214 { 209 215 // There are some optional attributes of a domain to retrieve from file // + lon lat? 210 std:: map<StdString, StdSize>::const_iterator itMapNj = dimSizeMap.begin(), itMapNi,211 iteMap = dimSizeMap.end();212 213 for (int i = 0; i < elementPosition; ++i, ++itMapN j) {}214 itMapN i = itMapNj; ++itMapNi;216 std::list<std::pair<StdString, StdSize> >::const_iterator itMapNi = dimSizeMap.begin(), itMapNj, 217 iteMap = dimSizeMap.end(); 218 219 for (int i = 0; i < elementPosition; ++i, ++itMapNi) {} 220 itMapNj = itMapNi; ++itMapNj; 215 221 216 222 if (this->isRectilinear(fieldId)) … … 225 231 readFieldVariableValue(domain->lonvalue_rectilinear_read_from_file, itMapNi->first, nBeginLon, nSizeLon, true); 226 232 domain->fillInRectilinearLonLat(); 233 } 234 else if (this->isUnstructured(fieldId)) 235 { 236 int ni = domain->ni; 237 std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 238 nBeginLatLon[0] = domain->ibegin.getValue(); 239 nSizeLatLon[0] = ni; 240 241 StdString latName = this->getLatCoordName(fieldId); 242 domain->latvalue_1d.resize(ni); 243 readFieldVariableValue(domain->latvalue_1d, latName, nBeginLatLon, nSizeLatLon); 244 StdString lonName = this->getLonCoordName(fieldId); 245 domain->lonvalue_1d.resize(ni); 246 readFieldVariableValue(domain->lonvalue_1d, lonName, nBeginLatLon, nSizeLatLon); 247 248 StdString boundsLatName = this->getBoundsId(latName); 249 if (0 == boundsLatName.compare("")) 250 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 251 << "Field '" << fieldId << std::endl 252 << "Trying to read attributes from unstructured grid." 253 << "Latitude variable " << latName << " does not have bounds."); 254 StdString boundsLonName = this->getBoundsId(lonName); 255 if (0 == boundsLonName.compare("")) 256 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 257 << "Field '" << fieldId << std::endl 258 << "Trying to read attributes from unstructured grid." 259 << "Longitude variable " << lonName << " does not have bounds."); 260 261 int nbVertex = this->getNbVertex(fieldId); 262 domain->nvertex.setValue(nbVertex); 263 std::vector<StdSize> nBeginBndsLatLon(2), nSizeBndsLatLon(2); 264 nBeginBndsLatLon[0] = domain->ibegin.getValue(); nSizeBndsLatLon[0] = ni; 265 nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 266 267 domain->bounds_lat_1d.resize(nbVertex,ni); 268 readFieldVariableValue(domain->bounds_lat_1d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 269 domain->bounds_lon_1d.resize(nbVertex,ni); 270 readFieldVariableValue(domain->bounds_lon_1d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 227 271 } 228 272 else if (this->isCurvilinear(fieldId)) … … 254 298 << "Longitude variable " << lonName << " does not have bounds."); 255 299 256 domain->nvertex.setValue(4); 300 int nbVertex = this->getNbVertex(fieldId); 301 domain->nvertex.setValue(nbVertex); 257 302 std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 258 303 nBeginBndsLatLon[0] = domain->jbegin.getValue(); nSizeBndsLatLon[0] = nj; 259 304 nBeginBndsLatLon[1] = domain->ibegin.getValue(); nSizeBndsLatLon[1] = ni; 260 nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = 4;261 262 domain->bounds_lat_2d.resize( 4,ni,nj);305 nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 306 307 domain->bounds_lat_2d.resize(nbVertex,ni,nj); 263 308 readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 264 domain->bounds_lon_2d.resize( 4,ni,nj);309 domain->bounds_lon_2d.resize(nbVertex,ni,nj); 265 310 readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 266 }267 else if (this->isUnstructured(fieldId))268 {269 270 311 } 271 312 } … … 278 319 \param [in] fieldId id (or name) associated with the grid 279 320 */ 280 void CNc4DataInput::readDomainAttributesFromFile(CDomain* domain, std:: map<StdString, StdSize>& dimSizeMap,321 void CNc4DataInput::readDomainAttributesFromFile(CDomain* domain, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 281 322 int elementPosition, const StdString& fieldId) 282 323 { 283 324 // There are some mandatory attributes of a domain to retrieve from file 284 325 // + ni_glo, nj_glo 285 std:: map<StdString, StdSize>::const_iterator itMapNj = dimSizeMap.begin(), itMapNi,286 iteMap = dimSizeMap.end();287 for (int i = 0; i < elementPosition; ++i, ++itMapN j) {}288 itMapN i = itMapNj; ++itMapNi;326 std::list<std::pair<StdString, StdSize> >::const_iterator itMapNi = dimSizeMap.begin(), itMapNj, 327 iteMap = dimSizeMap.end(); 328 for (int i = 0; i < elementPosition; ++i, ++itMapNi) {} 329 itMapNj = itMapNi; ++itMapNj; 289 330 290 331 if (this->isRectilinear(fieldId) || this->isCurvilinear(fieldId)) 291 332 { 292 333 domain->nj_glo.setValue(itMapNj->second); 293 domain->ni_glo.setValue( (itMapNi)->second);334 domain->ni_glo.setValue(itMapNi->second); 294 335 } 295 336 else if (this->isUnstructured(fieldId)) 296 337 { 297 338 domain->nj_glo.setValue(1); 339 domain->ni_glo.setValue(itMapNi->second); 298 340 } 299 341 } … … 306 348 \param [in] fieldId id (or name) associated with the grid 307 349 */ 308 void CNc4DataInput::readAxisAttributesFromFile(CAxis* axis, std:: map<StdString, StdSize>& dimSizeMap,350 void CNc4DataInput::readAxisAttributesFromFile(CAxis* axis, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 309 351 int elementPosition, const StdString& fieldId) 310 352 { 311 std:: map<StdString, StdSize>::const_iterator itMapN = dimSizeMap.begin(),312 iteMap= dimSizeMap.end();353 std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(), 354 iteMap = dimSizeMap.end(); 313 355 for (int i = 0; i < elementPosition; ++i, ++itMapN) {} 314 356 axis->n_glo.setValue(itMapN->second); … … 322 364 \param [in] fieldId id (or name) associated with the grid 323 365 */ 324 void CNc4DataInput::readAxisAttributeValueFromFile(CAxis* axis, std:: map<StdString, StdSize>& dimSizeMap,366 void CNc4DataInput::readAxisAttributeValueFromFile(CAxis* axis, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 325 367 int elementPosition, const StdString& fieldId) 326 368 { 327 std:: map<StdString, StdSize>::const_iterator itMapN = dimSizeMap.begin(),328 iteMap= dimSizeMap.end();369 std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(), 370 iteMap = dimSizeMap.end(); 329 371 for (int i = 0; i < elementPosition; ++i, ++itMapN) {} 330 372
Note: See TracChangeset
for help on using the changeset viewer.