- Timestamp:
- 06/06/17 17:58:16 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/transformation/Functions/average_reduction.cpp
r979 r1158 3 3 \author Ha NGUYEN 4 4 \since 8 Sep 2016 5 \date 8 Sep 20165 \date 9 Jan 2017 6 6 7 7 \brief average reduction 8 8 */ 9 9 #include "average_reduction.hpp" 10 #include "utils.hpp" 10 11 11 12 namespace xios { … … 29 30 const double* dataInput, 30 31 CArray<double,1>& dataOut, 31 std::vector<bool>& flagInitial) 32 std::vector<bool>& flagInitial, 33 bool ignoreMissingValue) 32 34 { 33 if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; } 35 if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; } 34 36 35 int nbLocalIndex = localIndex.size(); 36 int currentlocalIndex = 0; 37 double currentWeight = 0.0; 38 for (int idx = 0; idx < nbLocalIndex; ++idx) 37 if (ignoreMissingValue) 39 38 { 40 currentlocalIndex = localIndex[idx].first; 41 currentWeight = localIndex[idx].second; 39 int nbLocalIndex = localIndex.size(); 40 int currentlocalIndex = 0; 41 double currentWeight = 0.0; 42 42 43 if (flagInitial[currentlocalIndex]) 43 dataOut=std::numeric_limits<double>::quiet_NaN(); 44 45 for (int idx = 0; idx < nbLocalIndex; ++idx) 44 46 { 45 dataOut(currentlocalIndex) = *(dataInput + idx); 46 flagInitial[currentlocalIndex] = false; 47 currentlocalIndex = localIndex[idx].first; 48 currentWeight = localIndex[idx].second; 49 if (!NumTraits<double>::isnan(*(dataInput + idx))) 50 { 51 if (flagInitial[currentlocalIndex]) 52 { 53 dataOut(currentlocalIndex) = *(dataInput + idx); 54 flagInitial[currentlocalIndex] = false; 55 } 56 else 57 { 58 dataOut(currentlocalIndex) += *(dataInput + idx); 59 weights_(currentlocalIndex) += 1.0; 60 } 61 } 47 62 } 48 else 63 } 64 else 65 { 66 int nbLocalIndex = localIndex.size(); 67 int currentlocalIndex = 0; 68 double currentWeight = 0.0; 69 for (int idx = 0; idx < nbLocalIndex; ++idx) 49 70 { 50 dataOut(currentlocalIndex) += *(dataInput + idx); 51 weights_(currentlocalIndex) += 1.0; 71 currentlocalIndex = localIndex[idx].first; 72 currentWeight = localIndex[idx].second; 73 74 if (flagInitial[currentlocalIndex]) 75 { 76 dataOut(currentlocalIndex) = *(dataInput + idx); 77 flagInitial[currentlocalIndex] = false; 78 } 79 else 80 { 81 dataOut(currentlocalIndex) += *(dataInput + idx); 82 weights_(currentlocalIndex) += 1.0; 83 } 52 84 } 53 85 }
Note: See TracChangeset
for help on using the changeset viewer.