Changeset 666 for XIOS/trunk/src/node/domain.cpp
- Timestamp:
- 08/24/15 14:53:27 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/domain.cpp
r665 r666 138 138 checkLocalIDomain(); 139 139 checkLocalJDomain(); 140 141 ibegin_client = ibegin; ni_client = ni; iend_client = ibegin + ni - 1;142 jbegin_client = jbegin; nj_client = nj; jend_client = jbegin + nj - 1;143 140 144 141 if (i_index.isEmpty()) … … 340 337 data_i_index.resize(dni) ; 341 338 data_j_index.resize(dni) ; 342 data_n_index.setValue(dni); 339 343 340 for (int i = 0; i < dni; ++i) 344 341 { … … 353 350 data_j_index.resize(dni) ; 354 351 355 data_n_index.setValue(dni);356 357 352 for(int count = 0, j = 0; j < data_nj.getValue(); ++j) 358 353 { … … 367 362 } 368 363 369 void CDomain::completeLonClient() 364 //---------------------------------------------------------------- 365 void CDomain::completeLonLatClient(void) 370 366 { 371 367 int i,j,k ; 372 368 CArray<double,1> lonvalue_temp(ni*nj) ; 373 369 CArray<double,2> bounds_lon_temp(nvertex,ni*nj); 374 375 if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 376 ERROR("CDomain::completeLonLatClient(void)", 377 <<"Only one longitude value can be used but both lonvalue_1d and lonvalue_2d are defined! "<<endl 378 <<"Define only one longitude value: lonvalue_1d or lonvalue_2d "); 379 380 if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) 381 { 382 if (lonvalue_1d.numElements() != i_index.numElements()) 383 ERROR("CDomain::completeLonLatClient(void)", 384 <<"lonvalue_1d has not the same size as the local domain"<<endl 385 <<"Local size is "<<i_index.numElements()<<endl 386 <<"lonvalue_1d size is "<<lonvalue_1d.numElements()); 387 } 388 389 if (lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 390 { 391 if ((lonvalue_2d.extent(0) != ni) || 392 (lonvalue_2d.extent(1) != nj)) 393 ERROR("CDomain::completeLonLatClient(void)", 394 <<"the lonvalue has not the same size as the local domain"<<endl 395 <<"Local size is "<<ni<<"x"<<nj<<endl 396 <<"Lonvalue size is "<<lonvalue_2d.extent(0)<<"x"<<lonvalue_2d.extent(1)); 397 } 370 CArray<double,1> latvalue_temp(ni*nj) ; 371 CArray<double,2> bounds_lat_temp(nvertex,ni*nj); 398 372 399 373 if (!lonvalue_2d.isEmpty()) … … 403 377 { 404 378 lonvalue_temp(i+j*ni) = lonvalue_2d(i,j); 379 latvalue_temp(i+j*ni) = latvalue_2d(i,j); 405 380 if (hasBounds) 406 381 { 407 382 k=j*ni+i; 408 for(int n=0;n<nvertex;++n) bounds_lon_temp(n,k) = bounds_lon_2d(n,i,j); 383 for(int n=0;n<nvertex;++n) 384 { 385 bounds_lon_temp(n,k) = bounds_lon_2d(n,i,j); 386 bounds_lat_temp(n,k) = bounds_lat_2d(n,i,j); 387 } 409 388 } 410 389 } … … 415 394 if (type_attr::rectilinear == type) 416 395 { 417 if ( ni == lonvalue_1d.numElements())396 if ((ni == lonvalue_1d.numElements()) && (nj == latvalue_1d.numElements())) 418 397 { 419 398 for(j=0;j<nj;++j) … … 422 401 k=j*ni+i; 423 402 lonvalue_temp(k) = lonvalue_1d(i); 403 latvalue_temp(k) = latvalue_1d(j); 424 404 if (hasBounds) 425 405 { 426 for(int n=0;n<nvertex;++n) bounds_lon_temp(n,k) = bounds_lon_1d(n,i); 406 for(int n=0;n<nvertex;++n) 407 { 408 bounds_lon_temp(n,k) = bounds_lon_1d(n,i); 409 bounds_lat_temp(n,k) = bounds_lat_1d(n,j); 410 } 427 411 } 428 412 } … … 430 414 else 431 415 ERROR("CDomain::completeLonClient(void)", 432 <<"The lonvalue_1d has not the same size as the local domain"<<endl 433 <<"Local size is "<<ni<<endl 434 <<"Lonvalue_1d size is "<<lonvalue_1d.numElements()); 416 <<"lonvalue_1d and latvalue_1d has not the same size as the local domain"<<endl 417 <<"Local size is "<<ni<<"x " << nj<< endl 418 <<"lonvalue_1d size is "<<lonvalue_1d.numElements() 419 <<"latvalue_1d size is "<<latvalue_1d.numElements()); 435 420 } 436 421 else if (type==type_attr::curvilinear || type==type_attr::unstructured) 437 422 { 438 423 lonvalue_temp=lonvalue_1d; 424 latvalue_temp=latvalue_1d; 439 425 if (hasBounds) 440 426 { 441 427 bounds_lon_temp=bounds_lon_1d; 442 }443 }444 }445 446 StdSize dm = zoom_ni_client * zoom_nj_client;447 448 // Make sure that this attribute is non-empty for every client.449 if (0 != dm)450 {451 lonvalue_client.resize(dm);452 if (hasBounds) bounds_lon_client.resize(nvertex, dm);453 }454 455 456 for (i = 0; i < zoom_ni_client; ++i)457 {458 for (j = 0; j < zoom_nj_client; ++j)459 {460 lonvalue_client(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni );461 if (hasBounds)462 {463 for(int n=0;n<nvertex;n++)464 {465 bounds_lon_client(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni );466 }467 }468 }469 }470 }471 472 void CDomain::completeLatClient()473 {474 int i,j,k;475 CArray<double,1> latvalue_temp(ni*nj) ;476 CArray<double,2> bounds_lat_temp(nvertex,ni*nj);477 478 if (!latvalue_1d.isEmpty() && !latvalue_2d.isEmpty())479 ERROR("CDomain::completeLonLatClient(void)",480 <<"Only one longitude value can be used but both latvalue_1d and latvalue_2d are defined! "<<endl481 <<"Define only one longitude value: latvalue_1d or latvalue_2d ");482 483 if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty())484 {485 if (latvalue_1d.numElements() != i_index.numElements())486 ERROR("CDomain::completeLonLatClient(void)",487 <<"the latvalue_1d has not the same size as the local domain"<<endl488 <<"Local size is "<<i_index.numElements()<<endl489 <<"Mask size is "<<latvalue_1d.numElements());490 }491 492 if (latvalue_1d.isEmpty() && !latvalue_2d.isEmpty())493 {494 if ((latvalue_2d.extent(0) != ni) ||495 (latvalue_2d.extent(1) != nj))496 ERROR("CDomain::completeLonLatClient(void)",497 <<"the mask has not the same size as the local domain"<<endl498 <<"Local size is "<<ni<<"x"<<nj<<endl499 <<"Mask size is "<<latvalue_2d.extent(0)<<"x"<<latvalue_2d.extent(1));500 }501 502 if (!latvalue_2d.isEmpty())503 {504 for (j = 0; j < nj; ++j)505 for (i = 0; i < ni; ++i)506 {507 latvalue_temp(i+j*ni) = latvalue_2d(i,j);508 if (hasBounds)509 {510 k=j*ni+i;511 for(int n=0;n<nvertex;n++) bounds_lat_temp(n,k) = bounds_lat_2d(n,i,j);512 }513 }514 }515 516 if (!latvalue_1d.isEmpty())517 {518 if (type_attr::rectilinear == type)519 {520 521 if (nj == latvalue_1d.numElements())522 {523 for(j=0;j<nj;++j)524 for(i=0;i<ni;++i)525 {526 k=j*ni+i;527 latvalue_temp(k) = latvalue_1d(j);528 if (hasBounds)529 {530 for(int n=0;n<nvertex;n++) bounds_lat_temp(n,k) = bounds_lat_1d(n,j);531 }532 }533 }534 else535 ERROR("CDomain::completeLonClient(void)",536 <<"The latvalue_1d has not the same size as the local domain"<<endl537 <<"Local size is "<<nj<<endl538 <<"Latvalue_1d size is "<<latvalue_1d.numElements());539 }540 else if (type==type_attr::curvilinear || type==type_attr::unstructured)541 {542 latvalue_temp=latvalue_1d;543 if (hasBounds)544 {545 428 bounds_lat_temp=bounds_lat_1d; 546 429 } … … 548 431 } 549 432 550 StdSize dm = zoom_ni_client * zoom_nj_client; 433 int i_ind,j_ind; 434 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 435 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 436 437 int globalIndexCountZoom = 0; 438 int nbIndex = i_index.numElements(); 439 for (i = 0; i < nbIndex; ++i) 440 { 441 i_ind=i_index(i); 442 j_ind=j_index(i); 443 444 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 445 { 446 ++globalIndexCountZoom; 447 } 448 } 551 449 552 450 // Make sure that this attribute is non-empty for every client. 553 if (0 != dm) 554 { 555 latvalue_client.resize(dm); 556 if (hasBounds) bounds_lat_client.resize(nvertex,dm); 557 } 558 559 for (i = 0; i < zoom_ni_client; i++) 560 { 561 for (j = 0; j < zoom_nj_client; j++) 451 if (0 != globalIndexCountZoom) 452 { 453 lonvalue_client.resize(globalIndexCountZoom); 454 latvalue_client.resize(globalIndexCountZoom); 455 if (hasBounds) 562 456 { 563 latvalue_client(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 457 bounds_lon_client.resize(nvertex,globalIndexCountZoom); 458 bounds_lat_client.resize(nvertex,globalIndexCountZoom); 459 } 460 } 461 462 int nCountZoom = 0; 463 for (i = 0; i < nbIndex; ++i) 464 { 465 i_ind=i_index(i); 466 j_ind=j_index(i); 467 468 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 469 { 470 lonvalue_client(nCountZoom) = lonvalue_temp(i); 471 latvalue_client(nCountZoom) = latvalue_temp(i); 564 472 if (hasBounds) 565 473 { 566 for (int n=0;n<nvertex;n++)474 for (int n = 0; n < nvertex; ++n) 567 475 { 568 bounds_lat_client(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 476 bounds_lon_client(n,nCountZoom) = bounds_lon_temp(n,i); 477 bounds_lat_client(n,nCountZoom) = bounds_lat_temp(n,i); 569 478 } 570 479 } 480 ++nCountZoom; 571 481 } 572 482 } 573 }574 575 //----------------------------------------------------------------576 void CDomain::completeLonLatClient(void)577 {578 completeLonClient();579 completeLatClient();580 }581 582 583 //----------------------------------------------------------------584 void CDomain::checkZoom(void)585 {586 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ;587 zoom_ibegin_client = ibegin_client > global_zoom_ibegin ? ibegin_client : global_zoom_ibegin ;588 zoom_iend_client = iend_client < global_zoom_iend ? iend_client : global_zoom_iend ;589 zoom_ni_client=zoom_iend_client-zoom_ibegin_client+1 ;590 if (zoom_ni_client<0) zoom_ni_client=0 ;591 592 593 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ;594 zoom_jbegin_client = jbegin_client > global_zoom_jbegin ? jbegin_client : global_zoom_jbegin ;595 zoom_jend_client = jend_client < global_zoom_jend ? jend_client : global_zoom_jend ;596 zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ;597 if (zoom_nj_client<0) zoom_nj_client=0;598 483 } 599 484 … … 691 576 hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || 692 577 (!latvalue_2d.isEmpty() && !lonvalue_2d.isEmpty()); 578 if (hasLonLat) 579 { 580 if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 581 ERROR("CDomain::completeLonLatClient(void)", 582 <<"Only one longitude value can be used but both lonvalue_1d and lonvalue_2d are defined! "<<endl 583 <<"Define only one longitude value: lonvalue_1d or lonvalue_2d "); 584 585 if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) 586 { 587 if (lonvalue_1d.numElements() != i_index.numElements()) 588 ERROR("CDomain::completeLonLatClient(void)", 589 <<"lonvalue_1d has not the same size as the local domain"<<endl 590 <<"Local size is "<<i_index.numElements()<<endl 591 <<"lonvalue_1d size is "<<lonvalue_1d.numElements()); 592 } 593 594 if (lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 595 { 596 if ((lonvalue_2d.extent(0) != ni) || 597 (lonvalue_2d.extent(1) != nj)) 598 ERROR("CDomain::completeLonLatClient(void)", 599 <<"the lonvalue has not the same size as the local domain"<<endl 600 <<"Local size is "<<ni<<"x"<<nj<<endl 601 <<"Lonvalue size is "<<lonvalue_2d.extent(0)<<"x"<<lonvalue_2d.extent(1)); 602 } 603 604 if (!latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) 605 ERROR("CDomain::completeLonLatClient(void)", 606 <<"Only one longitude value can be used but both latvalue_1d and latvalue_2d are defined! "<<endl 607 <<"Define only one longitude value: latvalue_1d or latvalue_2d "); 608 609 if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty()) 610 { 611 if (latvalue_1d.numElements() != i_index.numElements()) 612 ERROR("CDomain::completeLonLatClient(void)", 613 <<"the latvalue_1d has not the same size as the local domain"<<endl 614 <<"Local size is "<<i_index.numElements()<<endl 615 <<"Mask size is "<<latvalue_1d.numElements()); 616 } 617 618 if (latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) 619 { 620 if ((latvalue_2d.extent(0) != ni) || 621 (latvalue_2d.extent(1) != nj)) 622 ERROR("CDomain::completeLonLatClient(void)", 623 <<"the mask has not the same size as the local domain"<<endl 624 <<"Local size is "<<ni<<"x"<<nj<<endl 625 <<"Mask size is "<<latvalue_2d.extent(0)<<"x"<<latvalue_2d.extent(1)); 626 } 627 } 693 628 } 694 629 … … 697 632 CContext* context=CContext::getCurrent() ; 698 633 699 this->checkZoom();700 634 if (this->isClientAfterTransformationChecked) return; 701 635 if (context->hasClient) … … 742 676 CContext* context=CContext::getCurrent() ; 743 677 744 this->checkZoom();745 678 if (this->isChecked) return; 746 679 if (context->hasClient) … … 759 692 760 693 this->checkDomain(); 761 this->checkZoom();762 694 this->checkLonLat(); 763 695 this->checkBounds(); … … 769 701 this->checkDomainData(); 770 702 this->checkCompression(); 771 this->completeLonLatClient(); 703 772 704 } 773 705 else … … 777 709 if (context->hasClient) 778 710 { 779 computeConnectedServer() ; 780 sendServerAttribut() ; 781 sendLonLatArea() ; 711 this->computeConnectedServer(); 712 this->completeLonLatClient(); 713 this->sendServerAttribut(); 714 this->sendLonLatArea(); 782 715 } 783 716 … … 837 770 void CDomain::computeConnectedServer(void) 838 771 { 839 ibegin_client=ibegin; ni_client=ni; iend_client=ibegin_client + ni_client - 1;840 jbegin_client=jbegin; nj_client=nj; jend_client=jbegin_client + nj_client - 1;841 842 772 CContext* context=CContext::getCurrent() ; 843 773 CContextClient* client=context->client ; … … 846 776 847 777 int i,j,i_ind,j_ind, nbIndex; 848 int zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ;849 int zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ;778 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 779 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 850 780 851 781 // Precompute number of index … … 857 787 j_ind=j_index(i); 858 788 859 if (i_ind >= global_zoom_ibegin && i_ind <= zoom_iend && j_ind >= global_zoom_jbegin && j_ind <=zoom_jend)789 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 860 790 { 861 791 ++globalIndexCountZoom; … … 878 808 globalIndexDomain(globalIndexCount) = globalIndex; 879 809 ++globalIndexCount; 880 if (i_ind >= global_zoom_ibegin && i_ind <= zoom_iend && j_ind >= global_zoom_jbegin && j_ind <=zoom_jend)810 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 881 811 { 882 812 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; … … 1076 1006 { 1077 1007 idx = static_cast<int>(it->second[n]); 1078 i = i_index(idx); 1079 j = j_index(idx); 1080 ind = (i - zoom_ibegin_client) + (j - zoom_jbegin_client) * zoom_ni_client; 1081 1082 lon(n) = lonvalue_client(ind); 1083 lat(n) = latvalue_client(ind); 1008 lon(n) = lonvalue_client(idx); 1009 lat(n) = latvalue_client(idx); 1084 1010 1085 1011 if (hasBounds) … … 1088 1014 CArray<double,2>& boundslat = list_boundslat.back(); 1089 1015 1090 for (nv = 0; nv < nvertex; nv++)1016 for (nv = 0; nv < nvertex; ++nv) 1091 1017 { 1092 boundslon(nv, n) = bounds_lon_client(nv, i nd);1093 boundslat(nv, n) = bounds_lat_client(nv, i nd);1018 boundslon(nv, n) = bounds_lon_client(nv, idx); 1019 boundslat(nv, n) = bounds_lat_client(nv, idx); 1094 1020 } 1095 1021 } … … 1252 1178 if (hasBounds) 1253 1179 { 1254 for (int nv = 0; nv < nvertex; nv++)1180 for (int nv = 0; nv < nvertex; ++nv) 1255 1181 bounds_lon_srv(nv, ind_srv) = boundslon(nv, ind); 1256 1182 }
Note: See TracChangeset
for help on using the changeset viewer.