Ignore:
Timestamp:
01/16/18 23:54:35 (6 years ago)
Author:
ymipsl
Message:

Bug fix in non distributed transformation : mask is now correctly taking into account.

YM

Location:
XIOS/dev/XIOS_DEV_CMIP6/src/transformation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.cpp

    r1402 r1404  
    873873  vector<int> nIndexSrc(nElement) ; 
    874874  vector<int> nIndexDst(nElement) ; 
     875  vector< CArray<bool,1>* > maskSrc(nElement) ; 
     876  vector< CArray<bool,1>* > maskDst(nElement) ; 
     877     
    875878  int nlocalIndexSrc=1 ; 
    876879  int nlocalIndexDest=1 ; 
     880  CArray<bool,1> maskScalar(1) ; 
     881  maskScalar  = true ; 
     882   
    877883   
    878884  for(int i=0 ; i<nElement; i++) 
     
    883889      CDomain* domain=domainListSrcP[elementPositionInGridSrc2DomainPosition_[i]] ; 
    884890      nIndexSrc[i] = domain->i_index.numElements() ; 
     891      maskSrc[i]=&domain->localMask ; 
    885892    } 
    886893    else if (1 == dimElement) //axis 
     
    888895      CAxis* axis=axisListSrcP[elementPositionInGridSrc2DomainPosition_[i]] ; 
    889896      nIndexSrc[i] = axis->index.numElements() ; 
     897      maskSrc[i]=&axis->mask ; 
    890898    } 
    891899    else  //scalar 
    892900    { 
    893901      nIndexSrc[i]=1 ; 
     902      maskSrc[i]=&maskScalar ; 
    894903    } 
    895904    nlocalIndexSrc=nlocalIndexSrc*nIndexSrc[i] ; 
    896905  } 
     906 
     907 
    897908 
    898909  int offset=1 ; 
     
    903914    { 
    904915      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 ; 
    906922    } 
    907923    else if (1 == dimElement) //axis 
    908924    { 
    909925      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 ; 
    911932    } 
    912933    else  //scalar 
    913934    { 
    914935      nIndexDst[i]=1 ; 
     936      maskDst[i]=&maskScalar ; 
    915937    } 
    916938    if (i<elementPositionInGrid) offset=offset*nIndexDst[i] ; 
    917939    nlocalIndexDest=nlocalIndexDest*nIndexDst[i] ; 
    918940  } 
     941 
     942 
     943 
     944 
     945 
    919946 
    920947  vector<int> dstLocalInd ; 
     
    928955    dstLocalInd.resize(nindex_glo,-1) ; 
    929956    int nIndex=domain->i_index.numElements() ; 
     957    CArray<bool,1>& localMask=domain->localMask ; 
     958    int unmaskedInd=0 ; 
     959    int globIndex ; 
    930960    for(int i=0;i<nIndex;i++) 
    931961    { 
    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      } 
    934968    } 
    935969  } 
     
    940974    dstLocalInd.resize(nindex_glo,-1) ; 
    941975    int nIndex=axis->index.numElements() ; 
     976    CArray<bool,1>& localMask=axis->mask ; // axis mask must include later data_index 
     977    int unmaskedInd=0 ; 
    942978    for(int i=0;i<nIndex;i++) 
    943979    { 
    944       dstLocalInd[axis->index(i)]=i ; 
     980      if (localMask(i)) 
     981      { 
     982        dstLocalInd[axis->index(i)]=unmaskedInd ; 
     983        unmaskedInd++ ; 
     984      } 
    945985    } 
    946986  } 
     
    9861026 
    9871027   
    988   nonDistributedrecursiveFunct(nElement-1,elementPositionInGrid,srcInd, nIndexSrc, t, dstIndWeight,   
     1028  nonDistributedrecursiveFunct(nElement-1,elementPositionInGrid,maskSrc,maskDst, srcInd, nIndexSrc, t, dstIndWeight,   
    9891029                               currentInd,localSrc,localDst,weight, localMaskOnSrcGrid, localMaskOnGridDest ); 
    9901030                
     
    9921032 
    9931033 
    994 void CGenericAlgorithmTransformation::nonDistributedrecursiveFunct(int currentPos, int elementPositionInGrid, int& srcInd, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 
     1034void 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, 
    9951035                    vector<int>& localSrc, vector<int>& localDst, vector<double>& weight,  CArray<bool,1>& localMaskOnGridSrc, vector<bool>& localMaskOnGridDest ) 
    9961036{ 
     
    9991039    if (currentPos!=0) 
    10001040    { 
     1041      CArray<bool,1>& mask = *maskSrc[currentPos] ; 
     1042      
    10011043      for(int i=0;i<nIndexSrc[currentPos];i++) 
    10021044      { 
    1003         nonDistributedrecursiveFunct(currentPos-1, elementPositionInGrid, srcInd, nIndexSrc, t, dstIndWeight, currentInd, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 
     1045        if (mask(i)) 
     1046        { 
     1047          nonDistributedrecursiveFunct(currentPos-1, elementPositionInGrid, maskSrc, maskDst, srcInd, nIndexSrc, t, dstIndWeight, currentInd, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 
     1048        } 
    10041049      } 
    10051050    } 
    10061051    else 
    10071052    { 
     1053      CArray<bool,1>& mask = *maskSrc[currentPos] ; 
    10081054      for(int i=0;i<nIndexSrc[currentPos];i++) 
    10091055      { 
    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) 
    10131059          { 
    1014             if (localMaskOnGridSrc(srcInd)) 
     1060            for(vector<pair<int,double> >::iterator it = dstIndWeight[t][currentInd].begin(); it!=dstIndWeight[t][currentInd].end(); ++it) 
    10151061            { 
    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)++ ; 
    10201070            } 
    1021             (it->first)++ ; 
    10221071          } 
    1023         } 
    1024         srcInd++ ; 
    1025         if (t < dstIndWeight.size()-1) t++ ; 
     1072          srcInd++ ; 
     1073          if (t < dstIndWeight.size()-1) t++ ; 
     1074        } 
    10261075      } 
    10271076    } 
     
    10331082    { 
    10341083 
    1035  
     1084      CArray<bool,1>& mask = *maskSrc[currentPos] ; 
    10361085      for(int i=0;i<nIndexSrc[currentPos];i++) 
    10371086      { 
    10381087        t=0 ; 
    1039         nonDistributedrecursiveFunct(currentPos-1, elementPositionInGrid, srcInd, nIndexSrc, t, dstIndWeight , i,  localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 
     1088        if (mask(i)) 
     1089        { 
     1090          nonDistributedrecursiveFunct(currentPos-1, elementPositionInGrid, maskSrc, maskDst, srcInd, nIndexSrc, t, dstIndWeight , i,  localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 
     1091        } 
    10401092      } 
    10411093    } 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.hpp

    r1400 r1404  
    8989  void computeTransformationMappingNonDistributed(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst, 
    9090                                                  vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, vector<bool>& localMaskOnGridDest); 
    91   void nonDistributedrecursiveFunct(int currentPos, int elementPositionInGrid, int& srcInd, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 
     91  void 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, 
    9292                                     vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, CArray<bool,1>& localMaskOnGridSrc, vector<bool>& localMaskOnGridDest) ; 
    9393 
Note: See TracChangeset for help on using the changeset viewer.