Changeset 825 for XIOS/trunk
- Timestamp:
- 02/19/16 14:34:03 (8 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/inputs/REMAP/iodef.xml
r824 r825 81 81 <generate_rectilinear_domain /> 82 82 </domain> 83 <domain id="src_domain_curvilinear" type=" rectilinear">83 <domain id="src_domain_curvilinear" type="curvilinear"> 84 84 <generate_rectilinear_domain /> 85 85 </domain> -
XIOS/trunk/src/io/inetcdf4.cpp
r811 r825 28 28 this->timeCounterName = timeCounterName; 29 29 if (!CNetCdfInterface::isDimExisted(this->ncidp, this->timeCounterName)) this->timeCounterName=this->getUnlimitedDimensionName() ; 30 30 31 31 } 32 32 … … 63 63 int varid = 0; 64 64 int grpid = this->getGroup(path); 65 CNetCdfInterface::inqVarId(grpid, varname, varid); 65 if (this->hasVariable(varname, path)) 66 CNetCdfInterface::inqVarId(grpid, varname, varid); 66 67 return varid; 67 68 } … … 344 345 { 345 346 const StdString& varname = *it; 346 if ( varname.compare(0, name.size(), name) == 0)return true;347 if ((varname.compare(0, name.size(), name) == 0) && (0 != name.size())) return true; 347 348 } 348 349 return false; … … 726 727 const CVarPath* const path) 727 728 { 729 StdString lonName; 728 730 std::list<StdString>::const_iterator itbList, itList, iteList; 729 731 std::list<StdString> clist = this->getCoordinatesIdList(varname, path); … … 735 737 StdString unit = this->getAttributeValue(CCFKeywords::XIOS_CF_units, &(*itList), path); 736 738 if (CCFConvention::XIOS_CF_Longitude_units.end() != CCFConvention::XIOS_CF_Longitude_units.find(unit)) 737 return *itList; 738 } 739 } 739 { 740 lonName = *itList; 741 return lonName; 742 } 743 } 744 } 745 return lonName; 740 746 } 741 747 … … 743 749 const CVarPath* const path) 744 750 { 751 StdString latName; 745 752 std::list<StdString>::const_iterator itbList, itList, iteList; 746 753 std::list<StdString> clist = this->getCoordinatesIdList(varname, path); … … 752 759 StdString unit = this->getAttributeValue(CCFKeywords::XIOS_CF_units, &(*itList), path); 753 760 if (CCFConvention::XIOS_CF_Latitude_units.end() != CCFConvention::XIOS_CF_Latitude_units.find(unit)) 754 return *itList; 755 } 756 } 761 { 762 latName = *itList; 763 return latName; 764 } 765 } 766 } 767 return latName; 757 768 } 758 769 -
XIOS/trunk/src/io/nc4_data_input.cpp
r811 r825 147 147 std::map<StdString, StdSize> dimSizeMap = SuperClassWriter::getDimensions(&fieldId); 148 148 std::list<StdString> dimList = SuperClassWriter::getDimensionsList(&fieldId); 149 149 150 150 realGridDim = SuperClassWriter::isTemporal(fieldId) ? dimSizeMap.size() - 1 : dimSizeMap.size(); 151 151 if (isUnstructuredGrid) ++realGridDim; … … 157 157 158 158 // Remove unlimited dimension from the map, we dont need it anymore 159 if (SuperClassWriter::isTemporal(fieldId)) 159 if (SuperClassWriter::isTemporal(fieldId)) 160 160 { 161 161 dimSizeMap.erase(SuperClassWriter::getUnlimitedDimensionName()); 162 162 dimList.pop_front() ; // assume time dimension is first 163 163 } 164 164 165 165 int mapSize = dimSizeMap.size() - 1; 166 166 std::list<std::pair<StdString, StdSize> > listDimSize; … … 232 232 itMapNj = itMapNi; ++itMapNj; 233 233 234 if ( this->isRectilinear(fieldId))234 if ((CDomain::type_attr::rectilinear == domain->type))// || this->isRectilinear(fieldId)) 235 235 { 236 236 // Ok, try to read some f.. attributes such as longitude and latitude 237 domain->latvalue_rectilinear_read_from_file.resize(itMapNj->second); 238 std::vector<StdSize> nBeginLat(1, 0), nSizeLat(1, itMapNj->second); 239 readFieldVariableValue(domain->latvalue_rectilinear_read_from_file, itMapNj->first, nBeginLat, nSizeLat, true); 240 241 domain->lonvalue_rectilinear_read_from_file.resize(itMapNi->second); 242 std::vector<StdSize> nBeginLon(1, 0), nSizeLon(1, itMapNi->second); 243 readFieldVariableValue(domain->lonvalue_rectilinear_read_from_file, itMapNi->first, nBeginLon, nSizeLon, true); 237 bool hasLat = SuperClassWriter::hasVariable(itMapNj->first); 238 if (hasLat) 239 { 240 domain->latvalue_rectilinear_read_from_file.resize(itMapNj->second); 241 std::vector<StdSize> nBeginLat(1, 0), nSizeLat(1, itMapNj->second); 242 readFieldVariableValue(domain->latvalue_rectilinear_read_from_file, itMapNj->first, nBeginLat, nSizeLat, true); 243 } 244 245 bool hasLon = SuperClassWriter::hasVariable(itMapNi->first); 246 if (hasLon) 247 { 248 domain->lonvalue_rectilinear_read_from_file.resize(itMapNi->second); 249 std::vector<StdSize> nBeginLon(1, 0), nSizeLon(1, itMapNi->second); 250 readFieldVariableValue(domain->lonvalue_rectilinear_read_from_file, itMapNi->first, nBeginLon, nSizeLon, true); 251 } 244 252 domain->fillInRectilinearLonLat(); 245 253 } 246 else if ( this->isCurvilinear(fieldId))254 else if ((CDomain::type_attr::curvilinear == domain->type))// || (this->isCurvilinear(fieldId))) 247 255 { 248 256 int ni = domain->ni; … … 253 261 254 262 StdString latName = this->getLatCoordName(fieldId); 255 domain->latvalue_2d.resize(ni,nj); 256 readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon); 263 if (SuperClassWriter::hasVariable(latName)) //(0 != latName.compare("")) 264 { 265 domain->latvalue_2d.resize(ni,nj); 266 readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon); 267 } 257 268 StdString lonName = this->getLonCoordName(fieldId); 258 domain->lonvalue_2d.resize(ni,nj); 259 readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon); 269 if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare("")) 270 { 271 domain->lonvalue_2d.resize(ni,nj); 272 readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon); 273 } 260 274 261 275 StdString boundsLatName = this->getBoundsId(latName); 262 if (0 == boundsLatName.compare(""))263 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)",264 << "Field '" << fieldId << std::endl265 << "Trying to read attributes from curvilinear grid."266 << "Latitude variable " << latName << " does not have bounds.");267 276 StdString boundsLonName = this->getBoundsId(lonName); 268 if (0 == boundsLonName.compare(""))269 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)",270 << "Field '" << fieldId << std::endl271 << "Trying to read attributes from curvilinear grid."272 << "Longitude variable " << lonName << " does not have bounds.");273 277 274 278 int nbVertex = this->getNbVertex(fieldId); 275 domain->nvertex.setValue(nbVertex); 279 if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) //if ((0 != boundsLatName.compare("")) || (0 != boundsLonName.compare(""))) 280 domain->nvertex.setValue(nbVertex); 276 281 std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 277 282 nBeginBndsLatLon[0] = domain->jbegin.getValue(); nSizeBndsLatLon[0] = nj; … … 279 284 nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 280 285 281 domain->bounds_lat_2d.resize(nbVertex,ni,nj); 282 readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 283 domain->bounds_lon_2d.resize(nbVertex,ni,nj); 284 readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 285 } 286 else if (this->isUnstructured(fieldId)) 286 if (SuperClassWriter::hasVariable(boundsLatName)) //(0 != boundsLatName.compare("")) 287 { 288 domain->bounds_lat_2d.resize(nbVertex,ni,nj); 289 readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 290 291 } 292 if (SuperClassWriter::hasVariable(boundsLonName)) //(0 != boundsLonName.compare("")) 293 { 294 domain->bounds_lon_2d.resize(nbVertex,ni,nj); 295 readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 296 } 297 } 298 else if ((CDomain::type_attr::unstructured == domain->type))// || (this->isUnstructured(fieldId))) 287 299 { 288 300 /* … … 292 304 << "Trying to read attributes from unstructured grid." 293 305 << "i_index of domain" << domain->getId() << " is mandatory"); 294 306 295 307 int ni = domain->i_index.numElements(); 296 308 */ … … 302 314 for(int idx = 0; idx < ni; ++idx) domain->i_index(idx)=ibegin+idx ; 303 315 } 304 316 305 317 std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 306 318 nSizeLatLon[0] = domain->ni_glo.getValue(); … … 308 320 309 321 StdString latName = this->getLatCoordName(fieldId); 310 readFieldVariableValue(globalLonLat, latName, nBeginLatLon, nSizeLatLon); 311 domain->latvalue_1d.resize(ni); 312 for (int idx = 0; idx < ni; ++idx) 313 domain->latvalue_1d(idx) = globalLonLat(domain->i_index(idx)); 322 if (SuperClassWriter::hasVariable(latName)) //(0 != latName.compare("")) 323 { 324 readFieldVariableValue(globalLonLat, latName, nBeginLatLon, nSizeLatLon); 325 domain->latvalue_1d.resize(ni); 326 for (int idx = 0; idx < ni; ++idx) 327 domain->latvalue_1d(idx) = globalLonLat(domain->i_index(idx)); 328 } 314 329 315 330 StdString lonName = this->getLonCoordName(fieldId); 316 readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 317 domain->lonvalue_1d.resize(ni); 318 for (int idx = 0; idx < ni; ++idx) 319 domain->lonvalue_1d(idx) = globalLonLat(domain->i_index(idx)); 331 if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare("")) 332 { 333 readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 334 domain->lonvalue_1d.resize(ni); 335 for (int idx = 0; idx < ni; ++idx) 336 domain->lonvalue_1d(idx) = globalLonLat(domain->i_index(idx)); 337 } 320 338 321 339 StdString boundsLatName = this->getBoundsId(latName); 322 if (0 == boundsLatName.compare(""))323 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)",324 << "Field '" << fieldId << std::endl325 << "Trying to read attributes from unstructured grid."326 << "Latitude variable " << latName << " does not have bounds.");327 340 StdString boundsLonName = this->getBoundsId(lonName); 328 if (0 == boundsLonName.compare(""))329 ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)",330 << "Field '" << fieldId << std::endl331 << "Trying to read attributes from unstructured grid."332 << "Longitude variable " << lonName << " does not have bounds.");333 341 334 342 int nbVertex = this->getNbVertex(fieldId); 335 domain->nvertex.setValue(nbVertex); 343 if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) // (0 != boundsLatName.compare("")) || (0 != boundsLonName.compare(""))) 344 domain->nvertex.setValue(nbVertex); 345 336 346 std::vector<StdSize> nBeginBndsLatLon(2), nSizeBndsLatLon(2); 337 347 nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni_glo.getValue(); 338 348 nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 339 349 340 CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 341 readFieldVariableValue(globalBndsLonLat, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 342 domain->bounds_lat_1d.resize(nbVertex,ni); 343 for (int idx = 0; idx < ni; ++idx) 344 for (int jdx = 0; jdx < nbVertex; ++jdx) 345 domain->bounds_lat_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 346 347 readFieldVariableValue(globalBndsLonLat, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 348 domain->bounds_lon_1d.resize(nbVertex,ni); 349 for (int idx = 0; idx < ni; ++idx) 350 for (int jdx = 0; jdx < nbVertex; ++jdx) 351 domain->bounds_lon_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 350 if (SuperClassWriter::hasVariable(boundsLatName)) //(0 != boundsLatName.compare("")) 351 { 352 CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 353 readFieldVariableValue(globalBndsLonLat, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 354 domain->bounds_lat_1d.resize(nbVertex,ni); 355 for (int idx = 0; idx < ni; ++idx) 356 for (int jdx = 0; jdx < nbVertex; ++jdx) 357 domain->bounds_lat_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 358 } 359 360 if (SuperClassWriter::hasVariable(boundsLonName)) //(0 != boundsLonName.compare("")) 361 { 362 CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 363 readFieldVariableValue(globalBndsLonLat, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 364 domain->bounds_lon_1d.resize(nbVertex,ni); 365 for (int idx = 0; idx < ni; ++idx) 366 for (int jdx = 0; jdx < nbVertex; ++jdx) 367 domain->bounds_lon_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 368 } 352 369 } 353 370 }
Note: See TracChangeset
for help on using the changeset viewer.