Ignore:
Timestamp:
01/23/19 10:31:44 (5 years ago)
Author:
yushan
Message:

dev on ADA. add flag switch _usingEP/_usingMPI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/src/node/grid.hpp

    r1545 r1642  
    1919namespace xios { 
    2020 
    21    /// ////////////////////// Dᅵᅵclarations ////////////////////// /// 
     21   /// ////////////////////// Declarations ////////////////////// /// 
    2222 
    2323   class CGridGroup; 
     
    9191         StdSize  getDataSize(void) const; 
    9292 
    93          /// Entrᅵᅵes-sorties de champs 
     93         /// Entrees-sorties de champs 
    9494         template <int n> 
    9595         void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; 
     96         template <int n> 
     97         void maskField(const CArray<double,n>& field, CArray<double,1>& stored) const; 
    9698         template <int n> 
    9799         void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const;   
     
    203205         bool hasTransform(); 
    204206         size_t getGlobalWrittenSize(void) ; 
    205          void getLocalMask(CArray<bool,1>& localMask) ; 
    206          template<int N> 
    207          void getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask) ; 
    208207      public: 
    209208         CArray<int, 1> storeIndex_client; 
     209         CArray<bool, 1> storeMask_client; 
    210210 
    211211/** Map containing indexes that will be sent in sendIndex(). */ 
     
    247247         CArray<size_t,1> indexFromClients; 
    248248 
     249         bool hasMask(void) const; 
    249250         void checkMask(void); 
    250251         void createMask(void); 
     
    273274        void restoreField_arr(const CArray<double, 1>& stored, double* const data) const; 
    274275        void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const; 
     276        void maskField_arr(const double* const data, CArray<double, 1>& stored) const; 
    275277 
    276278        void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); 
     
    372374   template <int n> 
    373375   void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const 
     376   TRY 
    374377   { 
    375378//#ifdef __XIOS_DEBUG 
     
    383386      this->storeField_arr(field.dataFirst(), stored); 
    384387   } 
     388   CATCH 
     389 
     390   template <int n> 
     391   void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const 
     392   { 
     393//#ifdef __XIOS_DEBUG 
     394      if (this->getDataSize() != field.numElements()) 
     395         ERROR("void CGrid::inputField(const  CArray<double,n>& field, CArray<double,1>& stored) const", 
     396                << "[ Awaiting data of size = " << this->getDataSize() << ", " 
     397                << "Received data size = "      << field.numElements() << " ] " 
     398                << "The data array does not have the right size! " 
     399                << "Grid = " << this->getId()) 
     400//#endif 
     401      this->maskField_arr(field.dataFirst(), stored); 
     402   } 
    385403 
    386404   template <int n> 
    387405   void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const 
     406   TRY 
    388407   { 
    389408//#ifdef __XIOS_DEBUG 
     
    397416      this->restoreField_arr(stored, field.dataFirst()); 
    398417   } 
     418   CATCH 
    399419 
    400420   /*! 
     
    406426   template <int N> 
    407427   void CGrid::uncompressField(const CArray<double,N>& data, CArray<double,1>& outData) const 
     428   TRY 
    408429   {       
    409430     uncompressField_arr(data.dataFirst(), outData); 
    410431   } 
     432   CATCH 
    411433 
    412434   template<int N> 
     
    416438                             const CArray<int,1>& axisDomainOrder, 
    417439                             bool createMask) 
     440   TRY 
    418441   { 
    419442     int idx = 0; 
     
    510533      ++idx; 
    511534    } 
    512  
    513    } 
     535   } 
     536   CATCH_DUMP_ATTR 
    514537 
    515538   template<int N> 
     
    517540                                  const std::vector<int>& eachDimSize, 
    518541                                  bool newValue) 
     542   TRY 
    519543   { 
    520544      if (N != eachDimSize.size()) 
     
    531555      gridMask = newValue; 
    532556   } 
     557   CATCH_DUMP_ATTR 
    533558                                  
    534559 
     
    540565   template<int N> 
    541566   void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify) 
     567   TRY 
    542568   {      
    543569     int num = indexToModify.numElements(); 
     
    547573     } 
    548574   } 
     575   CATCH_DUMP_ATTR 
     576 
    549577   ///-------------------------------------------------------------- 
    550578 
    551579 
    552 /*! 
    553   A grid can have multiple dimension, so can its mask in the form of multi-dimension array. 
    554 It's not a good idea to store all multi-dimension arrays corresponding to each mask. 
    555 One of the ways is to convert this array into 1-dimension one and every process is taken place on it. 
    556   \param [in] multi-dimension array grid mask 
    557 */ 
    558 template<int N> 
    559 void CGrid::getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask) 
    560 { 
    561   if (gridMask.isEmpty()) return ; 
    562   int dim = gridMask.dimensions(); 
    563   std::vector<int> dimensionSizes(dim); 
    564   for (int i = 0; i < dim; ++i) dimensionSizes[i] = gridMask.extent(i); 
    565  
    566   std::vector<int> idxLoop(dim,0); 
    567   int ssize = gridMask.numElements(), idx = 0; 
    568   localMask.resize(ssize); 
    569   while (idx < ssize) 
    570   { 
    571     for (int i = 0; i < dim-1; ++i) 
    572     { 
    573       if (idxLoop[i] == dimensionSizes[i]) 
    574       { 
    575         idxLoop[i] = 0; 
    576         ++idxLoop[i+1]; 
    577       } 
    578     } 
    579  
    580     int maskIndex = idxLoop[0]; 
    581     int mulDim = 1; 
    582     for (int k = 1; k < dim; ++k) 
    583     { 
    584       mulDim *= dimensionSizes[k-1]; 
    585       maskIndex += idxLoop[k]*mulDim; 
    586     } 
    587     localMask(maskIndex) = *(gridMask.dataFirst()+maskIndex); 
    588  
    589     ++idxLoop[0]; 
    590     ++idx; 
    591   } 
    592 } 
    593580 
    594581   // Declare/Define CGridGroup and CGridDefinition 
Note: See TracChangeset for help on using the changeset viewer.