Ignore:
Timestamp:
04/23/21 15:00:35 (3 years ago)
Author:
oabramkina
Message:

Merging branch dev_oa with tiling into trunk

File:
1 edited

Legend:

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

    r1972 r2131  
    3535      , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 
    3636      , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 
     37      , isTiled_(false), isTiledOnly_(false) 
    3738   { 
    3839   } 
     
    4849      , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 
    4950      , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 
     51      , isTiled_(false), isTiledOnly_(false) 
    5052   { 
    5153    } 
     
    246248   { 
    247249      return isCompressible_; 
     250   } 
     251   CATCH 
     252 
     253   bool CDomain::isTiled(void) const 
     254   TRY 
     255   { 
     256      return isTiled_; 
     257   } 
     258   CATCH 
     259 
     260   bool CDomain::isTiledOnly(void) const 
     261   TRY 
     262   { 
     263      return isTiledOnly_; 
     264   } 
     265   CATCH 
     266 
     267   int CDomain::getTileId(int i, int j) const 
     268   TRY 
     269   { 
     270     int tileId = 0; 
     271     bool stop = false; 
     272     while (!stop) 
     273     { 
     274       if ((i >= tile_ibegin(tileId) ) && (i < tile_ni(tileId)+tile_ibegin(tileId) ) 
     275           && (j >= tile_jbegin(tileId) ) && (j < tile_nj(tileId)+tile_jbegin(tileId) ) ) 
     276         stop = true; 
     277       ++tileId; 
     278     } 
     279     return (tileId - 1); 
    248280   } 
    249281   CATCH 
     
    12601292        } 
    12611293      } 
     1294   } 
     1295   CATCH_DUMP_ATTR 
     1296 
     1297   //---------------------------------------------------------------- 
     1298 
     1299   /*! 
     1300    * For tiled domains, data_i/j_index should not take into 
     1301    * account parameters defining data (data_ni/nj, data_i/jbegin...) 
     1302    * \param [out] dataIndexI 
     1303    * \param [out] dataIndexJ 
     1304    * \param [out] infoIndexI 
     1305    * \param [out] infoIndexJ 
     1306    */ 
     1307 
     1308   void CDomain::computeCompressionTiled(CArray<int,1>& dataIndexI, CArray<int,1>& dataIndexJ, 
     1309                                         CArray<int,1>& infoIndexI, CArray<int,1>& infoIndexJ) 
     1310   TRY 
     1311   { 
     1312     const int dsize = ni * nj; 
     1313     dataIndexI.resize(dsize); 
     1314     dataIndexJ.resize(dsize); 
     1315 
     1316     dataIndexJ = 0; 
     1317     for (int k = 0; k < ni * nj; ++k) 
     1318       dataIndexI(k) = k; 
     1319 
     1320     infoIndexI.resize(ni*nj); 
     1321     for (int j = 0; j < nj; ++j) 
     1322       for (int i = 0; i < ni; ++i) infoIndexI(i+j*ni) = i+ibegin; 
     1323 
     1324     infoIndexJ.resize(ni*nj); 
     1325     for (int j = 0; j < nj; ++j) 
     1326       for (int i = 0; i < ni; ++i) infoIndexJ(i+j*ni) = j+jbegin; 
    12621327   } 
    12631328   CATCH_DUMP_ATTR 
     
    17231788   CATCH_DUMP_ATTR 
    17241789 
     1790   //---------------------------------------------------------------- 
     1791   void CDomain::checkTiles() 
     1792   TRY 
     1793   { 
     1794     if (!ntiles.isEmpty() && ntiles.getValue() >=1) isTiled_ = true; 
     1795     if (!tile_only.isEmpty() && tile_only.getValue() == true) { 
     1796       isTiled_ = true; 
     1797       isTiledOnly_ = true; 
     1798     } 
     1799 
     1800     if (isTiled_) 
     1801     { 
     1802 
     1803       // Attributes tile_ni/nj and tile_i/jbegin are mandatory for tiled domains 
     1804       if (tile_ni.numElements() != ntiles || tile_ibegin.numElements() != ntiles) 
     1805           ERROR("CDomain::checkTiles()", 
     1806                 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1807                 << "'tile_ni' or 'tile_ibegin' are ill defined: these attributes must be specified for tiled domains and be of the size 'ntiles'." << std::endl 
     1808                 << "The number of tiles is  " << ntiles.getValue() << " while the size of 'tile_ni' is " << tile_ni.numElements()  
     1809                 << " and the size of 'tile_ibegin' is " << tile_ibegin.numElements() << "."); 
     1810 
     1811       if (tile_nj.numElements() != ntiles || tile_jbegin.numElements() != ntiles) 
     1812           ERROR("CDomain::checkTiles()", 
     1813                 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1814                 << "'tile_nj' or 'tile_jbegin' are ill defined: these attributes must be specified for tiled domains and be of the size 'ntiles'." << std::endl 
     1815                 << "The number of tiles is  " << ntiles.getValue() << " while the size of 'tile_nj' is " << tile_nj.numElements() 
     1816                 << " and the size of 'tile_jbegin' is " << tile_jbegin.numElements() << "."); 
     1817 
     1818       // Check on consistency of individual tile sizes and local domain size 
     1819       int sizeTiles = 0; 
     1820       for (int iTile = 0; iTile < ntiles.getValue(); ++iTile) 
     1821       { 
     1822         sizeTiles += tile_ni(iTile) * tile_nj(iTile); 
     1823       } 
     1824       if (sizeTiles != (ni*nj)) 
     1825           ERROR("CDomain::checkTiles()", 
     1826                 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     1827                 << "tiles should cover the entire local domain and cannot overlap." << std::endl << "."); 
     1828 
     1829 
     1830       // Fill in tile_data_ni/nj and tile_data_i/jbegin if they are not specified 
     1831       if (tile_data_ni.numElements() == 0 || tile_data_nj.numElements() == 0) 
     1832       { 
     1833         tile_data_ni.resize(ntiles); 
     1834         tile_data_nj.resize(ntiles); 
     1835         for (int iTile = 0; iTile < ntiles.getValue(); ++iTile) 
     1836         { 
     1837           tile_data_ni(iTile) = tile_ni(iTile); 
     1838           tile_data_nj(iTile) = tile_nj(iTile); 
     1839         } 
     1840       } 
     1841 
     1842       if (tile_data_ibegin.numElements() == 0 || tile_data_jbegin.numElements() == 0) 
     1843       { 
     1844         tile_data_ibegin.resize(ntiles); 
     1845         tile_data_jbegin.resize(ntiles); 
     1846         tile_data_ibegin = 0; 
     1847         tile_data_jbegin = 0; 
     1848       } 
     1849 
     1850     } // isTiled_ 
     1851   } 
     1852   CATCH_DUMP_ATTR 
     1853 
     1854   //---------------------------------------------------------------- 
     1855   int CDomain::getTileDataISize(int tileId) const 
     1856   TRY 
     1857   { 
     1858     int retvalue = (tile_data_ni(tileId) > tile_ni(tileId)) ? tile_data_ni(tileId) : tile_ni(tileId); 
     1859     return retvalue; 
     1860   } 
     1861   CATCH_DUMP_ATTR 
     1862 
     1863   //---------------------------------------------------------------- 
     1864   int CDomain::getTileDataJSize(int tileId) const 
     1865   TRY 
     1866   { 
     1867     int retvalue = (tile_data_nj(tileId) > tile_nj(tileId)) ? tile_data_nj(tileId) : tile_nj(tileId); 
     1868     return retvalue; 
     1869   } 
     1870   CATCH_DUMP_ATTR 
     1871 
    17251872   void CDomain::checkAttributesOnClientAfterTransformation() 
    17261873   TRY 
     
    17561903        this->checkArea(); 
    17571904        this->checkLonLat(); 
     1905        this->checkTiles(); 
    17581906      } 
    17591907 
Note: See TracChangeset for help on using the changeset viewer.