Refactoring the main function, added submethod. Removed valgrind uninitialized error
This commit is contained in:
parent
3516b7d25c
commit
e42a7a3a97
@ -9,6 +9,26 @@
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
|
||||
|
||||
void printDeckDiagnostics(Opm::DeckConstPtr deck, bool printAllKeywords) {
|
||||
int recognizedKeywords = 0;
|
||||
int unrecognizedKeywords = 0;
|
||||
for (size_t i = 0; i < deck->size(); i++) {
|
||||
if (!deck->getKeyword(i)->isKnown()) {
|
||||
unrecognizedKeywords++;
|
||||
std::cout << "Warning, this looks like a keyword, but is not in the configuration: " << deck->getKeyword(i)->name() << std::endl;
|
||||
} else
|
||||
recognizedKeywords++;
|
||||
|
||||
if (printAllKeywords) {
|
||||
std::cout << "Keyword (" << i << "): " << deck->getKeyword(i)->name() << " " << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << "Number of recognized keywords: " << recognizedKeywords << std::endl;
|
||||
std::cout << "Number of unrecognized keywords: " << unrecognizedKeywords << std::endl;
|
||||
std::cout << "Total number of keywords: " << deck->size() << std::endl;
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@ -18,38 +38,19 @@ int main(int argc, char** argv) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bool showKeywords = false;
|
||||
bool printKeywords = false;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
std::string arg(argv[i]);
|
||||
if (arg == "-a")
|
||||
showKeywords = true;
|
||||
printKeywords = true;
|
||||
}
|
||||
|
||||
try {
|
||||
Opm::ParserPtr parser(new Opm::Parser(JSON_CONFIG_FILE));
|
||||
std::string file = argv[1];
|
||||
Opm::DeckConstPtr deck = parser->parse(file);
|
||||
int recognizedKeywords = 0;
|
||||
int unrecognizedKeywords = 0;
|
||||
for (size_t i = 0; i < deck->size(); i++) {
|
||||
if (!deck->getKeyword(i)->isKnown()) {
|
||||
unrecognizedKeywords++;
|
||||
std::cout << "Warning, this looks like a keyword, but is not in the configuration: " << deck->getKeyword(i)->name() << std::endl;
|
||||
}
|
||||
else
|
||||
recognizedKeywords++;
|
||||
Opm::ParserPtr parser(new Opm::Parser(JSON_CONFIG_FILE));
|
||||
std::string file = argv[1];
|
||||
Opm::DeckConstPtr deck = parser->parse(file);
|
||||
|
||||
printDeckDiagnostics(deck, printKeywords);
|
||||
|
||||
if (showKeywords) {
|
||||
std::cout << "Keyword (" << i << "): " << deck->getKeyword(i)->name() << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << "Number of recognized keywords: " << recognizedKeywords << std::endl;
|
||||
std::cout << "Number of unrecognized keywords: " << unrecognizedKeywords << std::endl;
|
||||
std::cout << "Total number of keywords: " << deck->size() << std::endl;
|
||||
|
||||
} catch (std::invalid_argument exception) {
|
||||
std::cout << "Unable to read file, error:" << std::endl << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace Opm {
|
||||
|
||||
void RawRecord::splitSingleRecordString() {
|
||||
char currentChar;
|
||||
char tokenStartCharacter;
|
||||
char tokenStartCharacter=' ';
|
||||
std::string currentToken = "";
|
||||
for (unsigned i = 0; i < m_sanitizedRecordString.size(); i++) {
|
||||
currentChar = m_sanitizedRecordString[i];
|
||||
|
Loading…
Reference in New Issue
Block a user