Changeset 666 for XIOS/trunk/src/node/axis.cpp
- Timestamp:
- 08/24/15 14:53:27 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/axis.cpp
r657 r666 76 76 void CAxis::checkAttributes(void) 77 77 { 78 if (this-> size.isEmpty())78 if (this->n_glo.isEmpty()) 79 79 ERROR("CAxis::checkAttributes(void)", 80 << "Attribute < size> of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be specified");81 StdSize size = this-> size.getValue();82 83 isDistributed_ = !this-> ibegin.isEmpty() || !this->ni.isEmpty();84 85 if (!this-> ibegin.isEmpty())86 { 87 StdSize ibegin = this-> ibegin.getValue();80 << "Attribute <n_glo> of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be specified"); 81 StdSize size = this->n_glo.getValue(); 82 83 isDistributed_ = !this->begin.isEmpty() || !this->n.isEmpty(); 84 85 if (!this->begin.isEmpty()) 86 { 87 StdSize ibegin = this->begin.getValue(); 88 88 if ((ibegin < 0) || (ibegin > size-1)) 89 89 ERROR("CAxis::checkAttributes(void)", 90 90 << "Attribute <ibegin> of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be non-negative and smaller than size-1"); 91 91 } 92 else this-> ibegin.setValue(0);93 94 if (!this->n i.isEmpty())95 { 96 StdSize ni = this->n i.getValue();92 else this->begin.setValue(0); 93 94 if (!this->n.isEmpty()) 95 { 96 StdSize ni = this->n.getValue(); 97 97 if ((ni < 0) || (ni > size)) 98 98 ERROR("CAxis::checkAttributes(void)", 99 99 << "Attribute <ni> of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be non-negative and smaller than size"); 100 100 } 101 else this->n i.setValue(size);101 else this->n.setValue(size); 102 102 103 103 StdSize true_size = value.numElements(); 104 if (this->n i.getValue() != true_size)104 if (this->n.getValue() != true_size) 105 105 ERROR("CAxis::checkAttributes(void)", 106 106 << "The array \'value\' of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] has a different size that the one defined by the \'size\' attribute"); … … 121 121 } 122 122 else if (data_n.isEmpty()) 123 data_n.setValue(n i.getValue());123 data_n.setValue(n.getValue()); 124 124 125 125 if (data_index.isEmpty()) … … 127 127 int dn = data_n.getValue(); 128 128 data_index.resize(dn); 129 for (int i = 0; i < dn; ++i) data_index(i) = (i+1);129 for (int i = 0; i < dn; ++i) data_index(i) = i; 130 130 } 131 131 } … … 133 133 void CAxis::checkZoom(void) 134 134 { 135 if (0 == global_zoom_size) global_zoom_size = this-> size.getValue();135 if (0 == global_zoom_size) global_zoom_size = this->n_glo.getValue(); 136 136 } 137 137 138 138 void CAxis::checkMask() 139 139 { 140 int begin_mask = 0,141 end_mask = ni.getValue()-1;142 143 if (!zoom_begin.isEmpty())144 {145 int zoom_end = zoom_begin.getValue() + zoom_size.getValue() - 1;146 147 begin_mask = std::max(ibegin.getValue(), zoom_begin.getValue());148 end_mask = std::min(ibegin.getValue() + ni.getValue()-1, zoom_end);149 150 begin_mask -= ibegin.getValue();151 end_mask -= ibegin.getValue();152 }153 154 155 140 if (!mask.isEmpty()) 156 141 { 157 if (mask.extent(0) != n i)142 if (mask.extent(0) != n) 158 143 ERROR("CAxis::checkMask(void)", 159 144 << "the mask has not the same size than the local axis" << endl 160 << "Local size is " << n i<< "x" << endl145 << "Local size is " << n << "x" << endl 161 146 << "Mask size is " << mask.extent(0) << "x"); 162 for (int i = 0; i < ni; ++i)163 {164 if (i < begin_mask && i > end_mask) mask(i) = false;165 }166 147 } 167 148 else // (!mask.hasValue()) 168 149 { // Si aucun masque n'est défini, 169 150 // on en crée un nouveau qui valide l'intégralité du domaine. 170 mask.resize(n i);171 for (int i = 0; i < n i.getValue(); ++i)151 mask.resize(n); 152 for (int i = 0; i < n.getValue(); ++i) 172 153 { 173 if (i >= begin_mask && i <= end_mask) 174 mask(i) = true; 175 else mask(i) = false; 154 mask(i) = true; 176 155 } 177 156 } … … 182 161 if (!bounds.isEmpty()) 183 162 { 184 if (bounds.extent(0) != n i|| bounds.extent(1) != 2)163 if (bounds.extent(0) != n || bounds.extent(1) != 2) 185 164 ERROR("CAxis::checkAttributes(void)", 186 165 << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension axis size x 2" << endl 187 << "Axis size is " << n i<< endl166 << "Axis size is " << n << endl 188 167 << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1)); 189 168 hasBounds_ = true; … … 255 234 void CAxis::sendValue() 256 235 { 257 if (n i.getValue() == size.getValue())236 if (n.getValue() == n_glo.getValue()) 258 237 { 259 238 sendNonDistributedValue(); … … 272 251 int nbServer = client->serverSize; 273 252 int range, clientSize = client->clientSize; 253 size_t ni = this->n.getValue(); 254 size_t ibegin = this->begin.getValue(); 274 255 275 256 CArray<size_t,1> globalIndexAxis(ni); 276 size_t ibegin = this->ibegin.getValue();277 257 int zoom_end = global_zoom_begin+global_zoom_size-1; 278 258 std::vector<size_t> globalAxisZoom; … … 285 265 286 266 std::vector<int> nGlobDomain(1); 287 nGlobDomain[0] = size.getValue();267 nGlobDomain[0] = n_glo.getValue(); 288 268 289 269 size_t globalSizeIndex = 1, indexBegin, indexEnd; … … 348 328 int zoom_end = global_zoom_begin+global_zoom_size-1; 349 329 int nb =0; 350 for (size_t idx = 0; idx < n i; ++idx)351 { 352 size_t globalIndex = ibegin + idx;330 for (size_t idx = 0; idx < n; ++idx) 331 { 332 size_t globalIndex = begin + idx; 353 333 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nb; 354 334 } … … 356 336 CArray<double,1> val(nb); 357 337 nb = 0; 358 for (size_t idx = 0; idx < n i; ++idx)359 { 360 size_t globalIndex = ibegin + idx;338 for (size_t idx = 0; idx < n; ++idx) 339 { 340 size_t globalIndex = begin + idx; 361 341 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 362 342 { … … 424 404 { 425 405 idx = static_cast<int>(it->second[n]); 426 ind = idx - ibegin;406 ind = idx - begin; 427 407 428 408 val(n) = value(ind); … … 602 582 } 603 583 604 if ( size == ni)584 if (n_glo == n) 605 585 { 606 586 zoom_begin_srv = global_zoom_begin;
Note: See TracChangeset
for help on using the changeset viewer.