Changeset 1275


Ignore:
Timestamp:
09/25/17 10:59:29 (3 years ago)
Author:
ymipsl
Message:

implement diurnal cycle transformation taken as a grid tranformation : scalar -> axis

YM

Location:
XIOS/dev/XIOS_DEV_CMIP6/src
Files:
6 added
19 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/config/node_type.conf

    r976 r1275  
    8787#endif //__XIOS_CReduceDomainToScalar__ 
    8888 
     89#ifdef __XIOS_CTemporalSplitting__ 
     90   DECLARE_NODE(TemporalSplitting, temporal_splitting) 
     91#endif //__XIOS_CTemporalSplitting__ 
     92 
    8993#ifdef __XIOS_CContext__ 
    9094   DECLARE_NODE_PAR(Context, context) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/filter/spatial_transform_filter.cpp

    r1260 r1275  
    2727      size_t inputCount = 1 + (auxInputs.empty() ? 0 : auxInputs.size()); 
    2828      double defaultValue  = (hasMissingValue) ? std::numeric_limits<double>::quiet_NaN() : 0.0; 
    29       boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 
    30  
     29 
     30 
     31      const CGridTransformationSelector::ListAlgoType& algoList = gridTransformation->getAlgoList() ; 
     32      CGridTransformationSelector::ListAlgoType::const_iterator it  ; 
     33 
     34      bool isSpatialTemporal=false ; 
     35      for (it=algoList.begin();it!=algoList.end();++it)  if (it->second.first == TRANS_TEMPORAL_SPLITTING) isSpatialTemporal=true ; 
     36 
     37      boost::shared_ptr<CSpatialTransformFilter> filter ; 
     38      if( isSpatialTemporal) filter = boost::shared_ptr<CSpatialTransformFilter>(new CSpatialTemporalFilter(gc, engine, gridTransformation, defaultValue, inputCount)); 
     39      else filter = boost::shared_ptr<CSpatialTransformFilter>(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 
     40 
     41       
    3142      if (!lastFilter) 
    3243        lastFilter = filter; 
     
    5667      onOutputReady(outputPacket); 
    5768  } 
     69 
     70 
     71 
     72 
     73 
     74  CSpatialTemporalFilter::CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, double outputValue, size_t inputSlotsCount) 
     75    : CSpatialTransformFilter(gc, engine, outputValue, inputSlotsCount), record(0) 
     76  { 
     77      const CGridTransformationSelector::ListAlgoType& algoList = gridTransformation->getAlgoList() ; 
     78      CGridTransformationSelector::ListAlgoType::const_iterator it  ; 
     79 
     80      int pos ; 
     81      for (it=algoList.begin();it!=algoList.end();++it)  
     82        if (it->second.first == TRANS_TEMPORAL_SPLITTING) 
     83        { 
     84          pos=it->first ; 
     85          if (pos < algoList.size()-1) 
     86            ERROR("SpatialTemporalFilter::CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, double outputValue, size_t inputSlotsCount))", 
     87                  "temporal splitting operation must be the last of whole transformation on same grid") ; 
     88        } 
     89           
     90      CGrid* grid=gridTransformation->getGridDestination() ; 
     91 
     92      CAxis* axis = grid->getAxis(gridTransformation->getElementPositionInGridDst2AxisPosition().find(pos)->second) ; 
     93 
     94      nrecords = axis->index.numElements() ; 
     95  } 
     96 
     97 
     98  void CSpatialTemporalFilter::onInputReady(std::vector<CDataPacketPtr> data) 
     99  { 
     100    CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 
     101    CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 
     102 
     103    if (outputPacket) 
     104    { 
     105      size_t nelements=outputPacket->data.numElements() ; 
     106      if (!tmpData.numElements()) 
     107      { 
     108        tmpData.resize(nelements); 
     109        tmpData=outputDefaultValue ; 
     110      } 
     111 
     112      nelements/=nrecords ; 
     113      size_t offset=nelements*record ; 
     114      for(size_t i=0;i<nelements;++i)  tmpData(i+offset) = outputPacket->data(i) ; 
     115     
     116      record ++ ; 
     117      if (record==nrecords) 
     118      { 
     119        record=0 ; 
     120        CDataPacketPtr packet = CDataPacketPtr(new CDataPacket); 
     121        packet->date = data[0]->date; 
     122        packet->timestamp = data[0]->timestamp; 
     123        packet->status = data[0]->status; 
     124        packet->data.resize(tmpData.numElements()); 
     125        packet->data = tmpData; 
     126        onOutputReady(packet); 
     127        tmpData.resize(0) ; 
     128      } 
     129    } 
     130  } 
     131 
    58132 
    59133  CSpatialTransformFilterEngine::CSpatialTransformFilterEngine(CGridTransformation* gridTransformation) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/filter/spatial_transform_filter.hpp

    r1158 r1275  
    4949      double outputDefaultValue; 
    5050  }; // class CSpatialTransformFilter 
     51 
     52 
     53 /*! 
     54   * A specific spatial filter for the temporal_splitting transformation scalar -> axis. An incoming flux will be stored in an aditional dimension given by the destination axis. 
     55   * At each flux received, the storing index (record) is increased. When it reach the size of the axis (nrecords) a new flux is generated and the record is reset to 0 
     56   */ 
     57 
     58 class CSpatialTemporalFilter : public CSpatialTransformFilter 
     59  { 
     60    public: 
     61      /*! 
     62       * Constructs a filter wrapping the specified spatial transformation. 
     63       * 
     64       * \param gc the associated garbage collector 
     65       * \param engine the engine defining the spatial transformation 
     66       * \param [in] gridTransformation the associated transformations 
     67       * \param outputValue default value of output pin 
     68       * \param [in] inputSlotsCount number of input, by default there is only one for field src 
     69       */ 
     70      CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, double outputValue, size_t inputSlotsCount = 1); 
     71 
     72 
     73    protected: 
     74      /*! 
     75        Overriding this function to process transformations with auxillary inputs 
     76      */ 
     77      void virtual onInputReady(std::vector<CDataPacketPtr> data); 
     78      //! Current record in the filter 
     79      int record ; 
     80      //! Maximum number of records 
     81      int nrecords; 
     82      //! Temporary storage for output flux 
     83      CArray<double, 1> tmpData;  
     84 
     85 
     86  }; // class CSpatialTemporalFilter 
     87 
    5188 
    5289  /*! 
  • XIOS/dev/XIOS_DEV_CMIP6/src/generate_fortran_interface.cpp

    r981 r1275  
    4141  CReduceDomainToAxis reduceDomainToAxis; 
    4242  CExtractDomainToAxis extractDomainToAxis; 
     43  CTemporalSplitting temporalSplitting; 
    4344 
    4445  CReduceAxisToScalar reduceAxisToScalar; 
    4546  CExtractAxisToScalar extractAxisToScalar; 
    4647  CReduceDomainToScalar reduceDomainToScalar; 
    47  
     48   
    4849  ostringstream oss; 
    4950  ofstream file; 
     
    354355  file.close(); 
    355356 
     357  file.open((path+"temporal_splitting_interface_attr.F90").c_str()); 
     358  temporalSplitting.generateFortran2003Interface(file); 
     359  file.close(); 
     360 
    356361  file.open((path+"icextract_domain_to_axis_attr.cpp").c_str()); 
    357362  extractDomainToAxis.generateCInterface(file); 
    358363  file.close(); 
    359364 
     365  file.open((path+"ictemporal_splitting_attr.cpp").c_str()); 
     366  temporalSplitting.generateCInterface(file); 
     367  file.close(); 
     368 
    360369  file.open((path+"iextract_domain_to_axis_attr.F90").c_str()); 
    361370  extractDomainToAxis.generateFortranInterface(file); 
     371  file.close(); 
     372 
     373  file.open((path+"itemporal_splitting_attr.F90").c_str()); 
     374  temporalSplitting.generateFortranInterface(file); 
    362375  file.close(); 
    363376 
     
    394407  file.close(); 
    395408 
     409  file.open((path+"temporal_splitting_interface_attr.F90").c_str()); 
     410  temporalSplitting.generateFortran2003Interface(file); 
     411  file.close(); 
     412 
    396413  file.open((path+"icreduce_domain_to_scalar_attr.cpp").c_str()); 
    397414  reduceDomainToScalar.generateCInterface(file); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/group_factory_decl.cpp

    r976 r1275  
    3939  macro(CExtractAxisToScalarGroup) 
    4040  macro(CReduceDomainToScalarGroup) 
     41  macro(CTemporalSplittingGroup) 
     42 
    4143} 
  • XIOS/dev/XIOS_DEV_CMIP6/src/group_template_decl.cpp

    r976 r1275  
    2828  macro(ExtractAxisToScalar) 
    2929  macro(ReduceDomainToScalar) 
    30  
     30  macro(TemporalSplitting) 
    3131} 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp

    r1258 r1275  
    5252     m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_AXIS; 
    5353     m["extract_domain"] = TRANS_EXTRACT_DOMAIN_TO_AXIS; 
     54     m["temporal_splitting"] = TRANS_TEMPORAL_SPLITTING; 
    5455   } 
    5556 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/node_enum.hpp

    r976 r1275  
    3333         eExpandDomain, 
    3434         eExtractAxisToScalar, 
    35          eReduceDomainToScalar 
    36  
     35         eReduceDomainToScalar, 
     36         eTemporalSplitting 
    3737      } ENodeType; 
    3838 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/node_type.hpp

    r976 r1275  
    2424#include "extract_axis_to_scalar.hpp" 
    2525#include "reduce_domain_to_scalar.hpp" 
     26#include "temporal_splitting.hpp" 
    2627 
    2728 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/transformation_enum.hpp

    r976 r1275  
    2020        TRANS_EXTRACT_AXIS_TO_SCALAR = 11, 
    2121        TRANS_REDUCE_DOMAIN_TO_SCALAR = 12, 
     22        TRANS_TEMPORAL_SPLITTING = 13, 
    2223      } ETranformationType; 
    2324 
  • XIOS/dev/XIOS_DEV_CMIP6/src/object_factory_decl.cpp

    r976 r1275  
    4040  macro(CExtractAxisToScalar) 
    4141  macro(CReduceDomainToScalar) 
     42  macro(CTemporalSplitting) 
    4243 
    4344  macro(CFieldGroup) 
     
    6263  macro(CExtractAxisToScalarGroup) 
    6364  macro(CReduceDomainToScalarGroup) 
     65  macro(CTemporalSplittingGroup) 
    6466} 
  • XIOS/dev/XIOS_DEV_CMIP6/src/object_template_decl.cpp

    r976 r1275  
    2727  template class CObjectTemplate<CExtractAxisToScalar>; 
    2828  template class CObjectTemplate<CReduceDomainToScalar>; 
     29  template class CObjectTemplate<CTemporalSplitting>; 
    2930 
    3031  template class CObjectTemplate<CContextGroup>; 
     
    4950  template class CObjectTemplate<CExtractAxisToScalarGroup>; 
    5051  template class CObjectTemplate<CReduceDomainToScalarGroup>; 
     52  template class CObjectTemplate<CTemporalSplittingGroup>; 
    5153} 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/algo_types.hpp

    r976 r1275  
    2020#include "axis_algorithm_transformation.hpp" 
    2121#include "axis_algorithm_extract_domain.hpp" 
     22#include "axis_algorithm_temporal_splitting.hpp" 
    2223 
    2324#include "domain_algorithm_zoom.hpp" 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/axis_algorithm_transformation.cpp

    r895 r1275  
    1919 
    2020CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CAxis* axisSource) 
    21  : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(axisSource), domainSrc_(0) 
     21 : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(axisSource), domainSrc_(0),scalarSrc_(0) 
    2222{ 
    2323  axisDestGlobalSize_ = axisDestination->n_glo.getValue(); 
     
    3030 
    3131CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CDomain* domainSource) 
    32  : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(0), domainSrc_(domainSource) 
     32 : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(0), domainSrc_(domainSource),scalarSrc_(0) 
    3333{ 
    3434  axisDestGlobalSize_ = axisDestination->n_glo.getValue(); 
     
    4040} 
    4141 
     42CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CScalar* scalarSource) 
     43 : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(0), domainSrc_(0), scalarSrc_(scalarSource) 
     44{ 
     45  axisDestGlobalSize_ = axisDestination->n_glo.getValue(); 
     46  int niDest = axisDestination->n.getValue(); 
     47  int ibeginDest = axisDestination->begin.getValue(); 
     48 
     49  for (int idx = 0; idx < niDest; ++idx) 
     50    if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx); 
     51} 
    4252CAxisAlgorithmTransformation::~CAxisAlgorithmTransformation() 
    4353{ 
     
    6676  if (2 == elementType) nIndexSize = domainSrc_->i_index.numElements(); 
    6777  else if (1 == elementType) nIndexSize = axisSrc_->index.numElements(); 
     78  else nIndexSize=1  ; //  scalar 
     79   
    6880  CClientClientDHTInt::Index2VectorInfoTypeMap globalIndex2ProcRank; 
    6981  globalIndex2ProcRank.rehash(std::ceil(nIndexSize/globalIndex2ProcRank.max_load_factor())); 
    7082  for (int idx = 0; idx < nIndexSize; ++idx) 
    7183  { 
    72     if (2 == elementType) 
     84    if (2 == elementType) // domain 
    7385    { 
    7486      globalIndex = domainSrc_->i_index(idx) + domainSrc_->j_index(idx) * domainSrc_->ni_glo; 
    7587    } 
    76     else if (1 == elementType) 
     88    else if (1 == elementType) // axis 
    7789    { 
    7890      globalIndex = axisSrc_->index(idx); 
     91    } 
     92    else // scalar 
     93    { 
     94      globalIndex = 0; 
    7995    } 
    8096 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/axis_algorithm_transformation.hpp

    r934 r1275  
    1717class CAxis; 
    1818class CDomain; 
    19  
     19class CScalar; 
    2020/*! 
    2121  \class CAxisAlgorithmTransformation 
     
    2727  CAxisAlgorithmTransformation(CAxis* axisDestination, CAxis* axisSource); 
    2828  CAxisAlgorithmTransformation(CAxis* axisDestination, CDomain* domainSource); 
     29  CAxisAlgorithmTransformation(CAxis* axisDestination, CScalar* scalarSource); 
    2930 
    3031  virtual ~CAxisAlgorithmTransformation(); 
     
    5253  //! Domain on grid source 
    5354  CDomain* domainSrc_; 
     55 
     56  //! Scalar on grid source 
     57 
     58  CScalar* scalarSrc_; 
    5459}; 
    5560 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/grid_transformation_selector.cpp

    r1158 r1275  
    2929  CAxisAlgorithmInverse::registerTrans(); 
    3030  CAxisAlgorithmReduceDomain::registerTrans(); 
     31  CAxisAlgorithmTemporalSplitting::registerTrans(); 
    3132 
    3233  //! Domain 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/grid_transformation_selector.hpp

    r978 r1275  
    5151  const std::vector<StdString>& getAuxInputs() const { return auxInputs_; } 
    5252  const std::vector<CGenericAlgorithmTransformation*>& getAlgos() const { return algoTransformation_; } 
     53  const std::map<int, int> getElementPositionInGridSrc2AxisPosition() const { return elementPositionInGridSrc2AxisPosition_ ;} 
     54  const std::map<int, int> getElementPositionInGridSrc2DomainPosition() const { return elementPositionInGridSrc2DomainPosition_ ;} 
     55  const std::map<int, int> getElementPositionInGridSrc2ScalarPosition() const { return elementPositionInGridSrc2ScalarPosition_ ;} 
     56  const std::map<int, int> getElementPositionInGridDst2AxisPosition() const { return elementPositionInGridDst2AxisPosition_ ;} 
     57  const std::map<int, int> getElementPositionInGridDst2DomainPosition() const { return elementPositionInGridDst2DomainPosition_ ;} 
     58  const std::map<int, int> getElementPositionInGridDst2ScalarPosition() const { return elementPositionInGridDst2ScalarPosition_ ;} 
     59 
    5360 
    5461protected: 
  • XIOS/dev/XIOS_DEV_CMIP6/src/type/type_util.hpp

    r976 r1275  
    4848    class CReduceDomainToScalar; 
    4949    class CReduceDomainToScalarGroup; 
    50  
     50    class CTemporalSplitting; 
     51    class CTemporalSplittingGroup; 
     52     
    5153  template <typename T> inline string getStrType(void); 
    5254 
     
    112114  macro(CReduceDomainToScalar) 
    113115  macro(CReduceDomainToScalarGroup) 
     116  macro(CTemporalSplitting) 
     117  macro(CTemporalSplittingGroup) 
    114118   
    115119#undef macro 
  • XIOS/dev/XIOS_DEV_CMIP6/src/xml_parser_decl.cpp

    r976 r1275  
    3333    macro( ExtractAxisToScalar ) 
    3434    macro( ReduceDomainToScalar ) 
     35    macro( TemporalSplitting ) 
    3536  } 
    3637} 
Note: See TracChangeset for help on using the changeset viewer.