Changeset 610 for XIOS/trunk/src/node/domain.cpp
- Timestamp:
- 06/10/15 10:39:10 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.