Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetErrorStringLineCount and GetErrorStringLine return empty lines for some errors #6

Open
scharlton2 opened this issue Jan 12, 2023 · 0 comments

Comments

@scharlton2
Copy link
Contributor

scharlton2 commented Jan 12, 2023

Example:

id = CreateIphreeqc()

if (id .LT. 0) stop

res = SetErrorStringOn(id, .TRUE.)

res = LoadDatabase(id, 'phreeqc.dat')

res = AccumulateLine(id,"SOLUTION")
res = AccumulateLine(id,"pH abc")
res = AccumulateLine(id,"xx")

res = RunAccumulated(id)

if (res .NE. 0) then
   do i = 1, GetErrorStringLineCount(id)
      call GetErrorStringLine(id,i,Line)
      write (*,'(I0,1x,A)') i, trim(line)
   enddo
endif

write (*,'(/"Returned accumulating line with ",I0," errors."/)') res

Outputs:

1
2 ERROR: Concentration data error for ph in solution input.
3
4 ERROR: No element or master species given for concentration input.
5 ERROR: Calculations terminating due to input errors.

Returned accumulating line with 2 errors.

Cause

Empty line is added here (Line 42):

void PHRQ_base::
error_msg(const std::string & stdstr, int stop)
{
this->base_error_count++;
std::ostringstream msg;
msg << "ERROR: " << stdstr << "\n";
if (this->io)
{
this->io->output_msg(msg.str().c_str());
this->io->log_msg(msg.str().c_str());
this->io->error_msg("\n");
this->io->error_msg(msg.str().c_str(), stop!=0);
}
else
{
#if !defined(R_SO)
std::cerr << msg.str().c_str();
std::cout << msg.str().c_str();
#endif
}
if (stop != 0)
{
throw PhreeqcStop();
}
}

Proposed fix

modify IPhreeqc::update_errors to skip calling this->ErrorLines.push_back(line); for empty lines.

scharlton2 pushed a commit that referenced this issue Mar 9, 2023
c3ed55b0 Introduce end-of-line normalization (#6)

git-subtree-dir: phreeqc3-doc
git-subtree-split: c3ed55b0e443c4ea3b85ecfc4fd8c78416a53321
scharlton2 pushed a commit that referenced this issue Mar 9, 2023
91aa5fd8 Introduce end-of-line normalization (#6)

git-subtree-dir: database
git-subtree-split: 91aa5fd89b2f211b1dc85020c227df1a35676318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant