XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
sum_reduction.cpp
Aller à la documentation de ce fichier.
1 
9 #include "sum_reduction.hpp"
10 #include "utils.hpp"
11 
12 namespace xios {
13 
16 {
17 }
18 
20 {
21  return (new CSumReductionAlgorithm());
22 }
23 
25 {
27 }
28 
29 void CSumReductionAlgorithm::apply(const std::vector<std::pair<int,double> >& localIndex,
30  const double* dataInput,
31  CArray<double,1>& dataOut,
32  std::vector<bool>& flagInitial,
33  bool ignoreMissingValue, bool firstPass)
34 {
35  if (ignoreMissingValue)
36  {
37  int nbLocalIndex = localIndex.size();
38  int currentlocalIndex = 0;
39 
40  if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN();
41 
42  for (int idx = 0; idx < nbLocalIndex; ++idx)
43  {
44  currentlocalIndex = localIndex[idx].first;
45  if (!NumTraits<double>::isNan(*(dataInput + idx)))
46  {
47  if (flagInitial[currentlocalIndex])
48  {
49  dataOut(currentlocalIndex) = *(dataInput + idx);
50  flagInitial[currentlocalIndex] = false;
51  }
52  else
53  {
54  dataOut(currentlocalIndex) += *(dataInput + idx);
55  }
56  }
57  }
58  }
59  else
60  {
61  int nbLocalIndex = localIndex.size();
62  int currentlocalIndex = 0;
63  for (int idx = 0; idx < nbLocalIndex; ++idx)
64  {
65  currentlocalIndex = localIndex[idx].first;
66  if (flagInitial[currentlocalIndex])
67  {
68  dataOut(currentlocalIndex) = *(dataInput + idx);
69  flagInitial[currentlocalIndex] = false;
70  }
71  else
72  {
73  dataOut(currentlocalIndex) += *(dataInput + idx);
74  }
75  }
76  }
77 }
78 
79 }
virtual size_t size(void) const
Definition: array_new.hpp:548
Some utils for Xios.
#define xios(arg)
static CReductionAlgorithm * create()
virtual void apply(const std::vector< std::pair< int, double > > &localIndex, const double *dataInput, CArray< double, 1 > &dataOut, std::vector< bool > &flagInitial, bool ignoreMissingValue, bool firstPass)
Apply a reduction operation on local data.
static bool registerOperation(EReductionType reduceType, CreateOperationCallBack createFn)
Definition: reduction.cpp:46
Interface for all reduction alogrithms.
Definition: reduction.hpp:22