diff --git a/src/phasicFlow/globals/error.cpp b/src/phasicFlow/globals/error.cpp index 7b0d3bc5..bd6a754a 100644 --- a/src/phasicFlow/globals/error.cpp +++ b/src/phasicFlow/globals/error.cpp @@ -69,7 +69,7 @@ pFlow::ioErrorMessage( ) { errorStream << "\n>>> Fatal IO file error\n" - << " IO error at number " << Red_Text(fileLineNumber) + << " IO error at number " << Red_Text(fileLineNumber+1) << " of file " << Red_Text(fileName) << '\n'; errorStream << " IO operation is peformed from function " << Red_Text(fnName) << " in file " << Red_Text(fName) diff --git a/src/phasicFlow/streams/token/token.hpp b/src/phasicFlow/streams/token/token.hpp index c0ba324f..ba12076c 100755 --- a/src/phasicFlow/streams/token/token.hpp +++ b/src/phasicFlow/streams/token/token.hpp @@ -356,7 +356,7 @@ public: /// Token is WORD, DIRECTIVE, STRING, VARIABLE or VERBATIM inline bool isStringType() const; - + inline bool isComma()const; //- Access /// Return boolean token value. diff --git a/src/phasicFlow/streams/token/tokenI.hpp b/src/phasicFlow/streams/token/tokenI.hpp index 459018e7..db3f62b3 100755 --- a/src/phasicFlow/streams/token/tokenI.hpp +++ b/src/phasicFlow/streams/token/tokenI.hpp @@ -673,6 +673,13 @@ inline bool pFlow::token::isStringType() const return (isWord() || isString()); } +inline bool pFlow::token::isComma()const +{ + if( type_ == tokenType::PUNCTUATION && + pToken() == punctuationToken::COMMA) return true; + return false; +} + inline void pFlow::token::setBad() { reset(); diff --git a/utilities/particlesPhasicFlow/positionFile/positionFile.cpp b/utilities/particlesPhasicFlow/positionFile/positionFile.cpp index ebcbf7dd..cd55ab12 100755 --- a/utilities/particlesPhasicFlow/positionFile/positionFile.cpp +++ b/utilities/particlesPhasicFlow/positionFile/positionFile.cpp @@ -42,39 +42,72 @@ bool pFlow::positionFile::positionPointsFile() token tok; - while (!is.eof() || !is.bad()) + while (!is.bad()) { // read position x - is >> tempPoint.x_; + + is >> tok; + if(tok.good()&& tok.isNumber()&& !is.eof()) + { + tempPoint.x() = tok.realToken(); + } + else + { + ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading position x!\n"; + return false; + } if(commaSeparated_) { is >> tok; - if(tok.type() != token::COMMA) + if( !tok.isComma() || is.eof()) { - fatalErrorInFunction << "Error datafile format, the data not comma separated!"; + ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading comma!\n"; return false; } } // read position y - is >> tempPoint.y_; + is >> tok; + if(tok.good()&& tok.isNumber()&& !is.eof()) + { + tempPoint.y() = tok.realToken(); + } + else + { + ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading position y!\n"; + return false; + } if(commaSeparated_) { is >> tok; - if(tok.type() != token::COMMA) + if(!tok.isComma() || is.eof()) { - fatalErrorInFunction << "Error datafile format, the data not comma separated!"; + ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading comma!\n"; return false; } } // read position z - is >> tempPoint.z_; + is >> tok; + if(tok.good()&& tok.isNumber()&& !is.eof()) + { + tempPoint.z() = tok.realToken(); + } + else + { + ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading position z!\n"; + return false; + } // insert position data to vector position_.push_back(tempPoint); + + is>>tok; + if(is.eof()) break; + + is.putBack(tok); } REPORT(0) << "Done!" << END_REPORT; @@ -104,7 +137,7 @@ pFlow::positionFile::positionFile position_ ( "position", - max(maxNumberOfParticles(), position_.size()), + 1, 0, RESERVE() )