Ignore:
Timestamp:
01/07/22 12:17:18 (2 years ago)
Author:
ymipsl
Message:

Improve file reading reading

  • add_offset and scaling_factor attributes are set when present in reading file
  • Add new attribute for axis to scale axis_value when read from file : convert_from_factor
  • fix bugs when time dimension in reading file is not unlimited

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/io/inetcdf4.cpp

    r1639 r2280  
    2828 
    2929    this->timeCounterName = timeCounterName; 
     30 
    3031    if (!CNetCdfInterface::isDimExisted(this->ncidp, this->timeCounterName)) this->timeCounterName=this->getUnlimitedDimensionName() ; 
    3132 
     
    8788    CNetCdfInterface::inqAtt(grpid, varid, attname, retvalue.first, retvalue.second); 
    8889    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 ; 
    89100  } 
    90101 
     
    174185  } 
    175186 
    176   StdSize CINetCDF4::getNbOfTimestep(const CVarPath* const path) 
    177   { 
    178     return this->getDimensions(NULL, path)[this->getUnlimitedDimensionName(path)]; 
    179   } 
    180  
    181187  std::set<StdString> CINetCDF4::getBoundVariables(const CVarPath* const path) 
    182188  { 
     
    337343    return false; 
    338344  } 
     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   
    339371 
    340372  bool CINetCDF4::hasVariable(const StdString& name, 
Note: See TracChangeset for help on using the changeset viewer.