Ignore:
Timestamp:
02/08/18 15:40:25 (6 years ago)
Author:
oabramkina
Message:

Bugfix in case of a hole defined on an axis.

Location:
XIOS/dev/XIOS_DEV_CMIP6/src
Files:
3 edited

Legend:

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

    r1415 r1421  
    12851285            int nbWritten = indexToWrite.numElements(); 
    12861286            CArray<double,1> axis_value(indexToWrite.numElements()); 
    1287             for (int i = 0; i < nbWritten; i++) axis_value(i) = axis->value(indexToWrite(i)); 
     1287            for (int i = 0; i < nbWritten; i++) 
     1288            { 
     1289              if (i < axis->value.numElements()) 
     1290                axis_value(i) = axis->value(indexToWrite(i)); 
     1291              else 
     1292                axis_value(i) = 0.; 
     1293            } 
     1294 
    12881295            CArray<double,2> axis_bounds; 
    12891296            CArray<string,1> axis_label; 
     
    12911298            { 
    12921299              axis_label.resize(indexToWrite.numElements()); 
    1293               for (int i = 0; i < nbWritten; i++) axis_label(i) = axis->label(indexToWrite(i)); 
     1300              for (int i = 0; i < nbWritten; i++) 
     1301              { 
     1302                if (i < axis->label.numElements()) 
     1303                  axis_label(i) = axis->label(indexToWrite(i)); 
     1304                else 
     1305                  axis_label(i) = boost::lexical_cast<string>(0);  // Write 0 as a label 
     1306              } 
    12941307            } 
    12951308 
     
    13061319                    for (int i = 0; i < nbWritten; ++i) 
    13071320                    { 
    1308                       axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    1309                       axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
     1321                      if (i < axis->bounds.columns()) 
     1322                      { 
     1323                        axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
     1324                        axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
     1325                      } 
     1326                      else 
     1327                      { 
     1328                        axis_bounds(0, i) = 0.; 
     1329                        axis_bounds(1, i) = 0.; 
     1330 
     1331                      } 
    13101332                    } 
    13111333 
     
    13371359                  for (int i = 0; i < nbWritten; ++i) 
    13381360                  { 
    1339                     axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    1340                     axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
     1361                    if (i < axis->bounds.columns()) 
     1362                    { 
     1363                      axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
     1364                      axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
     1365                    } 
     1366                    else 
     1367                    { 
     1368                      axis_bounds(0, i) = 0.; 
     1369                      axis_bounds(1, i) = 0.; 
     1370                    } 
    13411371                  } 
    13421372                  SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp

    r1416 r1421  
    1616namespace xios { 
    1717 
    18    /// ////////////////////// Définitions ////////////////////// /// 
     18   /// ////////////////////// Definitions ////////////////////// /// 
    1919 
    2020   CAxis::CAxis(void) 
     
    284284      } 
    285285 
     286      // Remove this check because it doen't make sense in case of a hole or overlapping axes 
    286287      if (!this->value.isEmpty()) 
    287288      { 
    288         StdSize true_size = value.numElements(); 
    289         if (this->n.getValue() != true_size) 
    290           ERROR("CAxis::checkAttributes(void)", 
    291                 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
    292                 << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     289//        StdSize true_size = value.numElements(); 
     290//        if (this->n.getValue() != true_size) 
     291//          ERROR("CAxis::checkAttributes(void)", 
     292//                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     293//                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
    293294        this->hasValue = true; 
    294295      } 
    295296 
    296       this->checkData(); 
    297       this->checkZoom(); 
    298       this->checkMask(); 
    299297      this->checkBounds(); 
    300       this->checkLabel(); 
     298 
     299      CContext* context=CContext::getCurrent(); 
     300      if (context->hasClient) 
     301      { 
     302        this->checkData(); 
     303        this->checkZoom(); 
     304        this->checkMask(); 
     305        this->checkLabel(); 
     306      } 
    301307   } 
    302308 
     
    457463     if (this->areClientAttributesChecked_) return; 
    458464 
    459      this->checkAttributes(); 
     465     CContext* context=CContext::getCurrent(); 
     466     if (context->hasClient && !context->hasServer) this->checkAttributes(); 
    460467 
    461468     this->areClientAttributesChecked_ = true; 
     
    697704      } 
    698705 
    699       localIndexToWriteOnServer.resize(nbWritten); 
     706      localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
     707//      localIndexToWriteOnServer.resize(nbWritten); 
    700708 
    701709      nbWritten = 0; 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp

    r1401 r1421  
    1919namespace xios { 
    2020 
    21    /// ////////////////////// Déclarations ////////////////////// /// 
     21   /// ////////////////////// Dᅵᅵclarations ////////////////////// /// 
    2222 
    2323   class CGridGroup; 
     
    9191         StdSize  getDataSize(void) const; 
    9292 
    93          /// Entrées-sorties de champs  
     93         /// Entrᅵᅵes-sorties de champs 
    9494         template <int n> 
    9595         void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; 
     
    421421     int dim = domainMasks.size() * 2 + axisMasks.size(); 
    422422     std::vector<CDomain*> domainP = this->getDomains(); 
     423     std::vector<CAxis*> axisP = this->getAxis(); 
    423424 
    424425     std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); 
     
    434435      } 
    435436      else if (1 == axisDomainOrder(i)) { 
    436         eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements(); 
     437//        eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements(); 
     438        eachDimSize[indexMap[i]] = axisP[idxAxis]->n; 
    437439        ++idx; ++idxAxis; 
    438440      } 
     
    486488        else if (1 == axisDomainOrder(i)) 
    487489        { 
    488           maskValue = maskValue && (*axisMasks[idxAxis])(idxLoop[indexMap[i]]); 
     490          int idxTmp = idxLoop[indexMap[i]]; 
     491          if (idxTmp < (*axisMasks[idxDomain]).numElements()) 
     492            maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp); 
     493          else 
     494            maskValue = false; 
     495 
    489496          ++idxAxis; 
    490497        } 
Note: See TracChangeset for help on using the changeset viewer.