Ignore:
Timestamp:
03/28/23 16:42:11 (15 months ago)
Author:
ymipsl
Message:

First guess in supression of attached mode replaced by online reader and write filters

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/dev/XIOS_ATTACHED/src/transformation/scalar_algorithm/scalar_algorithm_redistribute.cpp

    r2460 r2482  
    88#include "grid.hpp" 
    99#include "grid_transformation_factory_impl.hpp" 
     10#include "context.hpp" 
    1011 
    1112namespace xios 
     
    4748  { 
    4849 
     50    CContext* context = CContext::getCurrent();  
     51 
     52    scalarDestination->n.reset(); 
     53    scalarDestination->mask.reset(); 
     54    scalarDestination->value.reset(); 
     55    scalarDestination->bounds.reset(); 
     56 
     57    redistributeScalar->checkValid(scalarSource); 
     58 
     59    // define the global index of the new domain 
     60 
     61    CArray<size_t,1> globalIndex ; 
     62 
     63    if (    redistributeScalar->type == CRedistributeScalar::type_attr::bands  
     64         || redistributeScalar->type == CRedistributeScalar::type_attr::column  
     65         || redistributeScalar->type == CRedistributeScalar::type_attr::root ) 
     66    { 
     67      if (context->getIntraCommRank()==0) 
     68      { 
     69        scalarDestination->n = 1; 
     70        globalIndex.resize(1) ; 
     71        globalIndex(0)=0 ; 
     72      } 
     73      else 
     74      { 
     75        scalarDestination->n = 0; 
     76        globalIndex.resize(0) ; 
     77      } 
     78    } 
     79    else if (redistributeScalar->type == CRedistributeScalar::type_attr::full) 
     80    { 
     81      scalarDestination->n = 1; 
     82      globalIndex.resize(1) ; 
     83      globalIndex(0)=0 ; 
     84    } 
     85     
     86    auto& transMap = this->transformationMapping_; 
     87    for(int i=0; i<globalIndex.numElements(); i++) transMap[globalIndex(i)]=globalIndex(i) ; 
     88 
     89    auto elementDst=shared_ptr<CLocalElement>(new CLocalElement(context->getIntraCommRank(), 1, globalIndex)) ; 
     90    elementDst->addFullView() ; 
     91 
     92    auto transformConnector = make_shared<CTransformConnector>(scalarSource->getLocalView(CElementView::FULL), elementDst->getView(CElementView::FULL),context->getIntraComm()) ; 
     93    transformConnector->computeConnector() ; 
     94 
     95    CArray<double,1> valSrc, valDst ; 
     96    valSrc.resize(scalarSource->getLocalView(CElementView::FULL)->getSize()) ; 
     97    valDst.resize(scalarDestination->getLocalView(CElementView::FULL)->getSize()) ; 
     98     
     99    if (scalarSource->hasValue()) 
     100    { 
     101      if (valSrc.numElements()>0)  valSrc(0)=scalarSource->value ; 
     102      transformConnector->transfer(valSrc, valDst) ; 
     103      if (valDst.numElements()>0)  scalarDestination->value = valDst(0) ; 
     104    } 
     105 
     106    if (scalarSource->hasBounds())  
     107    { 
     108      transformConnector->transfer(2, scalarSource->bounds, scalarDestination->bounds) ; 
     109    } 
     110     
     111    if (scalarSource->hasLabel()) 
     112    { 
     113//ym transferTransformConnector.transfer(axisSrc->label, axisDestination->label) ;  -> probably not supported now, see later 
     114    } 
     115 
     116    // transfer the mask 
     117    auto transformMask = make_shared<CTransformConnector>(scalarSource->getLocalView(CElementView::WORKFLOW), elementDst->getView(CElementView::FULL),context->getIntraComm()) ; 
     118    transformMask->computeConnector() ; 
     119 
     120    CArray<bool,1> workflow(scalarSource->getLocalView(CElementView::WORKFLOW)->getSize()) ; 
     121    CArray<bool,1> mask ; 
     122    mask.resize(scalarSource->getLocalView(CElementView::FULL)->getSize()) ; 
     123    workflow=true ; 
     124     
     125    transformMask->transfer(workflow, mask, false) ;    
     126    scalarDestination->mask = mask(0) ; 
    49127 
    50128    scalarDestination->checkAttributes() ; 
Note: See TracChangeset for help on using the changeset viewer.