Changeset 807


Ignore:
Timestamp:
12/13/15 15:37:26 (5 years ago)
Author:
ymipsl
Message:

Fix problem for reading dimension variable in file.

When reading file, dimension was not query in correct order due to usage of map instead a list for dimension information storage.

YM

File:
1 edited

Legend:

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

    r802 r807  
    145145    bool isUnstructuredGrid = SuperClassWriter::isUnstructured(fieldId); 
    146146    std::map<StdString, StdSize> dimSizeMap = SuperClassWriter::getDimensions(&fieldId); 
     147    std::list<StdString> dimList = SuperClassWriter::getDimensionsList(&fieldId); 
     148     
    147149    realGridDim = SuperClassWriter::isTemporal(fieldId) ? dimSizeMap.size() - 1 : dimSizeMap.size(); 
    148150    if (isUnstructuredGrid) ++realGridDim; 
     
    154156 
    155157    // Remove unlimited dimension from the map, we dont need it anymore 
    156     if (SuperClassWriter::isTemporal(fieldId)) dimSizeMap.erase(SuperClassWriter::getUnlimitedDimensionName()); 
     158    if (SuperClassWriter::isTemporal(fieldId))  
     159    { 
     160      dimSizeMap.erase(SuperClassWriter::getUnlimitedDimensionName()); 
     161      dimList.pop_front() ;  // assume time dimension is first 
     162    } 
     163     
    157164    int mapSize = dimSizeMap.size() - 1; 
    158165    std::list<std::pair<StdString, StdSize> > listDimSize; 
     166/* 
    159167    for (std::map<StdString, StdSize>::const_iterator itMap = dimSizeMap.begin(); itMap != dimSizeMap.end(); ++itMap) 
    160168      listDimSize.push_front(*itMap); 
     169*/ 
     170    for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 
     171      listDimSize.push_front(*dimSizeMap.find(*it)); 
    161172 
    162173    // Now process domain and axis 
     
    274285    else if (this->isUnstructured(fieldId)) 
    275286    { 
     287      /* 
    276288      if (domain->i_index.isEmpty()) 
    277289         ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     
    279291              << "Trying to read attributes from unstructured grid." 
    280292              << "i_index of domain" << domain->getId() << " is mandatory"); 
    281  
     293       
    282294      int ni = domain->i_index.numElements(); 
     295*/ 
     296      int ni     = domain->ni; 
     297      int ibegin = domain->ibegin; 
     298      if (domain->i_index.isEmpty()) 
     299      { 
     300        domain->i_index.resize(ni) ; 
     301        for(int idx = 0; idx < ni; ++idx) domain->i_index(idx)=ibegin+idx ; 
     302      } 
     303       
    283304      std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 
    284305      nSizeLatLon[0]  = domain->ni_glo.getValue(); 
Note: See TracChangeset for help on using the changeset viewer.