Ignore:
Timestamp:
11/23/18 14:48:14 (6 years ago)
Author:
oabramkina
Message:

Dev: adding exception handling.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/node/axis.cpp

    r1600 r1612  
    4848   bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_); 
    4949   bool CAxis::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
     50   TRY 
    5051   { 
    5152     m["zoom_axis"] = TRANS_ZOOM_AXIS; 
     
    6061 
    6162   } 
     63   CATCH 
    6264 
    6365   ///--------------------------------------------------------------- 
    6466 
    6567   const std::set<StdString> & CAxis::getRelFiles(void) const 
     68   TRY 
    6669   { 
    6770      return (this->relFiles); 
    6871   } 
     72   CATCH 
    6973 
    7074   bool CAxis::IsWritten(const StdString & filename) const 
     75   TRY 
    7176   { 
    7277      return (this->relFiles.find(filename) != this->relFiles.end()); 
    7378   } 
     79   CATCH 
    7480 
    7581   bool CAxis::isWrittenCompressed(const StdString& filename) const 
     82   TRY 
    7683   { 
    7784      return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 
    7885   } 
     86   CATCH 
    7987 
    8088   bool CAxis::isDistributed(void) const 
     89   TRY 
    8190   { 
    8291      bool distributed = (!this->begin.isEmpty() && !this->n.isEmpty() && (this->begin + this->n < this->n_glo)) || 
    8392             (!this->n.isEmpty() && (this->n != this->n_glo)); 
    84       // A same stupid condition to make sure that if there is only one client, axis 
     93      // A condition to make sure that if there is only one client, axis 
    8594      // should be considered to be distributed. This should be a temporary solution      
    8695      distributed |= (1 == CContext::getCurrent()->client->clientSize); 
    8796      return distributed; 
    8897   } 
     98   CATCH 
    8999 
    90100   /*! 
     
    94104    */ 
    95105   bool CAxis::isCompressible(void) const 
     106   TRY 
    96107   { 
    97108      return isCompressible_; 
    98109   } 
     110   CATCH 
    99111 
    100112   void CAxis::addRelFile(const StdString & filename) 
     113   TRY 
    101114   { 
    102115      this->relFiles.insert(filename); 
    103116   } 
     117   CATCH_DUMP_ATTR 
    104118 
    105119   void CAxis::addRelFileCompressed(const StdString& filename) 
     120   TRY 
    106121   { 
    107122      this->relFilesCompressed.insert(filename); 
    108123   } 
     124   CATCH_DUMP_ATTR 
    109125 
    110126   //---------------------------------------------------------------- 
     
    115131   */ 
    116132   int CAxis::getNumberWrittenIndexes(MPI_Comm writtenCom) 
     133   TRY 
    117134   { 
    118135     int writtenSize; 
     
    120137     return numberWrittenIndexes_[writtenSize]; 
    121138   } 
     139   CATCH_DUMP_ATTR 
    122140 
    123141   /*! 
     
    126144   */ 
    127145   int CAxis::getTotalNumberWrittenIndexes(MPI_Comm writtenCom) 
     146   TRY 
    128147   { 
    129148     int writtenSize; 
     
    131150     return totalNumberWrittenIndexes_[writtenSize]; 
    132151   } 
     152   CATCH_DUMP_ATTR 
    133153 
    134154   /*! 
     
    137157   */ 
    138158   int CAxis::getOffsetWrittenIndexes(MPI_Comm writtenCom) 
     159   TRY 
    139160   { 
    140161     int writtenSize; 
     
    142163     return offsetWrittenIndexes_[writtenSize]; 
    143164   } 
     165   CATCH_DUMP_ATTR 
    144166 
    145167   CArray<int, 1>& CAxis::getCompressedIndexToWriteOnServer(MPI_Comm writtenCom) 
     168   TRY 
    146169   { 
    147170     int writtenSize; 
     
    149172     return compressedIndexToWriteOnServer[writtenSize]; 
    150173   } 
     174   CATCH_DUMP_ATTR 
     175 
    151176   //---------------------------------------------------------------- 
    152177 
     
    158183   std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 
    159184                                                         CServerDistributionDescription::ServerDistributionType distType) 
     185   TRY 
    160186   { 
    161187 
     
    221247       } 
    222248     } 
    223  
    224249     return attributesSizes; 
    225250   } 
     251   CATCH_DUMP_ATTR 
    226252 
    227253   //---------------------------------------------------------------- 
     
    234260 
    235261   CAxis* CAxis::createAxis() 
     262   TRY 
    236263   { 
    237264     CAxis* axis = CAxisGroup::get("axis_definition")->createChild(); 
    238265     return axis; 
    239266   } 
     267   CATCH 
    240268 
    241269   /*! 
     
    244272   */ 
    245273   void CAxis::checkAttributes(void) 
     274   TRY 
    246275   { 
    247276     CContext* context=CContext::getCurrent(); 
     
    311340      } 
    312341   } 
     342   CATCH_DUMP_ATTR 
    313343 
    314344   /*! 
     
    317347 
    318348   void CAxis::checkData() 
     349   TRY 
    319350   { 
    320351      if (data_begin.isEmpty()) data_begin.setValue(0); 
     
    363394 
    364395   } 
     396   CATCH_DUMP_ATTR 
    365397 
    366398    size_t CAxis::getGlobalWrittenSize(void) 
     
    373405   */ 
    374406   void CAxis::checkMask() 
     407   TRY 
    375408   { 
    376409      if (!mask.isEmpty()) 
     
    391424      } 
    392425   } 
     426   CATCH_DUMP_ATTR 
    393427 
    394428   /*! 
     
    396430   */ 
    397431   void CAxis::checkBounds() 
     432   TRY 
    398433   { 
    399434     if (!bounds.isEmpty()) 
     
    408443     else hasBounds = false; 
    409444   } 
     445   CATCH_DUMP_ATTR 
    410446 
    411447  void CAxis::checkLabel() 
     448  TRY 
    412449  { 
    413450    if (!label.isEmpty()) 
     
    422459    else hasLabel = false; 
    423460  } 
     461  CATCH_DUMP_ATTR 
    424462 
    425463  /*! 
     
    427465  */ 
    428466  void CAxis::checkEligibilityForCompressedOutput() 
     467  TRY 
    429468  { 
    430469    // We don't check if the mask is valid here, just if a mask has been defined at this point. 
    431470    isCompressible_ = !mask.isEmpty(); 
    432471  } 
     472  CATCH_DUMP_ATTR 
    433473 
    434474  /*! 
     
    436476  */ 
    437477  bool CAxis::dispatchEvent(CEventServer& event) 
     478  TRY 
    438479  { 
    439480     if (SuperClass::dispatchEvent(event)) return true; 
     
    461502     } 
    462503  } 
     504  CATCH 
    463505 
    464506   /*! 
     
    466508   */ 
    467509   void CAxis::checkAttributesOnClient() 
     510   TRY 
    468511   { 
    469512     if (this->areClientAttributesChecked_) return; 
     
    474517     this->areClientAttributesChecked_ = true; 
    475518   } 
     519   CATCH_DUMP_ATTR 
    476520 
    477521   /* 
     
    481525   void CAxis::checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, 
    482526                                                          CServerDistributionDescription::ServerDistributionType distType) 
     527   TRY 
    483528   { 
    484529     CContext* context=CContext::getCurrent() ; 
     
    494539     this->isClientAfterTransformationChecked = true; 
    495540   } 
     541   CATCH_DUMP_ATTR 
    496542 
    497543   /* 
     
    504550   void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
    505551                                     CServerDistributionDescription::ServerDistributionType distType) 
     552   TRY 
    506553   { 
    507554     if (!this->areClientAttributesChecked_) checkAttributesOnClient(); 
     
    514561     this->isChecked = true; 
    515562   } 
     563   CATCH_DUMP_ATTR 
    516564 
    517565  /*! 
     
    522570  void CAxis::sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
    523571                             CServerDistributionDescription::ServerDistributionType distType) 
     572  TRY 
    524573  { 
    525574     sendDistributionAttribute(globalDim, orderPositionInGrid, distType); 
     
    536585     }      
    537586  } 
     587  CATCH_DUMP_ATTR 
    538588 
    539589  /* 
     
    547597  void CAxis::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, 
    548598                                     CServerDistributionDescription::ServerDistributionType distType) 
     599  TRY 
    549600  { 
    550601    CContext* context = CContext::getCurrent(); 
     
    666717    } 
    667718  } 
     719  CATCH_DUMP_ATTR 
    668720 
    669721  /* 
     
    673725  */ 
    674726  void CAxis::computeWrittenIndex() 
     727  TRY 
    675728  {   
    676729    if (computedWrittenIndex_) return; 
     
    714767 
    715768  } 
     769  CATCH_DUMP_ATTR 
    716770 
    717771  void CAxis::computeWrittenCompressedIndex(MPI_Comm writtenComm) 
     772  TRY 
    718773  { 
    719774    int writtenCommSize; 
     
    804859    } 
    805860  } 
     861  CATCH_DUMP_ATTR 
    806862 
    807863  /*! 
     
    814870  void CAxis::sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid, 
    815871                                        CServerDistributionDescription::ServerDistributionType distType) 
     872  TRY 
    816873  { 
    817874    std::list<CContextClient*>::iterator it; 
     
    852909    } 
    853910  } 
     911  CATCH_DUMP_ATTR 
    854912 
    855913  /* 
     
    858916  */ 
    859917  void CAxis::recvDistributionAttribute(CEventServer& event) 
     918  TRY 
    860919  { 
    861920    CBufferIn* buffer = event.subEvents.begin()->buffer; 
     
    864923    get(axisId)->recvDistributionAttribute(*buffer); 
    865924  } 
     925  CATCH 
    866926 
    867927  /* 
     
    870930  */ 
    871931  void CAxis::recvDistributionAttribute(CBufferIn& buffer) 
     932  TRY 
    872933  { 
    873934    int ni_srv, begin_srv; 
     
    879940    begin.setValue(begin_srv); 
    880941  } 
     942  CATCH_DUMP_ATTR 
    881943 
    882944  /* 
     
    886948  */ 
    887949  void CAxis::sendNonDistributedAttributes() 
     950  TRY 
    888951  { 
    889952    std::list<CContextClient*>::iterator it; 
     
    9391002    } 
    9401003  } 
     1004  CATCH_DUMP_ATTR 
    9411005 
    9421006  /* 
     
    9451009  */ 
    9461010  void CAxis::recvNonDistributedAttributes(CEventServer& event) 
     1011  TRY 
    9471012  { 
    9481013    list<CEventServer::SSubEvent>::iterator it; 
     
    9551020    } 
    9561021  } 
     1022  CATCH 
    9571023 
    9581024  /* 
     
    9621028  */ 
    9631029  void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer) 
     1030  TRY 
    9641031  {  
    9651032    CArray<int,1> tmp_index, tmp_data_index; 
     
    10031070    for (int idx = 0; idx < index.numElements(); ++idx) globalLocalIndexMap_[index(idx)] = idx; 
    10041071  } 
     1072  CATCH_DUMP_ATTR 
    10051073 
    10061074  /* 
     
    10101078  */ 
    10111079  void CAxis::sendDistributedAttributes(void) 
     1080  TRY 
    10121081  { 
    10131082    int ind, idx; 
     
    11131182    } 
    11141183  } 
     1184  CATCH_DUMP_ATTR 
    11151185 
    11161186  /* 
     
    11191189  */ 
    11201190  void CAxis::recvDistributedAttributes(CEventServer& event) 
     1191  TRY 
    11211192  { 
    11221193    string axisId; 
     
    11341205    get(axisId)->recvDistributedAttributes(ranks, buffers); 
    11351206  } 
     1207  CATCH 
    11361208 
    11371209  /* 
     
    11411213  */ 
    11421214  void CAxis::recvDistributedAttributes(vector<int>& ranks, vector<CBufferIn*> buffers) 
     1215  TRY 
    11431216  { 
    11441217    int nbReceived = ranks.size(), idx, ind, gloInd, locInd; 
     
    12591332    data_n.setValue(data_index.numElements()); 
    12601333  } 
     1334  CATCH_DUMP_ATTR 
    12611335 
    12621336  /*! 
     
    12681342  */ 
    12691343  bool CAxis::isEqual(CAxis* obj) 
     1344  TRY 
    12701345  { 
    12711346    vector<StdString> excludedAttr; 
     
    12911366    return objEqual; 
    12921367  } 
     1368  CATCH_DUMP_ATTR 
    12931369 
    12941370  /* 
     
    12981374  */ 
    12991375  CTransformation<CAxis>* CAxis::addTransformation(ETranformationType transType, const StdString& id) 
     1376  TRY 
    13001377  { 
    13011378    transformationMap_.push_back(std::make_pair(transType, CTransformation<CAxis>::createTransformation(transType,id))); 
    13021379    return transformationMap_.back().second; 
    13031380  } 
     1381  CATCH_DUMP_ATTR 
    13041382 
    13051383  /* 
     
    13071385  */ 
    13081386  bool CAxis::hasTransformation() 
     1387  TRY 
    13091388  { 
    13101389    return (!transformationMap_.empty()); 
    13111390  } 
     1391  CATCH_DUMP_ATTR 
    13121392 
    13131393  /* 
     
    13161396  */ 
    13171397  void CAxis::setTransformations(const TransMapTypes& axisTrans) 
     1398  TRY 
    13181399  { 
    13191400    transformationMap_ = axisTrans; 
    13201401  } 
     1402  CATCH_DUMP_ATTR 
    13211403 
    13221404  /* 
     
    13251407  */ 
    13261408  CAxis::TransMapTypes CAxis::getAllTransformations(void) 
     1409  TRY 
    13271410  { 
    13281411    return transformationMap_; 
    13291412  } 
     1413  CATCH_DUMP_ATTR 
    13301414 
    13311415  /* 
     
    13341418  */ 
    13351419  void CAxis::duplicateTransformation(CAxis* src) 
     1420  TRY 
    13361421  { 
    13371422    if (src->hasTransformation()) 
     
    13401425    } 
    13411426  } 
     1427  CATCH_DUMP_ATTR 
    13421428 
    13431429  /*! 
     
    13451431   */ 
    13461432  void CAxis::solveInheritanceTransformation() 
     1433  TRY 
    13471434  { 
    13481435    if (hasTransformation() || !hasDirectAxisReference()) 
     
    13611448        refAxis[i]->setTransformations(axis->getAllTransformations()); 
    13621449  } 
     1450  CATCH_DUMP_ATTR 
    13631451 
    13641452  void CAxis::setContextClient(CContextClient* contextClient) 
     1453  TRY 
    13651454  { 
    13661455    if (clientsSet.find(contextClient)==clientsSet.end()) 
     
    13701459    } 
    13711460  } 
     1461  CATCH_DUMP_ATTR 
    13721462 
    13731463  void CAxis::parse(xml::CXMLNode & node) 
     1464  TRY 
    13741465  { 
    13751466    SuperClass::parse(node); 
     
    14021493    } 
    14031494  } 
     1495  CATCH_DUMP_ATTR 
    14041496 
    14051497  DEFINE_REF_FUNC(Axis,axis) 
Note: See TracChangeset for help on using the changeset viewer.