 Timestamp:
 01/16/18 23:54:35 (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.cpp
r1402 r1404 873 873 vector<int> nIndexSrc(nElement) ; 874 874 vector<int> nIndexDst(nElement) ; 875 vector< CArray<bool,1>* > maskSrc(nElement) ; 876 vector< CArray<bool,1>* > maskDst(nElement) ; 877 875 878 int nlocalIndexSrc=1 ; 876 879 int nlocalIndexDest=1 ; 880 CArray<bool,1> maskScalar(1) ; 881 maskScalar = true ; 882 877 883 878 884 for(int i=0 ; i<nElement; i++) … … 883 889 CDomain* domain=domainListSrcP[elementPositionInGridSrc2DomainPosition_[i]] ; 884 890 nIndexSrc[i] = domain>i_index.numElements() ; 891 maskSrc[i]=&domain>localMask ; 885 892 } 886 893 else if (1 == dimElement) //axis … … 888 895 CAxis* axis=axisListSrcP[elementPositionInGridSrc2DomainPosition_[i]] ; 889 896 nIndexSrc[i] = axis>index.numElements() ; 897 maskSrc[i]=&axis>mask ; 890 898 } 891 899 else //scalar 892 900 { 893 901 nIndexSrc[i]=1 ; 902 maskSrc[i]=&maskScalar ; 894 903 } 895 904 nlocalIndexSrc=nlocalIndexSrc*nIndexSrc[i] ; 896 905 } 906 907 897 908 898 909 int offset=1 ; … … 903 914 { 904 915 CDomain* domain=domainListDstP[elementPositionInGridDst2DomainPosition_[i]] ; 905 nIndexDst[i] = domain>i_index.numElements() ; 916 int nIndex=domain>i_index.numElements() ; 917 CArray<bool,1>& localMask=domain>localMask ; 918 int nbInd=0 ; 919 for(int j=0;j<nIndex;j++) if (localMask(j)) nbInd++ ; 920 nIndexDst[i] = nbInd ; 921 maskDst[i]=&domain>localMask ; 906 922 } 907 923 else if (1 == dimElement) //axis 908 924 { 909 925 CAxis* axis = axisListDstP[elementPositionInGridDst2DomainPosition_[i]] ; 910 nIndexDst[i] = axis>index.numElements() ; 926 int nIndex=axis>index.numElements() ; 927 CArray<bool,1>& localMask=axis>mask ; 928 int nbInd=0 ; 929 for(int j=0;i<nIndex;j++) if (localMask(j)) nbInd++ ; 930 nIndexDst[i] = nbInd ; 931 maskDst[i]=&axis>mask ; 911 932 } 912 933 else //scalar 913 934 { 914 935 nIndexDst[i]=1 ; 936 maskDst[i]=&maskScalar ; 915 937 } 916 938 if (i<elementPositionInGrid) offset=offset*nIndexDst[i] ; 917 939 nlocalIndexDest=nlocalIndexDest*nIndexDst[i] ; 918 940 } 941 942 943 944 945 919 946 920 947 vector<int> dstLocalInd ; … … 928 955 dstLocalInd.resize(nindex_glo,1) ; 929 956 int nIndex=domain>i_index.numElements() ; 957 CArray<bool,1>& localMask=domain>localMask ; 958 int unmaskedInd=0 ; 959 int globIndex ; 930 960 for(int i=0;i<nIndex;i++) 931 961 { 932 int globIndex=domain>j_index(i)*ni_glo+domain>i_index(i) ; 933 dstLocalInd[globIndex]=i ; 962 if (localMask(i)) 963 { 964 globIndex=domain>j_index(i)*ni_glo+domain>i_index(i) ; 965 dstLocalInd[globIndex]=unmaskedInd ; 966 unmaskedInd++ ; 967 } 934 968 } 935 969 } … … 940 974 dstLocalInd.resize(nindex_glo,1) ; 941 975 int nIndex=axis>index.numElements() ; 976 CArray<bool,1>& localMask=axis>mask ; // axis mask must include later data_index 977 int unmaskedInd=0 ; 942 978 for(int i=0;i<nIndex;i++) 943 979 { 944 dstLocalInd[axis>index(i)]=i ; 980 if (localMask(i)) 981 { 982 dstLocalInd[axis>index(i)]=unmaskedInd ; 983 unmaskedInd++ ; 984 } 945 985 } 946 986 } … … 986 1026 987 1027 988 nonDistributedrecursiveFunct(nElement1,elementPositionInGrid, srcInd, nIndexSrc, t, dstIndWeight,1028 nonDistributedrecursiveFunct(nElement1,elementPositionInGrid,maskSrc,maskDst, srcInd, nIndexSrc, t, dstIndWeight, 989 1029 currentInd,localSrc,localDst,weight, localMaskOnSrcGrid, localMaskOnGridDest ); 990 1030 … … 992 1032 993 1033 994 void CGenericAlgorithmTransformation::nonDistributedrecursiveFunct(int currentPos, int elementPositionInGrid, int& srcInd, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd,1034 void CGenericAlgorithmTransformation::nonDistributedrecursiveFunct(int currentPos, int elementPositionInGrid, vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, int& srcInd, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 995 1035 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, CArray<bool,1>& localMaskOnGridSrc, vector<bool>& localMaskOnGridDest ) 996 1036 { … … 999 1039 if (currentPos!=0) 1000 1040 { 1041 CArray<bool,1>& mask = *maskSrc[currentPos] ; 1042 1001 1043 for(int i=0;i<nIndexSrc[currentPos];i++) 1002 1044 { 1003 nonDistributedrecursiveFunct(currentPos1, elementPositionInGrid, srcInd, nIndexSrc, t, dstIndWeight, currentInd, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 1045 if (mask(i)) 1046 { 1047 nonDistributedrecursiveFunct(currentPos1, elementPositionInGrid, maskSrc, maskDst, srcInd, nIndexSrc, t, dstIndWeight, currentInd, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 1048 } 1004 1049 } 1005 1050 } 1006 1051 else 1007 1052 { 1053 CArray<bool,1>& mask = *maskSrc[currentPos] ; 1008 1054 for(int i=0;i<nIndexSrc[currentPos];i++) 1009 1055 { 1010 if ( dstIndWeight[t][currentInd].size()>0)1011 { 1012 for(vector<pair<int,double> >::iterator it = dstIndWeight[t][currentInd].begin(); it!=dstIndWeight[t][currentInd].end(); ++it)1056 if (mask(i)) 1057 { 1058 if (dstIndWeight[t][currentInd].size()>0) 1013 1059 { 1014 if (localMaskOnGridSrc(srcInd))1060 for(vector<pair<int,double> >::iterator it = dstIndWeight[t][currentInd].begin(); it!=dstIndWeight[t][currentInd].end(); ++it) 1015 1061 { 1016 localSrc.push_back(srcInd) ; 1017 localDst.push_back(it>first) ; 1018 weight.push_back(it>second) ; 1019 localMaskOnGridDest[it>first]=true ; 1062 if (localMaskOnGridSrc(srcInd)) 1063 { 1064 localSrc.push_back(srcInd) ; 1065 localDst.push_back(it>first) ; 1066 weight.push_back(it>second) ; 1067 localMaskOnGridDest[it>first]=true ; 1068 } 1069 (it>first)++ ; 1020 1070 } 1021 (it>first)++ ;1022 1071 } 1023 }1024 srcInd++ ;1025 if (t < dstIndWeight.size()1) t++ ;1072 srcInd++ ; 1073 if (t < dstIndWeight.size()1) t++ ; 1074 } 1026 1075 } 1027 1076 } … … 1033 1082 { 1034 1083 1035 1084 CArray<bool,1>& mask = *maskSrc[currentPos] ; 1036 1085 for(int i=0;i<nIndexSrc[currentPos];i++) 1037 1086 { 1038 1087 t=0 ; 1039 nonDistributedrecursiveFunct(currentPos1, elementPositionInGrid, srcInd, nIndexSrc, t, dstIndWeight , i, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 1088 if (mask(i)) 1089 { 1090 nonDistributedrecursiveFunct(currentPos1, elementPositionInGrid, maskSrc, maskDst, srcInd, nIndexSrc, t, dstIndWeight , i, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 1091 } 1040 1092 } 1041 1093 }
Note: See TracChangeset
for help on using the changeset viewer.