Changeset 1154


Ignore:
Timestamp:
06/06/17 10:53:33 (4 years ago)
Author:
mhnguyen
Message:

Correcting a bug: activating detect_missing_value on field source doesn't work correctly

+) If all source data corresponding to a destination data are NaN, this destination data
will turn to be NaN even its default value is zero

Test
+) On Curie
+) Work

Location:
XIOS/trunk/src/transformation
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/Functions/average_reduction.cpp

    r1076 r1154  
    3939    int nbLocalIndex = localIndex.size(); 
    4040    int currentlocalIndex = 0; 
    41     double currentWeight  = 0.0; 
    42  
    43     dataOut=std::numeric_limits<double>::quiet_NaN(); 
     41    double currentWeight  = 0.0;     
    4442 
    4543    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     
    5957          weights_(currentlocalIndex) += 1.0; 
    6058        } 
     59      } 
     60      else 
     61      { 
     62        if (flagInitial[currentlocalIndex])  
     63          dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    6164      } 
    6265    } 
  • XIOS/trunk/src/transformation/Functions/max_reduction.cpp

    r1076 r1154  
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0; 
    39     dataOut=std::numeric_limits<double>::quiet_NaN();     
     38    int currentlocalIndex = 0;     
    4039    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4140    { 
     
    5251          dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 
    5352        } 
     53      } 
     54      else 
     55      { 
     56        if (flagInitial[currentlocalIndex])  
     57          dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5458      } 
    5559    } 
  • XIOS/trunk/src/transformation/Functions/min_reduction.cpp

    r1076 r1154  
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0; 
    39     dataOut=std::numeric_limits<double>::quiet_NaN(); 
     38    int currentlocalIndex = 0;     
    4039    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4140    { 
     
    5251          dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex)); 
    5352        } 
     53      } 
     54      else 
     55      { 
     56        if (flagInitial[currentlocalIndex])  
     57          dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5458      } 
    5559    } 
  • XIOS/trunk/src/transformation/Functions/sum_reduction.cpp

    r1076 r1154  
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0; 
    39  
    40     dataOut=std::numeric_limits<double>::quiet_NaN(); 
     38    int currentlocalIndex = 0;     
    4139   
    4240    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     
    5452          dataOut(currentlocalIndex) += *(dataInput + idx); 
    5553        } 
     54      } 
     55      else 
     56      { 
     57        if (flagInitial[currentlocalIndex])  
     58          dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5659      } 
    5760    }     
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp

    r1104 r1154  
    4545      { 
    4646        dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second; 
    47       } 
    48     } 
    49  
    50     // for (int idx = 0; idx < nbLocalIndex; ++idx) 
    51     // { 
    52     //   if (!flagInitial[localIndex[idx].first]) 
    53     //     dataOut(localIndex[idx].first) = defaultValue; 
    54     // } 
     47        flagInitial[localIndex[idx].first] = true; // Reset flag to indicate not all data source are nan 
     48      } 
     49    } 
     50 
     51    // If all data source are nan then data destination must be nan 
     52    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     53    { 
     54      if (!flagInitial[localIndex[idx].first]) 
     55        dataOut(localIndex[idx].first) = defaultValue; 
     56    } 
    5557  } 
    5658  else 
Note: See TracChangeset for help on using the changeset viewer.