Changeset 610
- Timestamp:
- 06/10/15 10:39:10 (10 years ago)
- Location:
- XIOS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/branchs/xios-1.0/src/node/domain.cpp
r501 r610 16 16 17 17 namespace xios { 18 18 19 19 /// ////////////////////// Définitions ////////////////////// /// 20 20 … … 30 30 31 31 CDomain::~CDomain(void) 32 { 32 { 33 33 } 34 34 … … 37 37 const std::set<StdString> & CDomain::getRelFiles(void) const 38 38 { 39 return (this->relFiles); 40 } 41 42 //---------------------------------------------------------------- 43 39 return (this->relFiles); 40 } 41 42 //---------------------------------------------------------------- 43 44 44 bool CDomain::hasZoom(void) const 45 45 { 46 return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && 46 return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && 47 47 (this->zoom_nj.getValue() != this->nj_glo.getValue())); 48 48 } 49 50 //---------------------------------------------------------------- 51 49 50 //---------------------------------------------------------------- 51 52 52 bool CDomain::isEmpty(void) const 53 53 { 54 return ((this->zoom_ni_srv == 0) || 54 return ((this->zoom_ni_srv == 0) || 55 55 (this->zoom_nj_srv == 0)); 56 56 } … … 86 86 << "[ Id = " << this->getId() << " ] " 87 87 << "The global domain is badly defined," 88 << " check the \'ni_glo\' value !") 88 << " check the \'ni_glo\' value !") 89 89 } 90 90 nj_glo=ni_glo ; … … 111 111 ibegin=1 ; 112 112 iend=1 ; 113 113 114 114 } 115 115 else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || … … 119 119 << "[ Id = " << this->getId() << " ] " 120 120 << "The global domain is badly defined," 121 << " check the \'ni_glo\' et \'nj_glo\' values !") 121 << " check the \'ni_glo\' et \'nj_glo\' values !") 122 122 } 123 123 checkLocalIDomain() ; 124 124 checkLocalJDomain() ; 125 125 126 126 if (i_index.isEmpty()) 127 127 { 128 128 i_index.resize(ni,nj) ; 129 129 for(int j=0;j<nj;j++) 130 for(int i=0;i<ni;i++) i_index(i,j)=i ; 130 for(int i=0;i<ni;i++) i_index(i,j)=i ; 131 131 } 132 132 133 133 if (j_index.isEmpty()) 134 134 { 135 135 j_index.resize(ni,nj) ; 136 136 for(int j=0;j<nj;j++) 137 for(int i=0;i<ni;i++) j_index(i,j)=j ; 137 for(int i=0;i<ni;i++) j_index(i,j)=j ; 138 138 } 139 139 140 140 } 141 141 … … 211 211 << "Domain is wrong defined," 212 212 << " Check the values : nj, nj_glo, jbegin, jend") ; 213 213 214 214 ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 215 215 jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; … … 221 221 { 222 222 using namespace std; 223 223 224 224 int ibegin_mask = 0, 225 225 jbegin_mask = 0, 226 226 iend_mask = iend.getValue() - ibegin.getValue(), 227 227 jend_mask = jend.getValue() - jbegin.getValue(); 228 228 229 229 if (!zoom_ibegin.isEmpty()) 230 230 { 231 231 int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; 232 232 int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; 233 233 234 234 ibegin_mask = max (ibegin.getValue(), zoom_ibegin.getValue()); 235 235 jbegin_mask = max (jbegin.getValue(), zoom_jbegin.getValue()); 236 236 iend_mask = min (iend.getValue(), zoom_iend); 237 237 jend_mask = min (jend.getValue(), zoom_jend); 238 238 239 239 ibegin_mask -= ibegin.getValue(); 240 240 jbegin_mask -= jbegin.getValue(); … … 242 242 jend_mask -= jbegin.getValue(); 243 243 } 244 244 245 245 246 246 if (!mask.isEmpty()) … … 251 251 <<"the mask has not the same size than the local domain"<<endl 252 252 <<"Local size is "<<ni<<"x"<<nj<<endl 253 <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 253 <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 254 254 for (int i = 0; i < ni; i++) 255 255 { … … 283 283 284 284 void CDomain::checkDomainData(void) 285 { 285 { 286 286 if (!data_dim.isEmpty() && 287 287 !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) … … 378 378 data_i_index.resize(dni) ; 379 379 data_j_index.resize(dni) ; 380 380 381 381 data_n_index.setValue(dni); 382 382 383 383 for(int count = 0, j = 0; j < data_nj.getValue(); j++) 384 384 { … … 394 394 395 395 //---------------------------------------------------------------- 396 396 397 397 void CDomain::completeLonLatClient(void) 398 398 { … … 402 402 CArray<double,2> bounds_lon_temp(nvertex,ni*nj) ; 403 403 CArray<double,2> bounds_lat_temp(nvertex,ni*nj) ; 404 404 405 405 if (type.isEmpty()) 406 406 { 407 if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) 407 if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) 408 408 { 409 409 type.setValue(type_attr::curvilinear) ; 410 410 isCurvilinear=true ; 411 411 } 412 else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) 412 else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) 413 413 { 414 414 type.setValue(type_attr::regular) ; … … 429 429 { 430 430 for(j=0;j<nj;j++) 431 for(i=0;i<ni;i++) 431 for(i=0;i<ni;i++) 432 432 { 433 433 k=j*ni+i ; … … 436 436 if (hasBounds) 437 437 { 438 for(int n=0;n<nvertex;n++) 438 for(int n=0;n<nvertex;n++) 439 439 { 440 440 bounds_lon_temp(n,k)=bounds_lon(n,i) ; … … 444 444 } 445 445 } 446 446 447 447 StdSize dm = zoom_ni_client * zoom_nj_client; 448 448 449 449 lonvalue.resize(dm); 450 450 latvalue.resize(dm); 451 451 452 452 for (int i = 0; i < zoom_ni_client; i++) 453 453 { 454 454 for (int j = 0; j < zoom_nj_client; j++) 455 455 { 456 lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 456 lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 457 457 latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); 458 458 if (hasBounds) 459 459 { 460 for(int n=0;n<nvertex;n++) 460 for(int n=0;n<nvertex;n++) 461 461 { 462 bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 462 bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 463 463 bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); 464 464 } … … 467 467 } 468 468 } 469 469 470 470 471 471 //---------------------------------------------------------------- … … 487 487 int zoom_iend = zoom_ibegin + zoom_ni - 1; 488 488 int zoom_jend = zoom_jbegin + zoom_nj - 1; 489 489 490 490 if (zoom_ibegin < 1 || zoom_jbegin < 1 || zoom_iend > ni_glo || zoom_jend > nj_glo) 491 491 ERROR("CDomain::checkZoom(void)", … … 496 496 else 497 497 { 498 zoom_ni = ni_glo; 498 zoom_ni = ni_glo; 499 499 zoom_nj = nj_glo; 500 500 zoom_ibegin = 1; 501 501 zoom_jbegin = 1; 502 502 } 503 503 504 504 // compute client zoom indices 505 505 … … 510 510 if (zoom_ni_client<0) zoom_ni_client=0 ; 511 511 512 512 513 513 int zoom_jend=zoom_jbegin+zoom_nj-1 ; 514 514 zoom_jbegin_client = jbegin_client > zoom_jbegin ? jbegin_client : zoom_jbegin ; … … 518 518 519 519 } 520 520 521 521 void CDomain::checkBounds(void) 522 522 { … … 524 524 { 525 525 hasBounds=true ; 526 526 527 527 } 528 else 528 else 529 529 { 530 530 hasBounds=false; … … 532 532 } 533 533 } 534 534 535 535 //---------------------------------------------------------------- 536 536 … … 543 543 this->checkZoom(); 544 544 this->checkBounds(); 545 545 546 546 if (context->hasClient) 547 547 { // CÃŽté client uniquement … … 556 556 // ne sert plus // this->completeLonLatServer(); 557 557 } 558 558 559 559 if (context->hasClient) 560 560 { … … 563 563 sendLonLat() ; 564 564 } 565 565 566 566 this->isChecked = true; 567 567 } 568 568 569 569 void CDomain::sendServerAttribut(void) 570 570 { … … 572 572 int ibegin_srv=1 ; 573 573 int iend_srv=ni_glo.getValue() ; 574 574 575 575 int nj_srv ; 576 576 int jbegin_srv ; 577 577 int jend_srv ; 578 578 579 579 CContext* context=CContext::getCurrent() ; 580 580 CContextClient* client=context->client ; 581 581 int nbServer=client->serverSize ; 582 582 int serverRank=client->getServerLeader() ; 583 583 584 584 jend_srv=0 ; 585 585 for(int i=0;i<=serverRank;i++) … … 590 590 jend_srv=jbegin_srv+nj_srv-1 ; 591 591 } 592 593 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 592 593 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 594 594 if (client->isServerLeader()) 595 595 { … … 606 606 { 607 607 int i,j,i_ind,j_ind ; 608 608 609 609 ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 610 610 jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; 611 611 612 612 CContext* context = CContext::getCurrent() ; 613 613 CContextClient* client=context->client ; … … 617 617 int zoom_iend=zoom_ibegin+zoom_ni-1 ; 618 618 int zoom_jend=zoom_jbegin+zoom_nj-1 ; 619 619 620 620 int blockSize=nj_glo/nbServer ; 621 621 int ns=nj_glo%nbServer ; 622 622 int pos=ns*(blockSize+1) ; 623 623 int serverNum ; 624 624 625 625 mapConnectedServer.resize(ni,nj) ; 626 626 vector<int> nbData(nbServer,0) ; 627 627 vector<int> indServer(nbServer,-1) ; 628 628 vector<bool> IsConnected(nbServer,false) ; 629 629 630 630 for(j=0;j<nj;j++) 631 631 for(i=0;i<ni;i++) … … 633 633 i_ind=ibegin+i_index(i,j)-1 ; 634 634 j_ind=jbegin+j_index(i,j)-1 ; 635 635 636 636 if (j_ind<pos) serverNum=j_ind/(blockSize+1) ; 637 637 else serverNum=ns+(j_ind-pos)/blockSize ; 638 638 IsConnected[serverNum]=true ; 639 639 640 640 if (i_ind >= zoom_ibegin-1 && i_ind <= zoom_iend-1 && j_ind >= zoom_jbegin-1 && j_ind <= zoom_jend-1) 641 641 { … … 647 647 648 648 649 for(serverNum=0 ; serverNum<nbServer ; serverNum++) 649 for(serverNum=0 ; serverNum<nbServer ; serverNum++) 650 650 if (IsConnected[serverNum]) 651 651 { … … 655 655 nbDataSrv.push_back(nbData[serverNum]) ; 656 656 } 657 657 658 658 i_indSrv.resize(connectedServer.size()) ; 659 659 j_indSrv.resize(connectedServer.size()) ; 660 660 661 661 for(j=0;j<nj;j++) 662 for(i=0;i<ni;i++) 662 for(i=0;i<ni;i++) 663 663 { 664 664 if (mapConnectedServer(i,j)>=0) … … 670 670 } 671 671 } 672 672 673 673 int nbConnectedServer=connectedServer.size() ; 674 674 … … 677 677 int* sendBuff=new int[nbConnectedServer] ; 678 678 valarray<int> nbClient(0,client->serverSize) ; 679 679 680 680 for(int n=0;n<nbConnectedServer;n++) sendBuff[n]=connectedServer[n] ; 681 681 682 682 // get connected server for everybody 683 683 MPI_Allgather(&nbConnectedServer,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm) ; 684 684 685 685 displ[0]=0 ; 686 686 for(int n=1;n<client->clientSize;n++) displ[n]=displ[n-1]+recvCount[n-1] ; 687 687 int recvSize=displ[client->clientSize-1]+recvCount[client->clientSize-1] ; 688 688 int* recvBuff=new int[recvSize] ; 689 690 689 690 691 691 MPI_Allgatherv(sendBuff,nbConnectedServer,MPI_INT,recvBuff,recvCount,displ,MPI_INT,client->intraComm) ; 692 692 for(int n=0;n<recvSize;n++) nbClient[recvBuff[n]]++ ; 693 693 694 694 for(int n=0;n<nbConnectedServer;n++) nbSenders.push_back(nbClient[connectedServer[n]]) ; 695 695 696 696 delete [] recvCount ; 697 697 delete [] displ ; … … 703 703 void CDomain::sendLonLat(void) 704 704 { 705 int ns,n,i,j,ind,nv ; 706 CContext* context = CContext::getCurrent() ; 707 CContextClient* client=context->client ; 705 int ns,n,i,j,ind,nv; 706 CContext* context = CContext::getCurrent(); 707 CContextClient* client = context->client; 708 708 709 // send lon lat for each connected server 709 CEventClient event(getType(), EVENT_ID_LON_LAT);710 711 list< shared_ptr<CMessage> > list_msg ;712 list< CArray<int,1>* > list_indi,list_indj;713 list< CArray<double,1>* >list_lon,list_lat;714 list< CArray<double,2>* >list_boundslon,list_boundslat;715 716 for (int ns=0;ns<connectedServer.size();ns++)710 CEventClient event(getType(), EVENT_ID_LON_LAT); 711 712 list<CMessage> list_msg; 713 list<CArray<int,1> > list_indi,list_indj; 714 list<CArray<double,1> >list_lon,list_lat; 715 list<CArray<double,2> >list_boundslon,list_boundslat; 716 717 for (int ns = 0; ns < connectedServer.size(); ns++) 717 718 { 718 int nbData = nbDataSrv[ns] ; 719 CArray<int,1> indi(nbData) ; 720 CArray<int,1> indj(nbData) ; 721 CArray<double,1> lon(nbData) ; 722 CArray<double,1> lat(nbData) ; 723 CArray<double,2> boundslon(nvertex,nbData) ; 724 CArray<double,2> boundslat(nvertex,nbData) ; 725 726 for(n=0;n<nbData;n++) 727 { 728 i=i_indSrv[ns][n] ; 729 j=j_indSrv[ns][n] ; 730 ind=(i-(zoom_ibegin_client-1))+(j-(zoom_jbegin_client-1))*zoom_ni_client ; 731 732 lon(n)=lonvalue(ind) ; 733 lat(n)=latvalue(ind) ; 719 int nbData = nbDataSrv[ns]; 720 721 list_indi.push_back(CArray<int,1>(nbData)); 722 list_indj.push_back(CArray<int,1>(nbData)); 723 list_lon.push_back(CArray<double,1>(nbData)); 724 list_lat.push_back(CArray<double,1>(nbData)); 725 726 if (hasBounds) 727 { 728 list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 729 list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 730 } 731 732 CArray<int,1>& indi = list_indi.back(); 733 CArray<int,1>& indj = list_indj.back(); 734 CArray<double,1>& lon = list_lon.back(); 735 CArray<double,1>& lat = list_lat.back(); 736 737 for (n = 0; n < nbData; n++) 738 { 739 i = i_indSrv[ns][n]; 740 j = j_indSrv[ns][n]; 741 ind = (i - (zoom_ibegin_client - 1)) + (j - (zoom_jbegin_client - 1)) * zoom_ni_client; 742 743 lon(n) = lonvalue(ind); 744 lat(n) = latvalue(ind); 745 734 746 if (hasBounds) 735 747 { 736 for(nv=0;nv<nvertex;nv++) 748 CArray<double,2>& boundslon = list_boundslon.back(); 749 CArray<double,2>& boundslat = list_boundslat.back(); 750 751 for(nv = 0; nv < nvertex; nv++) 737 752 { 738 boundslon(nv,n) =bounds_lon(nv,ind);739 boundslat(nv,n) =bounds_lat(nv,ind);753 boundslon(nv,n) = bounds_lon(nv,ind); 754 boundslat(nv,n) = bounds_lat(nv,ind); 740 755 } 741 756 } 742 indi(n)=ibegin+i_index(i-ibegin+1,j-jbegin+1)-1 ; 743 indj(n)=jbegin+j_index(i-ibegin+1,j-jbegin+1)-1 ; 744 } 745 746 list_indi.push_back(new CArray<int,1>(indi.copy())) ; 747 list_indj.push_back(new CArray<int,1>(indj.copy())) ; 748 list_lon.push_back(new CArray<double,1>(lon.copy())) ; 749 list_lat.push_back(new CArray<double,1>(lat.copy())) ; 750 if (hasBounds) list_boundslon.push_back(new CArray<double,2>(boundslon.copy())) ; 751 if (hasBounds) list_boundslat.push_back(new CArray<double,2>(boundslat.copy())) ; 752 753 list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 754 755 *list_msg.back()<<this->getId()<<(int)type ; // enum ne fonctionne pour les message => ToFix 756 *list_msg.back()<<isCurvilinear ; 757 *list_msg.back()<<*list_indi.back()<<*list_indj.back()<<*list_lon.back()<<*list_lat.back() ; 758 if (hasBounds) *list_msg.back()<<*list_boundslon.back()<<*list_boundslat.back(); 759 event.push(connectedServer[ns],nbSenders[ns],*list_msg.back()) ; 757 758 indi(n) = ibegin + i_index(i - ibegin + 1, j - jbegin + 1) - 1; 759 indj(n) = jbegin + j_index(i - ibegin + 1, j - jbegin + 1) - 1; 760 } 761 762 list_msg.push_back(CMessage()); 763 764 list_msg.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 765 list_msg.back() << isCurvilinear; 766 list_msg.back() << list_indi.back() << list_indj.back() << list_lon.back() << list_lat.back(); 767 if (hasBounds) list_msg.back() << list_boundslon.back() << list_boundslat.back(); 768 769 event.push(connectedServer[ns], nbSenders[ns], list_msg.back()); 760 770 } 761 771 762 client->sendEvent(event) ; 763 764 765 for(list<CArray<int,1>* >::iterator it=list_indi.begin();it!=list_indi.end();it++) delete *it; 766 for(list<CArray<int,1>* >::iterator it=list_indj.begin();it!=list_indj.end();it++) delete *it; 767 for(list<CArray<double,1>* >::iterator it=list_lon.begin();it!=list_lon.end();it++) delete *it; 768 for(list<CArray<double,1>* >::iterator it=list_lat.begin();it!=list_lat.end();it++) delete *it; 769 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslon.begin();it!=list_boundslon.end();it++) delete *it; 770 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++) delete *it; 771 772 client->sendEvent(event); 772 773 } 773 774 774 775 775 776 bool CDomain::dispatchEvent(CEventServer& event) 776 { 777 778 if (SuperClass::dispatchEvent(event)) return true ; 779 else 780 { 781 switch(event.type) 782 { 783 case EVENT_ID_SERVER_ATTRIBUT : 784 recvServerAttribut(event) ; 785 return true ; 786 break ; 787 case EVENT_ID_LON_LAT : 788 recvLonLat(event) ; 789 return true ; 790 break ; 791 default : 792 ERROR("bool CContext::dispatchEvent(CEventServer& event)", 793 <<"Unknown Event") ; 794 return false ; 795 } 796 } 797 } 798 777 { 778 if (SuperClass::dispatchEvent(event)) return true; 779 else 780 { 781 switch(event.type) 782 { 783 case EVENT_ID_SERVER_ATTRIBUT: 784 recvServerAttribut(event); 785 return true; 786 break; 787 case EVENT_ID_LON_LAT: 788 recvLonLat(event); 789 return true; 790 break; 791 default: 792 ERROR("bool CContext::dispatchEvent(CEventServer& event)", 793 << "Unknown Event"); 794 return false; 795 } 796 } 797 } 798 799 799 void CDomain::recvServerAttribut(CEventServer& event) 800 800 { … … 804 804 get(domainId)->recvServerAttribut(*buffer) ; 805 805 } 806 806 807 807 void CDomain::recvServerAttribut(CBufferIn& buffer) 808 808 { … … 811 811 812 812 buffer>>ni_srv>>ibegin_srv>>iend_srv>>nj_srv>>jbegin_srv>>jend_srv; 813 814 813 814 815 815 zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; 816 816 zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; 817 817 zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; 818 818 819 819 zoom_jbegin_srv = zoom_jbegin.getValue() > jbegin_srv ? zoom_jbegin.getValue() : jbegin_srv ; 820 820 zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; 821 821 zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; 822 822 823 if (zoom_ni_srv<=0 || zoom_nj_srv<=0) 823 if (zoom_ni_srv<=0 || zoom_nj_srv<=0) 824 824 { 825 825 zoom_ibegin_srv=1 ; zoom_iend_srv=0 ; zoom_ni_srv=0 ; … … 830 830 latvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 831 831 latvalue_srv = 0. ; 832 if (hasBounds) 832 if (hasBounds) 833 833 { 834 834 bounds_lon_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; … … 838 838 } 839 839 } 840 840 841 841 void CDomain::recvLonLat(CEventServer& event) 842 842 { 843 list<CEventServer::SSubEvent>::iterator it 844 for (it =event.subEvents.begin();it!=event.subEvents.end();++it)843 list<CEventServer::SSubEvent>::iterator it; 844 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 845 845 { 846 CBufferIn* buffer =it->buffer;847 string domainId 848 *buffer >>domainId;849 get(domainId)->recvLonLat( *buffer);846 CBufferIn* buffer = it->buffer; 847 string domainId; 848 *buffer >> domainId; 849 get(domainId)->recvLonLat(it->rank, *buffer); 850 850 } 851 851 } 852 853 void CDomain::recvLonLat( CBufferIn& buffer)852 853 void CDomain::recvLonLat(int rank, CBufferIn& buffer) 854 854 { 855 CArray<int,1> indi;856 CArray<int,1> indj;857 CArray<double,1> lon 858 CArray<double,1> lat 859 CArray<double,2> boundslon 860 CArray<double,2> boundslat 861 862 int type_int 863 buffer >>type_int>>isCurvilinear>>indi>>indj>>lon>>lat;864 if (hasBounds) buffer >>boundslon>>boundslat;865 type.setValue((type_attr::t_enum)type_int) 866 867 int i, j,ind_srv;868 for (int ind=0;ind<indi.numElements();ind++)855 CArray<int,1>& indi = indiSrv[rank]; 856 CArray<int,1>& indj = indjSrv[rank]; 857 CArray<double,1> lon; 858 CArray<double,1> lat; 859 CArray<double,2> boundslon; 860 CArray<double,2> boundslat; 861 862 int type_int; 863 buffer >> type_int >> isCurvilinear >> indi >> indj >> lon >> lat; 864 if (hasBounds) buffer >> boundslon >> boundslat; 865 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 866 867 int i, j, ind_srv; 868 for (int ind = 0; ind < indi.numElements(); ind++) 869 869 { 870 i =indi(ind) ; j=indj(ind);871 ind_srv =(i-(zoom_ibegin_srv-1))+(j-(zoom_jbegin_srv-1))*zoom_ni_srv;872 lonvalue_srv(ind_srv) =lon(ind);873 latvalue_srv(ind_srv) =lat(ind);874 if (hasBounds) 875 { 876 for (int nv=0;nv<nvertex;nv++)870 i = indi(ind); j = indj(ind); 871 ind_srv = (i - (zoom_ibegin_srv - 1)) + (j - (zoom_jbegin_srv - 1)) * zoom_ni_srv; 872 lonvalue_srv(ind_srv) = lon(ind); 873 latvalue_srv(ind_srv) = lat(ind); 874 if (hasBounds) 875 { 876 for (int nv = 0; nv < nvertex; nv++) 877 877 { 878 bounds_lon_srv(nv, ind_srv)=boundslon(nv,ind);879 bounds_lat_srv(nv, ind_srv)=boundslat(nv,ind);878 bounds_lon_srv(nv, ind_srv) = boundslon(nv, ind); 879 bounds_lat_srv(nv, ind_srv) = boundslat(nv, ind); 880 880 } 881 881 } … … 883 883 } 884 884 //---------------------------------------------------------------- 885 886 887 885 886 887 888 888 ///--------------------------------------------------------------- 889 889 -
XIOS/branchs/xios-1.0/src/node/domain.hpp
r501 r610 15 15 16 16 namespace xios { 17 17 18 18 /// ////////////////////// Déclarations ////////////////////// /// 19 19 … … 39 39 EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_LON_LAT 40 40 } ; 41 41 42 42 /// typedef /// 43 43 typedef CObjectTemplate<CDomain> SuperClass; … … 68 68 void checkDomainData(void); 69 69 void checkCompression(void); 70 70 71 71 void checkZoom(void); 72 72 void checkBounds(void); … … 74 74 75 75 public : 76 76 77 77 /// Autres /// 78 78 … … 84 84 bool hasZoom(void) const; 85 85 bool isEmpty(void) const; 86 87 86 87 88 88 int ni_client,ibegin_client,iend_client ; 89 89 int zoom_ni_client,zoom_ibegin_client,zoom_iend_client ; … … 100 100 CArray<double, 1> lonvalue_srv, latvalue_srv ; 101 101 CArray<double, 2> bounds_lon_srv, bounds_lat_srv ; 102 103 104 vector<int> connectedServer ; // list of connected server 102 103 104 vector<int> connectedServer ; // list of connected server 105 105 vector<int> nbSenders ; // for each communication with a server, number of communicating client 106 vector<int> nbDataSrv ; // size of data to send to each server 106 vector<int> nbDataSrv ; // size of data to send to each server 107 107 vector< vector<int> > i_indSrv ; // for each server, i global index to send 108 108 vector< vector<int> > j_indSrv ; // for each server, j global index to send 109 109 110 110 CArray<int,2> mapConnectedServer ; // (ni,nj) => mapped to connected server number, -1 if no server is target 111 111 112 112 // vector<int> ib_srv, ie_srv, in_srv ; 113 113 // vector<int> jb_srv, je_srv, jn_srv ; 114 114 115 115 public : 116 116 117 117 /// Mutateur /// 118 118 void addRelFile(const StdString & filename); 119 119 void completeLonLatClient(void); 120 void sendServerAttribut(void) 121 void sendLonLat(void) 122 void computeConnectedServer(void) 123 static bool dispatchEvent(CEventServer& event) 124 static void recv LonLat(CEventServer& event);125 static void recv ServerAttribut(CEventServer& event);126 void recv LonLat(CBufferIn& buffer);127 void recv ServerAttribut(CBufferIn& buffer);128 120 void sendServerAttribut(void); 121 void sendLonLat(void); 122 void computeConnectedServer(void); 123 static bool dispatchEvent(CEventServer& event); 124 static void recvServerAttribut(CEventServer& event); 125 static void recvLonLat(CEventServer& event); 126 void recvServerAttribut(CBufferIn& buffer); 127 void recvLonLat(int rank, CBufferIn& buffer); 128 129 129 /// Destructeur /// 130 130 virtual ~CDomain(void); … … 133 133 static StdString GetName(void); 134 134 static StdString GetDefName(void); 135 135 136 136 static ENodeType GetType(void); 137 137 … … 144 144 bool isChecked; 145 145 std::set<StdString> relFiles; 146 std::map<int, CArray<int,1> > indiSrv, indjSrv; 146 147 147 148 }; // class CDomain -
XIOS/trunk/src/node/domain.cpp
r595 r610 792 792 void CDomain::sendLonLat(void) 793 793 { 794 int ns,n,i,j,ind,nv, idx; 795 CContext* context = CContext::getCurrent() ; 796 CContextClient* client=context->client ; 794 int ns, n, i, j, ind, nv, idx; 795 CContext* context = CContext::getCurrent(); 796 CContextClient* client=context->client; 797 797 798 // send lon lat for each connected server 798 799 CEventClient eventLon(getType(),EVENT_ID_LON) ; 800 CEventClient eventLat(getType(),EVENT_ID_LAT) ; 801 802 list<shared_ptr<CMessage> > list_msgLon ; 803 list<shared_ptr<CMessage> > list_msgLat ; 804 list< CArray<int,1>* > list_indi,list_indj ; 805 list< CArray<double,1>* >list_lon,list_lat ; 806 list< CArray<double,2>* >list_boundslon,list_boundslat ; 807 808 std::map<int, std::vector<size_t> >::const_iterator it, itbMap, iteMap; 809 itbMap = indSrv_.begin(); 799 CEventClient eventIndex(getType(), EVENT_ID_INDEX); 800 CEventClient eventLon(getType(), EVENT_ID_LON); 801 CEventClient eventLat(getType(), EVENT_ID_LAT); 802 803 list<CMessage> list_msgsIndex, list_msgsLon, list_msgsLat; 804 list<CArray<int,1> > list_indi, list_indj; 805 list<CArray<double,1> > list_lon, list_lat; 806 list<CArray<double,2> > list_boundslon, list_boundslat; 807 808 std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 810 809 iteMap = indSrv_.end(); 811 810 for (int k = 0; k < connectedServerRank_.size(); ++k) … … 815 814 it = indSrv_.find(rank); 816 815 if (iteMap != it) 817 nbData = (it->second).size(); 818 819 CArray<int,1> indi(nbData) ; 820 CArray<int,1> indj(nbData) ; 821 CArray<double,1> lon(nbData) ; 822 CArray<double,1> lat(nbData) ; 823 CArray<double,2> boundslon(nvertex,nbData); 824 CArray<double,2> boundslat(nvertex,nbData); 816 nbData = it->second.size(); 817 818 list_indi.push_back(CArray<int,1>(nbData)); 819 list_indj.push_back(CArray<int,1>(nbData)); 820 list_lon.push_back(CArray<double,1>(nbData)); 821 list_lat.push_back(CArray<double,1>(nbData)); 822 823 if (hasBounds) 824 { 825 list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 826 list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 827 } 828 829 CArray<int,1>& indi = list_indi.back(); 830 CArray<int,1>& indj = list_indj.back(); 831 CArray<double,1>& lon = list_lon.back(); 832 CArray<double,1>& lat = list_lat.back(); 825 833 826 834 for (n = 0; n < nbData; ++n) 827 835 { 828 idx = static_cast<int>((it->second)[n]); 829 i = idx%ni_glo; 830 j = idx/ni_glo; 831 ind=(i-(zoom_ibegin_client))+(j-(zoom_jbegin_client))*zoom_ni_client ; 832 833 lon(n)=lonvalue(ind) ; 834 lat(n)=latvalue(ind) ; 836 idx = static_cast<int>(it->second[n]); 837 i = idx % ni_glo; 838 j = idx / ni_glo; 839 ind = (i - zoom_ibegin_client) + (j - zoom_jbegin_client) * zoom_ni_client; 840 841 lon(n) = lonvalue(ind); 842 lat(n) = latvalue(ind); 843 835 844 if (hasBounds) 836 845 { 837 for(nv=0;nv<nvertex;nv++) 846 CArray<double,2>& boundslon = list_boundslon.back(); 847 CArray<double,2>& boundslat = list_boundslat.back(); 848 849 for (nv = 0; nv < nvertex; nv++) 838 850 { 839 boundslon(nv, n)=bounds_lon(nv,ind);840 boundslat(nv, n)=bounds_lat(nv,ind);851 boundslon(nv, n) = bounds_lon(nv, ind); 852 boundslat(nv, n) = bounds_lat(nv, ind); 841 853 } 842 854 } 843 indi(n)=ibegin+i_index(i-ibegin,j-jbegin) ; 844 indj(n)=jbegin+j_index(i-ibegin,j-jbegin) ; 845 } 846 847 list_indi.push_back(new CArray<int,1>(indi.copy())) ; 848 list_indj.push_back(new CArray<int,1>(indj.copy())) ; 849 list_lon.push_back(new CArray<double,1>(lon.copy())) ; 850 list_lat.push_back(new CArray<double,1>(lat.copy())) ; 851 if (hasBounds) list_boundslon.push_back(new CArray<double,2>(boundslon.copy())) ; 852 if (hasBounds) list_boundslat.push_back(new CArray<double,2>(boundslat.copy())) ; 853 854 list_msgLon.push_back(shared_ptr<CMessage>(new CMessage)) ; 855 list_msgLat.push_back(shared_ptr<CMessage>(new CMessage)) ; 856 857 *list_msgLon.back()<<this->getId()<<(int)type ; // enum ne fonctionne pour les message => ToFix 858 *list_msgLat.back()<<this->getId()<<(int)type ; 859 *list_msgLon.back()<<isCurvilinear ; 860 *list_msgLat.back()<<isCurvilinear ; 861 *list_msgLon.back()<<*list_indi.back()<<*list_indj.back()<<*list_lon.back() ; 862 *list_msgLat.back()<<*list_indi.back()<<*list_indj.back()<<*list_lat.back() ; 855 856 indi(n) = ibegin + i_index(i - ibegin, j - jbegin); 857 indj(n) = jbegin + j_index(i - ibegin, j - jbegin); 858 } 859 860 list_msgsIndex.push_back(CMessage()); 861 862 list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 863 list_msgsIndex.back() << isCurvilinear; 864 list_msgsIndex.back() << list_indi.back() << list_indj.back(); 865 866 list_msgsLon.push_back(CMessage()); 867 list_msgsLat.push_back(CMessage()); 868 869 list_msgsLon.back() << this->getId() << list_lon.back(); 870 list_msgsLat.back() << this->getId() << list_lat.back(); 863 871 864 872 if (hasBounds) 865 873 { 866 *list_msgLon.back()<<*list_boundslon.back(); 867 *list_msgLat.back()<<*list_boundslat.back(); 868 } 869 870 eventLon.push(rank,nbConnectedClients_[rank],*list_msgLon.back()) ; 871 eventLat.push(rank,nbConnectedClients_[rank],*list_msgLat.back()) ; 872 } 873 874 client->sendEvent(eventLon) ; 875 client->sendEvent(eventLat) ; 876 877 878 for(list<CArray<int,1>* >::iterator it=list_indi.begin();it!=list_indi.end();it++) delete *it; 879 for(list<CArray<int,1>* >::iterator it=list_indj.begin();it!=list_indj.end();it++) delete *it; 880 for(list<CArray<double,1>* >::iterator it=list_lon.begin();it!=list_lon.end();it++) delete *it; 881 for(list<CArray<double,1>* >::iterator it=list_lat.begin();it!=list_lat.end();it++) delete *it; 882 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslon.begin();it!=list_boundslon.end();it++) delete *it; 883 if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++) delete *it; 874 list_msgsLon.back() << list_boundslon.back(); 875 list_msgsLat.back() << list_boundslat.back(); 876 } 877 878 eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 879 eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); 880 eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); 881 } 882 883 client->sendEvent(eventIndex); 884 client->sendEvent(eventLon); 885 client->sendEvent(eventLat); 884 886 } 885 887 886 888 bool CDomain::dispatchEvent(CEventServer& event) 887 { 888 889 if (SuperClass::dispatchEvent(event)) return true ; 890 else 891 { 892 switch(event.type) 893 { 894 case EVENT_ID_SERVER_ATTRIBUT : 895 recvServerAttribut(event) ; 896 return true ; 897 break ; 898 case EVENT_ID_LON : 899 recvLon(event) ; 900 return true ; 901 break ; 902 case EVENT_ID_LAT : 903 recvLat(event) ; 904 return true ; 905 break ; 906 default : 907 ERROR("bool CContext::dispatchEvent(CEventServer& event)", 908 <<"Unknown Event") ; 909 return false ; 910 } 911 } 912 } 889 { 890 if (SuperClass::dispatchEvent(event)) return true; 891 else 892 { 893 switch(event.type) 894 { 895 case EVENT_ID_SERVER_ATTRIBUT: 896 recvServerAttribut(event); 897 return true; 898 break; 899 case EVENT_ID_INDEX: 900 recvIndex(event); 901 return true; 902 break; 903 case EVENT_ID_LON: 904 recvLon(event); 905 return true; 906 break; 907 case EVENT_ID_LAT: 908 recvLat(event); 909 return true; 910 break; 911 default: 912 ERROR("bool CContext::dispatchEvent(CEventServer& event)", 913 << "Unknown Event"); 914 return false; 915 } 916 } 917 } 913 918 914 919 void CDomain::recvServerAttribut(CEventServer& event) … … 953 958 } 954 959 960 void CDomain::recvIndex(CEventServer& event) 961 { 962 list<CEventServer::SSubEvent>::iterator it; 963 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 964 { 965 CBufferIn* buffer = it->buffer; 966 string domainId; 967 *buffer >> domainId; 968 get(domainId)->recvIndex(it->rank, *buffer); 969 } 970 } 971 972 void CDomain::recvIndex(int rank, CBufferIn& buffer) 973 { 974 int type_int; 975 buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; 976 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 977 } 978 955 979 void CDomain::recvLon(CEventServer& event) 956 980 { 957 list<CEventServer::SSubEvent>::iterator it ; 958 for (it=event.subEvents.begin();it!=event.subEvents.end();++it) 959 { 960 CBufferIn* buffer=it->buffer; 961 string domainId ; 962 *buffer>>domainId ; 963 get(domainId)->recvLon(*buffer) ; 964 } 965 } 966 967 void CDomain::recvLon(CBufferIn& buffer) 968 { 969 CArray<int,1> indi ; 970 CArray<int,1> indj ; 971 CArray<double,1> lon ; 972 CArray<double,2> boundslon ; 973 974 int type_int ; 975 buffer>>type_int>>isCurvilinear>>indi>>indj>>lon ; 976 if (hasBounds) buffer>>boundslon ; 977 type.setValue((type_attr::t_enum)type_int) ; // probleme des type enum avec les buffers : ToFix 978 979 int i,j,ind_srv ; 980 for(int ind=0;ind<indi.numElements();ind++) 981 { 982 i=indi(ind) ; j=indj(ind) ; 983 ind_srv=(i-(zoom_ibegin_srv))+(j-(zoom_jbegin_srv))*zoom_ni_srv ; 984 lonvalue_srv(ind_srv)=lon(ind) ; 981 list<CEventServer::SSubEvent>::iterator it; 982 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 983 { 984 CBufferIn* buffer = it->buffer; 985 string domainId; 986 *buffer >> domainId; 987 get(domainId)->recvLon(it->rank, *buffer); 988 } 989 } 990 991 void CDomain::recvLon(int rank, CBufferIn& buffer) 992 { 993 CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 994 CArray<double,1> lon; 995 CArray<double,2> boundslon; 996 997 buffer >> lon; 998 if (hasBounds) buffer >> boundslon; 999 1000 int i, j, ind_srv; 1001 for (int ind = 0; ind < indi.numElements(); ind++) 1002 { 1003 i = indi(ind); j = indj(ind); 1004 ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 1005 lonvalue_srv(ind_srv) = lon(ind); 985 1006 if (hasBounds) 986 1007 { 987 for(int nv=0;nv<nvertex;nv++) 988 { 989 bounds_lon_srv(nv,ind_srv)=boundslon(nv,ind) ; 990 } 1008 for (int nv = 0; nv < nvertex; nv++) 1009 bounds_lon_srv(nv, ind_srv) = boundslon(nv, ind); 991 1010 } 992 1011 } … … 995 1014 void CDomain::recvLat(CEventServer& event) 996 1015 { 997 list<CEventServer::SSubEvent>::iterator it ; 998 for (it=event.subEvents.begin();it!=event.subEvents.end();++it) 999 { 1000 CBufferIn* buffer=it->buffer; 1001 string domainId ; 1002 *buffer>>domainId ; 1003 get(domainId)->recvLat(*buffer) ; 1004 } 1005 } 1006 1007 void CDomain::recvLat(CBufferIn& buffer) 1008 { 1009 CArray<int,1> indi ; 1010 CArray<int,1> indj ; 1011 CArray<double,1> lat ; 1012 CArray<double,2> boundslat ; 1013 1014 int type_int ; 1015 buffer>>type_int>>isCurvilinear>>indi>>indj>>lat ; 1016 if (hasBounds) buffer>>boundslat ; 1017 type.setValue((type_attr::t_enum)type_int) ; // probleme des type enum avec les buffers : ToFix 1018 int i,j,ind_srv ; 1019 for(int ind=0;ind<indi.numElements();ind++) 1020 { 1021 i=indi(ind) ; j=indj(ind) ; 1022 ind_srv=(i-(zoom_ibegin_srv))+(j-(zoom_jbegin_srv))*zoom_ni_srv ; 1023 latvalue_srv(ind_srv)=lat(ind) ; 1016 list<CEventServer::SSubEvent>::iterator it; 1017 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 1018 { 1019 CBufferIn* buffer = it->buffer; 1020 string domainId; 1021 *buffer >> domainId; 1022 get(domainId)->recvLat(it->rank, *buffer); 1023 } 1024 } 1025 1026 void CDomain::recvLat(int rank, CBufferIn& buffer) 1027 { 1028 CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 1029 CArray<double,1> lat; 1030 CArray<double,2> boundslat; 1031 1032 buffer >> lat; 1033 if (hasBounds) buffer >> boundslat; 1034 1035 int i, j, ind_srv; 1036 for (int ind = 0; ind < indi.numElements(); ind++) 1037 { 1038 i = indi(ind); j = indj(ind); 1039 ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 1040 latvalue_srv(ind_srv) = lat(ind); 1024 1041 if (hasBounds) 1025 1042 { 1026 for(int nv=0;nv<nvertex;nv++) 1027 { 1028 bounds_lat_srv(nv,ind_srv)=boundslat(nv,ind) ; 1029 } 1043 for (int nv = 0; nv < nvertex; nv++) 1044 bounds_lat_srv(nv, ind_srv) = boundslat(nv, ind); 1030 1045 } 1031 1046 } -
XIOS/trunk/src/node/domain.hpp
r594 r610 38 38 enum EEventId 39 39 { 40 EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_ LAT, EVENT_ID_LON40 EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT 41 41 } ; 42 42 … … 129 129 void sendLonLat(void) ; 130 130 void computeConnectedServer(void) ; 131 static bool dispatchEvent(CEventServer& event) ; 132 static void recvLat(CEventServer& event) ; 133 static void recvLon(CEventServer& event) ; 134 static void recvServerAttribut(CEventServer& event) ; 135 void recvLat(CBufferIn& buffer) ; 136 void recvLon(CBufferIn& buffer) ; 137 void recvServerAttribut(CBufferIn& buffer) ; 131 static bool dispatchEvent(CEventServer& event); 132 static void recvServerAttribut(CEventServer& event); 133 static void recvIndex(CEventServer& event); 134 static void recvLon(CEventServer& event); 135 static void recvLat(CEventServer& event); 136 void recvServerAttribut(CBufferIn& buffer); 137 void recvIndex(int rank, CBufferIn& buffer); 138 void recvLon(int rank, CBufferIn& buffer); 139 void recvLat(int rank, CBufferIn& buffer); 138 140 139 141 /// Destructeur /// … … 155 157 std::set<StdString> relFiles; 156 158 bool isClientChecked; // Verify whether all attributes of domain on the client side are good 159 std::map<int, CArray<int,1> > indiSrv, indjSrv; 157 160 std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 158 161 std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server
Note: See TracChangeset
for help on using the changeset viewer.