Ignore:
Timestamp:
01/14/19 10:47:44 (5 years ago)
Author:
oabramkina
Message:

Backporting r1618 to dev before merging it to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/transformation/domain_algorithm_interpolate.cpp

    r1612 r1634  
    311311  CArray<double,2> boundsLonSrcUnmasked(nVertexSrc,nSrcLocalUnmasked); 
    312312  CArray<double,2> boundsLatSrcUnmasked(nVertexSrc,nSrcLocalUnmasked); 
     313  CArray<double,1> areaSrcUnmasked(nSrcLocalUnmasked); 
     314   
    313315  long int * globalSrcUnmasked = new long int [nSrcLocalUnmasked]; 
    314316 
    315317  nSrcLocalUnmasked=0 ; 
     318  bool hasSrcArea=domainSrc_->hasArea && !domainSrc_->radius.isEmpty() && !interpDomain_->use_area.isEmpty() && interpDomain_->use_area==true  ; 
     319  double srcAreaFactor ; 
     320  if (hasSrcArea) srcAreaFactor=1./(domainSrc_->radius*domainSrc_->radius) ; 
     321   
    316322  for (int idx=0 ; idx < nSrcLocal; idx++) 
    317323  { 
     
    323329        boundsLatSrcUnmasked(n,nSrcLocalUnmasked) = boundsLatSrc(n,idx) ; 
    324330      } 
     331      if (hasSrcArea) areaSrcUnmasked(nSrcLocalUnmasked) = domainSrc_->areavalue(idx)*srcAreaFactor ; 
    325332      globalSrcUnmasked[nSrcLocalUnmasked]=globalSrc[idx] ; 
    326333      ++nSrcLocalUnmasked ; 
    327334    } 
    328335  } 
    329  
     336  
    330337 
    331338  int nDstLocalUnmasked = 0 ; 
     
    334341  CArray<double,2> boundsLonDestUnmasked(nVertexDest,nDstLocalUnmasked); 
    335342  CArray<double,2> boundsLatDestUnmasked(nVertexDest,nDstLocalUnmasked); 
     343  CArray<double,1>   areaDstUnmasked(nDstLocalUnmasked); 
     344 
    336345  long int * globalDstUnmasked = new long int [nDstLocalUnmasked]; 
    337346 
    338347  nDstLocalUnmasked=0 ; 
     348  bool hasDstArea=domainDest_->hasArea && !domainDest_->radius.isEmpty() && !interpDomain_->use_area.isEmpty() && interpDomain_->use_area==true ; 
     349  double dstAreaFactor ; 
     350  if (hasDstArea) dstAreaFactor=1./(domainDest_->radius*domainDest_->radius) ; 
    339351  for (int idx=0 ; idx < nDstLocal; idx++) 
    340352  { 
     
    346358        boundsLatDestUnmasked(n,nDstLocalUnmasked) = boundsLatDest(n,idx) ; 
    347359      } 
     360      if (hasDstArea) areaDstUnmasked(nDstLocalUnmasked) = domainDest_->areavalue(idx)*dstAreaFactor ; 
    348361      globalDstUnmasked[nDstLocalUnmasked]=globalDst[idx] ; 
    349362      ++nDstLocalUnmasked ; 
     
    351364  } 
    352365 
    353   mapper.setSourceMesh(boundsLonSrcUnmasked.dataFirst(), boundsLatSrcUnmasked.dataFirst(), nVertexSrc, nSrcLocalUnmasked, &srcPole[0], globalSrcUnmasked); 
    354   mapper.setTargetMesh(boundsLonDestUnmasked.dataFirst(), boundsLatDestUnmasked.dataFirst(), nVertexDest, nDstLocalUnmasked, &dstPole[0], globalDstUnmasked); 
     366  double* ptAreaSrcUnmasked = NULL ; 
     367  if (hasSrcArea) ptAreaSrcUnmasked=areaSrcUnmasked.dataFirst() ; 
     368 
     369  double* ptAreaDstUnmasked = NULL ; 
     370  if (hasDstArea) ptAreaDstUnmasked=areaDstUnmasked.dataFirst() ; 
     371 
     372  mapper.setSourceMesh(boundsLonSrcUnmasked.dataFirst(), boundsLatSrcUnmasked.dataFirst(), ptAreaSrcUnmasked, nVertexSrc, nSrcLocalUnmasked, &srcPole[0], globalSrcUnmasked); 
     373  mapper.setTargetMesh(boundsLonDestUnmasked.dataFirst(), boundsLatDestUnmasked.dataFirst(), ptAreaDstUnmasked, nVertexDest, nDstLocalUnmasked, &dstPole[0], globalDstUnmasked); 
    355374 
    356375  std::vector<double> timings = mapper.computeWeights(orderInterp,renormalize,quantity); 
     
    9861005    size_t nbIndex=dataOut.numElements() ;  
    9871006 
    988     for (int idx = 0; idx < nbIndex; ++idx) 
    989     { 
    990       if (allMissing(idx)) dataOut(idx) = defaultValue; // If all data source are nan then data destination must be nan 
     1007    if (allMissing.numElements()>0) 
     1008    { 
     1009      for (int idx = 0; idx < nbIndex; ++idx) 
     1010      { 
     1011        if (allMissing(idx)) dataOut(idx) = defaultValue; // If all data source are nan then data destination must be nan 
     1012      } 
    9911013    } 
    9921014     
Note: See TracChangeset for help on using the changeset viewer.