Changeset 938


Ignore:
Timestamp:
09/22/16 10:59:07 (8 years ago)
Author:
mhnguyen
Message:

Modifying reduce_axis_to_domain attribute to prevent error-prone

+) Change attribute from string to enum
+) Remove some redundant codes

Test
+) Ok

Location:
XIOS/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/config/reduce_domain_to_axis_attribute.conf

    r895 r938  
    22 
    33/* Direction to apply operation (i, j) */ 
    4 DECLARE_ATTRIBUTE(StdString, direction) 
     4DECLARE_ENUM2(direction,  iDir, jDir) 
  • XIOS/trunk/src/node/reduce_domain_to_axis.cpp

    r895 r938  
    5454    std::set<StdString> opString(opLists, opLists + sizeof(opLists)/sizeof(opLists[0])); 
    5555 
    56     StdString dirLists[]= {"i","j"}; 
    57     std::set<StdString> dirString(dirLists, dirLists + sizeof(dirLists)/sizeof(dirLists[0])); 
    58  
    5956    if (this->operation.isEmpty()) 
    6057      ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 
     
    7269    if (this->direction.isEmpty()) 
    7370      ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 
    74              << "A direction to apply the operation must be defined. It should be: 'i' or 'j'" 
     71             << "A direction to apply the operation must be defined. It should be: 'iDir' or 'jDir'" 
    7572             << "Domain source " <<domainSrc->getId() << std::endl 
    7673             << "Axis destination " << axisDst->getId()); 
    77  
    78     StdString direction = this->direction; 
    79     if (dirString.end() == dirString.find(direction)) 
    80     { 
    81       ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 
    82        << "Direction '" << direction << " is undefined. Please make sure to use a supported one: i or j" 
    83        << "Domain source " <<domainSrc->getId() << std::endl 
    84        << "Axis destination " << axisDst->getId()); 
    85     } 
    86     else 
    87     { 
    88       if (0 == direction.compare("j")) 
    89       { 
    90         if (axis_n_glo != domain_ni_glo) 
    91          ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 
    92            << "Reduce domain along j, axis destination should have n_glo equal to ni_glo of domain source" 
    93            << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_ni_glo << std::endl 
    94            << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 
    95       } 
    96       if (0 == direction.compare("i")) 
    97       { 
    98         if (axis_n_glo != domain_nj_glo) 
    99          ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 
    100            << "Reduce domain along i, axis destination should have n_glo equal to nj_glo of domain source" 
    101            << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl 
    102            << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 
    103       } 
    104     } 
    10574  } 
    10675 
  • XIOS/trunk/src/transformation/axis_algorithm_reduce_domain.cpp

    r933 r938  
    4848  algo->checkValid(axisDestination, domainSource); 
    4949  StdString op = algo->operation; 
    50   StdString direction = algo->direction; 
    51   dir_ = (0 == direction.compare("i")) ? iDir : jDir; 
     50  dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction)  ? iDir : jDir; 
    5251  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
    5352} 
Note: See TracChangeset for help on using the changeset viewer.