Changeset 1106 for XIOS


Ignore:
Timestamp:
04/25/17 10:57:55 (7 years ago)
Author:
mhnguyen
Message:

Fixing bug of referencing to an object.

+) From now on, two objects of a same grid element (domain, axis, scalar) are equal if
they have the same non-empty attributes and the same transformations.
(This is very common case with inheritance by *_ref).

Test
+) On Curie
+) Ok with toy_cmip6

Location:
XIOS/trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/axis.cpp

    r1050 r1106  
    977977  } 
    978978 
     979  /*! 
     980    Compare two axis objects.  
     981    They are equal if only if they have identical attributes as well as their values. 
     982    Moreover, they must have the same transformations. 
     983  \param [in] axis Compared axis 
     984  \return result of the comparison 
     985  */ 
     986  bool CAxis::isEqual(CAxis* obj) 
     987  { 
     988    bool objEqual = SuperClass::isEqual(obj); 
     989    if (!objEqual) return objEqual; 
     990 
     991    TransMapTypes thisTrans = this->getAllTransformations(); 
     992    TransMapTypes objTrans  = obj->getAllTransformations(); 
     993 
     994    TransMapTypes::const_iterator it, itb, ite; 
     995    std::vector<ETranformationType> thisTransType, objTransType; 
     996    for (it = thisTrans.begin(); it != thisTrans.end(); ++it) 
     997      thisTransType.push_back(it->first); 
     998    for (it = objTrans.begin(); it != objTrans.end(); ++it) 
     999      objTransType.push_back(it->first); 
     1000 
     1001    if (thisTransType.size() != objTransType.size()) return false; 
     1002    for (int idx = 0; idx < thisTransType.size(); ++idx) 
     1003      objEqual &= (thisTransType[idx] == objTransType[idx]); 
     1004 
     1005    return objEqual; 
     1006  } 
     1007 
    9791008  CTransformation<CAxis>* CAxis::addTransformation(ETranformationType transType, const StdString& id) 
    9801009  { 
     
    9961025  { 
    9971026    return transformationMap_; 
    998   } 
    999  
    1000   /*! 
    1001     Check the validity of all transformations applied on axis 
    1002   This functions is called AFTER all inherited attributes are solved 
    1003   */ 
    1004   void CAxis::checkTransformations() 
    1005   { 
    1006     TransMapTypes::const_iterator itb = transformationMap_.begin(), it, 
    1007                                   ite = transformationMap_.end(); 
    1008 //    for (it = itb; it != ite; ++it) 
    1009 //    { 
    1010 //      (it->second)->checkValid(this); 
    1011 //    } 
    10121027  } 
    10131028 
  • XIOS/trunk/src/node/axis.hpp

    r1050 r1106  
    117117         void duplicateTransformation(CAxis*); 
    118118         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); 
     119         bool isEqual(CAxis* axis); 
    119120 
    120121      public: 
     
    131132         void checkZoom(); 
    132133         void checkBounds(); 
    133          void checkLabel(); 
    134          void checkTransformations(); 
     134         void checkLabel();          
    135135         void sendValue(); 
    136136         void computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 
  • XIOS/trunk/src/node/domain.cpp

    r1078 r1106  
    22382238  } 
    22392239 
     2240  /*! 
     2241    Compare two domain objects.  
     2242    They are equal if only if they have identical attributes as well as their values. 
     2243    Moreover, they must have the same transformations. 
     2244  \param [in] domain Compared domain 
     2245  \return result of the comparison 
     2246  */ 
     2247  bool CDomain::isEqual(CDomain* obj) 
     2248  { 
     2249    bool objEqual = SuperClass::isEqual(obj); 
     2250    if (!objEqual) return objEqual; 
     2251 
     2252    TransMapTypes thisTrans = this->getAllTransformations(); 
     2253    TransMapTypes objTrans  = obj->getAllTransformations(); 
     2254 
     2255    TransMapTypes::const_iterator it, itb, ite; 
     2256    std::vector<ETranformationType> thisTransType, objTransType; 
     2257    for (it = thisTrans.begin(); it != thisTrans.end(); ++it) 
     2258      thisTransType.push_back(it->first); 
     2259    for (it = objTrans.begin(); it != objTrans.end(); ++it) 
     2260      objTransType.push_back(it->first); 
     2261 
     2262    if (thisTransType.size() != objTransType.size()) return false; 
     2263    for (int idx = 0; idx < thisTransType.size(); ++idx) 
     2264      objEqual &= (thisTransType[idx] == objTransType[idx]); 
     2265 
     2266    return objEqual; 
     2267  } 
     2268 
    22402269  CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) 
    22412270  { 
     
    22692298  { 
    22702299    return transformationMap_; 
    2271   } 
    2272  
    2273   /*! 
    2274     Check the validity of all transformations applied on domain 
    2275   This functions is called AFTER all inherited attributes are solved 
    2276   */ 
    2277   void CDomain::checkTransformations() 
    2278   { 
    2279     TransMapTypes::const_iterator itb = transformationMap_.begin(), it, 
    2280                                   ite = transformationMap_.end(); 
    2281 //    for (it = itb; it != ite; ++it) 
    2282 //    { 
    2283 //      (it->second)->checkValid(this); 
    2284 //    } 
    22852300  } 
    22862301 
  • XIOS/trunk/src/node/domain.hpp

    r1078 r1106  
    124124 
    125125         std::vector<int> getNbGlob(); 
     126         bool isEqual(CDomain* domain); 
    126127      public: 
    127128         /// Mutateur /// 
     
    132133         void sendLonLatArea(void); 
    133134         void computeConnectedServer(void) ; 
    134  
     135         void computeLocalMask(void) ; 
     136          
    135137         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
    136138                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g); 
     
    181183         void checkArea(void); 
    182184         void checkLonLat(); 
    183          void checkZoom(void); 
    184          void computeLocalMask(void) ; 
    185  
    186          void checkTransformations(); 
     185         void checkZoom(void);     
     186          
    187187         void setTransformations(const TransMapTypes&); 
    188188         void computeNGlobDomain(); 
  • XIOS/trunk/src/node/scalar.cpp

    r976 r1106  
    6565  } 
    6666 
     67  /*! 
     68    Compare two scalar objects.  
     69    They are equal if only if they have identical attributes as well as their values. 
     70    Moreover, they must have the same transformations. 
     71  \param [in] scalar Compared scalar 
     72  \return result of the comparison 
     73  */ 
     74  bool CScalar::isEqual(CScalar* obj) 
     75  { 
     76    bool objEqual = SuperClass::isEqual(obj); 
     77    if (!objEqual) return objEqual; 
     78 
     79    TransMapTypes thisTrans = this->getAllTransformations(); 
     80    TransMapTypes objTrans  = obj->getAllTransformations(); 
     81 
     82    TransMapTypes::const_iterator it, itb, ite; 
     83    std::vector<ETranformationType> thisTransType, objTransType; 
     84    for (it = thisTrans.begin(); it != thisTrans.end(); ++it) 
     85      thisTransType.push_back(it->first); 
     86    for (it = objTrans.begin(); it != objTrans.end(); ++it) 
     87      objTransType.push_back(it->first); 
     88 
     89    if (thisTransType.size() != objTransType.size()) return false; 
     90    for (int idx = 0; idx < thisTransType.size(); ++idx) 
     91      objEqual &= (thisTransType[idx] == objTransType[idx]); 
     92 
     93    return objEqual; 
     94  } 
     95 
    6796  CTransformation<CScalar>* CScalar::addTransformation(ETranformationType transType, const StdString& id) 
    6897  { 
     
    84113  { 
    85114    return transformationMap_; 
    86   } 
    87  
    88   /*! 
    89     Check the validity of all transformations applied on scalar 
    90   This functions is called AFTER all inherited attributes are solved 
    91   */ 
    92   void CScalar::checkTransformations() 
    93   { 
    94     TransMapTypes::const_iterator itb = transformationMap_.begin(), it, 
    95                                   ite = transformationMap_.end(); 
    96 //    for (it = itb; it != ite; ++it) 
    97 //    { 
    98 //      (it->second)->checkValid(this); 
    99 //    } 
    100115  } 
    101116 
  • XIOS/trunk/src/node/scalar.hpp

    r888 r1106  
    7676           void duplicateTransformation(CScalar*); 
    7777           CTransformation<CScalar>* addTransformation(ETranformationType transType, const StdString& id=""); 
     78           bool isEqual(CScalar* scalar); 
    7879 
    7980         private: 
    8081           std::set<StdString> relFiles; 
     82           TransMapTypes transformationMap_; 
    8183 
    82          private: 
    83             TransMapTypes transformationMap_; 
    84             void checkTransformations(); 
     84         private:            
    8585            void setTransformations(const TransMapTypes&); 
    8686 
  • XIOS/trunk/src/transformation/grid_transformation_selector.cpp

    r980 r1106  
    202202 
    203203    // If source and destination grid share the same scalar 
    204     if ((-1 != scalarDstPos) && (-1 != scalarSrcPos) && 
    205         (scalarListDestP[scalarDstPos] == scalarListSrcP[scalarSrcPos]) && !isSameGrid_) return; 
     204    if ((-1 != scalarDstPos) && (-1 != scalarSrcPos)  && !isSameGrid_ && 
     205        ((scalarListDestP[scalarDstPos] == scalarListSrcP[scalarSrcPos]) || 
     206         (scalarListDestP[scalarDstPos]->isEqual(scalarListSrcP[scalarSrcPos])))) return; 
    206207 
    207208    if (scalarListDestP[scalarDstPos]->hasTransformation()) 
     
    242243 
    243244    // If source and destination grid share the same axis 
    244     if ((-1 != axisDstPos) && (-1 != axisSrcPos) && 
    245         (axisListDestP[axisDstPos] == axisListSrcP[axisSrcPos]) && !isSameGrid_) return; 
     245    if ((-1 != axisDstPos) && (-1 != axisSrcPos) && !isSameGrid_ && 
     246        ((axisListDestP[axisDstPos] == axisListSrcP[axisSrcPos]) || 
     247         (axisListDestP[axisDstPos]->isEqual(axisListSrcP[axisSrcPos]))) ) return; 
    246248 
    247249    if (axisListDestP[axisDstPos]->hasTransformation()) 
     
    281283 
    282284    // If source and destination grid share the same domain 
    283     if ((-1 != domDstPos) && (-1 != domSrcPos) && 
    284         (domListDestP[domDstPos] == domListSrcP[domSrcPos]) && !isSameGrid_) return; 
     285    if ((-1 != domDstPos) && (-1 != domSrcPos) && !isSameGrid_ && 
     286        ((domListDestP[domDstPos] == domListSrcP[domSrcPos]) || 
     287         (domListDestP[domDstPos]->isEqual(domListSrcP[domSrcPos])))) return; 
    285288 
    286289    if (domListDestP[domDstPos]->hasTransformation()) 
Note: See TracChangeset for help on using the changeset viewer.