Ignore:
Timestamp:
03/06/18 11:36:29 (6 years ago)
Author:
oabramkina
Message:

Few bugfixes for reading:

  • still adjusting the algorithm on determining the type of a domain
  • adding a check on existence of a variable before accessing its attributes/dimensions (this was causing a problem in case of an axis without value or label and thus not written as a netcdf variable).

Tested rigorously.

Location:
XIOS/dev/XIOS_DEV_CMIP6/src/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/inetcdf4.cpp

    r1445 r1447  
    8383    std::pair<nc_type, StdSize> retvalue; 
    8484    int grpid = this->getGroup(path); 
    85     int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL; 
     85    int varid = (var != NULL && this->hasVariable(*var, path)) ? this->getVariable(*var, path) : NC_GLOBAL; 
    8686    CNetCdfInterface::inqAtt(grpid, varid, attname, retvalue.first, retvalue.second); 
    8787    return retvalue; 
     
    216216    int nbdim = 0, *dimid = NULL; 
    217217    int grpid = this->getGroup(path); 
    218     int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL; 
     218    int varid = (var != NULL && this->hasVariable(*var, path)) ? this->getVariable(*var, path) : NC_GLOBAL; 
    219219    std::list<StdString> retvalue; 
    220220 
    221     if (var != NULL) 
     221    if (var != NULL && this->hasVariable(*var, path)) 
    222222    { 
    223223      CNetCdfInterface::inqVarNDims(grpid, varid, nbdim); 
     
    247247    int nbdim = 0, *dimid = NULL; 
    248248    int grpid = this->getGroup(path); 
    249     int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL; 
     249    int varid = (var != NULL && this->hasVariable(*var, path)) ? this->getVariable(*var, path) : NC_GLOBAL; 
    250250    std::map<StdString, StdSize> retvalue; 
    251251 
    252     if (var != NULL) 
     252    if (var != NULL && this->hasVariable(*var, path)) 
    253253    { 
    254254      CNetCdfInterface::inqVarNDims(grpid, varid, nbdim); 
     
    282282    std::list<StdString> retvalue; 
    283283    int grpid = this->getGroup(path); 
    284     int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL; 
    285  
    286     if (var != NULL) 
     284    int varid = (var != NULL && this->hasVariable(*var, path)) ? this->getVariable(*var, path) : NC_GLOBAL; 
     285 
     286    if (var != NULL && this->hasVariable(*var, path)) 
    287287      CNetCdfInterface::inqVarNAtts(grpid, varid, nbatt); 
    288288    else 
     
    376376  { 
    377377    int grpid = this->getGroup(path); 
    378     int varid = (var != NULL) ? this->getVariable(*var, path) : NC_GLOBAL; 
     378    int varid = (var != NULL && this->hasVariable(*var, path)) ? this->getVariable(*var, path) : NC_GLOBAL; 
    379379    std::pair<nc_type , StdSize> attinfos = this->getAttribute(name, var, path); 
    380380    std::vector<T> retvalue(attinfos.second); 
     
    494494  bool CINetCDF4::isRectilinear(const StdString& name, const CVarPath* const path) 
    495495  { 
    496     std::list<StdString> coords = this->getCoordinatesIdList(name, path); 
    497     std::list<StdString>::const_iterator it = coords.begin(), end = coords.end(); 
    498     std::set<StdString> dimVarList; 
    499  
     496    std::list<StdString> varCoords = this->getCoordinatesIdList(name, path); 
     497    std::list<StdString> varDims = this->getDimensionsList(&name, path); 
     498    std::list<StdString>::const_iterator it = varCoords.begin(), end = varCoords.end(); 
     499    std::set<StdString> varDims1D; 
     500 
     501    // Firstly, loop over coordinate list 
    500502    for (; it != end; it++) 
    501503    { 
    502504      const StdString& coord = *it; 
    503       if (this->hasVariable(coord, path) && !this->isTemporal(coord, path) && this->isLonOrLat(coord, path)) 
    504       { 
    505         std::map<StdString, StdSize> dimvar = this->getDimensions(&coord, path); 
    506         if ((dimvar.size() == 1)) 
     505      if (this->hasVariable(coord, path) && !this->isTemporal(coord, path) ) 
     506      { 
     507        std::map<StdString, StdSize> coordDims = this->getDimensions(&coord, path); 
     508        for (std::map<StdString, StdSize>::const_iterator itTmp = coordDims.begin(); itTmp != coordDims.end(); itTmp++) 
    507509        { 
    508           dimVarList.insert(dimvar.begin()->first); 
     510          varDims.remove(itTmp->first); 
     511        } 
     512        if (this->isLonOrLat(coord, path) && coordDims.size() == 1) 
     513        { 
     514          varDims1D.insert(coordDims.begin()->first); 
    509515          continue; 
    510516        } 
    511517      } 
    512518    } 
    513     return (dimVarList.size() != 1); 
     519    // Secondly, loop over remaining dimensions 
     520    for (it= varDims.begin(); it != varDims.end(); it++) 
     521    { 
     522      const StdString& coord = *it; 
     523      std::map<StdString, StdSize> coordDims = this->getDimensions(&coord, path); 
     524      if (this->hasVariable(coord, path) && !this->isTemporal(coord, path) ) 
     525      { 
     526        if (this->isLonOrLat(coord, path) && coordDims.size() == 1) 
     527        { 
     528          varDims1D.insert(coordDims.begin()->first); 
     529          continue; 
     530        } 
     531      } 
     532    } 
     533 
     534    return (varDims1D.size() == 2); 
    514535  } 
    515536 
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/nc4_data_input.cpp

    r1434 r1447  
    350350      StdString boundsLonName = this->getBoundsId(lonName); 
    351351 
    352       int nbVertex = this->getNbVertex(fieldId); 
     352      int nbVertex = 4; //this->getNbVertex(fieldId); 
    353353      if (!domain->nvertex.isEmpty() && (domain->nvertex != nbVertex)) 
    354354      { 
Note: See TracChangeset for help on using the changeset viewer.