Changeset 816 for XIOS/trunk


Ignore:
Timestamp:
01/26/16 18:19:04 (8 years ago)
Author:
mhnguyen
Message:

Changing value of axis from obligatory to optional attribute

Test
+) On Curie
+) Test passes

Location:
XIOS/trunk/src
Files:
3 edited

Legend:

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

    r802 r816  
    639639        { 
    640640          SuperClassWriter::addDimension(axisid, zoom_size); 
    641           dims.push_back(axisid); 
    642           SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 
    643  
    644           if (!axis->name.isEmpty()) 
    645             SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 
    646  
    647           if (!axis->standard_name.isEmpty()) 
    648             SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 
    649  
    650           if (!axis->long_name.isEmpty()) 
    651             SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 
    652  
    653           if (!axis->unit.isEmpty()) 
    654             SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 
    655  
    656           if (!axis->positive.isEmpty()) 
     641          if (axis->hasValue) 
    657642          { 
    658             SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 
    659             SuperClassWriter::addAttribute("positive", 
    660                                            (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 
    661                                            &axisid); 
    662           } 
    663  
    664           StdString axisBoundsId = axisid + "_bounds"; 
    665           if (!axis->bounds.isEmpty()) 
    666           { 
    667             dims.push_back("axis_nbounds"); 
    668             SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 
    669             SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 
    670           } 
    671  
    672           SuperClassWriter::definition_end(); 
    673           switch (SuperClass::type) 
    674           { 
    675             case MULTI_FILE: 
     643            dims.push_back(axisid); 
     644            SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 
     645 
     646            if (!axis->name.isEmpty()) 
     647              SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 
     648 
     649            if (!axis->standard_name.isEmpty()) 
     650              SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 
     651 
     652            if (!axis->long_name.isEmpty()) 
     653              SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 
     654 
     655            if (!axis->unit.isEmpty()) 
     656              SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 
     657 
     658            if (!axis->positive.isEmpty()) 
    676659            { 
    677               CArray<double,1> axis_value(zoom_size_srv); 
    678               for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value_srv(i); 
    679               SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
    680  
    681               if (!axis->bounds.isEmpty()) 
    682                 SuperClassWriter::writeData(axis->bound_srv, axisBoundsId, isCollective, 0); 
    683  
    684               SuperClassWriter::definition_start(); 
    685  
    686               break; 
     660              SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 
     661              SuperClassWriter::addAttribute("positive", 
     662                                             (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 
     663                                             &axisid); 
    687664            } 
    688             case ONE_FILE: 
     665 
     666            StdString axisBoundsId = axisid + "_bounds"; 
     667            if (!axis->bounds.isEmpty()) 
    689668            { 
    690               CArray<double,1> axis_value(zoom_size_srv); 
    691               axis_value = axis->value_srv; 
    692  
    693               std::vector<StdSize> start(1), startBounds(2) ; 
    694               std::vector<StdSize> count(1), countBounds(2) ; 
    695               start[0] = startBounds[0] = zoom_begin_srv-axis->global_zoom_begin; 
    696               count[0] = countBounds[0] = zoom_size_srv; 
    697               startBounds[1] = 0; 
    698               countBounds[1] = 2; 
    699               SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
    700  
    701               if (!axis->bounds.isEmpty()) 
    702                 SuperClassWriter::writeData(axis->bound_srv, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
    703  
    704               SuperClassWriter::definition_start(); 
    705  
    706               break; 
     669              dims.push_back("axis_nbounds"); 
     670              SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 
     671              SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 
    707672            } 
    708             default : 
    709               ERROR("CNc4DataOutput::writeDomain(domain)", 
    710                     << "[ type = " << SuperClass::type << "]" 
    711                     << " not implemented yet !"); 
     673 
     674            SuperClassWriter::definition_end(); 
     675 
     676            switch (SuperClass::type) 
     677            { 
     678              case MULTI_FILE: 
     679              { 
     680                CArray<double,1> axis_value(zoom_size_srv); 
     681                for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value_srv(i); 
     682                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
     683 
     684                if (!axis->bounds.isEmpty()) 
     685                  SuperClassWriter::writeData(axis->bound_srv, axisBoundsId, isCollective, 0); 
     686 
     687                SuperClassWriter::definition_start(); 
     688 
     689                break; 
     690              } 
     691              case ONE_FILE: 
     692              { 
     693                CArray<double,1> axis_value(zoom_size_srv); 
     694                axis_value = axis->value_srv; 
     695 
     696                std::vector<StdSize> start(1), startBounds(2) ; 
     697                std::vector<StdSize> count(1), countBounds(2) ; 
     698                start[0] = startBounds[0] = zoom_begin_srv-axis->global_zoom_begin; 
     699                count[0] = countBounds[0] = zoom_size_srv; 
     700                startBounds[1] = 0; 
     701                countBounds[1] = 2; 
     702                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
     703 
     704                if (!axis->bounds.isEmpty()) 
     705                  SuperClassWriter::writeData(axis->bound_srv, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
     706 
     707                SuperClassWriter::definition_start(); 
     708 
     709                break; 
     710              } 
     711              default : 
     712                ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 
     713                      << "[ type = " << SuperClass::type << "]" 
     714                      << " not implemented yet !"); 
     715            } 
    712716          } 
    713717        } 
  • XIOS/trunk/src/node/axis.cpp

    r815 r816  
    2626      , isDistributed_(false), hasBounds_(false), isCompressible_(false) 
    2727      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    28       , transformationMap_(), global_zoom_begin(0), global_zoom_size(0) 
     28      , transformationMap_(), global_zoom_begin(0), global_zoom_size(0), hasValue(false) 
    2929   { 
    3030   } 
     
    3535      , isDistributed_(false), hasBounds_(false), isCompressible_(false) 
    3636      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    37       , transformationMap_(), global_zoom_begin(0), global_zoom_size(0) 
     37      , transformationMap_(), global_zoom_begin(0), global_zoom_size(0), hasValue(false) 
    3838   { 
    3939   } 
     
    220220      else this->n.setValue(size); 
    221221 
    222       StdSize true_size = value.numElements(); 
    223       if (this->n.getValue() != true_size) 
    224         ERROR("CAxis::checkAttributes(void)", 
    225               << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
    226               << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     222      if (!this->value.isEmpty()) 
     223      { 
     224        StdSize true_size = value.numElements(); 
     225        if (this->n.getValue() != true_size) 
     226          ERROR("CAxis::checkAttributes(void)", 
     227                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     228                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     229        this->hasValue = true; 
     230      } 
     231 
     232//      StdSize true_size = value.numElements(); 
     233//      if (this->n.getValue() != true_size) 
     234//        ERROR("CAxis::checkAttributes(void)", 
     235//              << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     236//              << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
    227237 
    228238      this->checkData(); 
     
    351361     { 
    352362       sendServerAttribut(globalDim, orderPositionInGrid, distType); 
    353        sendValue(globalDim, orderPositionInGrid, distType); 
     363       if (hasValue) sendValue(globalDim, orderPositionInGrid, distType); 
    354364     } 
    355365 
     
    864874      zoom_size_srv  = zoom_end_srv - zoom_begin_srv + 1; 
    865875    } 
    866     value_srv.resize(zoom_size_srv); 
    867     bound_srv.resize(2,zoom_size_srv); 
     876    if (hasValue) 
     877    { 
     878      value_srv.resize(zoom_size_srv); 
     879      if (hasBounds_)  bound_srv.resize(2,zoom_size_srv); 
     880    } 
    868881  } 
    869882 
  • XIOS/trunk/src/node/axis.hpp

    r815 r816  
    119119        CArray<double,1> value_srv; 
    120120        CArray<double,2> bound_srv; 
     121        bool hasValue; 
    121122 
    122123      private: 
Note: See TracChangeset for help on using the changeset viewer.