Changeset 633
- Timestamp:
- 07/09/15 14:05:43 (10 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml
r624 r633 26 26 <domain_definition> 27 27 <domain id="domain_atm" /> 28 <domain id="domain_atm_zoom" /> 28 <domain id="domain_atm_zoom" domain_ref="domain_atm"> 29 <zoom_domain zoom_ibegin="39" zoom_ni="20" zoom_jbegin="39" zoom_nj="5"/> 30 </domain> 29 31 </domain_definition> 30 32 … … 35 37 </grid> 36 38 <grid id="grid_A_atm_zoom"> 37 <domain domain_ref="domain_atm " />39 <domain domain_ref="domain_atm_zoom" /> 38 40 <axis axis_ref="axis_atm_zoom" /> 39 41 </grid> -
XIOS/trunk/inputs/Version2/iodef.xml
r631 r633 11 11 <field id="field_Two_Axis" operation="average" freq_op="3600s" grid_ref="grid_Two_Axis" /> 12 12 <field id="field_All_Axis" operation="average" freq_op="3600s" grid_ref="grid_All_Axis" /> 13 <field id="field_Axis_transformed" operation="average" freq_op="3600s" field_ref="field_ A" grid_ref="grid_Axis_tranformed" />13 <field id="field_Axis_transformed" operation="average" freq_op="3600s" field_ref="field_Two_Axis" grid_ref="grid_Axis_tranformed" /> 14 14 <field id="field_Axis_transformed_Interpolated" operation="average" freq_op="3600s" field_ref="field_Axis" grid_ref="grid_Axis_tranformed_Interpolated" /> 15 15 <field id="field_Scalar" operation="average" freq_op="3600s" grid_ref="ScalarGrid" /> … … 17 17 18 18 <file_definition type="multiple_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 19 <file id="output" name="output" >19 <file id="output" name="output" type="one_file"> 20 20 <field field_ref="field_A" /> 21 21 </file> … … 26 26 <field field_ref="field_All_Axis" /> 27 27 </file> 28 <file id="output_Axis_transformed" name="output_Axis_transformed" >28 <file id="output_Axis_transformed" name="output_Axis_transformed" type="one_file"> 29 29 <field field_ref="field_Axis_transformed" /> 30 30 </file> … … 87 87 <grid id="grid_Axis_tranformed"> 88 88 <!-- <domain domain_ref="domain_A" />--> 89 <domain domain_ref="domain_A_zoom" />90 <axis axis_ref="axis_H" />91 <!-- <axis axis_ref="axis_E" />-->92 <!-- <axis axis_ref="axis_F" />-->89 <!-- <domain domain_ref="domain_A_zoom" />--> 90 <!-- <axis axis_ref="axis_H" />--> 91 <axis axis_ref="axis_E" /> 92 <axis axis_ref="axis_F" /> 93 93 </grid> 94 94 <grid id="grid_Axis_tranformed_Interpolated"> -
XIOS/trunk/src/config/axis_attribute.conf
r609 r633 10 10 DECLARE_ATTRIBUTE(int, zoom_size) 11 11 DECLARE_ENUM2(positive, up, down) 12 13 /* LOCAL */ 12 14 DECLARE_ARRAY(double, 1, value) 13 15 -
XIOS/trunk/src/node/axis.cpp
r631 r633 12 12 #include "zoom_axis.hpp" 13 13 #include "interpolate_axis.hpp" 14 #include "server_distribution_description.hpp" 15 #include "client_server_mapping_distributed.hpp" 14 16 15 17 namespace xios { … … 20 22 : CObjectTemplate<CAxis>() 21 23 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 22 , isDistributed_(false) 24 , isDistributed_(false), hasBounds_(false) 23 25 , transformationMap_(), global_zoom_begin(0), global_zoom_size(0) 24 26 { … … 28 30 : CObjectTemplate<CAxis>(id) 29 31 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 30 , isDistributed_(false) 32 , isDistributed_(false), hasBounds_(false) 31 33 , transformationMap_(), global_zoom_begin(0), global_zoom_size(0) 32 34 { … … 99 101 else this->ni.setValue(size); 100 102 101 // StdSize true_size = value.numElements(); 102 // if (this->ni.getValue() != true_size) 103 // ERROR("CAxis::checkAttributes(void)", 104 // << "The array \'value\' of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] has a different size that the one defined by the \'size\' attribute"); 105 103 StdSize true_size = value.numElements(); 104 if (this->ni.getValue() != true_size) 105 ERROR("CAxis::checkAttributes(void)", 106 << "The array \'value\' of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] has a different size that the one defined by the \'size\' attribute"); 106 107 107 108 this->checkData(); 109 this->checkZoom(); 108 110 this->checkMask(); 109 this->checkZoom(); 110 111 if (!bounds.isEmpty()) 112 { 113 if (bounds.extent(0) != size || bounds.extent(1) != 2) 114 ERROR("CAxis::checkAttributes(void)", 115 << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension axis size x 2" << endl 116 << "Axis size is " << size << endl 117 << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1)); 118 } 111 this->checkBounds(); 119 112 } 120 113 … … 185 178 } 186 179 180 void CAxis::checkBounds() 181 { 182 if (!bounds.isEmpty()) 183 { 184 if (bounds.extent(0) != ni || bounds.extent(1) != 2) 185 ERROR("CAxis::checkAttributes(void)", 186 << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension axis size x 2" << endl 187 << "Axis size is " << ni << endl 188 << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1)); 189 hasBounds_ = true; 190 } 191 else hasBounds_ = false; 192 } 193 194 187 195 bool CAxis::dispatchEvent(CEventServer& event) 188 196 { … … 196 204 return true; 197 205 break; 206 case EVENT_ID_INDEX: 207 recvIndex(event); 208 return true; 209 break; 210 case EVENT_ID_DISTRIBUTED_VALUE: 211 recvDistributedValue(event); 212 return true; 213 break; 214 case EVENT_ID_NON_DISTRIBUTED_VALUE: 215 recvNonDistributedValue(event); 216 return true; 217 break; 198 218 default : 199 219 ERROR("bool CContext::dispatchEvent(CEventServer& event)", … … 227 247 { 228 248 sendServerAttribut(globalDim, orderPositionInGrid, distType); 249 sendValue(); 229 250 } 230 251 231 252 this->isChecked = true; 232 253 } 254 255 void CAxis::sendValue() 256 { 257 if (ni.getValue() == size.getValue()) 258 { 259 sendNonDistributedValue(); 260 } 261 else 262 { 263 computeConnectedServer(); 264 sendDistributedValue(); 265 } 266 } 267 268 void CAxis::computeConnectedServer() 269 { 270 CContext* context = CContext::getCurrent(); 271 CContextClient* client = context->client; 272 int nbServer = client->serverSize; 273 int range, clientSize = client->clientSize; 274 275 CArray<size_t,1> globalIndexAxis(ni); 276 size_t ibegin = this->ibegin.getValue(); 277 int zoom_end = global_zoom_begin+global_zoom_size-1; 278 std::vector<size_t> globalAxisZoom; 279 for (size_t idx = 0; idx < ni; ++idx) 280 { 281 size_t globalIndex = ibegin + idx; 282 globalIndexAxis(idx) = globalIndex; 283 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) globalAxisZoom.push_back(globalIndex); 284 } 285 286 std::vector<int> nGlobDomain(1); 287 nGlobDomain[0] = size.getValue(); 288 289 size_t globalSizeIndex = 1, indexBegin, indexEnd; 290 for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 291 indexBegin = 0; 292 for (int i = 0; i < clientSize; ++i) 293 { 294 range = globalSizeIndex / clientSize; 295 if (i < (globalSizeIndex%clientSize)) ++range; 296 if (i == client->clientRank) break; 297 indexBegin += range; 298 } 299 indexEnd = indexBegin + range - 1; 300 301 CServerDistributionDescription serverDescription(nGlobDomain); 302 serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 303 CClientServerMappingDistributed clientServerMap(serverDescription.getGlobalIndexRange(), client->intraComm); 304 clientServerMap.computeServerIndexMapping(globalIndexAxis); 305 const std::map<int, std::vector<size_t> >& globalIndexAxisOnServer = clientServerMap.getGlobalIndexOnServer(); 306 307 std::map<int, std::vector<size_t> >::const_iterator it = globalIndexAxisOnServer.begin(), 308 ite = globalIndexAxisOnServer.end(); 309 std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 310 iteVec = (globalAxisZoom).end(); 311 indSrv_.clear(); 312 for (; it != ite; ++it) 313 { 314 int rank = it->first; 315 const std::vector<size_t>& globalIndexTmp = it->second; 316 int nb = globalIndexTmp.size(); 317 318 for (int i = 0; i < nb; ++i) 319 { 320 if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 321 { 322 indSrv_[rank].push_back(globalIndexTmp[i]); 323 } 324 } 325 } 326 327 connectedServerRank_.clear(); 328 for (it = globalIndexAxisOnServer.begin(); it != ite; ++it) { 329 connectedServerRank_.push_back(it->first); 330 } 331 332 if (!indSrv_.empty()) 333 { 334 connectedServerRank_.clear(); 335 for (it = indSrv_.begin(); it != indSrv_.end(); ++it) 336 connectedServerRank_.push_back(it->first); 337 } 338 nbConnectedClients_ = clientServerMap.computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 339 340 } 341 342 void CAxis::sendNonDistributedValue() 343 { 344 CContext* context = CContext::getCurrent(); 345 CContextClient* client = context->client; 346 CEventClient event(getType(),EVENT_ID_NON_DISTRIBUTED_VALUE); 347 348 int zoom_end = global_zoom_begin+global_zoom_size-1; 349 int nb =0; 350 for (size_t idx = 0; idx < ni; ++idx) 351 { 352 size_t globalIndex = ibegin + idx; 353 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nb; 354 } 355 356 CArray<double,1> val(nb); 357 nb = 0; 358 for (size_t idx = 0; idx < ni; ++idx) 359 { 360 size_t globalIndex = ibegin + idx; 361 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 362 { 363 val(nb) = value(idx); 364 ++nb; 365 } 366 } 367 368 if (client->isServerLeader()) 369 { 370 std::list<CMessage> msgs; 371 372 const std::list<int>& ranks = client->getRanksServerLeader(); 373 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 374 { 375 // Use const int to ensure CMessage holds a copy of the value instead of just a reference 376 msgs.push_back(CMessage()); 377 CMessage& msg = msgs.back(); 378 msg << this->getId(); 379 msg << val; 380 event.push(*itRank,1,msg); 381 } 382 client->sendEvent(event); 383 } 384 else client->sendEvent(event); 385 } 386 387 void CAxis::sendDistributedValue(void) 388 { 389 int ns, n, i, j, ind, nv, idx; 390 CContext* context = CContext::getCurrent(); 391 CContextClient* client=context->client; 392 393 // send value for each connected server 394 CEventClient eventIndex(getType(), EVENT_ID_INDEX); 395 CEventClient eventVal(getType(), EVENT_ID_DISTRIBUTED_VALUE); 396 397 list<CMessage> list_msgsIndex, list_msgsVal; 398 list<CArray<int,1> > list_indi; 399 list<CArray<double,1> > list_val; 400 list<CArray<double,2> > list_bounds; 401 402 std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 403 iteMap = indSrv_.end(); 404 for (int k = 0; k < connectedServerRank_.size(); ++k) 405 { 406 int nbData = 0; 407 int rank = connectedServerRank_[k]; 408 it = indSrv_.find(rank); 409 if (iteMap != it) 410 nbData = it->second.size(); 411 412 list_indi.push_back(CArray<int,1>(nbData)); 413 list_val.push_back(CArray<double,1>(nbData)); 414 415 if (hasBounds_) 416 { 417 list_bounds.push_back(CArray<double,2>(2,nbData)); 418 } 419 420 CArray<int,1>& indi = list_indi.back(); 421 CArray<double,1>& val = list_val.back(); 422 423 for (n = 0; n < nbData; ++n) 424 { 425 idx = static_cast<int>(it->second[n]); 426 ind = idx - ibegin; 427 428 val(n) = value(ind); 429 indi(n) = idx; 430 431 if (hasBounds_) 432 { 433 CArray<double,2>& boundsVal = list_bounds.back(); 434 boundsVal(0, n) = bounds(0,n); 435 boundsVal(1, n) = bounds(1,n); 436 } 437 } 438 439 list_msgsIndex.push_back(CMessage()); 440 list_msgsIndex.back() << this->getId() << list_indi.back(); 441 442 list_msgsVal.push_back(CMessage()); 443 list_msgsVal.back() << this->getId() << list_val.back(); 444 445 if (hasBounds_) 446 { 447 list_msgsVal.back() << list_bounds.back(); 448 } 449 450 eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 451 eventVal.push(rank, nbConnectedClients_[rank], list_msgsVal.back()); 452 } 453 454 client->sendEvent(eventIndex); 455 client->sendEvent(eventVal); 456 } 457 458 void CAxis::recvIndex(CEventServer& event) 459 { 460 list<CEventServer::SSubEvent>::iterator it; 461 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 462 { 463 CBufferIn* buffer = it->buffer; 464 string domainId; 465 *buffer >> domainId; 466 get(domainId)->recvIndex(it->rank, *buffer); 467 } 468 } 469 470 void CAxis::recvIndex(int rank, CBufferIn& buffer) 471 { 472 buffer >> indiSrv_[rank]; 473 } 474 475 void CAxis::recvDistributedValue(CEventServer& event) 476 { 477 list<CEventServer::SSubEvent>::iterator it; 478 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 479 { 480 CBufferIn* buffer = it->buffer; 481 string domainId; 482 *buffer >> domainId; 483 get(domainId)->recvDistributedValue(it->rank, *buffer); 484 } 485 } 486 487 void CAxis::recvDistributedValue(int rank, CBufferIn& buffer) 488 { 489 CArray<int,1> &indi = indiSrv_[rank]; 490 CArray<double,1> val; 491 CArray<double,2> boundsVal; 492 493 buffer >> val; 494 if (hasBounds_) buffer >> boundsVal; 495 496 int i, j, ind_srv; 497 for (int ind = 0; ind < indi.numElements(); ++ind) 498 { 499 i = indi(ind); 500 ind_srv = i - zoom_begin_srv; 501 value_srv(ind_srv) = val(ind); 502 if (hasBounds_) 503 { 504 bound_srv(0,ind_srv) = boundsVal(0, ind); 505 bound_srv(1,ind_srv) = boundsVal(1, ind); 506 } 507 } 508 } 509 510 void CAxis::recvNonDistributedValue(CEventServer& event) 511 { 512 list<CEventServer::SSubEvent>::iterator it; 513 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 514 { 515 CBufferIn* buffer = it->buffer; 516 string domainId; 517 *buffer >> domainId; 518 get(domainId)->recvNonDistributedValue(it->rank, *buffer); 519 } 520 } 521 522 void CAxis::recvNonDistributedValue(int rank, CBufferIn& buffer) 523 { 524 CArray<double,1> val; 525 buffer >> val; 526 527 for (int ind = 0; ind < val.numElements(); ++ind) 528 { 529 value_srv(ind) = val(ind); 530 if (hasBounds_) 531 { 532 bound_srv(0,ind) = bounds(0,ind); 533 bound_srv(1,ind) = bounds(1,ind); 534 } 535 } 536 } 233 537 234 538 void CAxis::sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, … … 263 567 msg << this->getId(); 264 568 msg << ni << begin << end; 265 msg <<global_zoom_begin<<global_zoom_size;569 msg << global_zoom_begin << global_zoom_size; 266 570 267 571 event.push(*itRank,1,msg); … … 304 608 zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 305 609 } 610 value_srv.resize(zoom_size_srv); 611 bound_srv.resize(2,zoom_size_srv); 306 612 } 307 613 -
XIOS/trunk/src/node/axis.hpp
r631 r633 39 39 enum EEventId 40 40 { 41 EVENT_ID_SERVER_ATTRIBUT 41 EVENT_ID_SERVER_ATTRIBUT, 42 EVENT_ID_INDEX, 43 EVENT_ID_DISTRIBUTED_VALUE, 44 EVENT_ID_NON_DISTRIBUTED_VALUE 42 45 } ; 43 46 … … 102 105 int ni_srv, begin_srv, end_srv; 103 106 int global_zoom_begin, global_zoom_size; // The real global zoom begin and zoom size after axis is transformed (zoomed) 107 CArray<double,1> value_srv; 108 CArray<double,2> bound_srv; 104 109 private : 105 110 void checkData(); 106 111 void checkMask(); 107 112 void checkZoom(); 113 void checkBounds(); 108 114 void checkTransformations(); 109 115 void computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid, 110 116 CServerDistributionDescription::ServerDistributionType disType); 117 void sendValue(); 118 void computeConnectedServer(void); 119 void sendDistributedValue(); 120 void sendNonDistributedValue(); 111 121 122 static void recvIndex(CEventServer& event); 123 static void recvDistributedValue(CEventServer& event); 124 static void recvNonDistributedValue(CEventServer& event); 125 void recvIndex(int rank, CBufferIn& buffer); 126 void recvDistributedValue(int rank, CBufferIn& buffer); 127 void recvNonDistributedValue(int rank, CBufferIn& buffer); 112 128 113 129 void setTransformations(const TransMapTypes&); … … 118 134 TransMapTypes transformationMap_; 119 135 bool isDistributed_; 120 136 std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 137 std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 138 std::vector<int> connectedServerRank_; 139 std::map<int, CArray<int,1> > indiSrv_; 140 bool hasBounds_; 121 141 DECLARE_REF_FUNC(Axis,axis) 122 142 }; // class CAxis -
XIOS/trunk/src/node/domain.cpp
r631 r633 563 563 zoom_jend_client = jend_client < global_zoom_jend ? jend_client : global_zoom_jend ; 564 564 zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ; 565 if (zoom_nj_client<0) zoom_nj_client=0 ; 566 567 // int zoom_iend=zoom_ibegin+zoom_ni-1 ; 568 // zoom_ibegin_client = ibegin_client > zoom_ibegin ? ibegin_client : zoom_ibegin ; 569 // zoom_iend_client = iend_client < zoom_iend ? iend_client : zoom_iend ; 570 // zoom_ni_client=zoom_iend_client-zoom_ibegin_client+1 ; 571 // if (zoom_ni_client<0) zoom_ni_client=0 ; 572 // 573 // 574 // int zoom_jend=zoom_jbegin+zoom_nj-1 ; 575 // zoom_jbegin_client = jbegin_client > zoom_jbegin ? jbegin_client : zoom_jbegin ; 576 // zoom_jend_client = jend_client < zoom_jend ? jend_client : zoom_jend ; 577 // zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ; 578 // if (zoom_nj_client<0) zoom_nj_client=0 ; 579 565 if (zoom_nj_client<0) zoom_nj_client=0; 580 566 } 581 567 … … 615 601 616 602 this->checkDomain(); 617 // this->checkZoom();618 603 this->checkBounds(); 619 604 this->checkArea(); … … 624 609 this->checkDomainData(); 625 610 this->checkCompression(); 626 // this->completeLonLatClient();627 // this->computeConnectedServer() ;628 611 } 629 612 else -
XIOS/trunk/src/output/nc4_data_output.cpp
r631 r633 603 603 int zoom_size_srv = axis->zoom_size_srv; 604 604 int zoom_begin_srv = axis->zoom_begin_srv; 605 StdSizezoom_size = (MULTI_FILE == SuperClass::type) ? zoom_size_srv605 int zoom_size = (MULTI_FILE == SuperClass::type) ? zoom_size_srv 606 606 : axis->global_zoom_size; 607 StdSizezoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv607 int zoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv 608 608 : axis->global_zoom_begin; 609 609 610 if ((0 == zoom_size_srv) && (MULTI_FILE == SuperClass::type)) return; 610 611 611 612 std::vector<StdString> dims; … … 615 616 SuperClassWriter::addDimension(axisid, zoom_size); 616 617 dims.push_back(axisid); 617 618 SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 619 620 if (!axis->name.isEmpty()) 621 SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 622 623 if (!axis->standard_name.isEmpty()) 624 SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 625 626 if (!axis->long_name.isEmpty()) 627 SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 628 629 if (!axis->unit.isEmpty()) 630 SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 631 632 if (!axis->positive.isEmpty()) 633 { 634 SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 635 SuperClassWriter::addAttribute("positive", 636 (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 637 &axisid); 638 } 639 640 StdString axisBoundsId = axisid + "_bounds"; 641 if (!axis->bounds.isEmpty()) 642 { 643 dims.push_back("axis_nbounds"); 644 SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 645 SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 646 } 647 648 SuperClassWriter::definition_end(); 618 649 switch (SuperClass::type) 619 650 { 620 651 case MULTI_FILE: 652 { 653 CArray<double,1> axis_value(zoom_size_srv); 654 for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value_srv(i); 655 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 656 657 if (!axis->bounds.isEmpty()) 658 { 659 CArray<double,2> axisBounds(2, zoom_size_srv); 660 for (int i = 0; i < zoom_size_srv; i++) 661 { 662 axisBounds(0, i) = axis->bound_srv(i, 0); 663 axisBounds(1, i) = axis->bound_srv(i, 1); 664 } 665 SuperClassWriter::writeData(axisBounds, axisBoundsId, isCollective, 0); 666 } 667 668 SuperClassWriter::definition_start(); 669 670 break; 671 } 621 672 case ONE_FILE: 622 673 { 623 SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 624 625 if (!axis->name.isEmpty()) 626 SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 627 628 if (!axis->standard_name.isEmpty()) 629 SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 630 631 if (!axis->long_name.isEmpty()) 632 SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 633 634 if (!axis->unit.isEmpty()) 635 SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 636 637 if (!axis->positive.isEmpty()) 638 { 639 SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 640 SuperClassWriter::addAttribute("positive", 641 (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 642 &axisid); 643 } 644 645 StdString axisBoundsId = axisid + "_bounds"; 674 CArray<double,1> axis_value(zoom_size_srv); 675 axis_value = axis->value_srv; 676 677 std::vector<StdSize> start(1) ; 678 std::vector<StdSize> count(1) ; 679 start[0] = zoom_begin_srv-axis->global_zoom_begin; 680 count[0] = zoom_size_srv; 681 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 682 646 683 if (!axis->bounds.isEmpty()) 647 684 { 648 dims.push_back("axis_nbounds"); 649 SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 650 SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 651 } 652 653 SuperClassWriter::definition_end(); 654 655 CArray<double,1> axis_value(zoom_size); 656 for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value(i + zoom_begin_srv); 657 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 658 659 if (!axis->bounds.isEmpty()) 660 { 661 CArray<double,2> axisBounds(2, zoom_size); 662 for (int i = 0; i < zoom_size_srv; i++) 685 CArray<double,2> axisBounds(2, zoom_size_srv); 686 for (int i = 0; i < zoom_size_srv; ++i) 663 687 { 664 axisBounds(0, i ) = axis->bounds(i + zoom_begin_srv, 0);665 axisBounds(1, i ) = axis->bounds(i + zoom_begin_srv, 1);688 axisBounds(0, i+zoom_begin_srv) = axis->bound_srv(i, 0); 689 axisBounds(1, i+zoom_begin_srv) = axis->bound_srv(i, 1); 666 690 } 667 SuperClassWriter::writeData(axisBounds, axisBoundsId, isCollective, 0 );691 SuperClassWriter::writeData(axisBounds, axisBoundsId, isCollective, 0, &start, &count); 668 692 } 669 693 … … 940 964 } 941 965 942 943 // void CNc4DataOutput::writeField_(CField* field)944 // {945 // CContext* context = CContext::getCurrent() ;946 // CContextServer* server=context->server ;947 //948 // std::vector<StdString> dims, coodinates;949 // CGrid* grid = field->grid;950 // CDomain* domain = grid->domain;951 //952 // if (domain->isEmpty())953 // if (SuperClass::type==MULTI_FILE) return ;954 //955 // StdString timeid = StdString("time_counter");956 // StdString domid = (!domain->name.isEmpty())957 // ? domain->name.getValue() : domain->getId();958 // StdString appendDomid = (singleDomain) ? "" : "_"+domid ;959 //960 //// bool isCurvilinear = domain->isCurvilinear ;961 //// bool isCurvilinear = (domain->type == CDomain::type_attr::curvilinear) ;962 //963 // StdString dimXid,dimYid ;964 //965 // switch (domain->type)966 // {967 // case CDomain::type_attr::curvilinear :968 // dimXid = StdString("x").append(appendDomid);969 // dimYid = StdString("y").append(appendDomid);970 // break ;971 // case CDomain::type_attr::regular :972 // dimXid = StdString("lon").append(appendDomid);973 // dimYid = StdString("lat").append(appendDomid);974 // break ;975 // case CDomain::type_attr::unstructured :976 // dimXid = StdString("cell").append(appendDomid);977 // break ;978 // }979 //980 ///*981 // StdString lonid_loc = (server->intraCommSize > 1)982 // ? StdString("lon").append(appendDomid).append("_local")983 // : lonid;984 // StdString latid_loc = (server->intraCommSize > 1)985 // ? StdString("lat").append(appendDomid).append("_local")986 // : latid;987 //*/988 // StdString fieldid = (!field->name.isEmpty())989 // ? field->name.getValue() : field->getBaseFieldReference()->getId();990 //991 //// unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue();992 //// bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize);993 //// bool isCurvilinear = domain->isCurvilinear ;994 //995 // nc_type type ;996 // if (field->prec.isEmpty()) type = NC_FLOAT ;997 // else998 // {999 // if (field->prec==2) type = NC_SHORT ;1000 // else if (field->prec==4) type = NC_FLOAT ;1001 // else if (field->prec==8) type = NC_DOUBLE ;1002 // }1003 //1004 // bool wtime = !(!field->operation.isEmpty() && field->foperation->timeType() == func::CFunctor::once);1005 //1006 // if (wtime)1007 // {1008 //1009 // //StdOStringStream oss;1010 // // oss << "time_" << field->operation.getValue()1011 // // << "_" << field->getRelFile()->output_freq.getValue();1012 // //oss1013 // if (field->foperation->timeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant"));1014 // else if (field->foperation->timeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered"));1015 // dims.push_back(timeid);1016 // }1017 //1018 // std::vector<StdString> axisList = grid->getAxisList();1019 // if (!axisList.empty())1020 // {1021 // std::vector<StdString>::const_iterator itAxis = axisList.begin(), iteAxis = axisList.end();1022 // for (; itAxis != iteAxis; ++itAxis)1023 // {1024 // CAxis* axis = CAxis::get(*itAxis);1025 // StdString axisid = (!axis->name.isEmpty())1026 // ? axis->name.getValue() : axis->getId();1027 //1028 // dims.push_back(axisid);1029 // coodinates.push_back(axisid);1030 // }1031 // }1032 //1033 // switch (domain->type)1034 // {1035 // case CDomain::type_attr::curvilinear :1036 // coodinates.push_back(StdString("nav_lon").append(appendDomid));1037 // coodinates.push_back(StdString("nav_lat").append(appendDomid));1038 // break;1039 // case CDomain::type_attr::regular :1040 // case CDomain::type_attr::unstructured :1041 // coodinates.push_back(StdString("lon").append(appendDomid));1042 // coodinates.push_back(StdString("lat").append(appendDomid));1043 // break;1044 // }1045 //1046 // if ( domain->type == CDomain::type_attr::curvilinear || domain->type == CDomain::type_attr::regular)dims.push_back(dimYid);1047 // dims.push_back(dimXid);1048 //1049 // try1050 // {1051 // SuperClassWriter::addVariable(fieldid, type, dims);1052 //1053 // if (!field->standard_name.isEmpty())1054 // SuperClassWriter::addAttribute1055 // ("standard_name", field->standard_name.getValue(), &fieldid);1056 //1057 // if (!field->long_name.isEmpty())1058 // SuperClassWriter::addAttribute1059 // ("long_name", field->long_name.getValue(), &fieldid);1060 //1061 // if (!field->unit.isEmpty())1062 // SuperClassWriter::addAttribute1063 // ("units", field->unit.getValue(), &fieldid);1064 //1065 // if (!field->valid_min.isEmpty())1066 // SuperClassWriter::addAttribute1067 // ("valid_min", field->valid_min.getValue(), &fieldid);1068 //1069 // if (!field->valid_max.isEmpty())1070 // SuperClassWriter::addAttribute1071 // ("valid_max", field->valid_max.getValue(), &fieldid);1072 //1073 // if (!field->scale_factor.isEmpty())1074 // SuperClassWriter::addAttribute1075 // ("scale_factor", field->scale_factor.getValue(), &fieldid);1076 //1077 // if (!field->add_offset.isEmpty())1078 // SuperClassWriter::addAttribute1079 // ("add_offset", field->add_offset.getValue(), &fieldid);1080 //1081 // SuperClassWriter::addAttribute1082 // ("online_operation", field->operation.getValue(), &fieldid);1083 //1084 // // write child variables as attributes1085 //1086 //1087 // vector<CVariable*> listVars = field->getAllVariables() ;1088 // for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ;1089 //1090 //1091 // if (wtime)1092 // {1093 // CDuration duration = field->freq_op.getValue();1094 // duration.solveTimeStep(*(context->calendar));1095 // SuperClassWriter::addAttribute("interval_operation", duration.toStringUDUnits(), &fieldid);1096 //1097 // duration = field->getRelFile()->output_freq.getValue();1098 // duration.solveTimeStep(*(context->calendar));1099 // SuperClassWriter::addAttribute("interval_write", duration.toStringUDUnits(), &fieldid);1100 // }1101 //1102 // if (!field->default_value.isEmpty())1103 // {1104 // double default_value = field->default_value.getValue();1105 // float fdefault_value = (float)default_value;1106 // if (type == NC_DOUBLE)1107 // SuperClassWriter::setDefaultValue(fieldid, &default_value);1108 // else1109 // SuperClassWriter::setDefaultValue(fieldid, &fdefault_value);1110 // }1111 // else1112 // SuperClassWriter::setDefaultValue(fieldid, (double*)NULL);1113 //1114 // { // Ecriture des coordonnées1115 //1116 // StdString coordstr; //boost::algorithm::join(coodinates, " ")1117 // std::vector<StdString>::iterator1118 // itc = coodinates.begin(), endc = coodinates.end();1119 //1120 // for (; itc!= endc; itc++)1121 // {1122 // StdString & coord = *itc;1123 // if (itc+1 != endc)1124 // coordstr.append(coord).append(" ");1125 // else coordstr.append(coord);1126 // }1127 //1128 // SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid);1129 //1130 // }1131 // }1132 // catch (CNetCdfException& e)1133 // {1134 // StdString msg("On writing field : ");1135 // msg.append(fieldid); msg.append("\n");1136 // msg.append("In the context : ");1137 // msg.append(context->getId()); msg.append("\n");1138 // msg.append(e.what());1139 // ERROR("CNc4DataOutput::writeField_(CField* field)", << msg);1140 // }1141 // }1142 1143 966 //-------------------------------------------------------------- 1144 967 … … 1422 1245 } 1423 1246 1424 // //---------------------------------------------------------------1425 //1426 // void CNc4DataOutput::writeFieldData_ (CField* field)1427 // {1428 // CContext* context = CContext::getCurrent() ;1429 //// if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ;1430 // CContextServer* server=context->server ;1431 //1432 // CGrid* grid = field->grid ;1433 // CDomain* domain = grid->domain ;1434 //1435 // if(SuperClass::type==MULTI_FILE || !isCollective) if (domain->isEmpty()) return;1436 //1437 //1438 // StdString fieldid = (!field->name.isEmpty())1439 // ? field->name.getValue()1440 // : field->getBaseFieldReference()->getId();1441 //1442 // StdOStringStream oss;1443 // string timeAxisId ;1444 // if (field->foperation->timeType() == func::CFunctor::instant) timeAxisId="time_instant" ;1445 // else if (field->foperation->timeType() == func::CFunctor::centered) timeAxisId="time_centered" ;1446 //1447 // StdString timeBoundId("time_counter_bounds");1448 //1449 // StdString timeAxisBoundId;1450 // if (field->foperation->timeType() == func::CFunctor::instant) timeAxisBoundId="time_instant_bounds" ;1451 // else if (field->foperation->timeType() == func::CFunctor::centered) timeAxisBoundId="time_centered_bounds" ;1452 //1453 // CArray<double,1> time_data(1) ;1454 // CArray<double,1> time_counter(1) ;1455 // CArray<double,1> time_counter_bound(2);1456 // CArray<double,1> time_data_bound(2);1457 //1458 // bool wtime = !(!field->operation.isEmpty() && (field->foperation->timeType() == func::CFunctor::once));1459 //1460 // if (wtime)1461 // {1462 // time_counter(0)= (Time(*field->last_Write_srv) + Time(*field->lastlast_Write_srv)) / 2;1463 // if (field->foperation->timeType() == func::CFunctor::instant)1464 // time_data(0) = Time(*field->last_Write_srv);1465 // else if (field->foperation->timeType() == func::CFunctor::centered) time_data(0) = time_counter(0);1466 //1467 // time_counter_bound(0) = Time(*field->lastlast_Write_srv);1468 // time_counter_bound(1) = Time(*field->last_Write_srv);1469 // if (field->foperation->timeType() == func::CFunctor::instant)1470 // time_data_bound(0) = time_data_bound(1) = Time(*field->last_Write_srv);1471 // else if (field->foperation->timeType() == func::CFunctor::centered)1472 // {1473 // time_data_bound(0) = time_counter_bound(0);1474 // time_data_bound(1) = time_counter_bound(1);1475 // }1476 // }1477 //1478 // bool isRoot ;1479 // if (server->intraCommRank==0) isRoot=true ;1480 // else isRoot=false ;1481 //1482 // if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty())1483 // {1484 // double scaleFactor=1. ;1485 // double addOffset=0. ;1486 // if (!field->scale_factor.isEmpty()) scaleFactor=field->scale_factor ;1487 // if (!field->add_offset.isEmpty()) addOffset=field->add_offset ;1488 // field->scaleFactorAddOffset(scaleFactor,addOffset) ;1489 // }1490 //1491 // try1492 // {1493 // if (grid->hasAxis()) // 3D1494 // {1495 // CAxis* axis = grid->axis ;1496 // CArray<double,3> field_data3D(domain->zoom_ni_srv,domain->zoom_nj_srv,axis->zoom_size) ;1497 // if (!field->default_value.isEmpty()) field_data3D = field->default_value ;1498 //1499 // field->outputField(field_data3D);1500 //1501 // if (!field->prec.isEmpty() && field->prec==2) field_data3D=round(field_data3D) ;1502 //1503 // switch (SuperClass::type)1504 // {1505 // case (MULTI_FILE) :1506 // {1507 // SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1);1508 // if (wtime)1509 // {1510 // SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1);1511 // SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1);1512 // SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1);1513 // SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1);1514 // }1515 // break ;1516 // }1517 // case (ONE_FILE) :1518 // {1519 // std::vector<StdSize> start(3) ;1520 // std::vector<StdSize> count(3) ;1521 // if (domain->isEmpty())1522 // {1523 // start[0]=0 ; start[1]=0 ; start[2]=0 ;1524 // count[0]=0 ; count[1]=0 ; start[2]=0 ;1525 // }1526 // else1527 // {1528 // // start[2]=domain->zoom_ibegin_loc.getValue()-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_loc.getValue()-domain->zoom_jbegin.getValue() ; start[0]=0 ;1529 // start[2]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; start[0]=0 ;1530 // count[2]=domain->zoom_ni_srv ; count[1]=domain->zoom_nj_srv ; count[0] = axis->zoom_size.getValue();1531 // }1532 // SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1,&start,&count );1533 // if (wtime)1534 // {1535 // SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot );1536 // SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot );1537 // SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot );1538 // SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot);1539 // }1540 // break;1541 // }1542 // }1543 //1544 // }1545 // else // 2D1546 // {1547 // CArray<double,2> field_data2D(domain->zoom_ni_srv,domain->zoom_nj_srv) ;1548 // if (!field->default_value.isEmpty()) field_data2D = field->default_value ;1549 // field->outputField(field_data2D);1550 // if (!field->prec.isEmpty() && field->prec==2) field_data2D=round(field_data2D) ;1551 // switch (SuperClass::type)1552 // {1553 // case (MULTI_FILE) :1554 // {1555 // SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1);1556 // if (wtime)1557 // {1558 // SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1);1559 // SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1);1560 // SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1);1561 // SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1);1562 // }1563 // break;1564 // }1565 // case (ONE_FILE) :1566 // {1567 // std::vector<StdSize> start(2) ;1568 // std::vector<StdSize> count(2) ;1569 // if (domain->isEmpty())1570 // {1571 // start[0]=0 ; start[1]=0 ;1572 // count[0]=0 ; count[1]=0 ;1573 // }1574 // else1575 // {1576 // start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ;1577 // count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ;1578 // }1579 //1580 // SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1,&start,&count);1581 // if (wtime)1582 // {1583 // SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot);1584 // SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot);1585 // SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot);1586 // SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot);1587 // }1588 // break;1589 //1590 // }1591 // }1592 // }1593 // }1594 // catch (CNetCdfException& e)1595 // {1596 // StdString msg("On writing field data: ");1597 // msg.append(fieldid); msg.append("\n");1598 // msg.append("In the context : ");1599 // msg.append(context->getId()); msg.append("\n");1600 // msg.append(e.what());1601 // ERROR("CNc4DataOutput::writeFieldData_ (CField* field)", << msg);1602 // }1603 // }1604 1605 1247 //--------------------------------------------------------------- 1606 1248 -
XIOS/trunk/src/test/test_new_features.f90
r631 r633 17 17 INTEGER,PARAMETER :: ni_glo=5 18 18 INTEGER,PARAMETER :: nj_glo=5 19 INTEGER,PARAMETER :: llm= 1019 INTEGER,PARAMETER :: llm=5 20 20 INTEGER,PARAMETER :: llmInterPolated=5 21 21 DOUBLE PRECISION :: lval(llm)=1, tsTemp, lvalInterPolated(llmInterPolated)=1
Note: See TracChangeset
for help on using the changeset viewer.