Ignore:
Timestamp:
12/11/18 13:22:07 (5 years ago)
Author:
oabramkina
Message:

Exception handling on trunk.

To activate it, compilation flag -DXIOS_EXCEPTION should be added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/grid.hpp

    r1564 r1622  
    372372   template <int n> 
    373373   void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const 
     374   TRY 
    374375   { 
    375376//#ifdef __XIOS_DEBUG 
     
    383384      this->storeField_arr(field.dataFirst(), stored); 
    384385   } 
     386   CATCH 
    385387 
    386388   template <int n> 
    387389   void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const 
     390   TRY 
    388391   { 
    389392//#ifdef __XIOS_DEBUG 
     
    397400      this->restoreField_arr(stored, field.dataFirst()); 
    398401   } 
     402   CATCH 
    399403 
    400404   /*! 
     
    406410   template <int N> 
    407411   void CGrid::uncompressField(const CArray<double,N>& data, CArray<double,1>& outData) const 
     412   TRY 
    408413   {       
    409414     uncompressField_arr(data.dataFirst(), outData); 
    410415   } 
     416   CATCH 
    411417 
    412418   template<int N> 
     
    416422                             const CArray<int,1>& axisDomainOrder, 
    417423                             bool createMask) 
     424   TRY 
    418425   { 
    419426     if (!gridMask.isEmpty() || createMask) 
     
    515522     } 
    516523   } 
     524   CATCH_DUMP_ATTR 
    517525 
    518526   template<int N> 
     
    520528                                  const std::vector<int>& eachDimSize, 
    521529                                  bool newValue) 
     530   TRY 
    522531   { 
    523532      if (N != eachDimSize.size()) 
     
    534543      gridMask = newValue; 
    535544   } 
     545   CATCH_DUMP_ATTR 
    536546                                  
    537547 
     
    543553   template<int N> 
    544554   void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify) 
     555   TRY 
    545556   {      
    546557     int num = indexToModify.numElements(); 
     
    550561     } 
    551562   } 
     563   CATCH_DUMP_ATTR 
     564 
    552565   ///-------------------------------------------------------------- 
    553566 
    554  
    555 /*! 
    556   A grid can have multiple dimension, so can its mask in the form of multi-dimension array. 
    557 It's not a good idea to store all multi-dimension arrays corresponding to each mask. 
    558 One of the ways is to convert this array into 1-dimension one and every process is taken place on it. 
    559   \param [in] multi-dimension array grid mask 
    560 */ 
    561 template<int N> 
    562 void CGrid::getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask) 
    563 { 
    564   if (gridMask.isEmpty()) return ; 
    565   int dim = gridMask.dimensions(); 
    566   std::vector<int> dimensionSizes(dim); 
    567   for (int i = 0; i < dim; ++i) dimensionSizes[i] = gridMask.extent(i); 
    568  
    569   std::vector<int> idxLoop(dim,0); 
    570   int ssize = gridMask.numElements(), idx = 0; 
    571   localMask.resize(ssize); 
    572   while (idx < ssize) 
     567  /*! 
     568    A grid can have multiple dimension, so can its mask in the form of multi-dimension array. 
     569  It's not a good idea to store all multi-dimension arrays corresponding to each mask. 
     570  One of the ways is to convert this array into 1-dimension one and every process is taken place on it. 
     571    \param [in] multi-dimension array grid mask 
     572  */ 
     573  template<int N> 
     574  void CGrid::getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask) 
     575  TRY 
    573576  { 
    574     for (int i = 0; i < dim-1; ++i) 
     577    if (gridMask.isEmpty()) return ; 
     578    int dim = gridMask.dimensions(); 
     579    std::vector<int> dimensionSizes(dim); 
     580    for (int i = 0; i < dim; ++i) dimensionSizes[i] = gridMask.extent(i); 
     581 
     582    std::vector<int> idxLoop(dim,0); 
     583    int ssize = gridMask.numElements(), idx = 0; 
     584    localMask.resize(ssize); 
     585    while (idx < ssize) 
    575586    { 
    576       if (idxLoop[i] == dimensionSizes[i]) 
     587      for (int i = 0; i < dim-1; ++i) 
    577588      { 
    578         idxLoop[i] = 0; 
    579         ++idxLoop[i+1]; 
     589        if (idxLoop[i] == dimensionSizes[i]) 
     590        { 
     591          idxLoop[i] = 0; 
     592          ++idxLoop[i+1]; 
     593        } 
    580594      } 
     595 
     596      int maskIndex = idxLoop[0]; 
     597      int mulDim = 1; 
     598      for (int k = 1; k < dim; ++k) 
     599      { 
     600        mulDim *= dimensionSizes[k-1]; 
     601        maskIndex += idxLoop[k]*mulDim; 
     602      } 
     603      localMask(maskIndex) = *(gridMask.dataFirst()+maskIndex); 
     604 
     605      ++idxLoop[0]; 
     606      ++idx; 
    581607    } 
    582  
    583     int maskIndex = idxLoop[0]; 
    584     int mulDim = 1; 
    585     for (int k = 1; k < dim; ++k) 
    586     { 
    587       mulDim *= dimensionSizes[k-1]; 
    588       maskIndex += idxLoop[k]*mulDim; 
    589     } 
    590     localMask(maskIndex) = *(gridMask.dataFirst()+maskIndex); 
    591  
    592     ++idxLoop[0]; 
    593     ++idx; 
    594608  } 
    595 } 
     609   CATCH_DUMP_ATTR 
    596610 
    597611   // Declare/Define CGridGroup and CGridDefinition 
Note: See TracChangeset for help on using the changeset viewer.