source: XIOS/trunk/src/transformation/Functions/reduction.cpp

Last change on this file was 1852, checked in by ymipsl, 2 years ago

Compiler fix : solve the problem of crash occured with recent version of GCC, only in optimised mode > O1
It seems to be due to non return value from a non void function in case of early initialization (static initialization).
Thanks to A. Durocher who find the tip.

YM

File size: 2.0 KB
Line 
1#include "reduction.hpp"
2#include "sum_reduction.hpp"
3#include "min_reduction.hpp"
4#include "max_reduction.hpp"
5#include "extract.hpp"
6#include "average_reduction.hpp"
7
8namespace xios {
9
10CReductionAlgorithm::CallBackMap* CReductionAlgorithm::reductionCreationCallBacks_ = 0;
11std::map<StdString,EReductionType> CReductionAlgorithm::ReductionOperations = std::map<StdString,EReductionType>();
12bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>& m)
13{
14  // So so stupid way to intialize operation but it works ...
15  m["sum"] = TRANS_REDUCE_SUM;
16  CSumReductionAlgorithm::registerTrans();
17
18  m["min"] = TRANS_REDUCE_MIN;
19  CMinReductionAlgorithm::registerTrans();
20
21  m["max"] = TRANS_REDUCE_MAX;
22  CMaxReductionAlgorithm::registerTrans();
23
24  m["extract"] = TRANS_REDUCE_EXTRACT;
25  CExtractReductionAlgorithm::registerTrans();
26
27  m["average"] = TRANS_REDUCE_AVERAGE;
28  CAverageReductionAlgorithm::registerTrans();
29
30  return true;
31}
32
33bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations);
34
35CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType)
36{
37  int reduceTypeInt = reduceType;
38  CallBackMap::const_iterator it = (*reductionCreationCallBacks_).find(reduceType);
39  if ((*reductionCreationCallBacks_).end() == it)
40  {
41     ERROR("CReductionAlgorithm::createOperation(EReductionType reduceType)",
42           << "Operation type " << reduceType
43           << "doesn't exist. Please define.");
44  }
45  return (it->second)();
46}
47
48bool CReductionAlgorithm::registerOperation(EReductionType reduceType, CreateOperationCallBack createFn)
49{
50  if (0 == reductionCreationCallBacks_)
51    reductionCreationCallBacks_ = new CallBackMap();
52
53  return (*reductionCreationCallBacks_).insert(make_pair(reduceType, createFn)).second;
54}
55
56bool CReductionAlgorithm::unregisterOperation(EReductionType reduceType)
57{
58  int reduceTypeInt = reduceType;
59  return (1 == (*reductionCreationCallBacks_).erase(reduceType));
60}
61
62
63}
Note: See TracBrowser for help on using the repository browser.