Changeset 970 for XIOS/trunk/src


Ignore:
Timestamp:
10/13/16 15:48:43 (8 years ago)
Author:
mhnguyen
Message:

Making some changes in axis checking condition to make it coherent with checking condition on domain

+) Change order of checking

Test
+NO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/axis.cpp

    r968 r970  
    213213      StdSize size = this->n_glo.getValue(); 
    214214 
    215       if (!this->begin.isEmpty()) 
    216       { 
    217         if (begin < 0 || begin > size - 1) 
    218           ERROR("CAxis::checkAttributes(void)", 
    219                 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
    220                 << "The axis is wrongly defined, attribute 'begin' (" << begin.getValue() << ") must be non-negative and smaller than size-1 (" << size - 1 << ")."); 
    221       } 
    222       else this->begin.setValue(0); 
    223  
    224       if (!this->n.isEmpty()) 
    225       { 
    226         if (n < 0 || n > size) 
    227           ERROR("CAxis::checkAttributes(void)", 
    228                 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
    229                 << "The axis is wrongly defined, attribute 'n' (" << n.getValue() << ") must be non-negative and smaller than size (" << size << ")."); 
    230       } 
    231       else this->n.setValue(size); 
    232  
    233       isDistributed_ = (!this->begin.isEmpty() && !this->n.isEmpty() && (this->begin + this->n < this->n_glo)) || 
    234                        (!this->n.isEmpty() && (this->n != this->n_glo)); 
     215      if (!this->index.isEmpty()) 
     216      { 
     217        if (n.isEmpty()) n = index.numElements(); 
     218 
     219        // It's not so correct but if begin is not the first value of index  
     220        // then data on the local axis has user-defined distribution. In this case, begin has no meaning. 
     221        if (begin.isEmpty()) begin = index(0);          
     222      } 
     223      else  
     224      { 
     225        if (!this->begin.isEmpty()) 
     226        { 
     227          if (begin < 0 || begin > size - 1) 
     228            ERROR("CAxis::checkAttributes(void)", 
     229                  << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     230                  << "The axis is wrongly defined, attribute 'begin' (" << begin.getValue() << ") must be non-negative and smaller than size-1 (" << size - 1 << ")."); 
     231        } 
     232        else this->begin.setValue(0); 
     233 
     234        if (!this->n.isEmpty()) 
     235        { 
     236          if (n < 0 || n > size) 
     237            ERROR("CAxis::checkAttributes(void)", 
     238                  << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     239                  << "The axis is wrongly defined, attribute 'n' (" << n.getValue() << ") must be non-negative and smaller than size (" << size << ")."); 
     240        } 
     241        else this->n.setValue(size); 
     242 
     243        { 
     244          index.resize(n); 
     245          for (int i = 0; i < n; ++i) index(i) = i+begin; 
     246        } 
     247      } 
    235248 
    236249      if (!this->value.isEmpty()) 
     
    244257      } 
    245258 
    246       if (this->index.isEmpty()) 
    247       { 
    248         index.resize(n); 
    249         for (int i = 0; i < n; ++i) index(i) = i+begin; 
    250       } 
    251  
    252259      this->checkData(); 
    253260      this->checkZoom(); 
    254261      this->checkMask(); 
    255262      this->checkBounds(); 
     263 
     264      isDistributed_ = (!this->begin.isEmpty() && !this->n.isEmpty() && (this->begin + this->n < this->n_glo)) || 
     265                       (!this->n.isEmpty() && (this->n != this->n_glo)); 
    256266   } 
    257267 
Note: See TracChangeset for help on using the changeset viewer.