Changeset 980 for XIOS/trunk
- Timestamp:
- 10/24/16 16:16:40 (8 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/config/extract_domain_to_axis_attribute.conf
r895 r980 1 1 /* Direction to apply operation (i, j) */ 2 DECLARE_ ATTRIBUTE(StdString, direction)2 DECLARE_ENUM2(direction, iDir, jDir) 3 3 4 4 /* Position of extracted slice */ -
XIOS/trunk/src/config/reduce_axis_to_scalar_attribute.conf
r888 r980 1 DECLARE_ ATTRIBUTE(StdString, operation)1 DECLARE_ENUM4(operation, min, max, sum, average) 2 2 3 3 -
XIOS/trunk/src/config/reduce_domain_to_axis_attribute.conf
r938 r980 1 DECLARE_ ATTRIBUTE(StdString, operation)1 DECLARE_ENUM4(operation, min, max, sum, average) 2 2 3 3 /* Direction to apply operation (i, j) */ -
XIOS/trunk/src/interface/c_attr/icreduce_axis_to_scalar_attr.cpp
r891 r980 23 23 if (!cstr2string(operation, operation_size, operation_str)) return; 24 24 CTimer::get("XIOS").resume(); 25 reduce_axis_to_scalar_hdl->operation. setValue(operation_str);25 reduce_axis_to_scalar_hdl->operation.fromString(operation_str); 26 26 CTimer::get("XIOS").suspend(); 27 27 } … … 30 30 { 31 31 CTimer::get("XIOS").resume(); 32 if (!string_copy(reduce_axis_to_scalar_hdl->operation.getInherited Value(), operation, operation_size))32 if (!string_copy(reduce_axis_to_scalar_hdl->operation.getInheritedStringValue(), operation, operation_size)) 33 33 ERROR("void cxios_get_reduce_axis_to_scalar_operation(reduce_axis_to_scalar_Ptr reduce_axis_to_scalar_hdl, char * operation, int operation_size)", << "Input string is too short"); 34 34 CTimer::get("XIOS").suspend(); -
XIOS/trunk/src/node/extract_domain_to_axis.cpp
r895 r980 51 51 int domain_nj_glo = domainSrc->nj_glo; 52 52 53 StdString dirLists[]= {"i","j"};54 std::set<StdString> dirString(dirLists, dirLists + sizeof(dirLists)/sizeof(dirLists[0]));55 56 53 if (this->direction.isEmpty()) 57 54 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 58 << "A direction to apply the operation must be defined. It should be: 'i ' or 'j'"55 << "A direction to apply the operation must be defined. It should be: 'iDir' or 'jDir'" 59 56 << "Domain source " <<domainSrc->getId() << std::endl 60 57 << "Axis destination " << axisDst->getId()); 61 62 StdString direction = this->direction; 63 if (dirString.end() == dirString.find(direction)) 58 59 if (this->position.isEmpty()) 60 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 61 << "Position to extract axis must be defined. " << std::endl 62 << "Domain source " <<domainSrc->getId() << std::endl 63 << "Axis destination " << axisDst->getId()); 64 65 switch (direction) 64 66 { 65 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 66 << "Direction '" << direction << " is undefined. Please make sure to use a supported one: i or j" 67 << "Domain source " <<domainSrc->getId() << std::endl 68 << "Axis destination " << axisDst->getId()); 69 } 70 else 71 { 72 if (0 == direction.compare("j")) 73 { 67 case direction_attr::jDir: 74 68 if (axis_n_glo != domain_ni_glo) 75 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 76 << "Extract domain along j, axis destination should have n_glo equal to ni_glo of domain source" 77 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_ni_glo << std::endl 78 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 79 } 80 if (0 == direction.compare("i")) 81 { 82 if (axis_n_glo != domain_nj_glo) 83 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 84 << "Extract domain along i, axis destination should have n_glo equal to nj_glo of domain source" 85 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl 86 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 87 } 88 } 89 90 int position = this->position; 91 if (0 == direction.compare("j")) 92 { 93 if ((position < 0) || (position > domain_ni_glo)) 69 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 70 << "Extract domain along j, axis destination should have n_glo equal to ni_glo of domain source" 71 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_ni_glo << std::endl 72 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 73 if ((position < 0) || (position > domain_ni_glo)) 94 74 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 95 75 << "Extract domain along j, position should be inside 0 and ni_glo of domain source" … … 97 77 << "Axis destination " << axisDst->getId() << std::endl 98 78 << "Position " << position); 99 } 100 if (0 == direction.compare("i")) 101 { 102 if ((position < 0) || (position > domain_nj_glo)) 79 break; 80 81 case direction_attr::iDir: 82 if (axis_n_glo != domain_nj_glo) 83 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 84 << "Extract domain along i, axis destination should have n_glo equal to nj_glo of domain source" 85 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl 86 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 87 if ((position < 0) || (position > domain_nj_glo)) 103 88 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 104 89 << "Extract domain along i, position should be inside 0 and nj_glo of domain source" … … 106 91 << "Axis destination " << axisDst->getId() << std::endl 107 92 << "Position " << position); 93 break; 94 95 default: 96 break; 108 97 } 109 110 98 } 111 99 -
XIOS/trunk/src/node/reduce_axis_to_scalar.cpp
r891 r980 39 39 void CReduceAxisToScalar::checkValid(CScalar* scalarDst) 40 40 { 41 // int axisIBegin, axisNi, axisGlobalSize;42 // int begin, end, n;43 //44 // axisIBegin = axisDest->begin.getValue();45 // axisNi = axisDest->n.getValue();46 // axisGlobalSize = axisDest->n_glo.getValue();47 //48 // begin = (this->begin.isEmpty()) ? 0 : this->begin.getValue();49 // n = (this->n.isEmpty()) ? axisGlobalSize : this->n.getValue();50 // end = begin+n-1;51 //52 // if (begin < 0 || begin > axisGlobalSize - 1 || end < 0 || end > axisGlobalSize - 153 // || n < 1 || n > axisGlobalSize || begin > end)54 // ERROR("CReduceAxisToScalar::checkValid(CAxis* axisDest)",55 // << "One or more attributes among 'begin' (" << begin << "), 'end' (" << end << "), 'n' (" << n << ") "56 // << "of axis transformation [ id = '" << axisDest->getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified");57 //58 // this->begin.setValue(begin);59 // this->n.setValue(n);60 61 41 } 62 42 -
XIOS/trunk/src/node/reduce_domain_to_axis.cpp
r938 r980 51 51 int domain_nj_glo = domainSrc->nj_glo; 52 52 53 StdString opLists[]= {"sum","min","max"};54 std::set<StdString> opString(opLists, opLists + sizeof(opLists)/sizeof(opLists[0]));55 56 53 if (this->operation.isEmpty()) 57 54 ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", … … 60 57 << "Axis destination " << axisDst->getId()); 61 58 62 StdString op = this->operation; 63 if (opString.end() == opString.find(op)) 59 if (this->direction.isEmpty()) 64 60 ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 65 << "Operation '" << op << "' not found. Please make sure to use a supported one"66 << "Domain source " <<domainSrc->getId() << std::endl67 << "Axis destination " << axisDst->getId());61 << "A direction to apply the operation must be defined. It should be: 'iDir' or 'jDir'" 62 << "Domain source " <<domainSrc->getId() << std::endl 63 << "Axis destination " << axisDst->getId()); 68 64 69 65 if (this->direction.isEmpty()) … … 72 68 << "Domain source " <<domainSrc->getId() << std::endl 73 69 << "Axis destination " << axisDst->getId()); 70 71 72 switch (direction) 73 { 74 case direction_attr::jDir: 75 if (axis_n_glo != domain_ni_glo) 76 ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 77 << "Extract domain along j, axis destination should have n_glo equal to ni_glo of domain source" 78 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_ni_glo << std::endl 79 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 80 break; 81 82 case direction_attr::iDir: 83 if (axis_n_glo != domain_nj_glo) 84 ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 85 << "Extract domain along i, axis destination should have n_glo equal to nj_glo of domain source" 86 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl 87 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 88 break; 89 90 default: 91 break; 92 } 74 93 } 75 94 -
XIOS/trunk/src/transformation/axis_algorithm_extract_domain.cpp
r979 r980 48 48 algo->checkValid(axisDestination, domainSource); 49 49 StdString op = "extract"; 50 StdString direction = algo->direction; 51 dir_ = (0 == direction.compare("i")) ? iDir : jDir; 50 51 switch (algo->direction) 52 { 53 case CExtractDomainToAxis::direction_attr::jDir: 54 dir_ = jDir; 55 break; 56 case CExtractDomainToAxis::direction_attr::iDir: 57 dir_ = iDir; 58 break; 59 default: 60 break; 61 } 62 52 63 pos_ = algo->position; 53 64 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); -
XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp
r979 r980 46 46 { 47 47 algo->checkValid(axisDestination, domainSource); 48 StdString op = algo->operation; 48 StdString op; 49 switch (algo->operation) 50 { 51 case CReduceDomainToAxis::operation_attr::sum: 52 op = "sum"; 53 break; 54 case CReduceDomainToAxis::operation_attr::min: 55 op = "min"; 56 break; 57 case CReduceDomainToAxis::operation_attr::max: 58 op = "max"; 59 break; 60 case CReduceDomainToAxis::operation_attr::average: 61 op = "average"; 62 break; 63 default: 64 ERROR("CAxisAlgorithmReduceDomain::CAxisAlgorithmReduceDomain(CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo)", 65 << "Operation is wrongly defined. Supported operations: sum, min, max, average." << std::endl 66 << "Domain source " <<domainSource->getId() << std::endl 67 << "Axis destination " << axisDestination->getId()); 68 69 } 70 49 71 dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction) ? iDir : jDir; 50 72 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); -
XIOS/trunk/src/transformation/grid_transformation_selector.cpp
r978 r980 19 19 { 20 20 //! Scalar 21 CScalarAlgorithmReduce Scalar::registerTrans();22 CScalarAlgorithmExtract Scalar::registerTrans();21 CScalarAlgorithmReduceAxis::registerTrans(); 22 CScalarAlgorithmExtractAxis::registerTrans(); 23 23 CScalarAlgorithmReduceDomain::registerTrans(); 24 24 -
XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.cpp
r977 r980 17 17 18 18 namespace xios { 19 CGenericAlgorithmTransformation* CScalarAlgorithmExtract Scalar::create(CGrid* gridDst, CGrid* gridSrc,19 CGenericAlgorithmTransformation* CScalarAlgorithmExtractAxis::create(CGrid* gridDst, CGrid* gridSrc, 20 20 CTransformation<CScalar>* transformation, 21 21 int elementPositionInGrid, … … 34 34 int axisSrcIndex = elementPositionInGridSrc2AxisPosition[elementPositionInGrid]; 35 35 36 return (new CScalarAlgorithmExtract Scalar(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], extractAxis));36 return (new CScalarAlgorithmExtractAxis(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], extractAxis)); 37 37 } 38 38 39 bool CScalarAlgorithmExtract Scalar::registerTrans()39 bool CScalarAlgorithmExtractAxis::registerTrans() 40 40 { 41 41 CGridTransformationFactory<CScalar>::registerTransformation(TRANS_EXTRACT_AXIS_TO_SCALAR, create); 42 42 } 43 43 44 CScalarAlgorithmExtract Scalar::CScalarAlgorithmExtractScalar(CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo)44 CScalarAlgorithmExtractAxis::CScalarAlgorithmExtractAxis(CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo) 45 45 : CScalarAlgorithmTransformation(scalarDestination, axisSource), 46 46 reduction_(0) … … 52 52 } 53 53 54 void CScalarAlgorithmExtract Scalar::apply(const std::vector<std::pair<int,double> >& localIndex,54 void CScalarAlgorithmExtractAxis::apply(const std::vector<std::pair<int,double> >& localIndex, 55 55 const double* dataInput, 56 56 CArray<double,1>& dataOut, … … 61 61 } 62 62 63 CScalarAlgorithmExtract Scalar::~CScalarAlgorithmExtractScalar()63 CScalarAlgorithmExtractAxis::~CScalarAlgorithmExtractAxis() 64 64 { 65 65 if (0 != reduction_) delete reduction_; 66 66 } 67 67 68 void CScalarAlgorithmExtract Scalar::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)68 void CScalarAlgorithmExtractAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 69 69 { 70 70 this->transformationMapping_.resize(1); -
XIOS/trunk/src/transformation/scalar_algorithm_extract_axis.hpp
r960 r980 21 21 22 22 /*! 23 \class CScalarAlgorithmExtract Scalar23 \class CScalarAlgorithmExtractAxis 24 24 Extract a scalar from an axis 25 25 */ 26 class CScalarAlgorithmExtract Scalar: public CScalarAlgorithmTransformation26 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation 27 27 { 28 28 public: 29 CScalarAlgorithmExtract Scalar(CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo);29 CScalarAlgorithmExtractAxis(CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo); 30 30 31 31 virtual void apply(const std::vector<std::pair<int,double> >& localIndex, … … 35 35 const double& defaultValue); 36 36 37 virtual ~CScalarAlgorithmExtract Scalar();37 virtual ~CScalarAlgorithmExtractAxis(); 38 38 39 39 static bool registerTrans(); -
XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.cpp
r979 r980 18 18 19 19 namespace xios { 20 CGenericAlgorithmTransformation* CScalarAlgorithmReduce Scalar::create(CGrid* gridDst, CGrid* gridSrc,20 CGenericAlgorithmTransformation* CScalarAlgorithmReduceAxis::create(CGrid* gridDst, CGrid* gridSrc, 21 21 CTransformation<CScalar>* transformation, 22 22 int elementPositionInGrid, … … 35 35 int axisSrcIndex = elementPositionInGridSrc2AxisPosition[elementPositionInGrid]; 36 36 37 return (new CScalarAlgorithmReduce Scalar(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], reduceAxis));37 return (new CScalarAlgorithmReduceAxis(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], reduceAxis)); 38 38 } 39 39 40 bool CScalarAlgorithmReduce Scalar::registerTrans()40 bool CScalarAlgorithmReduceAxis::registerTrans() 41 41 { 42 42 CGridTransformationFactory<CScalar>::registerTransformation(TRANS_REDUCE_AXIS_TO_SCALAR, create); 43 43 } 44 44 45 CScalarAlgorithmReduce Scalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo)45 CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo) 46 46 : CScalarAlgorithmTransformation(scalarDestination, axisSource), 47 47 reduction_(0) 48 48 { 49 49 if (algo->operation.isEmpty()) 50 ERROR("CScalarAlgorithmReduce Scalar::CScalarAlgorithmReduceScalar(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)",50 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 51 51 << "Operation must be defined." 52 52 << "Axis source " <<axisSource->getId() << std::endl 53 53 << "Scalar destination " << scalarDestination->getId()); 54 StdString op = algo->operation; 54 StdString op; 55 switch (algo->operation) 56 { 57 case CReduceAxisToScalar::operation_attr::sum: 58 op = "sum"; 59 break; 60 case CReduceAxisToScalar::operation_attr::min: 61 op = "min"; 62 break; 63 case CReduceAxisToScalar::operation_attr::max: 64 op = "max"; 65 break; 66 case CReduceAxisToScalar::operation_attr::average: 67 op = "average"; 68 break; 69 default: 70 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 71 << "Operation is wrongly defined. Supported operations: sum, min, max, average." << std::endl 72 << "Domain source " <<axisSource->getId() << std::endl 73 << "Scalar destination " << scalarDestination->getId()); 74 75 } 76 55 77 if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 56 ERROR("CScalarAlgorithmReduce Scalar::CScalarAlgorithmReduceScalar(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)",78 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 57 79 << "Operation '" << op << "' not found. Please make sure to use a supported one" 58 80 << "Axis source " <<axisSource->getId() << std::endl … … 62 84 } 63 85 64 void CScalarAlgorithmReduce Scalar::apply(const std::vector<std::pair<int,double> >& localIndex,86 void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, 65 87 const double* dataInput, 66 88 CArray<double,1>& dataOut, … … 71 93 } 72 94 73 void CScalarAlgorithmReduce Scalar::updateData(CArray<double,1>& dataOut)95 void CScalarAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut) 74 96 { 75 97 reduction_->updateData(dataOut); 76 98 } 77 99 78 CScalarAlgorithmReduce Scalar::~CScalarAlgorithmReduceScalar()100 CScalarAlgorithmReduceAxis::~CScalarAlgorithmReduceAxis() 79 101 { 80 102 if (0 != reduction_) delete reduction_; 81 103 } 82 104 83 void CScalarAlgorithmReduce Scalar::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)105 void CScalarAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 84 106 { 85 107 this->transformationMapping_.resize(1); -
XIOS/trunk/src/transformation/scalar_algorithm_reduce_axis.hpp
r979 r980 21 21 22 22 /*! 23 \class CScalarAlgorithmReduce Scalar23 \class CScalarAlgorithmReduceAxis 24 24 Reducing an axis to a scalar 25 25 */ 26 class CScalarAlgorithmReduce Scalar: public CScalarAlgorithmTransformation26 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation 27 27 { 28 28 public: 29 CScalarAlgorithmReduce Scalar(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo);29 CScalarAlgorithmReduceAxis(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo); 30 30 31 31 virtual void apply(const std::vector<std::pair<int,double> >& localIndex, … … 37 37 virtual void updateData(CArray<double,1>& dataOut); 38 38 39 virtual ~CScalarAlgorithmReduce Scalar();39 virtual ~CScalarAlgorithmReduceAxis(); 40 40 41 41 static bool registerTrans();
Note: See TracChangeset
for help on using the changeset viewer.