Changeset 2280 for XIOS/trunk
- Timestamp:
- 01/07/22 12:17:18 (3 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/config/axis_attribute.conf
r1493 r2280 6 6 7 7 DECLARE_ATTRIBUTE(StdString, unit) 8 DECLARE_ATTRIBUTE(double, convert_from_factor) 8 9 DECLARE_ATTRIBUTE(StdString, formula) 9 10 DECLARE_ATTRIBUTE(StdString, formula_term) -
XIOS/trunk/src/io/inetcdf4.cpp
r1639 r2280 28 28 29 29 this->timeCounterName = timeCounterName; 30 30 31 if (!CNetCdfInterface::isDimExisted(this->ncidp, this->timeCounterName)) this->timeCounterName=this->getUnlimitedDimensionName() ; 31 32 … … 87 88 CNetCdfInterface::inqAtt(grpid, varid, attname, retvalue.first, retvalue.second); 88 89 return retvalue; 90 } 91 92 93 bool CINetCDF4::hasUnlimitedDimension(const CVarPath* const path) 94 { 95 int dimid = 0; 96 int grpid = this->getGroup(path); 97 CNetCdfInterface::inqUnLimDim(grpid, dimid); 98 if (dimid==-1) return false ; 99 else return true ; 89 100 } 90 101 … … 174 185 } 175 186 176 StdSize CINetCDF4::getNbOfTimestep(const CVarPath* const path)177 {178 return this->getDimensions(NULL, path)[this->getUnlimitedDimensionName(path)];179 }180 181 187 std::set<StdString> CINetCDF4::getBoundVariables(const CVarPath* const path) 182 188 { … … 337 343 return false; 338 344 } 345 346 template <class T> 347 bool CINetCDF4::hasAttribute(const StdString& name, const StdString* const var, const CVarPath* const path) 348 { 349 std::list<StdString> atts = this->getAttributes(var, path); 350 std::list<StdString>::const_iterator it = atts.begin(), end = atts.end(); 351 for (; it != end; it++) 352 { 353 const StdString& attname = *it; 354 if (attname.compare(0, name.size(), name) == 0) 355 { 356 std::pair<nc_type , StdSize> attinfos = this->getAttribute(name, var, path); 357 std::vector<T> retvalue(attinfos.second); 358 nc_type type = CNetCdfInterface::getNcType<T>(); 359 if (attinfos.first == type) return true; 360 else return false ; 361 } 362 } 363 return false; 364 } 365 366 template bool CINetCDF4::hasAttribute<double>(const StdString& name, const StdString* const var, const CVarPath* const path); 367 template bool CINetCDF4::hasAttribute<float>(const StdString& name, const StdString* const var, const CVarPath* const path); 368 template bool CINetCDF4::hasAttribute<int>(const StdString& name, const StdString* const var, const CVarPath* const path); 369 template bool CINetCDF4::hasAttribute<char>(const StdString& name, const StdString* const var, const CVarPath* const path); 370 339 371 340 372 bool CINetCDF4::hasVariable(const StdString& name, -
XIOS/trunk/src/io/inetcdf4.hpp
r1639 r2280 40 40 41 41 /// Getters /// 42 StdSize getNbOfTimestep(const CVarPath* const path = NULL);43 42 44 43 StdString getUnlimitedDimensionName(const CVarPath* const path = NULL); … … 112 111 /// Tests /// 113 112 bool hasMissingValue(const StdString& name, const CVarPath* const path = NULL); 114 113 bool hasAttribute(const StdString& name, const StdString* const var = NULL, const CVarPath* const path = NULL); 114 115 template <class T> 115 116 bool hasAttribute(const StdString& name, const StdString* const var = NULL, const CVarPath* const path = NULL); 116 117 … … 144 145 int getDimension(const StdString& dimname, const CVarPath* const path = NULL); 145 146 int getUnlimitedDimension(const CVarPath* const path = NULL); 147 bool hasUnlimitedDimension(const CVarPath* const path = NULL); 148 146 149 int getAttributeId(const StdString& name, 147 150 const StdString* const var = NULL, -
XIOS/trunk/src/io/nc4_data_input.cpp
r1639 r2280 35 35 if (SuperClassWriter::isTemporal(fieldId)) 36 36 { 37 // return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getUnlimitedDimensionName()];38 37 return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getTimeCounterName()]; 39 38 } … … 159 158 if (SuperClassWriter::isTemporal(fieldId)) 160 159 { 161 dimSizeMap.erase(SuperClassWriter::get UnlimitedDimensionName());160 dimSizeMap.erase(SuperClassWriter::getTimeCounterName()); 162 161 dimList.pop_front() ; // assume time dimension is first 163 162 } … … 195 194 listDimSize.push_front(*dimSizeMap.find(*it)); 196 195 } 196 197 // read specific field attribute 198 if (field->add_offset.isEmpty()) 199 { 200 if (SuperClassWriter::hasAttribute<float>("add_offset",&fieldId)) 201 field->add_offset = SuperClassWriter::getAttributeValue<float>("add_offset",&fieldId)[0] ; 202 else if (SuperClassWriter::hasAttribute<double>("add_offset",&fieldId)) 203 field->add_offset = SuperClassWriter::getAttributeValue<double>("add_offset",&fieldId)[0] ; 204 } 205 206 if (field->scale_factor.isEmpty()) 207 { 208 if (SuperClassWriter::hasAttribute<float>("scale_factor",&fieldId)) 209 field->scale_factor = SuperClassWriter::getAttributeValue<float>("scale_factor",&fieldId)[0] ; 210 else if (SuperClassWriter::hasAttribute<double>("scale_factor",&fieldId)) 211 field->scale_factor = SuperClassWriter::getAttributeValue<double>("scale_factor",&fieldId)[0] ; 212 } 197 213 198 214 // Now process domain and axis … … 579 595 if (!axis->n.isEmpty()) n = axis->n.getValue(); 580 596 axis->value.resize(n); 581 for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i); 597 double convertFromFactor=1.0 ; 598 if (!axis->convert_from_factor.isEmpty()) convertFromFactor = axis->convert_from_factor ; 599 for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i)*convertFromFactor; 582 600 } 583 601 }
Note: See TracChangeset
for help on using the changeset viewer.