usgs-coupled / iphreeqc

5 stars 4 forks source link

GetErrorStringLineCount and GetErrorStringLine return empty lines for some errors #6

Open scharlton2 opened 1 year ago

scharlton2 commented 1 year ago

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):

https://github.com/usgs-coupled/iphreeqc/blob/cfe6dec984bdf0362585743caf1b5d8d0000d0de/src/phreeqcpp/common/PHRQ_base.cxx#L32-L56

Proposed fix

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