Changeset 467 for XIOS/trunk/src/node/domain.cpp
- Timestamp:
- 01/29/14 11:49:29 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/domain.cpp
r456 r467 77 77 //---------------------------------------------------------------- 78 78 79 void CDomain::check GlobalDomain(void)79 void CDomain::checkDomain(void) 80 80 { 81 81 if (!type.isEmpty() && type==type_attr::unstructured) … … 93 93 if (!ibegin.isEmpty()) jbegin=ibegin ; 94 94 if (!iend.isEmpty()) jend=iend ; 95 if (!i_index.isEmpty()) 96 { 97 j_index.resize(1,nj) ; 98 for(int i=0;i<ni;i++) j_index(0,i)=i_index(i,0) ; 99 i_index.resize(1,nj) ; 100 for(int j=0;j<nj;j++) i_index(0,j)=0 ; 101 } 102 103 if (!mask.isEmpty()) 104 { 105 CArray<int,2> mask_tmp(nj,1) ; 106 mask_tmp = mask ; 107 mask.resize(1,nj) ; 108 for(int j=0;j<nj;j++) mask(0,j)=mask_tmp(j,0) ; 109 } 95 110 ni=1 ; 96 111 ibegin=1 ; 97 112 iend=1 ; 113 98 114 } 99 115 else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || … … 105 121 << " check the \'ni_glo\' et \'nj_glo\' values !") 106 122 } 123 checkLocalIDomain() ; 124 checkLocalJDomain() ; 125 126 if (i_index.isEmpty()) 127 { 128 i_index.resize(ni,nj) ; 129 for(int j=0;j<nj;j++) 130 for(int i=0;i<ni;i++) i_index(i,j)=i ; 131 } 132 133 if (j_index.isEmpty()) 134 { 135 j_index.resize(ni,nj) ; 136 for(int j=0;j<nj;j++) 137 for(int i=0;i<ni;i++) j_index(i,j)=j ; 138 } 139 107 140 } 108 141 … … 214 247 if (!mask.isEmpty()) 215 248 { 216 unsigned int niu = ni.getValue(), nju = nj.getValue(); 217 if ((mask.extent(0) != niu) || 218 (mask.extent(1) != nju)) 249 if ((mask.extent(0) != ni) || 250 (mask.extent(1) != nj)) 219 251 ERROR("CDomain::checkAttributes(void)", 220 252 <<"the mask has not the same size than the local domain"<<endl 221 <<"Local size is "<<ni u<<"x"<<nju<<endl253 <<"Local size is "<<ni<<"x"<<nj<<endl 222 254 <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 223 for (int i = 0; i < ni .getValue(); i++)224 { 225 for (int j = 0; j < nj .getValue(); j++)255 for (int i = 0; i < ni; i++) 256 { 257 for (int j = 0; j < nj; j++) 226 258 { 227 259 if (i < ibegin_mask && i > iend_mask && … … 423 455 for (int j = 0; j < zoom_nj_client; j++) 424 456 { 425 // lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client -1) + (j + zoom_jbegin_client -1)*ni );426 // latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni );427 457 lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 428 458 latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); … … 431 461 for(int n=0;n<nvertex;n++) 432 462 { 433 // bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client -1) + (j + zoom_jbegin_client -1)*ni );434 // bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni );435 463 bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 436 464 bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); … … 489 517 zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ; 490 518 if (zoom_nj_client<0) zoom_nj_client=0 ; 491 492 cout << zoom_ibegin<<" "<<zoom_ni <<" "<< zoom_jbegin<<" "<<zoom_nj<<endl ; 493 cout << zoom_ibegin_client<<" "<<zoom_ni_client <<" "<< zoom_jbegin_client<<" "<<zoom_nj_client<<endl ; 494 cout << ibegin_client<<" "<<iend_client <<" "<< jbegin_client<<" "<<jend_client<<endl ; 495 /* 496 { 497 int zoom_iend = zoom_ibegin + zoom_ni - 1; 498 int zoom_jend = zoom_jbegin + zoom_nj - 1; 499 500 if ( zoom_ibegin > iend || zoom_iend < ibegin ) 501 { 502 zoom_ni_loc = 0 ; 503 zoom_ibegin_loc = zoom_ibegin ; 504 } 505 else 506 { 507 int zoom_ibegin_loc_ = (zoom_ibegin > ibegin) ? zoom_ibegin : ibegin ; 508 int zoom_iend_loc_ = (zoom_iend < iend) ? zoom_iend : iend ; 509 int zoom_ni_loc_ = zoom_iend_loc_ - zoom_ibegin_loc_ + 1; 510 511 zoom_ni_loc = zoom_ni_loc_; 512 zoom_ibegin_loc = zoom_ibegin_loc_-ibegin.getValue()+1; 513 } 514 515 if ( zoom_jbegin > jend || zoom_jend < jbegin ) 516 { 517 zoom_nj_loc = 0 ; 518 zoom_jbegin_loc = zoom_jbegin ; 519 } 520 else 521 { 522 int zoom_jbegin_loc_ = ( zoom_jbegin > jbegin ) ? zoom_jbegin : jbegin ; 523 int zoom_jend_loc_ = (zoom_jend < jend) ? zoom_jend : jend ; 524 int zoom_nj_loc_ = zoom_jend_loc_ - zoom_jbegin_loc_ + 1; 525 526 zoom_nj_loc = zoom_nj_loc_; 527 zoom_jbegin_loc = zoom_jbegin_loc_-jbegin.getValue()+1; 528 } 529 } 530 */ 519 531 520 } 532 521 … … 552 541 CContext* context=CContext::getCurrent() ; 553 542 554 this->checkGlobalDomain(); 555 this->checkLocalIDomain(); 556 this->checkLocalJDomain(); 557 543 this->checkDomain(); 558 544 this->checkZoom(); 559 545 this->checkBounds(); … … 617 603 else client->sendEvent(event) ; 618 604 } 619 605 620 606 void CDomain::computeConnectedServer(void) 621 607 { 622 int ib,ie,in; 623 int jb,je,jn ; 624 625 int ni_srv=ni_glo.getValue() ; 626 int ibegin_srv=1 ; 627 int iend_srv=ni_glo.getValue() ; 628 629 int nj_serv,jbegin_srv, jend_srv ; 630 int zoom_ibegin_srv,zoom_iend_srv,zoom_ni_srv ; 631 int zoom_jbegin_srv,zoom_jend_srv,zoom_nj_srv ; 632 633 ibegin_client=ibegin.getValue() ; iend_client=iend.getValue() ; ni_client=ni.getValue() ; 634 jbegin_client=jbegin.getValue() ; jend_client=jend.getValue() ; nj_client=nj.getValue() ; 608 int i,j,i_ind,j_ind ; 609 610 ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 611 jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; 635 612 636 613 CContext* context = CContext::getCurrent() ; … … 638 615 int nbServer=client->serverSize ; 639 616 640 /*641 // compute client zoom indices642 int zoom_iend=zoom_ibegin.getValue()+zoom_ni.getValue()-1 ;643 zoom_ibegin_client = ibegin_client > zoom_ibegin.getValue() ? ibegin_client : zoom_ibegin.getValue() ;644 zoom_iend_client = iend_client < zoom_iend ? iend_client : zoom_iend ;645 zoom_ni_client=zoom_iend_client-zoom_ibegin_client+1 ;646 if (zoom_ni_client<0) zoom_ni_client=0 ;647 648 int zoom_jend=zoom_jbegin.getValue()+zoom_nj.getValue()-1 ;649 zoom_jbegin_client = jbegin_client > zoom_jbegin.getValue() ? jbegin_client : zoom_jbegin.getValue() ;650 zoom_jend_client = jend_client < zoom_jend ? jend_client : zoom_jend ;651 zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ;652 if (zoom_nj_client<0) zoom_nj_client=0 ;653 */654 617 // find how much client are connected to a server 655 618 int zoom_iend=zoom_ibegin+zoom_ni-1 ; 656 619 int zoom_jend=zoom_jbegin+zoom_nj-1 ; 657 620 658 jend_srv=0 ; 659 for(int ns=0;ns<nbServer;ns++) 660 { 661 jbegin_srv=jend_srv+1 ; 662 nj_srv=nj_glo.getValue()/nbServer ; 663 if (ns<nj_glo.getValue()%nbServer) nj_srv++ ; 664 jend_srv=jbegin_srv+nj_srv-1 ; 665 666 ib = ibegin_client>ibegin_srv ? ibegin_client : ibegin_srv ; 667 ie= iend_client< iend_srv? iend_client : iend_srv ; 668 in=ie-ib+1 ; 669 if (in<0) in=0 ; 670 671 jb= jbegin_client>jbegin_srv ? jbegin_client : jbegin_srv ; 672 je= jend_client<jend_srv ? jend_client : jend_srv ; 673 jn=je-jb+1 ; 674 if (jn<0) jn=0 ; 621 int blockSize=nj_glo/nbServer ; 622 int ns=nj_glo%nbServer ; 623 int pos=ns*(blockSize+1) ; 624 int serverNum ; 625 626 mapConnectedServer.resize(ni,nj) ; 627 vector<int> nbData(nbServer,0) ; 628 vector<int> indServer(nbServer,-1) ; 629 vector<bool> IsConnected(nbServer,false) ; 630 631 for(j=0;j<nj;j++) 632 for(i=0;i<ni;i++) 633 { 634 i_ind=ibegin+i_index(i,j)-1 ; 635 j_ind=jbegin+j_index(i,j)-1 ; 675 636 676 if (in>0 && jn>0) 677 { 678 zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; 679 zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; 680 zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; 681 if (zoom_ni_srv<0) zoom_ni_srv=0 ; 682 683 zoom_jbegin_srv = zoom_jbegin.getValue() > jbegin_srv ? zoom_jbegin.getValue() : jbegin_srv ; 684 zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; 685 zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; 686 if (zoom_nj_srv<0) zoom_nj_srv=0 ; 687 688 if (zoom_ni_srv>0 && zoom_nj_srv>0 && zoom_ni_client>0 && zoom_nj_client>0) 637 if (j_ind<pos) serverNum=j_ind/(blockSize+1) ; 638 else serverNum=ns+(j_ind-pos)/blockSize ; 639 IsConnected[serverNum]=true ; 640 641 if (i_ind >= zoom_ibegin-1 && i_ind <= zoom_iend-1 && j_ind >= zoom_jbegin-1 && j_ind <= zoom_jend-1) 689 642 { 690 ib = zoom_ibegin_client>zoom_ibegin_srv ? zoom_ibegin_client : zoom_ibegin_srv ; 691 ie=zoom_iend_client<zoom_iend_srv?zoom_iend_client:zoom_iend_srv ; 692 in=ie-ib+1 ; 693 if (in<0) in=0 ; 694 695 jb=zoom_jbegin_client>zoom_jbegin_srv?zoom_jbegin_client:zoom_jbegin_srv ; 696 je=zoom_jend_client<zoom_jend_srv?zoom_jend_client:zoom_jend_srv ; 697 jn=je-jb+1 ; 698 if (jn<0) jn=0 ; 643 mapConnectedServer(i,j)=serverNum ; 644 nbData[serverNum]++ ; 699 645 } 700 else 646 else mapConnectedServer(i,j)=-1 ; 647 } 648 649 650 for(serverNum=0 ; serverNum<nbServer ; serverNum++) 651 if (IsConnected[serverNum]) 652 { 653 ns=connectedServer.size() ; 654 indServer[serverNum]=ns; 655 connectedServer.push_back(serverNum) ; 656 nbDataSrv.push_back(nbData[serverNum]) ; 657 } 658 659 i_indSrv.resize(connectedServer.size()) ; 660 j_indSrv.resize(connectedServer.size()) ; 661 662 for(j=0;j<nj;j++) 663 for(i=0;i<ni;i++) 664 { 665 if (mapConnectedServer(i,j)>=0) 701 666 { 702 ib=1 ; ie=0 ; in=0 ; 703 jb=1 ; je=0 ; jn=0 ; 667 ns=indServer[mapConnectedServer(i,j)] ; 668 mapConnectedServer(i,j)= ns ; 669 i_indSrv[ns].push_back(i+ibegin-1) ; 670 j_indSrv[ns].push_back(j+jbegin-1) ; 704 671 } 705 706 // if (in>0 && jn>0) 707 // { 708 connectedServer.push_back(ns) ; 709 ib_srv.push_back(ib) ; 710 ie_srv.push_back(ie) ; 711 in_srv.push_back(in) ; 712 jb_srv.push_back(jb) ; 713 je_srv.push_back(je) ; 714 jn_srv.push_back(jn) ; 715 // } 716 717 } 718 } 672 } 673 719 674 int nbConnectedServer=connectedServer.size() ; 675 720 676 int* recvCount=new int[client->clientSize] ; 721 677 int* displ=new int[client->clientSize] ; … … 744 700 delete [] recvBuff ; 745 701 } 746 702 703 747 704 void CDomain::sendLonLat(void) 748 705 { 706 int ns,n,i,j,ind,nv ; 749 707 CContext* context = CContext::getCurrent() ; 750 708 CContextClient* client=context->client ; … … 752 710 CEventClient event(getType(),EVENT_ID_LON_LAT) ; 753 711 754 int ib,ie,in ;755 int jb,je,jn ;756 757 712 list<shared_ptr<CMessage> > list_msg ; 758 713 list< CArray<int,1>* > list_indi,list_indj ; … … 762 717 for(int ns=0;ns<connectedServer.size();ns++) 763 718 { 764 ib=ib_srv[ns] ; ie=ie_srv[ns] ; in=in_srv[ns] ; 765 jb=jb_srv[ns] ; je=je_srv[ns] ; jn=jn_srv[ns] ; 766 767 CArray<int,1> indi(in*jn) ; 768 CArray<int,1> indj(in*jn) ; 769 CArray<double,1> lon(in*jn) ; 770 CArray<double,1> lat(in*jn) ; 771 CArray<double,2> boundslon(nvertex,in*jn) ; 772 CArray<double,2> boundslat(nvertex,in*jn) ; 773 774 775 int ind_client,ind_loc ; 776 777 for(int j=jb;j<=je;j++) 778 for(int i=ib;i<=ie;i++) 719 int nbData = nbDataSrv[ns] ; 720 CArray<int,1> indi(nbData) ; 721 CArray<int,1> indj(nbData) ; 722 CArray<double,1> lon(nbData) ; 723 CArray<double,1> lat(nbData) ; 724 CArray<double,2> boundslon(nvertex,nbData) ; 725 CArray<double,2> boundslat(nvertex,nbData) ; 726 727 for(n=0;n<nbData;n++) 728 { 729 i=i_indSrv[ns][n] ; 730 j=j_indSrv[ns][n] ; 731 ind=(i-(zoom_ibegin_client-1))+(j-(zoom_jbegin_client-1))*zoom_ni_client ; 732 733 lon(n)=lonvalue(ind) ; 734 lat(n)=latvalue(ind) ; 735 if (hasBounds) 779 736 { 780 ind_client=(i-zoom_ibegin_client)+(j-zoom_jbegin_client)*zoom_ni_client ; 781 ind_loc=(i-ib)+(j-jb)*in ; 782 lon(ind_loc)=lonvalue(ind_client) ; 783 lat(ind_loc)=latvalue(ind_client) ; 784 if (hasBounds) 737 for(nv=0;nv<nvertex;nv++) 785 738 { 786 for(int n=0;n<nvertex;n++) 787 { 788 boundslon(n,ind_loc)=bounds_lon(n,ind_client); 789 boundslat(n,ind_loc)=bounds_lat(n,ind_client); 790 } 739 boundslon(nv,n)=bounds_lon(nv,ind); 740 boundslat(nv,n)=bounds_lat(nv,ind); 791 741 } 792 indi(ind_loc)=i ;793 indj(ind_loc)=j ;794 742 } 795 743 indi(n)=ibegin+i_index(i-ibegin+1,j-jbegin+1)-1 ; 744 indj(n)=jbegin+j_index(i-ibegin+1,j-jbegin+1)-1 ; 745 } 746 796 747 list_indi.push_back(new CArray<int,1>(indi.copy())) ; 797 748 list_indj.push_back(new CArray<int,1>(indj.copy())) ; … … 818 769 for(list<CArray<double,1>* >::iterator it=list_lat.begin();it!=list_lat.end();it++) delete *it; 819 770 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslon.begin();it!=list_boundslon.end();it++) delete *it; 820 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++) delete *it; 771 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++) delete *it; 821 772 822 773 } 774 823 775 824 776 bool CDomain::dispatchEvent(CEventServer& event) … … 860 812 861 813 buffer>>ni_srv>>ibegin_srv>>iend_srv>>nj_srv>>jbegin_srv>>jend_srv; 814 862 815 863 816 zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; … … 874 827 zoom_jbegin_srv=1 ; zoom_jend_srv=0 ; zoom_nj_srv=0 ; 875 828 } 876 877 829 lonvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 878 830 lonvalue_srv = 0. ; … … 908 860 CArray<double,2> boundslon ; 909 861 CArray<double,2> boundslat ; 910 862 911 863 int type_int ; 912 864 buffer>>type_int>>isCurvilinear>>indi>>indj>>lon>>lat ; … … 915 867 916 868 int i,j,ind_srv ; 917 918 869 for(int ind=0;ind<indi.numElements();ind++) 919 870 { 920 871 i=indi(ind) ; j=indj(ind) ; 921 ind_srv=(i- zoom_ibegin_srv)+(j-zoom_jbegin_srv)*zoom_ni_srv ;872 ind_srv=(i-(zoom_ibegin_srv-1))+(j-(zoom_jbegin_srv-1))*zoom_ni_srv ; 922 873 lonvalue_srv(ind_srv)=lon(ind) ; 923 874 latvalue_srv(ind_srv)=lat(ind) ; 924 875 if (hasBounds) 925 876 { 926 for(int n =0;n<nvertex;n++)877 for(int nv=0;nv<nvertex;nv++) 927 878 { 928 bounds_lon_srv(n ,ind_srv)=boundslon(n,ind) ;929 bounds_lat_srv(n ,ind_srv)=boundslat(n,ind) ;879 bounds_lon_srv(nv,ind_srv)=boundslon(nv,ind) ; 880 bounds_lat_srv(nv,ind_srv)=boundslat(nv,ind) ; 930 881 } 931 882 }
Note: See TracChangeset
for help on using the changeset viewer.