Changeset 2631 for XIOS3/trunk
- Timestamp:
- 05/29/24 19:16:58 (8 months ago)
- Location:
- XIOS3/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/config/axis_attribute.conf
r2479 r2631 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) -
XIOS3/trunk/src/io/inetcdf4.cpp
r2629 r2631 89 89 } 90 90 91 bool CINetCDF4::hasUnlimitedDimension(const CVarPath* const path) 92 { 93 int dimid = 0; 94 int grpid = this->getGroup(path); 95 CNetCdfInterface::inqUnLimDim(grpid, dimid); 96 if (dimid==-1) return false ; 97 else return true ; 98 } 99 91 100 int CINetCDF4::getUnlimitedDimension(const CVarPath* const path) 92 101 { … … 174 183 } 175 184 176 StdSize CINetCDF4::getNbOfTimestep(const CVarPath* const path)177 {178 return this->getDimensions(NULL, path)[this->getUnlimitedDimensionName(path)];179 }180 181 185 std::set<StdString> CINetCDF4::getBoundVariables(const CVarPath* const path) 182 186 { … … 337 341 return false; 338 342 } 343 344 345 template <class T> 346 bool CINetCDF4::hasAttribute(const StdString& name, const StdString* const var, const CVarPath* const path) 347 { 348 std::list<StdString> atts = this->getAttributes(var, path); 349 std::list<StdString>::const_iterator it = atts.begin(), end = atts.end(); 350 for (; it != end; it++) 351 { 352 const StdString& attname = *it; 353 if (attname.compare(0, name.size(), name) == 0) 354 { 355 std::pair<nc_type , StdSize> attinfos = this->getAttribute(name, var, path); 356 std::vector<T> retvalue(attinfos.second); 357 nc_type type = CNetCdfInterface::getNcType<T>(); 358 if (attinfos.first == type) return true; 359 else return false ; 360 } 361 } 362 return false; 363 } 364 365 template bool CINetCDF4::hasAttribute<double>(const StdString& name, const StdString* const var, const CVarPath* const path); 366 template bool CINetCDF4::hasAttribute<float>(const StdString& name, const StdString* const var, const CVarPath* const path); 367 template bool CINetCDF4::hasAttribute<int>(const StdString& name, const StdString* const var, const CVarPath* const path); 368 template bool CINetCDF4::hasAttribute<char>(const StdString& name, const StdString* const var, const CVarPath* const path); 339 369 340 370 bool CINetCDF4::hasVariable(const StdString& name, -
XIOS3/trunk/src/io/inetcdf4.hpp
r1639 r2631 40 40 41 41 /// Getters /// 42 StdSize getNbOfTimestep(const CVarPath* const path = NULL);43 42 44 43 StdString getUnlimitedDimensionName(const CVarPath* const path = NULL); … … 113 112 bool hasMissingValue(const StdString& name, const CVarPath* const path = NULL); 114 113 114 bool hasAttribute(const StdString& name, const StdString* const var = NULL, const CVarPath* const path = NULL); 115 116 template <class T> 115 117 bool hasAttribute(const StdString& name, const StdString* const var = NULL, const CVarPath* const path = NULL); 116 118 … … 144 146 int getDimension(const StdString& dimname, const CVarPath* const path = NULL); 145 147 int getUnlimitedDimension(const CVarPath* const path = NULL); 148 bool hasUnlimitedDimension(const CVarPath* const path = NULL); 146 149 int getAttributeId(const StdString& name, 147 150 const StdString* const var = NULL, -
XIOS3/trunk/src/io/nc4_data_input.cpp
r2628 r2631 36 36 if (SuperClassWriter::isTemporal(fieldId)) 37 37 { 38 // return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getUnlimitedDimensionName()];39 38 return SuperClassWriter::getDimensions(&fieldId)[SuperClassWriter::getTimeCounterName()]; 40 39 } … … 151 150 if (SuperClassWriter::isTemporal(fieldId)) 152 151 { 153 dimSizeMap.erase(SuperClassWriter::get UnlimitedDimensionName());152 dimSizeMap.erase(SuperClassWriter::getTimeCounterName()); 154 153 dimList.pop_front() ; // assume time dimension is first 155 154 } … … 187 186 listDimSize.push_front(*dimSizeMap.find(*it)); 188 187 } 188 189 // read specific field attribute 190 if (field->add_offset.isEmpty()) 191 { 192 if (SuperClassWriter::hasAttribute<float>("add_offset",&fieldId)) 193 field->add_offset = SuperClassWriter::getAttributeValue<float>("add_offset",&fieldId)[0] ; 194 else if (SuperClassWriter::hasAttribute<double>("add_offset",&fieldId)) 195 field->add_offset = SuperClassWriter::getAttributeValue<double>("add_offset",&fieldId)[0] ; 196 } 197 198 if (field->scale_factor.isEmpty()) 199 { 200 if (SuperClassWriter::hasAttribute<float>("scale_factor",&fieldId)) 201 field->scale_factor = SuperClassWriter::getAttributeValue<float>("scale_factor",&fieldId)[0] ; 202 else if (SuperClassWriter::hasAttribute<double>("scale_factor",&fieldId)) 203 field->scale_factor = SuperClassWriter::getAttributeValue<double>("scale_factor",&fieldId)[0] ; 204 } 189 205 190 206 // Now process domain and axis … … 571 587 if (!axis->n.isEmpty()) n = axis->n.getValue(); 572 588 axis->value.resize(n); 573 for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i); 589 590 double convertFromFactor=1.0 ; 591 if (!axis->convert_from_factor.isEmpty()) convertFromFactor = axis->convert_from_factor ; 592 for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i)*convertFromFactor; 574 593 } 575 594 }
Note: See TracChangeset
for help on using the changeset viewer.