- Timestamp:
- 01/10/17 13:52:53 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/transformation/Functions/average_reduction.cpp
r979 r1018 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 const double& defaultValue) 32 34 { 33 35 if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; } 36 bool hasMissingValue = NumTraits<double>::isnan(defaultValue); 34 37 35 int nbLocalIndex = localIndex.size(); 36 int currentlocalIndex = 0; 37 double currentWeight = 0.0; 38 for (int idx = 0; idx < nbLocalIndex; ++idx) 38 if (hasMissingValue) 39 39 { 40 currentlocalIndex = localIndex[idx].first; 41 currentWeight = localIndex[idx].second; 40 int nbLocalIndex = localIndex.size(); 41 int currentlocalIndex = 0; 42 double currentWeight = 0.0; 43 for (int idx = 0; idx < nbLocalIndex; ++idx) 44 { 45 currentlocalIndex = localIndex[idx].first; 46 currentWeight = localIndex[idx].second; 47 if (!NumTraits<double>::isnan(*(dataInput + idx))) 48 { 49 if (flagInitial[currentlocalIndex]) 50 { 51 dataOut(currentlocalIndex) = *(dataInput + idx); 52 flagInitial[currentlocalIndex] = false; 53 } 54 else 55 { 56 dataOut(currentlocalIndex) += *(dataInput + idx); 57 weights_(currentlocalIndex) += 1.0; 58 } 59 } 60 } 61 } 62 else 63 { 64 int nbLocalIndex = localIndex.size(); 65 int currentlocalIndex = 0; 66 double currentWeight = 0.0; 67 for (int idx = 0; idx < nbLocalIndex; ++idx) 68 { 69 currentlocalIndex = localIndex[idx].first; 70 currentWeight = localIndex[idx].second; 42 71 43 if (flagInitial[currentlocalIndex]) 44 { 45 dataOut(currentlocalIndex) = *(dataInput + idx); 46 flagInitial[currentlocalIndex] = false; 47 } 48 else 49 { 50 dataOut(currentlocalIndex) += *(dataInput + idx); 51 weights_(currentlocalIndex) += 1.0; 72 if (flagInitial[currentlocalIndex]) 73 { 74 dataOut(currentlocalIndex) = *(dataInput + idx); 75 flagInitial[currentlocalIndex] = false; 76 } 77 else 78 { 79 dataOut(currentlocalIndex) += *(dataInput + idx); 80 weights_(currentlocalIndex) += 1.0; 81 } 52 82 } 53 83 }
Note: See TracChangeset
for help on using the changeset viewer.