Ignore:
Timestamp:
11/23/18 14:48:14 (5 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/field.cpp

    r1594 r1612  
    7171 
    7272   void CField::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 
     73   TRY 
    7374   { 
    7475      this->vVariableGroup = newVVariableGroup; 
    7576   } 
     77   CATCH 
    7678 
    7779   CVariableGroup* CField::getVirtualVariableGroup(void) const 
     80   TRY 
    7881   { 
    7982      return this->vVariableGroup; 
    8083   } 
     84   CATCH 
    8185 
    8286   std::vector<CVariable*> CField::getAllVariables(void) const 
     87   TRY 
    8388   { 
    8489      return this->vVariableGroup->getAllChildren(); 
    8590   } 
     91   CATCH 
    8692 
    8793   void CField::solveDescInheritance(bool apply, const CAttributeMap* const parent) 
     94   TRY 
    8895   { 
    8996      SuperClassAttribute::setAttributes(parent, apply); 
    9097      this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 
    9198   } 
     99   CATCH_DUMP_ATTR 
    92100 
    93101  //---------------------------------------------------------------- 
    94102 
    95103  bool CField::dispatchEvent(CEventServer& event) 
     104  TRY 
    96105  { 
    97106    if (SuperClass::dispatchEvent(event)) return true; 
     
    131140    } 
    132141  } 
     142  CATCH 
    133143 
    134144  void CField::sendUpdateData(const CArray<double,1>& data) 
     145  TRY 
    135146  { 
    136147    CTimer::get("Field : send data").resume(); 
     
    189200    CTimer::get("Field : send data").suspend(); 
    190201  } 
     202  CATCH_DUMP_ATTR 
    191203 
    192204  void CField::recvUpdateData(CEventServer& event) 
     205  TRY 
    193206  { 
    194207    std::map<int,CBufferIn*> rankBuffers; 
     
    207220    CTimer::get("Field : recv data").suspend(); 
    208221  } 
     222  CATCH 
    209223 
    210224  void  CField::recvUpdateData(std::map<int,CBufferIn*>& rankBuffers) 
     225  TRY 
    211226  { 
    212227    CContext* context = CContext::getCurrent(); 
     
    249264    recvDataSrv.reset() ; 
    250265  } 
     266  CATCH_DUMP_ATTR 
    251267 
    252268  void CField::writeUpdateData(const CArray<double,1>& data) 
     269  TRY 
    253270  { 
    254271    CContext* context = CContext::getCurrent(); 
     
    277294    } 
    278295  } 
     296  CATCH_DUMP_ATTR 
    279297 
    280298  void CField::writeField(void) 
     299  TRY 
    281300  { 
    282301    if (!getRelFile()->isEmptyZone()) 
     
    290309    } 
    291310  } 
     311  CATCH_DUMP_ATTR 
    292312 
    293313  /* 
     
    299319  */ 
    300320  bool CField::sendReadDataRequest(const CDate& tsDataRequested) 
     321  TRY 
    301322  { 
    302323    CContext* context = CContext::getCurrent(); 
     
    330351    return !isEOF; 
    331352  } 
     353  CATCH_DUMP_ATTR 
    332354 
    333355  /*! 
     
    336358  */ 
    337359  bool CField::sendReadDataRequestIfNeeded(void) 
     360  TRY 
    338361  { 
    339362    const CDate& currentDate = CContext::getCurrent()->getCalendar()->getCurrentDate(); 
     
    353376    return dataRequested; 
    354377  } 
     378  CATCH_DUMP_ATTR 
    355379 
    356380  void CField::recvReadDataRequest(CEventServer& event) 
     381  TRY 
    357382  { 
    358383    CBufferIn* buffer = event.subEvents.begin()->buffer; 
     
    361386    get(fieldId)->recvReadDataRequest(); 
    362387  } 
     388  CATCH 
    363389 
    364390  /*! 
     
    369395  */ 
    370396  void CField::recvReadDataRequest(void) 
     397  TRY 
    371398  { 
    372399    CContext* context = CContext::getCurrent(); 
     
    449476    } 
    450477  } 
     478  CATCH_DUMP_ATTR 
    451479 
    452480  /*! 
     
    456484  */ 
    457485  CField::EReadField CField::readField(void) 
     486  TRY 
    458487  { 
    459488    CContext* context = CContext::getCurrent(); 
     
    508537    return readState; 
    509538  } 
     539  CATCH_DUMP_ATTR 
    510540 
    511541  /* 
     
    516546  */ 
    517547  void CField::recvReadDataReady(CEventServer& event) 
     548  TRY 
    518549  { 
    519550    string fieldId; 
     
    531562    get(fieldId)->recvReadDataReady(ranks, buffers); 
    532563  } 
     564  CATCH 
    533565 
    534566  /*! 
     
    538570  */ 
    539571  void CField::recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers) 
     572  TRY 
    540573  { 
    541574    CContext* context = CContext::getCurrent(); 
     
    574607      serverSourceFilter->streamDataFromServer(lastDataReceivedFromServer, data); 
    575608  } 
     609  CATCH_DUMP_ATTR 
    576610 
    577611  void CField::checkForLateDataFromServer(void) 
     612  TRY 
    578613  { 
    579614    CContext* context = CContext::getCurrent(); 
     
    607642    } 
    608643  } 
     644  CATCH_DUMP_ATTR 
    609645 
    610646  void CField::checkIfMustAutoTrigger(void) 
     647  TRY 
    611648  { 
    612649    mustAutoTrigger = serverSourceFilter ? serverSourceFilter->mustAutoTrigger() : false; 
    613650  } 
     651  CATCH_DUMP_ATTR 
    614652 
    615653  void CField::autoTriggerIfNeeded(void) 
     654  TRY 
    616655  { 
    617656    if (mustAutoTrigger) 
    618657      serverSourceFilter->trigger(CContext::getCurrent()->getCalendar()->getCurrentDate()); 
    619658  } 
     659  CATCH_DUMP_ATTR 
    620660 
    621661   //---------------------------------------------------------------- 
    622662 
    623663   void CField::setRelFile(CFile* _file) 
     664   TRY 
    624665   { 
    625666      this->file = _file; 
    626667      hasOutputFile = true; 
    627668   } 
     669   CATCH_DUMP_ATTR 
    628670 
    629671   //---------------------------------------------------------------- 
     
    636678 
    637679   CGrid* CField::getRelGrid(void) const 
     680   TRY 
    638681   { 
    639682      return this->grid; 
    640683   } 
     684   CATCH 
    641685 
    642686   //---------------------------------------------------------------- 
    643687 
    644688   CFile* CField::getRelFile(void) const 
     689   TRY 
    645690   { 
    646691      return this->file; 
    647692   } 
     693   CATCH 
    648694 
    649695   int CField::getNStep(void) const 
     696   TRY 
    650697   { 
    651698      return this->nstep; 
    652699   } 
     700   CATCH 
    653701 
    654702   func::CFunctor::ETimeType CField::getOperationTimeType() const 
     703   TRY 
    655704   { 
    656705     return operationTimeType; 
    657706   } 
     707   CATCH 
    658708 
    659709   //---------------------------------------------------------------- 
    660710 
    661711   void CField::incrementNStep(void) 
     712   TRY 
    662713   { 
    663714      this->nstep++; 
    664715   } 
     716   CATCH_DUMP_ATTR 
    665717 
    666718   void CField::resetNStep(int nstep /*= 0*/) 
     719   TRY 
    667720   { 
    668721      this->nstep = nstep; 
    669722   } 
     723   CATCH_DUMP_ATTR 
    670724 
    671725   void CField::resetNStepMax(void) 
     726   TRY 
    672727   { 
    673728      this->nstepMax = 0; 
    674729      nstepMaxRead = false; 
    675730   } 
     731   CATCH_DUMP_ATTR 
    676732 
    677733   //---------------------------------------------------------------- 
    678734 
    679735   bool CField::isActive(bool atCurrentTimestep /*= false*/) const 
     736   TRY 
    680737   { 
    681738      if (clientSourceFilter) 
     
    689746      return false; 
    690747   } 
     748   CATCH 
    691749 
    692750   //---------------------------------------------------------------- 
    693751 
    694752   bool CField::wasWritten() const 
     753   TRY 
    695754   { 
    696755     return written; 
    697756   } 
     757   CATCH 
    698758 
    699759   void CField::setWritten() 
     760   TRY 
    700761   { 
    701762     written = true; 
    702763   } 
     764   CATCH_DUMP_ATTR 
    703765 
    704766   //---------------------------------------------------------------- 
    705767 
    706768   bool CField::getUseCompressedOutput() const 
     769   TRY 
    707770   { 
    708771     return useCompressedOutput; 
    709772   } 
     773   CATCH 
    710774 
    711775   void CField::setUseCompressedOutput() 
     776   TRY 
    712777   { 
    713778     useCompressedOutput = true; 
    714779   } 
     780   CATCH_DUMP_ATTR 
    715781 
    716782   //---------------------------------------------------------------- 
    717783 
    718784   std::shared_ptr<COutputPin> CField::getInstantDataFilter() 
     785   TRY 
    719786   { 
    720787     return instantDataFilter; 
    721788   } 
     789   CATCH_DUMP_ATTR 
    722790 
    723791   //---------------------------------------------------------------- 
     
    728796   */ 
    729797   void CField::buildGridTransformationGraph() 
     798   TRY 
    730799   { 
    731800     CContext* context = CContext::getCurrent(); 
     
    738807     } 
    739808   } 
     809   CATCH_DUMP_ATTR 
    740810 
    741811   /*! 
     
    743813   */ 
    744814   void CField::generateNewTransformationGridDest() 
     815   TRY 
    745816   { 
    746817     CContext* context = CContext::getCurrent(); 
     
    797868     } 
    798869   } 
     870   CATCH_DUMP_ATTR 
    799871 
    800872   void CField::updateRef(CGrid* grid) 
     873   TRY 
    801874   { 
    802875     if (!grid_ref.isEmpty()) grid_ref.setValue(grid->getId()); 
     
    820893     } 
    821894   } 
     895   CATCH_DUMP_ATTR 
    822896    
    823897   /*! 
     
    826900   */ 
    827901   void CField::solveAllEnabledFieldsAndTransform() 
     902   TRY 
    828903   { 
    829904     CContext* context = CContext::getCurrent(); 
     
    862937     } 
    863938   } 
     939   CATCH_DUMP_ATTR 
    864940 
    865941   void CField::checkGridOfEnabledFields() 
     942   TRY 
    866943   { 
    867944     if (!isGridChecked) 
     
    871948     } 
    872949   } 
     950   CATCH_DUMP_ATTR 
    873951 
    874952   void CField::sendGridComponentOfEnabledFields() 
     953   TRY 
    875954   { 
    876955      solveGridDomainAxisRef(true); 
    877956      // solveCheckMaskIndex(true); 
    878957   } 
     958   CATCH_DUMP_ATTR 
    879959 
    880960   void CField::sendGridOfEnabledFields() 
     961   TRY 
    881962   { 
    882963      // solveGridDomainAxisRef(true); 
    883964      solveCheckMaskIndex(true); 
    884965   }    
     966   CATCH_DUMP_ATTR 
    885967 
    886968   void CField::solveOnlyReferenceEnabledField(bool doSending2Server) 
     969   TRY 
    887970   { 
    888971     CContext* context = CContext::getCurrent(); 
     
    910993     } 
    911994   } 
    912       
     995   CATCH_DUMP_ATTR 
     996 
    913997   void CField::solveAllReferenceEnabledField(bool doSending2Server) 
     998   TRY 
    914999   { 
    9151000     CContext* context = CContext::getCurrent(); 
     
    9401025     solveCheckMaskIndex(doSending2Server); 
    9411026   } 
     1027   CATCH_DUMP_ATTR 
    9421028 
    9431029   std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 
     1030   TRY 
    9441031   { 
    9451032     return grid->getAttributesBufferSize(client, bufferForWriting); 
    9461033   } 
     1034   CATCH_DUMP_ATTR 
    9471035 
    9481036   std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 
     1037   TRY 
    9491038   { 
    9501039     return grid->getDataBufferSize(client, getId(), bufferForWriting); 
    9511040   } 
     1041   CATCH_DUMP_ATTR 
    9521042 
    9531043   size_t CField::getGlobalWrittenSize() 
     1044   TRY 
    9541045   { 
    9551046     return grid->getGlobalWrittenSize(); 
    9561047   } 
     1048   CATCH_DUMP_ATTR 
    9571049 
    9581050   //---------------------------------------------------------------- 
    9591051 
    9601052   void CField::solveServerOperation(void) 
     1053   TRY 
    9611054   { 
    9621055      CContext* context = CContext::getCurrent(); 
     
    10011094      operationTimeType = functor->timeType(); 
    10021095   } 
     1096   CATCH_DUMP_ATTR 
    10031097 
    10041098   //---------------------------------------------------------------- 
     
    10131107    */ 
    10141108   void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput) 
     1109   TRY 
    10151110   {      
    10161111    if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform(); 
     
    11181213     } 
    11191214   } 
     1215   CATCH_DUMP_ATTR 
    11201216 
    11211217   /*! 
     
    11271223    */ 
    11281224   std::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc) 
     1225   TRY 
    11291226   { 
    11301227     if (instantDataFilter || field_ref.isEmpty()) 
     
    11501247     return filters.second; 
    11511248   } 
     1249   CATCH_DUMP_ATTR 
    11521250 
    11531251   /*! 
     
    11611259    */ 
    11621260   std::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc) 
     1261   TRY 
    11631262   { 
    11641263     if (instantDataFilter || !hasExpression()) 
     
    12031302     return selfReferenceFilter; 
    12041303   } 
     1304   CATCH_DUMP_ATTR 
    12051305 
    12061306   /*! 
     
    12141314    */ 
    12151315   std::shared_ptr<COutputPin> CField::getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 
     1316   TRY 
    12161317   { 
    12171318     std::map<CDuration, std::shared_ptr<COutputPin> >::iterator it = temporalDataFilters.find(outFreq); 
     
    12371338     return it->second; 
    12381339   } 
     1340   CATCH_DUMP_ATTR 
    12391341 
    12401342  /*! 
     
    12481350    
    12491351   std::shared_ptr<COutputPin> CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 
     1352   TRY 
    12501353   { 
    12511354     if (instantDataFilter || !hasExpression()) 
     
    12781381     } 
    12791382  } 
     1383   CATCH_DUMP_ATTR 
    12801384 
    12811385   //---------------------------------------------------------------- 
     
    12961400 
    12971401   void CField::solveGridReference(void) 
     1402   TRY 
    12981403   { 
    12991404      if (grid_ref.isEmpty() && domain_ref.isEmpty() && axis_ref.isEmpty() && scalar_ref.isEmpty()) 
     
    13791484      } 
    13801485   } 
     1486   CATCH_DUMP_ATTR 
    13811487 
    13821488   void CField::solveGridDomainAxisRef(bool checkAtt) 
     1489   TRY 
    13831490   { 
    13841491     grid->solveDomainAxisRef(checkAtt); 
    13851492   } 
     1493   CATCH_DUMP_ATTR 
    13861494 
    13871495   void CField::solveCheckMaskIndex(bool doSendingIndex) 
     1496   TRY 
    13881497   { 
    13891498     grid->checkMaskIndex(doSendingIndex); 
    13901499   } 
     1500   CATCH_DUMP_ATTR 
    13911501 
    13921502   void CField::solveTransformedGrid() 
     1503   TRY 
    13931504   { 
    13941505     if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) 
     
    14391550     } 
    14401551   } 
     1552   CATCH_DUMP_ATTR 
    14411553 
    14421554   void CField::solveGenerateGrid() 
     1555   TRY 
    14431556   { 
    14441557     if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) 
     
    14471560       grid->completeGrid(); 
    14481561   } 
     1562   CATCH_DUMP_ATTR 
    14491563 
    14501564   void CField::solveGridDomainAxisBaseRef() 
     1565   TRY 
    14511566   { 
    14521567     grid->solveDomainAxisRef(false); 
    14531568     grid->solveDomainAxisBaseRef(); 
    14541569   } 
     1570   CATCH_DUMP_ATTR 
    14551571 
    14561572   ///------------------------------------------------------------------- 
     
    14581574   template <> 
    14591575   void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void) 
     1576   TRY 
    14601577   { 
    14611578      if (this->group_ref.isEmpty()) return; 
     
    14811598      } 
    14821599   } 
     1600   CATCH_DUMP_ATTR 
    14831601 
    14841602   void CField::scaleFactorAddOffset(double scaleFactor, double addOffset) 
     1603   TRY 
    14851604   { 
    14861605     recvDataSrv = (recvDataSrv - addOffset) / scaleFactor; 
    14871606   } 
     1607   CATCH_DUMP_ATTR 
    14881608 
    14891609   void CField::invertScaleFactorAddOffset(double scaleFactor, double addOffset) 
     1610   TRY 
    14901611   { 
    14911612     recvDataSrv = recvDataSrv * scaleFactor + addOffset; 
    14921613   } 
     1614   CATCH_DUMP_ATTR 
    14931615 
    14941616   void CField::outputField(CArray<double,1>& fieldOut) 
     1617   TRY 
    14951618   {  
    14961619      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; 
     
    15011624      } 
    15021625   } 
     1626   CATCH_DUMP_ATTR 
    15031627 
    15041628   void CField::inputField(CArray<double,1>& fieldIn) 
     1629   TRY 
    15051630   { 
    15061631      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; 
     
    15101635        recvDataSrv(outIndexClient(idx)) = fieldIn(outIndexServer(idx)); 
    15111636      } 
    1512  
    1513    } 
     1637   } 
     1638   CATCH_DUMP_ATTR 
    15141639 
    15151640   void CField::outputCompressedField(CArray<double,1>& fieldOut) 
     1641   TRY 
    15161642   { 
    15171643      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; 
     
    15221648      } 
    15231649   } 
     1650   CATCH_DUMP_ATTR 
    15241651 
    15251652   ///------------------------------------------------------------------- 
    15261653 
    15271654   void CField::parse(xml::CXMLNode& node) 
     1655   TRY 
    15281656   { 
    15291657      string newContent ; 
     
    15401668      if (node.getContent(newContent)) content=newContent ; 
    15411669    } 
     1670   CATCH_DUMP_ATTR 
    15421671 
    15431672   /*! 
     
    15471676   */ 
    15481677   const std::vector<StdString>& CField::getRefDomainAxisIds() 
     1678   TRY 
    15491679   { 
    15501680     CGrid* cgPtr = getRelGrid(); 
     
    15751705     return (domAxisScalarIds_); 
    15761706   } 
     1707   CATCH_DUMP_ATTR 
    15771708 
    15781709   CVariable* CField::addVariable(const string& id) 
     1710   TRY 
    15791711   { 
    15801712     return vVariableGroup->createChild(id); 
    15811713   } 
     1714   CATCH 
    15821715 
    15831716   CVariableGroup* CField::addVariableGroup(const string& id) 
     1717   TRY 
    15841718   { 
    15851719     return vVariableGroup->createChildGroup(id); 
    15861720   } 
     1721   CATCH 
    15871722 
    15881723   void CField::setContextClient(CContextClient* contextClient) 
     1724   TRY 
    15891725   { 
    15901726     CContext* context = CContext::getCurrent(); 
     
    16021738     } 
    16031739   } 
     1740   CATCH_DUMP_ATTR 
    16041741 
    16051742   CContextClient* CField::getContextClient() 
     1743   TRY 
    16061744   { 
    16071745     return client; 
    16081746   } 
     1747   CATCH 
    16091748 
    16101749   void CField::sendAddAllVariables(CContextClient* client) 
     1750   TRY 
    16111751   { 
    16121752     std::vector<CVariable*> allVar = getAllVariables(); 
     
    16211761     } 
    16221762   } 
    1623  
     1763   CATCH_DUMP_ATTR 
    16241764 
    16251765   /*! 
     
    16291769     
    16301770   void CField::sendAllAttributesToServer(CContextClient* client) 
     1771   TRY 
    16311772   { 
    16321773     if (grid_ref.isEmpty()) 
     
    16381779     else SuperClass::sendAllAttributesToServer(client) ; 
    16391780   } 
     1781   CATCH_DUMP_ATTR 
    16401782     
    16411783   void CField::sendAddVariable(const string& id, CContextClient* client) 
     1784   TRY 
    16421785   { 
    16431786      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE, client); 
    16441787   } 
     1788   CATCH_DUMP_ATTR 
    16451789 
    16461790   void CField::sendAddVariableGroup(const string& id, CContextClient* client) 
     1791   TRY 
    16471792   { 
    16481793      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE_GROUP, client); 
    16491794   } 
     1795   CATCH_DUMP_ATTR 
    16501796 
    16511797   void CField::recvAddVariable(CEventServer& event) 
     1798   TRY 
    16521799   { 
    16531800 
     
    16571804      get(id)->recvAddVariable(*buffer); 
    16581805   } 
     1806   CATCH 
    16591807 
    16601808   void CField::recvAddVariable(CBufferIn& buffer) 
     1809   TRY 
    16611810   { 
    16621811      string id; 
     
    16641813      addVariable(id); 
    16651814   } 
     1815   CATCH_DUMP_ATTR 
    16661816 
    16671817   void CField::recvAddVariableGroup(CEventServer& event) 
     1818   TRY 
    16681819   { 
    16691820 
     
    16731824      get(id)->recvAddVariableGroup(*buffer); 
    16741825   } 
     1826   CATCH 
    16751827 
    16761828   void CField::recvAddVariableGroup(CBufferIn& buffer) 
     1829   TRY 
    16771830   { 
    16781831      string id; 
     
    16801833      addVariableGroup(id); 
    16811834   } 
     1835   CATCH_DUMP_ATTR 
    16821836 
    16831837   /*! 
     
    16851839    */ 
    16861840   void CField::checkTimeAttributes(CDuration* freqOp) 
     1841   TRY 
    16871842   { 
    16881843     bool isFieldRead  = file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read; 
     
    17061861       freq_offset.setValue(isFieldRead ? NoneDu : (freq_op.getValue() - TimeStep)); 
    17071862   } 
     1863   CATCH_DUMP_ATTR 
    17081864 
    17091865   /*! 
     
    17121868    */ 
    17131869   const string& CField::getExpression(void) 
     1870   TRY 
    17141871   { 
    17151872     if (!expr.isEmpty() && content.empty()) 
     
    17211878     return content; 
    17221879   } 
     1880   CATCH_DUMP_ATTR 
    17231881 
    17241882   bool CField::hasExpression(void) const 
     1883   TRY 
    17251884   { 
    17261885     return (!expr.isEmpty() || !content.empty()); 
    17271886   } 
     1887   CATCH 
    17281888 
    17291889   bool CField::hasGridMask(void) const 
     1890   TRY 
    17301891   { 
    17311892     return (this->grid->hasMask()); 
    17321893   } 
     1894   CATCH 
    17331895 
    17341896   DEFINE_REF_FUNC(Field,field) 
Note: See TracChangeset for help on using the changeset viewer.