source: XIOS/trunk/src/node/extract_domain.cpp @ 2250

Last change on this file since 2250 was 1852, checked in by ymipsl, 4 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.6 KB
Line 
1#include "extract_domain.hpp"
2#include "type.hpp"
3
4namespace xios {
5
6  /// ////////////////////// Définitions ////////////////////// ///
7
8  CExtractDomain::CExtractDomain(void)
9    : CObjectTemplate<CExtractDomain>(), CExtractDomainAttributes(), CTransformation<CDomain>()
10  { /* Ne rien faire de plus */ }
11
12  CExtractDomain::CExtractDomain(const StdString & id)
13    : CObjectTemplate<CExtractDomain>(id), CExtractDomainAttributes(), CTransformation<CDomain>()
14  { /* Ne rien faire de plus */ }
15
16  CExtractDomain::~CExtractDomain(void)
17  {}
18
19  CTransformation<CDomain>* CExtractDomain::create(const StdString& id, xml::CXMLNode* node)
20  {
21    CExtractDomain* extractDomain = CExtractDomainGroup::get("extract_domain_definition")->createChild(id);
22    if (node) extractDomain->parse(*node);
23    return static_cast<CTransformation<CDomain>*>(extractDomain);
24  }
25
26  bool CExtractDomain::_dummyRegistered = CExtractDomain::registerTrans();
27  bool CExtractDomain::registerTrans()
28  {
29    return registerTransformation(TRANS_EXTRACT_DOMAIN, CExtractDomain::create);
30  }
31
32  //----------------------------------------------------------------
33
34  StdString CExtractDomain::GetName(void)    { return StdString("extract_domain"); }
35  StdString CExtractDomain::GetDefName(void) { return StdString("extract_domain"); }
36  ENodeType CExtractDomain::GetType(void)    { return eExtractDomain; }
37
38  void CExtractDomain::checkValid(CDomain* domainSrc)
39  {
40    int ni_glo = domainSrc->ni_glo.getValue();
41    int nj_glo = domainSrc->nj_glo.getValue();
42
43    // Résolution et vérification des données globales de extract.
44    if (!this->ni.isEmpty() || !this->nj.isEmpty() ||
45        !this->ibegin.isEmpty() || !this->jbegin.isEmpty())
46    {
47       if (this->ni.isEmpty()     || this->nj.isEmpty() ||
48           this->ibegin.isEmpty() || this->jbegin.isEmpty())
49       {
50         ERROR("CExtractDomain::checkValid(CDomain* domainSrc)",
51               << "If one of extract attributes is defined then all extract attributes must be defined.") ;
52       }
53       else
54       {
55          int iend = ibegin + ni - 1;
56          int jend = jbegin + nj - 1;
57
58          if (ibegin < 0  || jbegin < 0 || iend > ni_glo - 1 || jend > nj_glo - 1)
59            ERROR("CExtractDomain::checkValid(CDomain* domainSrc)",
60                  << "Extract is wrongly defined, "
61                  << "please check the values : 'ni' (" << ni.getValue() << "), 'nj' (" << nj.getValue() << "), "
62                  << "'ibegin' (" << ibegin.getValue() << "), 'jbegin' (" << jbegin.getValue() << ")");
63       }
64    }
65    else
66    {
67       ni = ni_glo;
68       nj = nj_glo;
69       ibegin = 0;
70       jbegin = 0;
71    }
72  }
73
74}
Note: See TracBrowser for help on using the repository browser.