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/axis_algorithm/axis_algorithm_redistribute.cpp

    r2460 r2482  
    88#include "grid.hpp" 
    99#include "grid_transformation_factory_impl.hpp" 
     10#include "context.hpp" 
    1011 
    1112namespace xios 
     
    4647  TRY 
    4748  { 
     49    CContext* context = CContext::getCurrent();  
    4850 
     51    axisDestination->n_glo.reset(); 
     52    axisDestination->index.reset(); 
     53    axisDestination->n.reset(); 
     54    axisDestination->begin.reset(); 
     55 
     56    axisDestination->mask.reset(); 
     57    axisDestination->data_index.reset(); 
     58    axisDestination->data_n.reset(); 
     59    axisDestination->data_begin.reset(); 
     60 
     61    axisDestination->value.reset(); 
     62    axisDestination->label.reset(); 
     63    axisDestination->bounds.reset(); 
     64 
     65    redistributeAxis->checkValid(axisSource); 
     66 
     67    auto& index = redistributeAxis-> index ; 
     68    int n_glo = axisSource -> n_glo ; 
     69    axisDestination->n_glo = n_glo ; 
     70     
     71     
     72 
     73    // define the global index of the new domain 
     74 
     75    CArray<size_t,1> globalIndex ; 
     76 
     77    if (redistributeAxis->type == CRedistributeAxis::type_attr::index) 
     78    {    
     79      globalIndex.resize(index.numElements()) ; 
     80      globalIndex=index ; 
     81    } 
     82    else 
     83    { 
     84       
     85      auto distType = CRedistributeAxis::type_attr::column ; 
     86 
     87      if (redistributeAxis->type == CRedistributeAxis::type_attr::bands) distType = CRedistributeAxis::type_attr::column ; 
     88      else  distType=redistributeAxis->type; 
     89 
     90      int size, start ; 
     91      if (distType==CRedistributeAxis::type_attr::column) // Bands distribution to send to file server 
     92      { 
     93        int nbClient = context->getIntraCommSize() ; 
     94        int rankClient = context->getIntraCommRank() ; 
     95       
     96        size = n_glo/nbClient ; 
     97        if (rankClient < n_glo % nbClient) 
     98        { 
     99         size++ ; 
     100         start = rankClient*size ; 
     101        } 
     102        else start = (n_glo % nbClient)*(size+1) + (rankClient-(n_glo % nbClient)) * size ; 
     103 
     104      } 
     105      else if (distType==CRedistributeAxis::type_attr::full) // domain is not distributed ie all servers get the same local domain 
     106      { 
     107        size=n_glo ; start=0 ; 
     108      } 
     109      else if (distType==CRedistributeAxis::type_attr::root) // domain is not distributed ie all servers get the same local domain 
     110      { 
     111        if (context->getIntraCommRank()==0) { size=n_glo ; start=0 ; } 
     112        else { size=0 ; start=0 ; } 
     113      } 
     114 
     115      globalIndex.resize(size) ; 
     116      size_t ind ; 
     117      ind=0 ; 
     118      for(int i=start; i<start+size; i++) 
     119      { 
     120       globalIndex(ind) =  i ; 
     121       ind++ ; 
     122      } 
     123    } 
     124     
     125    axisDestination->index.resize(globalIndex.numElements()) ; 
     126    axisDestination->index = globalIndex ; 
     127    // apply the transformation to attributes 
     128 
     129    auto& transMap = this->transformationMapping_; 
     130    for(int i=0; i<globalIndex.numElements(); i++) transMap[globalIndex(i)]=globalIndex(i) ; 
     131 
     132    auto elementDst=shared_ptr<CLocalElement>(new CLocalElement(context->getIntraCommRank(), n_glo, globalIndex)) ; 
     133    elementDst->addFullView() ; 
     134 
     135    auto transformConnector = make_shared<CTransformConnector>(axisSource->getLocalView(CElementView::FULL), elementDst->getView(CElementView::FULL),context->getIntraComm()) ; 
     136    transformConnector->computeConnector() ; 
     137     
     138    if (axisSource->hasValue()) transformConnector->transfer(axisSource->value, axisDestination->value) ; 
     139     
     140     
     141     
     142    if (axisSource->hasBounds()) 
     143    { 
     144      CArray<double,1> boundsSrc(axisSource->bounds.dataFirst(),shape(axisSource->bounds.numElements()),neverDeleteData) ; 
     145      CArray<double,1> boundsDst ;  
     146      transformConnector->transfer(2, boundsSrc, boundsDst) ; 
     147      axisDestination->bounds.resize(2,globalIndex.numElements()) ; 
     148      axisDestination->bounds = CArray<double,2>(boundsDst.dataFirst(), shape(2,globalIndex.numElements()),neverDeleteData) ; 
     149    } 
     150     
     151    if (axisSource->hasLabel()) 
     152    { 
     153//ym transferTransformConnector.transfer(axisSrc->label, axisDestination->label) ;  -> probably not supported now, see later 
     154    } 
     155 
     156    // transfer the mask 
     157    auto transformMask = make_shared<CTransformConnector>(axisSource->getLocalView(CElementView::WORKFLOW), elementDst->getView(CElementView::FULL),context->getIntraComm()) ; 
     158    transformMask->computeConnector() ; 
     159 
     160    CArray<bool,1> workflow(axisSource->getLocalView(CElementView::WORKFLOW)->getSize()) ; 
     161    axisDestination->mask.resize(axisSource->getLocalView(CElementView::FULL)->getSize()) ; 
     162    workflow=true ; 
     163     
     164    transformMask->transfer(workflow,axisDestination->mask,false) ;    
    49165 
    50166    axisDestination->checkAttributes() ; 
     167    this->computeAlgorithm(axisSource->getLocalView(CElementView::WORKFLOW), axisDestination->getLocalView(CElementView::WORKFLOW)) ; 
    51168  } 
    52169  CATCH 
Note: See TracChangeset for help on using the changeset viewer.