From 06e7a4b980839df4e36513ab06f0d96303577dc5 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot <mouginot.baptiste@gmail.com> Date: Tue, 8 Jul 2014 12:43:59 +0000 Subject: [PATCH] correction of the AddToStock Segmentation Fault, make the prompt shorter :) git-svn-id: svn+ssh://svn.in2p3.fr/class@316 0e7d625b-0364-4367-a6be-d5be4a48d228 --- source/branches/CLASSV3/include/Storage.hxx | 3 +- source/branches/CLASSV3/src/EvolutionData.cxx | 26 ++++---- source/branches/CLASSV3/src/Scenario.cxx | 8 +-- source/branches/CLASSV3/src/Storage.cxx | 63 ++++++++++++++----- 4 files changed, 68 insertions(+), 32 deletions(-) diff --git a/source/branches/CLASSV3/include/Storage.hxx b/source/branches/CLASSV3/include/Storage.hxx index 60388f9da..666db1ec2 100644 --- a/source/branches/CLASSV3/include/Storage.hxx +++ b/source/branches/CLASSV3/include/Storage.hxx @@ -110,7 +110,8 @@ public : void TakeFromStock(IsotopicVector isotopicvector); //!< - void AddIV(IsotopicVector isotopicvector); //!< Add an Isotopicvector to the IVArray + void AddIV(IsotopicVector isotopicvector); //!< Add an Isotopicvector to the IVArray + void AddToStock(IsotopicVector isotopicvector) {AddIV(isotopicvector);} //!< Add an Isotopicvector to the IVArray //@} diff --git a/source/branches/CLASSV3/src/EvolutionData.cxx b/source/branches/CLASSV3/src/EvolutionData.cxx index e63fda7ea..c9faec54d 100755 --- a/source/branches/CLASSV3/src/EvolutionData.cxx +++ b/source/branches/CLASSV3/src/EvolutionData.cxx @@ -533,7 +533,7 @@ double EvolutionData::GetXSForAt(double t, ZAI zai, int ReactionId) break; case 3: XSEvol = Getn2nXS(); break; - default:ERROR << "!!Error!! !!!EvolutionData!!! \n Wrong ReactionId !!" << endl; + default:ERROR << " Wrong ReactionId !!" << endl; exit(1); } @@ -579,7 +579,7 @@ void EvolutionData::ReadDB(string DBfile, bool oldread) ifstream DecayDB(DBfile.c_str()); // Open the File if(!DecayDB) //check if file is correctly open { - INFO << "!!Warning!! !!!EvolutionData!!! \n Can't open \"" << DBfile << "\"\n" << endl; + INFO << " \n Can't open \"" << DBfile << "\"\n" << endl; } vector<double> vTime; @@ -589,8 +589,8 @@ void EvolutionData::ReadDB(string DBfile, bool oldread) getline(DecayDB, line); if( tlc(StringLine::NextWord(line, start, ' ')) != "time") { - ERROR << "!!Bad Trouble!! !!!EvolutionData!!! Bad Database file : " << DBfile << endl; - ERROR << "!!Bad Trouble!! !!!EvolutionData!!! The first Line MUST be the time line !!!" << endl; + ERROR << " Bad Database file : " << DBfile << endl; + ERROR << " The first Line MUST be the time line !!!" << endl; exit (1); } @@ -684,7 +684,7 @@ void EvolutionData::ReadKeff(string line, double* time, int NTimeStep) int start = 0; if( tlc(StringLine::NextWord(line, start, ' ')) != "keff" ) // Check the keyword { - ERROR << "!!ERROR!! !!!EvolutionData!!! \n Bad keyword : \"keff\" not found !" << endl; + ERROR << " Bad keyword : \"keff\" not found !" << endl; exit(1); } @@ -716,7 +716,7 @@ void EvolutionData::ReadFlux(string line, double* time, int NTimeStep) if( tlc(StringLine::NextWord(line, start, ' ')) != "flux" ) // Check the keyword { - ERROR << "!!ERROR!! !!!EvolutionData!!! \n Bad keyword : \"flux\" not found !" << endl; + ERROR << " Bad keyword : \"flux\" not found !" << endl; exit(1); } @@ -744,7 +744,7 @@ void EvolutionData::ReadInv(string line, double* time, int NTimeStep) int start = 0; if( tlc(StringLine::NextWord(line, start, ' ')) != "inv" ) // Check the keyword { - ERROR << "!!ERROR!! !!!EvolutionData!!! \n Bad keyword : \"inv\" not found !" << endl; + ERROR << " Bad keyword : \"inv\" not found !" << endl; exit(1); } // Read the Z A I @@ -777,7 +777,7 @@ void EvolutionData::ReadXSFis(string line, double* time, int NTimeStep) int start = 0; if( tlc(StringLine::NextWord(line, start, ' ')) != "xsfis" ) // Check the keyword { - ERROR << "!!ERROR!! !!!EvolutionData!!! \n Bad keyword : \"xsfis\" not found !" << endl; + ERROR << " Bad keyword : \"xsfis\" not found !" << endl; exit(1); } // Read the Z A I @@ -810,7 +810,7 @@ void EvolutionData::ReadXSCap(string line, double* time, int NTimeStep) int start = 0; if( tlc(StringLine::NextWord(line, start, ' ')) != "xscap" ) // Check the keyword { - ERROR << "!!ERROR!! !!!EvolutionData!!! \n Bad keyword : \"xscap\" not found !" << endl; + ERROR << " Bad keyword : \"xscap\" not found !" << endl; exit(1); } // Read the Z A I @@ -843,7 +843,7 @@ void EvolutionData::ReadXSn2n(string line, double* time, int NTimeStep) int start = 0; if( tlc(StringLine::NextWord(line, start, ' ')) != "xsn2n" ) // Check the keyword { - ERROR << "!!ERROR!! !!!EvolutionData!!! \n Bad keyword : \"xsn2n\" not found !" << endl; + ERROR << " Bad keyword : \"xsn2n\" not found !" << endl; exit(1); } // Read the Z A I @@ -920,7 +920,7 @@ void EvolutionData::OldReadDB(string DBfile) ifstream DecayDB(DBfile.c_str()); // Open the File if(!DecayDB) { - WARNING << "!!Warning!! !!!EvolutionData!!! \n Can't open \"" << DBfile << "\"\n" << endl; + WARNING << " Can't open \"" << DBfile << "\"\n" << endl; } vector<double> vTime; vector<double> vTimeErr; @@ -931,7 +931,7 @@ void EvolutionData::OldReadDB(string DBfile) getline(DecayDB, line); if( StringLine::NextWord(line, start, ' ') != "time") { - ERROR << "!!Bad Trouble!! !!!EvolutionData!!! Bad Database file : " << DBfile << endl; + ERROR << " Bad Database file : " << DBfile << endl; exit (1); } @@ -1132,7 +1132,7 @@ void EvolutionData::OldReadDB(string DBfile) ifstream InfoDB(InfoDBFile.c_str()); // Open the File if(!InfoDB) { - WARNING << "!!Warning!! !!!EvolutionData!!! \n Can't open \"" << InfoDBFile << "\"\n" << endl; + WARNING << " Can't open \"" << InfoDBFile << "\"\n" << endl; return; } diff --git a/source/branches/CLASSV3/src/Scenario.cxx b/source/branches/CLASSV3/src/Scenario.cxx index af5d3f838..e8da21322 100755 --- a/source/branches/CLASSV3/src/Scenario.cxx +++ b/source/branches/CLASSV3/src/Scenario.cxx @@ -772,14 +772,14 @@ void Scenario::ProgressPrintout(cSecond t) double Total = (t-fStartingTime)/3600/24/365.25; // Reset the line - for(int i = 0; i < 100; i++) + for(int i = 0; i < 10; i++) cout << " "; cout << flush ; cout << "\r["; - for(int i = 0; i < (int)(Time/Total*100.0); i++) + for(int i = 0; i < (int)(Time/Total*20.0); i++) cout << "|"; - for(int i = 100; i >= (int)(Time/Total*100.0); i--) + for(int i = 20; i >= (int)(Time/Total*20.0); i--) cout << "-"; cout << "] "; @@ -787,7 +787,7 @@ void Scenario::ProgressPrintout(cSecond t) if (Time < 10) cout << " "; if (Time < 100) cout << " "; cout << (int)Time << " / " << (int)Total << " Years \r"; - if(fLog->GetVerboseLVL() < 2) cout << flush; + if( fLog->GetVerboseLVL() < 2) cout << flush; else cout << endl; diff --git a/source/branches/CLASSV3/src/Storage.cxx b/source/branches/CLASSV3/src/Storage.cxx index 2ce36f408..93ce0a5df 100644 --- a/source/branches/CLASSV3/src/Storage.cxx +++ b/source/branches/CLASSV3/src/Storage.cxx @@ -63,7 +63,15 @@ void Storage::AddIV(IsotopicVector isotopicvector) AddCumulativeIVIn(isotopicvector); - if(GetParc()->GetStockManagement() ) + if(GetParc()) + { + if(GetParc()->GetStockManagement() ) + { + fIVArray.push_back(isotopicvector); + fIVArrayArrivalTime.push_back(fInternalTime); + } + } + else { fIVArray.push_back(isotopicvector); fIVArrayArrivalTime.push_back(fInternalTime); @@ -76,13 +84,37 @@ void Storage::AddIV(IsotopicVector isotopicvector) void Storage::TakeFractionFromStock(int IVId,double fraction) { - if(GetParc()->GetStockManagement() ) + if(GetParc()) + { + if(GetParc()->GetStockManagement() ) + { + if(fraction > 1 || fraction < 0) + { + WARNING << " You try to remove fraction superior than 1 or a negative one..." << endl; + } + else + { + AddCumulativeIVOut(fIVArray[IVId]*fraction); + + fInsideIV -= fIVArray[IVId] * fraction; + fIVArray[IVId] -= fIVArray[IVId] * fraction; + } + + } + else + { + ERROR << " TakeFractionFromStock can't be DEFINE without REAL stock management" << endl; + exit(1); + + } + } + else { if(fraction > 1 || fraction < 0) { WARNING << " You try to remove fraction superior than 1 or a negative one..." << endl; } - else + else { AddCumulativeIVOut(fIVArray[IVId]*fraction); @@ -91,12 +123,6 @@ void Storage::TakeFractionFromStock(int IVId,double fraction) } } - else - { - ERROR << " TakeFractionFromStock can't be DEFINE without REAL stock management" << endl; - exit(1); - - } @@ -105,16 +131,25 @@ void Storage::TakeFractionFromStock(int IVId,double fraction) void Storage::TakeFromStock(IsotopicVector isotopicvector) { - if(!GetParc()->GetStockManagement()) + if(GetParc()) { + if(!GetParc()->GetStockManagement()) + { - AddCumulativeIVOut(isotopicvector); - fInsideIV -= isotopicvector; + AddCumulativeIVOut(isotopicvector); + fInsideIV -= isotopicvector; + } + else + { + ERROR << " TakeFromStock can't be DEFINE WITH REAL stock management" << endl; + exit(1); + } } else { - ERROR << " TakeFromStock can't be DEFINE WITH REAL stock management" << endl; - exit(1); + AddCumulativeIVOut(isotopicvector); + fInsideIV -= isotopicvector; + } } -- GitLab