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
min_reduction.cpp
Aller à la documentation de ce fichier.
1 
9 #include "min_reduction.hpp"
10 #include "utils.hpp"
11 
12 namespace xios {
13 
16 {
17 }
18 
20 {
21  return (new CMinReductionAlgorithm());
22 }
23 
25 {
27 }
28 
29 void CMinReductionAlgorithm::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  if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN();
40  for (int idx = 0; idx < nbLocalIndex; ++idx)
41  {
42  currentlocalIndex = localIndex[idx].first;
43  if (!NumTraits<double>::isNan(*(dataInput + idx)))
44  {
45  if (flagInitial[currentlocalIndex])
46  {
47  dataOut(currentlocalIndex) = *(dataInput + idx);
48  flagInitial[currentlocalIndex] = false;
49  }
50  else
51  {
52  dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex));
53  }
54  }
55  }
56  }
57  else
58  {
59  int nbLocalIndex = localIndex.size();
60  int currentlocalIndex = 0;
61  for (int idx = 0; idx < nbLocalIndex; ++idx)
62  {
63  currentlocalIndex = localIndex[idx].first;
64  if (flagInitial[currentlocalIndex])
65  {
66  dataOut(currentlocalIndex) = *(dataInput + idx);
67  flagInitial[currentlocalIndex] = false;
68  }
69  else
70  {
71  dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex));
72  }
73  }
74  }
75 }
76 
77 }
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