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/file.cpp

    r1542 r1612  
    5353 
    5454   const StdString CFile::getFileOutputName(void) const 
     55   TRY 
    5556   { 
    5657     return (name.isEmpty() ? getId() : name) + (name_suffix.isEmpty() ? StdString("") :  name_suffix.getValue()); 
    5758   } 
     59   CATCH 
    5860 
    5961   //---------------------------------------------------------------- 
     
    6567   */ 
    6668   std::shared_ptr<CDataOutput> CFile::getDataOutput(void) const 
     69   TRY 
    6770   { 
    6871      return data_out; 
    6972   } 
     73   CATCH 
    7074 
    7175   /*! 
     
    7680   */ 
    7781   std::shared_ptr<CDataInput> CFile::getDataInput(void) const 
     82   TRY 
    7883   { 
    7984      return data_in; 
    8085   } 
     86   CATCH 
    8187 
    8288   /*! 
     
    8894   */ 
    8995   CFieldGroup* CFile::getVirtualFieldGroup(void) const 
     96   TRY 
    9097   { 
    9198      return (this->vFieldGroup); 
    9299   } 
     100   CATCH 
    93101 
    94102   /*! 
     
    100108   */ 
    101109   CVariableGroup* CFile::getVirtualVariableGroup(void) const 
     110   TRY 
    102111   { 
    103112      return (this->vVariableGroup); 
    104113   } 
     114   CATCH 
    105115 
    106116   //! Get all fields of a file 
    107117   std::vector<CField*> CFile::getAllFields(void) const 
     118   TRY 
    108119   { 
    109120      return (this->vFieldGroup->getAllChildren()); 
    110121   } 
     122   CATCH 
    111123 
    112124   //! Get all variables of a file 
    113125   std::vector<CVariable*> CFile::getAllVariables(void) const 
     126   TRY 
    114127   { 
    115128      return (this->vVariableGroup->getAllChildren()); 
    116129   } 
     130   CATCH 
    117131 
    118132   //---------------------------------------------------------------- 
     
    129143                                                int default_level, 
    130144                                                bool default_enabled) 
     145   TRY 
    131146   { 
    132147      if (!this->enabledFields.empty()) 
     
    145160         { 
    146161            if (! (*it)->enabled.getValue()) continue; 
    147 //            { it--; this->enabledFields.erase(it+1); continue; } 
    148162         } 
    149163         else // Si l'attribut 'enabled' n'est pas dfini ... 
    150164         { 
    151165            if (!default_enabled) continue; 
    152 //            { it--; this->enabledFields.erase(it+1); continue; } 
    153166         } 
    154167 
     
    156169         { 
    157170            if ((*it)->level.getValue() > _outputlevel) continue; 
    158 //            { it--; this->enabledFields.erase(it+1); continue; } 
    159171         } 
    160172         else // Si l'attribut 'level' n'est pas dfini ... 
    161173         { 
    162174            if (default_level > _outputlevel) continue; 
    163 //            { it--; this->enabledFields.erase(it+1); continue; } 
    164175         } 
    165176 
    166 //         CField* field_tmp=(*it).get(); 
    167 //         shared_ptr<CField> sptfield=*it; 
    168 //         field_tmp->refObject.push_back(sptfield); 
    169177         newEnabledFields.push_back(*it); 
    170          // Le champ est finalement actif, on y ajoute sa propre reference. 
    171 //         (*it)->refObject.push_back(*it); 
    172178         // Le champ est finalement actif, on y ajoute la rfrence au champ de base. 
    173179         (*it)->setRelFile(CFile::get(this)); 
     
    177183      return (this->enabledFields); 
    178184   } 
     185   CATCH_DUMP_ATTR 
    179186 
    180187   //---------------------------------------------------------------- 
    181188   //! Change virtual field group to a new one 
    182189   void CFile::setVirtualFieldGroup(CFieldGroup* newVFieldGroup) 
     190   TRY 
    183191   { 
    184192      this->vFieldGroup = newVFieldGroup; 
    185193   } 
     194   CATCH_DUMP_ATTR 
    186195 
    187196   //! Change virtual variable group to new one 
    188197   void CFile::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 
     198   TRY 
    189199   { 
    190200      this->vVariableGroup = newVVariableGroup; 
    191201   } 
     202   CATCH_DUMP_ATTR 
    192203 
    193204   //---------------------------------------------------------------- 
    194205   bool CFile::isSyncTime(void) 
     206   TRY 
    195207   { 
    196208     CContext* context = CContext::getCurrent(); 
     
    206218      return false; 
    207219    } 
     220    CATCH_DUMP_ATTR 
    208221 
    209222   //! Initialize a file in order to write into it 
    210223   void CFile::initWrite(void) 
     224   TRY 
    211225   { 
    212226      CContext* context = CContext::getCurrent(); 
     
    261275      if (time_counter_name.isEmpty()) time_counter_name = "time_counter"; 
    262276    } 
     277    CATCH_DUMP_ATTR 
    263278 
    264279    //! Initialize a file in order to write into it 
    265280    void CFile::initRead(void) 
     281    TRY 
    266282    { 
    267283      if (checkRead) return; 
     
    269285      checkRead = true; 
    270286    } 
     287    CATCH_DUMP_ATTR 
    271288 
    272289    /*! 
     
    274291    */ 
    275292    void CFile::createSubComFile() 
     293    TRY 
    276294    { 
    277295      CContext* context = CContext::getCurrent(); 
     
    292310      if (allZoneEmpty) MPI_Comm_free(&fileComm); 
    293311    } 
     312    CATCH_DUMP_ATTR 
    294313 
    295314    /* 
     
    299318    */ 
    300319    void CFile::checkWriteFile(void) 
     320    TRY 
    301321    { 
    302322      CContext* context = CContext::getCurrent(); 
     
    315335      } 
    316336    } 
     337    CATCH_DUMP_ATTR 
    317338 
    318339    /* 
     
    323344    */ 
    324345    void CFile::checkReadFile(void) 
     346    TRY 
    325347    { 
    326348      CContext* context = CContext::getCurrent(); 
     
    340362      } 
    341363    } 
     364    CATCH_DUMP_ATTR 
    342365 
    343366    /*! 
     
    346369    */ 
    347370    bool CFile::isEmptyZone() 
     371    TRY 
    348372    { 
    349373      return allZoneEmpty; 
    350374    } 
     375    CATCH_DUMP_ATTR 
    351376 
    352377    /*! 
     
    357382    */ 
    358383   bool CFile::checkSync(void) 
     384   TRY 
    359385   { 
    360386     CContext* context = CContext::getCurrent(); 
     
    371397      return false; 
    372398    } 
     399   CATCH_DUMP_ATTR 
    373400 
    374401    /*! 
     
    379406    */ 
    380407    bool CFile::checkSplit(void) 
     408    TRY 
    381409    { 
    382410      CContext* context = CContext::getCurrent(); 
     
    402430      return false; 
    403431    } 
     432    CATCH_DUMP_ATTR 
    404433 
    405434   /*! 
     
    408437   */ 
    409438   void CFile::createHeader(void) 
     439   TRY 
    410440   { 
    411441      CContext* context = CContext::getCurrent(); 
     
    594624      } 
    595625   } 
     626   CATCH_DUMP_ATTR 
    596627 
    597628  /*! 
     
    599630  */ 
    600631  void CFile::openInReadMode() 
     632  TRY 
    601633  { 
    602634    CContext* context = CContext::getCurrent(); 
     
    675707    } 
    676708  } 
     709  CATCH_DUMP_ATTR 
    677710 
    678711   //! Close file 
    679712   void CFile::close(void) 
     713   TRY 
    680714   { 
    681715     if (!allZoneEmpty) 
     
    690724      if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm); 
    691725   } 
     726   CATCH_DUMP_ATTR 
     727 
    692728   //---------------------------------------------------------------- 
    693729 
    694730   void CFile::readAttributesOfEnabledFieldsInReadMode() 
     731   TRY 
    695732   { 
    696733     if (enabledFields.empty()) return; 
     
    722759     close(); 
    723760   } 
    724  
     761   CATCH_DUMP_ATTR 
    725762 
    726763   /*! 
     
    729766   */ 
    730767   void CFile::parse(xml::CXMLNode & node) 
     768   TRY 
    731769   { 
    732770      SuperClass::parse(node); 
     
    741779        node.goToParentElement(); 
    742780      } 
    743  
    744    } 
     781   } 
     782   CATCH_DUMP_ATTR 
     783 
    745784   //---------------------------------------------------------------- 
    746785 
     
    750789   */ 
    751790   StdString CFile::toString(void) const 
     791   TRY 
    752792   { 
    753793      StdOStringStream oss; 
     
    762802      return (oss.str()); 
    763803   } 
     804   CATCH 
    764805 
    765806   //---------------------------------------------------------------- 
     
    772813   */ 
    773814   void CFile::solveDescInheritance(bool apply, const CAttributeMap * const parent) 
     815   TRY 
    774816   { 
    775817      SuperClassAttribute::setAttributes(parent,apply); 
     
    777819      this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 
    778820   } 
     821   CATCH_DUMP_ATTR 
    779822 
    780823   //---------------------------------------------------------------- 
     
    789832   */ 
    790833   void CFile::solveOnlyRefOfEnabledFields(bool sendToServer) 
     834   TRY 
    791835   { 
    792836     int size = this->enabledFields.size(); 
     
    796840     } 
    797841   } 
     842   CATCH_DUMP_ATTR 
    798843 
    799844   void CFile::checkGridOfEnabledFields() 
     845   TRY 
    800846   {  
    801847     int size = this->enabledFields.size(); 
     
    805851     } 
    806852   } 
     853   CATCH_DUMP_ATTR 
    807854 
    808855   void CFile::sendGridComponentOfEnabledFields() 
     856   TRY 
    809857   {  
    810858     int size = this->enabledFields.size(); 
     
    814862     } 
    815863   } 
     864   CATCH_DUMP_ATTR 
    816865 
    817866   /*! 
     
    820869   */ 
    821870   void CFile::sortEnabledFieldsForUgrid() 
     871   TRY 
    822872   { 
    823873     int size = this->enabledFields.size(); 
     
    868918     } 
    869919   } 
     920   CATCH_DUMP_ATTR 
    870921 
    871922   void CFile::sendGridOfEnabledFields() 
     923   TRY 
    872924   {  
    873925     int size = this->enabledFields.size(); 
     
    877929     } 
    878930   } 
     931   CATCH_DUMP_ATTR 
    879932 
    880933   void CFile::generateNewTransformationGridDest() 
     934   TRY 
    881935   { 
    882936     int size = this->enabledFields.size(); 
     
    886940     } 
    887941   } 
     942   CATCH_DUMP_ATTR 
    888943 
    889944   /*! 
     
    896951   */ 
    897952   void CFile::solveAllRefOfEnabledFieldsAndTransform(bool sendToServer) 
     953   TRY 
    898954   { 
    899955     int size = this->enabledFields.size(); 
     
    903959     } 
    904960   } 
     961   CATCH_DUMP_ATTR 
    905962 
    906963   /*! 
     
    910967    */ 
    911968   void CFile::buildFilterGraphOfEnabledFields(CGarbageCollector& gc) 
     969   TRY 
    912970   { 
    913971     int size = this->enabledFields.size(); 
     
    917975     } 
    918976   } 
     977   CATCH_DUMP_ATTR 
    919978 
    920979   /*! 
     
    922981    */ 
    923982   void CFile::postProcessFilterGraph() 
     983   TRY 
    924984   { 
    925985     int size = this->enabledFields.size(); 
     
    929989     } 
    930990   } 
     991   CATCH_DUMP_ATTR 
    931992 
    932993   /*! 
     
    934995   */ 
    935996   void CFile::prefetchEnabledReadModeFields(void) 
     997   TRY 
    936998   { 
    937999     if (mode.isEmpty() || mode.getValue() != mode_attr::read) 
     
    9421004       this->enabledFields[i]->sendReadDataRequest(CContext::getCurrent()->getCalendar()->getCurrentDate()); 
    9431005   } 
     1006   CATCH_DUMP_ATTR 
    9441007 
    9451008   /*! 
     
    9491012   */ 
    9501013   void CFile::doPreTimestepOperationsForEnabledReadModeFields(void) 
     1014   TRY 
    9511015   { 
    9521016     if (mode.isEmpty() || mode.getValue() != mode_attr::read) 
     
    9601024     } 
    9611025   } 
     1026   CATCH_DUMP_ATTR 
    9621027 
    9631028   /*! 
     
    9661031   */ 
    9671032   void CFile::doPostTimestepOperationsForEnabledReadModeFields(void) 
     1033   TRY 
    9681034   { 
    9691035     if (mode.isEmpty() || mode.getValue() != mode_attr::read) 
     
    9761042     } 
    9771043   } 
     1044   CATCH_DUMP_ATTR 
    9781045 
    9791046   void CFile::solveFieldRefInheritance(bool apply) 
     1047   TRY 
    9801048   { 
    9811049      // Rsolution des hritages par rfrence de chacun des champs contenus dans le fichier. 
     
    9841052         allF[i]->solveRefInheritance(apply); 
    9851053   } 
     1054   CATCH_DUMP_ATTR 
    9861055 
    9871056   //---------------------------------------------------------------- 
     
    9961065   */ 
    9971066   CField* CFile::addField(const string& id) 
     1067   TRY 
    9981068   { 
    9991069     return vFieldGroup->createChild(id); 
    10001070   } 
     1071   CATCH_DUMP_ATTR 
    10011072 
    10021073   /*! 
     
    10081079   */ 
    10091080   CFieldGroup* CFile::addFieldGroup(const string& id) 
     1081   TRY 
    10101082   { 
    10111083     return vFieldGroup->createChildGroup(id); 
    10121084   } 
     1085   CATCH_DUMP_ATTR 
    10131086 
    10141087   /*! 
     
    10231096   */ 
    10241097   CVariable* CFile::addVariable(const string& id) 
     1098   TRY 
    10251099   { 
    10261100     return vVariableGroup->createChild(id); 
    10271101   } 
     1102   CATCH_DUMP_ATTR 
    10281103 
    10291104   /*! 
     
    10351110   */ 
    10361111   CVariableGroup* CFile::addVariableGroup(const string& id) 
     1112   TRY 
    10371113   { 
    10381114     return vVariableGroup->createChildGroup(id); 
    10391115   } 
     1116   CATCH_DUMP_ATTR 
    10401117 
    10411118   void CFile::setContextClient(CContextClient* newContextClient) 
     1119   TRY 
    10421120   { 
    10431121     client = newContextClient; 
     
    10481126     } 
    10491127   } 
     1128   CATCH_DUMP_ATTR 
    10501129 
    10511130   CContextClient* CFile::getContextClient() 
     1131   TRY 
    10521132   { 
    10531133     return client; 
    10541134   } 
     1135   CATCH_DUMP_ATTR 
    10551136 
    10561137   void CFile::setReadContextClient(CContextClient* readContextclient) 
     1138   TRY 
    10571139   { 
    10581140     read_client = readContextclient; 
    10591141   } 
     1142   CATCH_DUMP_ATTR 
    10601143 
    10611144   CContextClient* CFile::getReadContextClient() 
     1145   TRY 
    10621146   { 
    10631147     return read_client; 
    10641148   } 
     1149   CATCH_DUMP_ATTR 
    10651150 
    10661151   /*! 
     
    10691154   */ 
    10701155   void CFile::sendAddField(const string& id, CContextClient* client) 
     1156   TRY 
    10711157   { 
    10721158      sendAddItem(id, EVENT_ID_ADD_FIELD, client); 
    10731159   } 
     1160   CATCH_DUMP_ATTR 
    10741161 
    10751162   /*! 
     
    10781165   */ 
    10791166   void CFile::sendAddFieldGroup(const string& id, CContextClient* client) 
     1167   TRY 
    10801168   { 
    10811169      sendAddItem(id, (int)EVENT_ID_ADD_FIELD_GROUP, client); 
    10821170   } 
     1171   CATCH_DUMP_ATTR 
    10831172 
    10841173   /*! 
     
    10871176   */ 
    10881177   void CFile::recvAddField(CEventServer& event) 
     1178   TRY 
    10891179   { 
    10901180 
     
    10941184      get(id)->recvAddField(*buffer); 
    10951185   } 
     1186   CATCH 
    10961187 
    10971188   /*! 
     
    11001191   */ 
    11011192   void CFile::recvAddField(CBufferIn& buffer) 
     1193   TRY 
    11021194   { 
    11031195      string id; 
     
    11051197      addField(id); 
    11061198   } 
     1199   CATCH_DUMP_ATTR 
    11071200 
    11081201   /*! 
     
    11111204   */ 
    11121205   void CFile::recvAddFieldGroup(CEventServer& event) 
     1206   TRY 
    11131207   { 
    11141208 
     
    11181212      get(id)->recvAddFieldGroup(*buffer); 
    11191213   } 
     1214   CATCH 
    11201215 
    11211216   /*! 
     
    11241219   */ 
    11251220   void CFile::recvAddFieldGroup(CBufferIn& buffer) 
     1221   TRY 
    11261222   { 
    11271223      string id; 
     
    11291225      addFieldGroup(id); 
    11301226   } 
     1227   CATCH_DUMP_ATTR 
    11311228 
    11321229   /*! 
     
    11371234   */ 
    11381235   void CFile::sendAddAllVariables(CContextClient* client) 
     1236   TRY 
    11391237   { 
    11401238     std::vector<CVariable*> allVar = getAllVariables(); 
     
    11491247     } 
    11501248   } 
     1249   CATCH_DUMP_ATTR 
    11511250 
    11521251   /*! 
     
    11561255   */ 
    11571256   void CFile::sendAddVariableGroup(const string& id, CContextClient* client) 
     1257   TRY 
    11581258   { 
    11591259      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE_GROUP, client); 
    11601260   } 
     1261   CATCH_DUMP_ATTR 
    11611262 
    11621263   /* 
     
    11661267   */ 
    11671268   void CFile::sendAddVariable(const string& id, CContextClient* client) 
     1269   TRY 
    11681270   { 
    11691271      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE, client); 
    11701272   } 
     1273   CATCH_DUMP_ATTR 
    11711274 
    11721275   /*! 
     
    11751278   */ 
    11761279   void CFile::recvAddVariable(CEventServer& event) 
    1177    { 
    1178  
     1280   TRY 
     1281   { 
    11791282      CBufferIn* buffer = event.subEvents.begin()->buffer; 
    11801283      string id; 
     
    11821285      get(id)->recvAddVariable(*buffer); 
    11831286   } 
     1287   CATCH 
    11841288 
    11851289   /*! 
     
    11881292   */ 
    11891293   void CFile::recvAddVariable(CBufferIn& buffer) 
     1294   TRY 
    11901295   { 
    11911296      string id; 
     
    11931298      addVariable(id); 
    11941299   } 
     1300   CATCH_DUMP_ATTR 
    11951301 
    11961302   /*! 
     
    11991305   */ 
    12001306   void CFile::recvAddVariableGroup(CEventServer& event) 
     1307   TRY 
    12011308   { 
    12021309 
     
    12061313      get(id)->recvAddVariableGroup(*buffer); 
    12071314   } 
     1315   CATCH 
    12081316 
    12091317   /*! 
     
    12121320   */ 
    12131321   void CFile::recvAddVariableGroup(CBufferIn& buffer) 
     1322   TRY 
    12141323   { 
    12151324      string id; 
     
    12171326      addVariableGroup(id); 
    12181327   } 
     1328   CATCH_DUMP_ATTR 
    12191329 
    12201330   /*! 
     
    12261336   */ 
    12271337   void CFile::sendEnabledFields(CContextClient* client) 
     1338   TRY 
    12281339   { 
    12291340     size_t size = this->enabledFields.size(); 
     
    12371348     } 
    12381349   } 
    1239  
     1350   CATCH_DUMP_ATTR 
    12401351 
    12411352   /*! 
     
    12471358   */ 
    12481359   bool CFile::dispatchEvent(CEventServer& event) 
     1360   TRY 
    12491361   { 
    12501362      if (SuperClass::dispatchEvent(event)) return true; 
     
    12781390      } 
    12791391   } 
    1280  
    1281  
    1282  
     1392   CATCH 
     1393 
     1394   ///-------------------------------------------------------------- 
     1395   /*! 
     1396   */ 
     1397   StdString CFile::dumpClassAttributes(void) 
     1398   { 
     1399     StdString str; 
     1400     CContext* context = CContext::getCurrent(); 
     1401     str.append("context=\""); 
     1402     str.append(context->getId()); 
     1403     str.append("\""); 
     1404     str.append(" enabled fields=\""); 
     1405     int size = this->enabledFields.size(); 
     1406     for (int i = 0; i < size; ++i) 
     1407     { 
     1408       str.append(this->enabledFields[i]->getId()); 
     1409       str.append(" "); 
     1410     } 
     1411     str.append("\""); 
     1412     return str; 
     1413   } 
    12831414 
    12841415   ///--------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.