Changeset 785 for XIOS/trunk/src/io/nc4_data_input.cpp
- Timestamp:
- 11/12/15 16:33:18 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/io/nc4_data_input.cpp
r783 r785 232 232 domain->fillInRectilinearLonLat(); 233 233 } 234 else if (this->isCurvilinear(fieldId)) 235 { 236 int ni = domain->ni; 237 int nj = domain->nj; 238 std::vector<StdSize> nBeginLatLon(2), nSizeLatLon(2); 239 nBeginLatLon[0] = domain->jbegin.getValue(); nBeginLatLon[1] = domain->ibegin.getValue(); 240 nSizeLatLon[0] = nj; nSizeLatLon[1] = ni; 241 242 StdString latName = this->getLatCoordName(fieldId); 243 domain->latvalue_2d.resize(ni,nj); 244 readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon); 245 StdString lonName = this->getLonCoordName(fieldId); 246 domain->lonvalue_2d.resize(ni,nj); 247 readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon); 248 249 StdString boundsLatName = this->getBoundsId(latName); 250 if (0 == boundsLatName.compare("")) 251 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 252 << "Field '" << fieldId << std::endl 253 << "Trying to read attributes from curvilinear grid." 254 << "Latitude variable " << latName << " does not have bounds."); 255 StdString boundsLonName = this->getBoundsId(lonName); 256 if (0 == boundsLonName.compare("")) 257 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 258 << "Field '" << fieldId << std::endl 259 << "Trying to read attributes from curvilinear grid." 260 << "Longitude variable " << lonName << " does not have bounds."); 261 262 int nbVertex = this->getNbVertex(fieldId); 263 domain->nvertex.setValue(nbVertex); 264 std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 265 nBeginBndsLatLon[0] = domain->jbegin.getValue(); nSizeBndsLatLon[0] = nj; 266 nBeginBndsLatLon[1] = domain->ibegin.getValue(); nSizeBndsLatLon[1] = ni; 267 nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 268 269 domain->bounds_lat_2d.resize(nbVertex,ni,nj); 270 readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 271 domain->bounds_lon_2d.resize(nbVertex,ni,nj); 272 readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 273 } 234 274 else if (this->isUnstructured(fieldId)) 235 275 { 236 int ni = domain->ni; 276 if (domain->i_index.isEmpty()) 277 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 278 << "Field '" << fieldId << std::endl 279 << "Trying to read attributes from unstructured grid." 280 << "i_index of domain" << domain->getId() << " is mandatory"); 281 282 int ni = domain->i_index.numElements(); 237 283 std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 238 n BeginLatLon[0] = domain->ibegin.getValue();239 nSizeLatLon[0] = ni;284 nSizeLatLon[0] = domain->ni_glo.getValue(); 285 CArray<double,1> globalLonLat(domain->ni_glo.getValue()); 240 286 241 287 StdString latName = this->getLatCoordName(fieldId); 288 readFieldVariableValue(globalLonLat, latName, nBeginLatLon, nSizeLatLon); 242 289 domain->latvalue_1d.resize(ni); 243 readFieldVariableValue(domain->latvalue_1d, latName, nBeginLatLon, nSizeLatLon); 290 for (int idx = 0; idx < ni; ++idx) 291 domain->latvalue_1d(idx) = globalLonLat(domain->i_index(idx)); 292 244 293 StdString lonName = this->getLonCoordName(fieldId); 294 readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 245 295 domain->lonvalue_1d.resize(ni); 246 readFieldVariableValue(domain->lonvalue_1d, lonName, nBeginLatLon, nSizeLatLon); 296 for (int idx = 0; idx < ni; ++idx) 297 domain->lonvalue_1d(idx) = globalLonLat(domain->i_index(idx)); 247 298 248 299 StdString boundsLatName = this->getBoundsId(latName); … … 262 313 domain->nvertex.setValue(nbVertex); 263 314 std::vector<StdSize> nBeginBndsLatLon(2), nSizeBndsLatLon(2); 264 nBeginBndsLatLon[0] = domain->ibegin.getValue(); nSizeBndsLatLon[0] = ni;315 nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni_glo.getValue(); 265 316 nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 266 317 318 CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 319 readFieldVariableValue(globalBndsLonLat, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 267 320 domain->bounds_lat_1d.resize(nbVertex,ni); 268 readFieldVariableValue(domain->bounds_lat_1d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 321 for (int idx = 0; idx < ni; ++idx) 322 for (int jdx = 0; jdx < nbVertex; ++jdx) 323 domain->bounds_lat_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 324 325 readFieldVariableValue(globalBndsLonLat, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 269 326 domain->bounds_lon_1d.resize(nbVertex,ni); 270 readFieldVariableValue(domain->bounds_lon_1d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 271 } 272 else if (this->isCurvilinear(fieldId)) 273 { 274 int ni = domain->ni; 275 int nj = domain->nj; 276 std::vector<StdSize> nBeginLatLon(2), nSizeLatLon(2); 277 nBeginLatLon[0] = domain->jbegin.getValue(); nBeginLatLon[1] = domain->ibegin.getValue(); 278 nSizeLatLon[0] = nj; nSizeLatLon[1] = ni; 279 280 StdString latName = this->getLatCoordName(fieldId); 281 domain->latvalue_2d.resize(ni,nj); 282 readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon); 283 StdString lonName = this->getLonCoordName(fieldId); 284 domain->lonvalue_2d.resize(ni,nj); 285 readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon); 286 287 StdString boundsLatName = this->getBoundsId(latName); 288 if (0 == boundsLatName.compare("")) 289 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 290 << "Field '" << fieldId << std::endl 291 << "Trying to read attributes from curvilinear grid." 292 << "Latitude variable " << latName << " does not have bounds."); 293 StdString boundsLonName = this->getBoundsId(lonName); 294 if (0 == boundsLonName.compare("")) 295 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 296 << "Field '" << fieldId << std::endl 297 << "Trying to read attributes from curvilinear grid." 298 << "Longitude variable " << lonName << " does not have bounds."); 299 300 int nbVertex = this->getNbVertex(fieldId); 301 domain->nvertex.setValue(nbVertex); 302 std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 303 nBeginBndsLatLon[0] = domain->jbegin.getValue(); nSizeBndsLatLon[0] = nj; 304 nBeginBndsLatLon[1] = domain->ibegin.getValue(); nSizeBndsLatLon[1] = ni; 305 nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 306 307 domain->bounds_lat_2d.resize(nbVertex,ni,nj); 308 readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 309 domain->bounds_lon_2d.resize(nbVertex,ni,nj); 310 readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 327 for (int idx = 0; idx < ni; ++idx) 328 for (int jdx = 0; jdx < nbVertex; ++jdx) 329 domain->bounds_lon_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 311 330 } 312 331 }
Note: See TracChangeset
for help on using the changeset viewer.