IPhreeqc: IPhreeqc Library Documentation (3.7.1-15876)

IPhreeqc
  • Home
  • C/Fortran Documentation
  • C++ Documentation
  • IPhreeqc VARIANT Documentation
IPhreeqc Library Documentation (3.7.1-15876)

IPhreeqc.h | C/Fortran Documentation
IPhreeqc.hpp | C++ Documentation
Var.h | IPhreeqc VARIANT Documentation

Generated by doxygen 1.8.10


IPhreeqc: IPhreeqc Class Reference

  • C++ Documentation
  • IPhreeqc VARIANT Documentation
Public Member Functions | Static Public Member Functions
IPhreeqc Class Reference

Provides an interface to PHREEQC (Version 3)–A Computer Program for Speciation, Batch-Reaction, One-Dimensional Transport, and Inverse Geochemical Calculations. More...

#include <IPhreeqc.hpp>

Inheritance diagram for IPhreeqc:

Public Member Functions

IPhreeqc (void)
virtual | ~IPhreeqc (void)
VRESULT | AccumulateLine (const char *line)
size_t | AddError (const char *error_msg)
size_t | AddWarning (const char *warning_msg)
void | ClearAccumulatedLines (void)
const std::string & | GetAccumulatedLines (void)
const char * | GetComponent (int n)
size_t | GetComponentCount (void)
int | GetCurrentSelectedOutputUserNumber (void) const
const char * | GetDumpFileName (void) const
bool | GetDumpFileOn (void) const
const char * | GetDumpString (void) const
const char * | GetDumpStringLine (int n)
int | GetDumpStringLineCount (void) const
bool | GetDumpStringOn (void) const
const char * | GetErrorFileName (void) const
bool | GetErrorFileOn (void) const
bool | GetErrorOn (void) const
const char * | GetErrorString (void)
const char * | GetErrorStringLine (int n)
int | GetErrorStringLineCount (void) const
bool | GetErrorStringOn (void) const
int | GetId (void) const
const char * | GetLogFileName (void) const
bool | GetLogFileOn (void) const
const char * | GetLogString (void) const
const char * | GetLogStringLine (int n) const
int | GetLogStringLineCount (void) const
bool | GetLogStringOn (void) const
int | GetNthSelectedOutputUserNumber (int n) const
const char * | GetOutputFileName (void) const
bool | GetOutputFileOn (void) const
const char * | GetOutputString (void) const
const char * | GetOutputStringLine (int n) const
int | GetOutputStringLineCount (void) const
bool | GetOutputStringOn (void) const
int | GetSelectedOutputColumnCount (void) const
int | GetSelectedOutputCount (void) const
const char * | GetSelectedOutputFileName (void) const
bool | GetSelectedOutputFileOn (void) const
int | GetSelectedOutputRowCount (void) const
const char * | GetSelectedOutputString (void) const
const char * | GetSelectedOutputStringLine (int n)
int | GetSelectedOutputStringLineCount (void) const
bool | GetSelectedOutputStringOn (void) const
VRESULT | GetSelectedOutputValue (int row, int col, VAR *pVAR)
VRESULT | GetSelectedOutputValue2 (int row, int col, int *vtype, double *dvalue, char *svalue, unsigned int svalue_length)
const char * | GetWarningString (void)
const char * | GetWarningStringLine (int n)
int | GetWarningStringLineCount (void) const
std::list< std::string > | ListComponents (void)
int | LoadDatabase (const char *filename)
int | LoadDatabaseString (const char *input)
void | OutputAccumulatedLines (void)
void | OutputErrorString (void)
void | OutputWarningString (void)
int | RunAccumulated (void)
int | RunFile (const char *filename)
int | RunString (const char *input)
void | SetBasicCallback (double(*fcn)(double x1, double x2, const char *str, void *cookie), void *cookie1)
void | SetBasicFortranCallback (double(*fcn)(double *x1, double *x2, const char *str, int l))
VRESULT | SetCurrentSelectedOutputUserNumber (int n)
void | SetDumpFileName (const char *filename)
void | SetDumpFileOn (bool bValue)
void | SetDumpStringOn (bool bValue)
void | SetErrorFileName (const char *filename)
void | SetErrorFileOn (bool bValue)
void | SetErrorOn (bool bValue)
void | SetErrorStringOn (bool bValue)
void | SetLogFileName (const char *filename)
void | SetLogFileOn (bool bValue)
void | SetLogStringOn (bool bValue)
void | SetOutputFileName (const char *filename)
void | SetOutputFileOn (bool bValue)
void | SetOutputStringOn (bool bValue)
void | SetSelectedOutputFileName (const char *filename)
void | SetSelectedOutputFileOn (bool bValue)
void | SetSelectedOutputStringOn (bool bValue)

Static Public Member Functions

static const char * GetVersionString (void)

Detailed Description

Provides an interface to PHREEQC (Version 3)–A Computer Program for Speciation, Batch-Reaction, One-Dimensional Transport, and Inverse Geochemical Calculations.

Constructor & Destructor Documentation

IPhreeqc::IPhreeqc ( void )

Constructor.

Example:
#include <cstdlib>
#include <iostream>
#include <IPhreeqc.hpp>
int main(void)
{
IPhreeqc iphreeqc;
if (iphreeqc.LoadDatabase("phreeqc.dat") != 0) {
std::cout << iphreeqc.GetErrorString() << std::endl;
return EXIT_FAILURE;
}
iphreeqc.AccumulateLine("TITLE Example 2.--Temperature dependence of solubility");
iphreeqc.AccumulateLine(" of gypsum and anhydrite ");
iphreeqc.AccumulateLine("SOLUTION 1 Pure water ");
iphreeqc.AccumulateLine(" pH 7.0 ");
iphreeqc.AccumulateLine(" temp 25.0 ");
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 1 ");
iphreeqc.AccumulateLine(" Gypsum 0.0 1.0 ");
iphreeqc.AccumulateLine(" Anhydrite 0.0 1.0 ");
iphreeqc.AccumulateLine("REACTION_TEMPERATURE 1 ");
iphreeqc.AccumulateLine(" 25.0 75.0 in 51 steps ");
iphreeqc.AccumulateLine("SELECTED_OUTPUT ");
iphreeqc.AccumulateLine(" -file ex2.sel ");
iphreeqc.AccumulateLine(" -temperature ");
iphreeqc.AccumulateLine(" -si anhydrite gypsum ");
iphreeqc.AccumulateLine("END ");
if (iphreeqc.RunAccumulated() != 0) {
std::cout << iphreeqc.GetErrorString() << std::endl;
return EXIT_FAILURE;
}
VAR v;
::VarInit(&v);
std::cout << "selected-output:" << std::endl;
for (int i = 0; i < iphreeqc.GetSelectedOutputRowCount(); ++i) {
for (int j = 0; j < iphreeqc.GetSelectedOutputColumnCount(); ++j) {
if (iphreeqc.GetSelectedOutputValue(i, j, &v) == VR_OK) {
switch (v.type) {
case TT_LONG:
std::cout << v.lVal << " ";
break;
case TT_DOUBLE:
std::cout << v.dVal << " ";
break;
case TT_STRING:
std::cout << v.sVal << " ";
break;
case TT_EMPTY:
std::cout << "<empty> ";
break;
case TT_ERROR:
std::cout << "<error> ";
break;
}
}
::VarClear(&v);
}
std::cout << std::endl;
}
return EXIT_SUCCESS;
}
virtual IPhreeqc::~IPhreeqc ( void )
virtual

Destructor

Member Function Documentation

VRESULT IPhreeqc::AccumulateLine ( const char * line )

Accumlulate line(s) for input to phreeqc.

Parameters
line The line(s) to add for input to phreeqc.
Return values
VR_OK | Success
VR_OUTOFMEMORY | Out of memory
See also
ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated
size_t IPhreeqc::AddError ( const char * error_msg )

Appends the given error message and increments the error count. Internally used to create an error condition.

Parameters
error_msg The error message to display.
Returns
The current error count.
See also
GetErrorString, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString
size_t IPhreeqc::AddWarning ( const char * warning_msg )

Appends the given warning message and increments the warning count. Internally used to create a warning condition.

Parameters
warning_msg The warning message to display.
Returns
The current warning count.
See also
GetWarningString, GetWarningStringLine, GetWarningStringLineCount, OutputWarningString
void IPhreeqc::ClearAccumulatedLines ( void )

Clears the accumulated input buffer. Input buffer is accumulated from calls to AccumulateLine.

See also
AccumulateLine, GetAccumulatedLines, OutputAccumulatedLines, RunAccumulated
const std::string& IPhreeqc::GetAccumulatedLines ( void )

Retrieve the accumulated input string. The accumulated input string can be run with RunAccumulated.

Returns
The accumulated input string.
See also
AccumulateLine, ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated
const char* IPhreeqc::GetComponent ( int n )

Retrieves the given component.

Parameters
n The zero-based index of the component to retrieve.
Returns
A null terminated string containing the given component. Returns an empty string if n is out of range.
See also
GetComponentCount, ListComponents
size_t IPhreeqc::GetComponentCount ( void )

Retrieves the number of components in the current list of components.

Returns
The current count of components.
See also
GetComponent, ListComponents
int IPhreeqc::GetCurrentSelectedOutputUserNumber ( void ) const

Retrieves the current SELECTED_OUTPUT user number. The initial setting is 1.

Returns
The current SELECTED_OUTPUT user number.
See also
GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber
const char* IPhreeqc::GetDumpFileName ( void ) const

Retrieves the name of the dump file. This file name is used if not specified within DUMP input. The default value is dump.id.out, where id is obtained from GetId.

Returns
filename The name of the file to write DUMP output to.
See also
GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileName, SetDumpFileOn, SetDumpStringOn
bool IPhreeqc::GetDumpFileOn ( void ) const

Retrieves the current value of the dump file switch.

Return values
true | Output is written to the DUMP (dump.id.out if unspecified, where id is obtained from GetId) file.
false | No output is written.
See also
GetDumpStringLine, GetDumpStringLineCount, GetDumpStringOn, GetDumpString, SetDumpFileOn, SetDumpStringOn
const char* IPhreeqc::GetDumpString ( void ) const

Retrieves the string buffer containing DUMP output.

Returns
A null terminated string containing DUMP output.
Precondition
SetDumpStringOn must have been set to true in order to receive DUMP output.
See also
GetDumpStringLine, GetDumpFileOn, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
const char* IPhreeqc::GetDumpStringLine ( int n )

Retrieves the given dump line.

Parameters
n The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition
SetDumpStringOn must have been set to true.
See also
GetDumpFileOn, GetDumpString, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
int IPhreeqc::GetDumpStringLineCount ( void ) const

Retrieves the number of lines in the current dump string buffer.

Returns
The number of lines.
Precondition
SetDumpStringOn must have been set to true.
See also
GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
bool IPhreeqc::GetDumpStringOn ( void ) const

Retrieves the current value of the dump string switch.

Return values
true | Output defined by the DUMP keyword is stored.
false | No output is stored.
See also
GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn, SetDumpStringOn
const char* IPhreeqc::GetErrorFileName ( void ) const

Retrieves the name of the error file. The default value is phreeqc.id.err, where id is obtained from GetId.

Returns
filename The name of the file to write to.
See also
GetErrorFileOn, GetErrorString, GetErrorStringOn, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileName, SetErrorFileOn, SetErrorStringOn
bool IPhreeqc::GetErrorFileOn ( void ) const

Retrieves the current value of the error file switch.

Return values
true | Errors are written to the phreeqc.id.err (where id is obtained from GetId) file.
false | No errors are written.
See also
SetErrorFileOn
bool IPhreeqc::GetErrorOn ( void ) const

Retrieves the current value of the error switch.

Return values
true | Error messages are sent to the error file and to the string buffer
false | No errors are sent.
See also
SetErrorOn
const char* IPhreeqc::GetErrorString ( void )

Retrieves the error messages from the last call to RunAccumulated, RunFile, RunString, LoadDatabase, or LoadDatabaseString.

Returns
A null terminated string containing error messages.
See also
GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString, SetErrorFileOn
const char* IPhreeqc::GetErrorStringLine ( int n )

Retrieves the given error line.

Returns
A null terminated string containing the given line of the error string buffer.
Parameters
n The zero-based index of the line to retrieve.
See also
GetErrorStringLineCount, OutputErrorString
int IPhreeqc::GetErrorStringLineCount ( void ) const

Retrieves the number of lines in the current error string buffer.

Returns
The number of lines.
See also
GetErrorStringLine, OutputErrorString
bool IPhreeqc::GetErrorStringOn ( void ) const

Retrieves the current value of the error string switch.

Return values
true | Error output is stored.
false | No error output is stored.
See also
GetErrorFileOn, GetErrorString, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn, SetErrorStringOn
int IPhreeqc::GetId ( void ) const

Retrieves the id of this object. Each instance receives an id which is incremented for each instance starting with the value zero.

Returns
The id.
const char* IPhreeqc::GetLogFileName ( void ) const

Retrieves the name of the log file. The default value is phreeqc.id.log, where id is obtained from GetId.

Returns
filename The name of the file to write to.
See also
GetLogFileOn, GetLogString, GetLogStringOn, GetLogStringLine, GetLogStringLineCount, SetLogFileName, SetLogFileOn, SetLogStringOn
bool IPhreeqc::GetLogFileOn ( void ) const

Retrieves the current value of the log file switch.

Return values
true | Log messages are written to the phreeqc.id.log (where id is obtained from GetId) file.
false | No log messages are written.
Remarks
Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also
SetLogFileOn
const char* IPhreeqc::GetLogString ( void ) const

Retrieves the string buffer containing phreeqc log output.

Returns
A null terminated string containing log output.
Precondition
SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also
GetLogStringLine, GetLogFileOn, GetLogStringLineCount, GetLogStringOn, SetLogFileOn, SetLogStringOn
const char* IPhreeqc::GetLogStringLine ( int n ) const

Retrieves the given log line.

Parameters
n The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition
SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also
GetLogFileOn, GetLogString, GetLogStringLineCount, GetLogStringOn, SetLogFileOn, SetLogStringOn
int IPhreeqc::GetLogStringLineCount ( void ) const

Retrieves the number of lines in the current log string buffer.

Returns
The number of lines.
Precondition
SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also
GetLogFileOn, GetLogString, GetLogStringLine, GetLogStringOn, SetLogFileOn, SetLogStringOn
bool IPhreeqc::GetLogStringOn ( void ) const

Retrieves the current value of the log string switch.

Return values
true | Log output is stored.
false | No log output is stored.
See also
GetLogFileOn, GetLogString, GetLogStringLine, GetLogStringLineCount, SetLogFileOn, SetLogStringOn
int IPhreeqc::GetNthSelectedOutputUserNumber ( int n ) const

Retrieves the nth user number of the currently defined SELECTED_OUTPUT blocks.

Parameters
n The zero-based index of the SELECTED_OUTPUT user number to retrieve.
Returns
The nth defined user number; a negative value indicates an error occured.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputCount, SetCurrentSelectedOutputUserNumber
const char* IPhreeqc::GetOutputFileName ( void ) const

Retrieves the name of the output file. The default value is phreeqc.id.out, where id is obtained from GetId.

Returns
filename The name of the file to write phreeqc output to.
See also
GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileName, SetOutputFileOn, SetOutputStringOn
bool IPhreeqc::GetOutputFileOn ( void ) const

Retrieves the current value of the output file switch.

Return values
true | Output is written to the phreeqc.id.out (where id is obtained from GetId) file.
false | No output is written.
See also
GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileName, SetOutputFileOn, SetOutputStringOn
const char* IPhreeqc::GetOutputString ( void ) const

Retrieves the string buffer containing phreeqc output.

Returns
A null terminated string containing phreeqc output.
Precondition
SetOutputStringOn must have been set to true in order to receive output.
See also
GetOutputStringLine, GetOutputFileOn, GetOutputStringLineCount, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn
const char* IPhreeqc::GetOutputStringLine ( int n ) const

Retrieves the given output line.

Parameters
n The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition
SetOutputStringOn must have been set to true.
See also
GetOutputFileOn, GetOutputString, GetOutputStringLineCount, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn
int IPhreeqc::GetOutputStringLineCount ( void ) const

Retrieves the number of lines in the current output string buffer.

Returns
The number of lines.
Precondition
SetOutputStringOn must have been set to true.
See also
GetOutputFileOn, GetOutputString, GetOutputStringLine, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn
bool IPhreeqc::GetOutputStringOn ( void ) const

Retrieves the current value of the output string switch.

Return values
true | Phreeqc output is stored.
false | No phreeqc output is stored.
See also
GetOutputFileOn, GetOutputString, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn, SetOutputStringOn
int IPhreeqc::GetSelectedOutputColumnCount ( void ) const

Retrieves the number of columns in the current selected-output buffer (see SetCurrentSelectedOutputUserNumber).

Returns
The number of columns.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputRowCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber
int IPhreeqc::GetSelectedOutputCount ( void ) const

Retrieves the count of SELECTED_OUTPUT blocks that are currently defined.

Returns
The number of SELECTED_OUTPUT blocks.
See also
GetCurrentSelectedOutputUserNumber, GetNthSelectedOutputUserNumber, SetCurrentSelectedOutputUserNumber
const char* IPhreeqc::GetSelectedOutputFileName ( void ) const

Retrieves the name of the current selected output file (see SetCurrentSelectedOutputUserNumber). This file name is used if not specified within SELECTED_OUTPUT input. The default value is selected_n.id.out, where id is obtained from GetId.

Returns
filename The name of the file to write to.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileName, SetSelectedOutputFileOn, SetSelectedOutputStringOn
bool IPhreeqc::GetSelectedOutputFileOn ( void ) const

Retrieves the current selected-output file switch (see SetCurrentSelectedOutputUserNumber).

Return values
true | Output is written to the selected-output (selected_n.id.out if unspecified, where id is obtained from GetId) file.
false | No output is written.
See also
GetSelectedOutputValue, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
int IPhreeqc::GetSelectedOutputRowCount ( void ) const

Retrieves the number of rows in the current selected-output buffer (see SetCurrentSelectedOutputUserNumber).

Returns
The number of rows.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
const char* IPhreeqc::GetSelectedOutputString ( void ) const

Retrieves the string buffer containing SELECTED_OUTPUT for the currently selected user number (see SetCurrentSelectedOutputUserNumber).

Returns
A null terminated string containing SELECTED_OUTPUT.
Precondition
SetSelectedOutputStringOn must have been set to true in order to receive SELECTED_OUTPUT.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputStringLine, GetSelectedOutputFileOn, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, GetSelectedOutputString, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
const char* IPhreeqc::GetSelectedOutputStringLine ( int n )

Retrieves the given selected output line of the currently selected user number (see SetCurrentSelectedOutputUserNumber).

Parameters
n The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition
SetSelectedOutputStringOn must have been set to true.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
int IPhreeqc::GetSelectedOutputStringLineCount ( void ) const

Retrieves the number of lines in the current selected output string buffer (see SetCurrentSelectedOutputUserNumber).

Returns
The number of lines.
Precondition
SetSelectedOutputStringOn must have been set to true.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
bool IPhreeqc::GetSelectedOutputStringOn ( void ) const

Retrieves the value of the current selected output string switch (see SetCurrentSelectedOutputUserNumber).

Return values
true | Output defined by the SELECTED_OUTPUT keyword is stored.
false | No output is stored.
See also
GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
VRESULT IPhreeqc::GetSelectedOutputValue | ( | int | row,
 |  | int | col,
 |  | VAR * | pVAR
 | ) |  |

Returns the VAR associated with the specified row and column. The current SELECTED_OUTPUT block is set using the SetCurrentSelectedOutputUserNumber method.

Parameters
row | The row index.
col | The column index.
pVAR | Pointer to the VAR to receive the requested data.
Return values
VR_OK | Success.
VR_INVALIDROW | The given row is out of range.
VR_INVALIDCOL | The given column is out of range.
VR_OUTOFMEMORY | Memory could not be allocated.
VR_BADINSTANCE | The given id is invalid.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, GetSelectedOutputValue2, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
Remarks
Row 0 contains the column headings to the selected_ouput.
Examples:
The headings will include a suffix and/or prefix in order to differentiate the columns.

Input Headings
  SELECTED_OUTPUT
        -reset false
        -totals Ca Na

  Ca(mol/kgw)  Na(mol/kgw)

  SELECTED_OUTPUT
        -reset false
        -molalities Fe+2 Hfo_sOZn+

  m_Fe+2(mol/kgw)  m_Hfo_sOZn+(mol/kgw)

  SELECTED_OUTPUT
        -reset false
        -activities H+ Ca+2

  la_H+  la_Ca+2

  SELECTED_OUTPUT
        -reset false
        -equilibrium_phases Calcite Dolomite

  Calcite  d_Calcite  Dolomite  d_Dolomite

  SELECTED_OUTPUT
        -reset false
        -saturation_indices CO2(g) Siderite

  si_CO2(g)  si_Siderite

  SELECTED_OUTPUT
        -reset false
        -gases CO2(g) N2(g)

  pressure "total mol" volume g_CO2(g) g_N2(g)

  SELECTED_OUTPUT
        -reset false
        -kinetic_reactants CH2O Pyrite

  k_CH2O dk_CH2O k_Pyrite dk_Pyrite

  SELECTED_OUTPUT
        -reset false
        -solid_solutions CaSO4 SrSO4

  s_CaSO4 s_SrSO4

VRESULT IPhreeqc::GetSelectedOutputValue2 | ( | int | row,
 |  | int | col,
 |  | int * | vtype,
 |  | double * | dvalue,
 |  | char * | svalue,
 |  | unsigned int | svalue_length
 | ) |  |

Returns the associated data with the specified row and column. The current SELECTED_OUTPUT block is set using the SetCurrentSelectedOutputUserNumber method.

Parameters
row | The row index.
col | The column index.
vtype | Receives the variable type. See VAR_TYPE.
dvalue | Receives the numeric value when (VTYPE=TT_DOUBLE) or (VTYPE=TT_LONG).
svalue | Receives the string variable when (VTYPE=TT_STRING). When (VTYPE=TT_DOUBLE) or (VTYPE=TT_LONG) this variable is filled with a string equivalent of DVALUE.
svalue_length | The length of the svalue buffer.
Return values
IPQ_OK | Success.
IPQ_INVALIDROW | The given row is out of range.
IPQ_INVALIDCOL | The given column is out of range.
IPQ_OUTOFMEMORY | Memory could not be allocated.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
Remarks
Row 0 contains the column headings to the selected_ouput.
Examples:
See GetSelectedOutputValue.
static const char* IPhreeqc::GetVersionString ( void )
static

Retrieves the string buffer containing the version in the form of X.X.X-XXXX.

Returns
A null terminated string containing the IPhreeqc version number.
const char* IPhreeqc::GetWarningString ( void )

Retrieves the warning messages from the last call to RunAccumulated, RunFile, RunString, LoadDatabase, or LoadDatabaseString.

Returns
A null terminated string containing warning messages.
See also
GetWarningStringLine, GetWarningStringLineCount, OutputWarningString
const char* IPhreeqc::GetWarningStringLine ( int n )

Retrieves the given warning line.

Parameters
n The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given warning line message.
See also
GetWarningStringLineCount, OutputWarningString
int IPhreeqc::GetWarningStringLineCount ( void ) const

Retrieves the number of lines in the current warning string buffer.

Returns
The number of lines.
See also
GetWarningStringLine, GetWarningString, OutputWarningString
std::list< std::string > IPhreeqc::ListComponents ( void )

Retrieves the current list of components.

Returns
The current list of components.
See also
GetComponent, GetComponentCount
int IPhreeqc::LoadDatabase ( const char * filename )

Load the specified database file into phreeqc.

Parameters
filename The name of the phreeqc database to load. The full path (or relative path with respect to the working directory) will be required if the file is not in the current working directory.
Returns
The number of errors encountered.
See also
LoadDatabaseString
Remarks
All previous definitions are cleared.
int IPhreeqc::LoadDatabaseString ( const char * input )

Load the specified string as a database into phreeqc.

Parameters
input String containing data to be used as the phreeqc database.
Returns
The number of errors encountered.
See also
LoadDatabaseString
Remarks
All previous definitions are cleared.
void IPhreeqc::OutputAccumulatedLines ( void )

Output the accumulated input buffer to stdout. The input buffer can be run with a call to RunAccumulated.

See also
AccumulateLine, ClearAccumulatedLines, RunAccumulated
void IPhreeqc::OutputErrorString ( void )

Output the error messages normally stored in the phreeqc.id.err (where id is obtained from GetId) file to stdout.

See also
GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, SetErrorFileOn
void IPhreeqc::OutputWarningString ( void )

Output the warning messages to stdout.

See also
GetWarningStringLine, GetWarningStringLineCount, GetWarningString
int IPhreeqc::RunAccumulated ( void )

Runs the input buffer as defined by calls to AccumulateLine.

Returns
The number of errors encountered.
See also
AccumulateLine, ClearAccumulatedLines, OutputAccumulatedLines, RunFile, RunString
Remarks
The accumulated input is cleared at the next call to AccumulateLine.
Precondition
LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
int IPhreeqc::RunFile ( const char * filename )

Runs the specified phreeqc input file.

Parameters
filename The name of the phreeqc input file to run.
Returns
The number of errors encountered during the run.
See also
RunAccumulated, RunString
Precondition
LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
int IPhreeqc::RunString ( const char * input )

Runs the specified string as input to phreeqc.

Parameters
input String containing phreeqc input.
Returns
The number of errors encountered during the run.
See also
RunAccumulated, RunFile
Precondition
LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
void IPhreeqc::SetBasicCallback | ( | double(*)(double x1, double x2, const char *str, void *cookie) | fcn,
 |  | void * | cookie1
 | ) |  |

Sets a C callback function for Basic programs. The syntax for the Basic command is 10 result = CALLBACK(x1, x2, string$) The syntax for the C function is double my_callback(double x1, double x2, const char * string)

Parameters
fcn | The name of a user-defined function.
cookie1 | A user defined value to be passed to the callback function.
See also
SetBasicFortranCallback
void IPhreeqc::SetBasicFortranCallback ( double(*)(double *x1, double *x2, const char *str, int l) fcn )

Sets a Fortran callback function for Basic programs. The syntax for the Basic command is 10 result = CALLBACK(x1, x2, string$) The syntax for the Fortran function is double precision my_callback(x1, x2, string), where x1 and x2 are double precision and string is a character variable.

Parameters
fcn The name of a user-defined function.
See also
SetBasicCallback
VRESULT IPhreeqc::SetCurrentSelectedOutputUserNumber ( int n )

Sets the current SELECTED_OUTPUT user number for use in subsequent calls to (GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue, GetSelectedOutputValue2) routines. The initial setting is 1.

Parameters
n The user number as specified in the SELECTED_OUTPUT block.
Return values
VR_OK | Success
VR_INVALIDARG | The given user number has not been defined.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue
void IPhreeqc::SetDumpFileName ( const char * filename )

Sets the name of the dump file. This file name is used if not specified within DUMP input. The default value is dump.id.out, where id is obtained from GetId.

Parameters
filename The name of the file to write DUMP output to.
See also
GetDumpFileName, GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpStringOn
void IPhreeqc::SetDumpFileOn ( bool bValue )

Sets the dump file switch on or off. This switch controls whether or not phreeqc writes to the DUMP (dump.id.out if unspecified, where id is obtained from GetId) file. The initial setting is false.

Parameters
bValue If true, turns on output to the DUMP file; if false, turns off output to the DUMP file.
See also
GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpStringOn
void IPhreeqc::SetDumpStringOn ( bool bValue )

Sets the dump string switch on or off. This switch controls whether or not the data normally sent to the dump file are stored in a buffer for retrieval. The initial setting is false.

Parameters
bValue If true, captures the output defined by the DUMP keyword into a string buffer; if false, output defined by the DUMP keyword is not captured to a string buffer.
See also
GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn
void IPhreeqc::SetErrorFileName ( const char * filename )

Sets the name of the error file. The default value is phreeqc.id.err, where id is obtained from GetId.

Parameters
filename The name of the file to write error output to.
See also
GetErrorFileName, GetErrorFileOn, GetErrorString, GetErrorStringOn, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn, SetErrorStringOn
void IPhreeqc::SetErrorFileOn ( bool bValue )

Sets the error file switch on or off. This switch controls whether or not error messages are written to the phreeqc.id.err (where id is obtained from GetId) file. The initial setting is true.

Parameters
bValue If true, writes errors to the error file; if false, no errors are written to the error file.
See also
GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString
void IPhreeqc::SetErrorOn ( bool bValue )

Sets the error switch on or off. This switch controls whether error messages are are generated and displayed. The initial setting is true.

Parameters
bValue If true, error messages are sent to the error file and error string buffer; if false, no error messages are generated.
See also
GetErrorOn, GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString
void IPhreeqc::SetErrorStringOn ( bool bValue )

Sets the error string switch on or off. This switch controls whether or not the data normally sent to the error file are stored in a buffer for retrieval. The initial setting is true.

Parameters
bValue If true, captures error output into a string buffer; if false, error output is not captured to a string buffer.
See also
GetErrorFileOn, GetErrorString, GetErrorStringOn, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn
void IPhreeqc::SetLogFileName ( const char * filename )

Sets the name of the log file. The default value is phreeqc.id.log, where id is obtained from GetId.

Parameters
filename The name of the file to write log output to.
See also
GetLogFileName, GetLogFileOn, GetLogString, GetLogStringOn, GetLogStringLine, GetLogStringLineCount, SetLogFileOn, SetLogStringOn
void IPhreeqc::SetLogFileOn ( bool bValue )

Sets the log file switch on or off. This switch controls whether or not phreeqc writes log messages to the phreeqc.id.log (where id is obtained from GetId) file. The initial setting is false.

Parameters
bValue If true, turns on output to the log file; if false, no log messages are written to the log file.
Remarks
Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also
GetLogFileOn
void IPhreeqc::SetLogStringOn ( bool bValue )

Sets the log string switch on or off. This switch controls whether or not the data normally sent to the log file are stored in a buffer for retrieval. The initial setting is false.

Parameters
bValue If true, captures log output into a string buffer; if false, log output is not captured to a string buffer.
See also
GetLogFileOn, GetLogString, GetLogStringOn, GetLogStringLine, GetLogStringLineCount, SetLogFileOn
void IPhreeqc::SetOutputFileName ( const char * filename )

Sets the name of the output file. The default value is phreeqc.id.out, where id is obtained from GetId.

Parameters
filename The name of the file to write phreeqc output to.
See also
GetOutputFileName, GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn, SetOutputStringOn
void IPhreeqc::SetOutputFileOn ( bool bValue )

Sets the output file switch on or off. This switch controls whether or not phreeqc writes to the phreeqc.id.out file (where id is obtained from GetId). This is the output that is normally generated when phreeqc is run. The initial setting is false.

Parameters
bValue If true, writes output to the output file; if false, no output is written to the output file.
See also
GetOutputFileOn
void IPhreeqc::SetOutputStringOn ( bool bValue )

Sets the output string switch on or off. This switch controls whether or not the data normally sent to the output file are stored in a buffer for retrieval. The initial setting is false.

Parameters
bValue If true, captures output into a string buffer; if false, output is not captured to a string buffer.
See also
GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn
void IPhreeqc::SetSelectedOutputFileName ( const char * filename )

Sets the name of the current selected output file (see SetCurrentSelectedOutputUserNumber). This file name is used if not specified within SELECTED_OUTPUT input. The default value is selected_n.id.out, where id is obtained from GetId.

Parameters
filename The name of the file to write SELECTED_OUTPUT output to.
See also
GetSelectedOutputFileName, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputStringOn
void IPhreeqc::SetSelectedOutputFileOn ( bool bValue )

Sets the selected-output file switch on or off. This switch controls whether or not phreeqc writes output to the current SELECTED_OUTPUT (selected_n.id.out if unspecified, where id is obtained from GetId) file. The initial setting is false.

Parameters
bValue If true, writes output to the selected-output file; if false, no output is written to the selected-output file.
See also
GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber
void IPhreeqc::SetSelectedOutputStringOn ( bool bValue )

Sets the selected output string switch on or off. This switch controls whether or not the data normally sent to the current SELECTED_OUTPUT file (see SetCurrentSelectedOutputUserNumber) are stored in a buffer for retrieval. The initial setting is false.

Parameters
bValue If true, captures the output defined by the SELECTED_OUTPUT keyword into a string buffer; if false, output defined by the SELECTED_OUTPUT keyword is not captured to a string buffer.
See also
GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
The documentation for this class was generated from the following file:
  • IPhreeqc.hpp


IPhreeqc: IPhreeqcStop Class Reference

IPhreeqcStop Class Reference

This class is derived from std::exception and is thrown when an unrecoverable error has occured. More...

#include <IPhreeqc.hpp>

Inheritance diagram for IPhreeqcStop:

Detailed Description

This class is derived from std::exception and is thrown when an unrecoverable error has occured.

The documentation for this class was generated from the following file:
  • IPhreeqc.hpp


IPhreeqc: IPhreeqc.h File Reference

  • src
Enumerations | Functions
IPhreeqc.h File Reference

C/Fortran Documentation. More...

#include "Var.h"

Go to the source code of this file.

Enumerations

enum IPQ_RESULT {
IPQ_OK = 0, IPQ_OUTOFMEMORY = -1, IPQ_BADVARTYPE = -2, IPQ_INVALIDARG = -3,
IPQ_INVALIDROW = -4, IPQ_INVALIDCOL = -5, IPQ_BADINSTANCE = -6
}
Enumeration used to return error codes. More...

Functions

IPQ_DLL_EXPORT IPQ_RESULT | AccumulateLine (int id, const char *line)
IPQ_DLL_EXPORT int | AddError (int id, const char *error_msg)
IPQ_DLL_EXPORT int | AddWarning (int id, const char *warn_msg)
IPQ_DLL_EXPORT IPQ_RESULT | ClearAccumulatedLines (int id)
IPQ_DLL_EXPORT int | CreateIPhreeqc (void)
IPQ_DLL_EXPORT IPQ_RESULT | DestroyIPhreeqc (int id)
IPQ_DLL_EXPORT const char * | GetComponent (int id, int n)
IPQ_DLL_EXPORT int | GetComponentCount (int id)
IPQ_DLL_EXPORT int | GetCurrentSelectedOutputUserNumber (int id)
IPQ_DLL_EXPORT const char * | GetDumpFileName (int id)
IPQ_DLL_EXPORT int | GetDumpFileOn (int id)
IPQ_DLL_EXPORT const char * | GetDumpString (int id)
IPQ_DLL_EXPORT const char * | GetDumpStringLine (int id, int n)
IPQ_DLL_EXPORT int | GetDumpStringLineCount (int id)
IPQ_DLL_EXPORT int | GetDumpStringOn (int id)
IPQ_DLL_EXPORT const char * | GetErrorFileName (int id)
IPQ_DLL_EXPORT int | GetErrorFileOn (int id)
IPQ_DLL_EXPORT int | GetErrorOn (int id)
IPQ_DLL_EXPORT const char * | GetErrorString (int id)
IPQ_DLL_EXPORT const char * | GetErrorStringLine (int id, int n)
IPQ_DLL_EXPORT int | GetErrorStringLineCount (int id)
IPQ_DLL_EXPORT int | GetErrorStringOn (int id)
IPQ_DLL_EXPORT const char * | GetLogFileName (int id)
IPQ_DLL_EXPORT int | GetLogFileOn (int id)
IPQ_DLL_EXPORT const char * | GetLogString (int id)
IPQ_DLL_EXPORT const char * | GetLogStringLine (int id, int n)
IPQ_DLL_EXPORT int | GetLogStringLineCount (int id)
IPQ_DLL_EXPORT int | GetLogStringOn (int id)
IPQ_DLL_EXPORT int | GetNthSelectedOutputUserNumber (int id, int n)
IPQ_DLL_EXPORT const char * | GetOutputFileName (int id)
IPQ_DLL_EXPORT int | GetOutputFileOn (int id)
IPQ_DLL_EXPORT const char * | GetOutputString (int id)
IPQ_DLL_EXPORT const char * | GetOutputStringLine (int id, int n)
IPQ_DLL_EXPORT int | GetOutputStringLineCount (int id)
IPQ_DLL_EXPORT int | GetOutputStringOn (int id)
IPQ_DLL_EXPORT int | GetSelectedOutputColumnCount (int id)
IPQ_DLL_EXPORT int | GetSelectedOutputCount (int id)
IPQ_DLL_EXPORT const char * | GetSelectedOutputFileName (int id)
IPQ_DLL_EXPORT int | GetSelectedOutputFileOn (int id)
IPQ_DLL_EXPORT int | GetSelectedOutputRowCount (int id)
IPQ_DLL_EXPORT const char * | GetSelectedOutputString (int id)
IPQ_DLL_EXPORT const char * | GetSelectedOutputStringLine (int id, int n)
IPQ_DLL_EXPORT int | GetSelectedOutputStringLineCount (int id)
IPQ_DLL_EXPORT int | GetSelectedOutputStringOn (int id)
IPQ_DLL_EXPORT IPQ_RESULT | GetSelectedOutputValue (int id, int row, int col, VAR *pVAR)
IPQ_DLL_EXPORT IPQ_RESULT | GetSelectedOutputValue2 (int id, int row, int col, int *vtype, double *dvalue, char *svalue, unsigned int svalue_length)
IPQ_DLL_EXPORT const char * | GetVersionString (void)
IPQ_DLL_EXPORT const char * | GetWarningString (int id)
IPQ_DLL_EXPORT const char * | GetWarningStringLine (int id, int n)
IPQ_DLL_EXPORT int | GetWarningStringLineCount (int id)
IPQ_DLL_EXPORT int | LoadDatabase (int id, const char *filename)
IPQ_DLL_EXPORT int | LoadDatabaseString (int id, const char *input)
IPQ_DLL_EXPORT void | OutputAccumulatedLines (int id)
IPQ_DLL_EXPORT void | OutputErrorString (int id)
IPQ_DLL_EXPORT void | OutputWarningString (int id)
IPQ_DLL_EXPORT int | RunAccumulated (int id)
IPQ_DLL_EXPORT int | RunFile (int id, const char *filename)
IPQ_DLL_EXPORT int | RunString (int id, const char *input)
IPQ_DLL_EXPORT IPQ_RESULT | SetBasicCallback (int id, double(*fcn)(double x1, double x2, const char *str, void *cookie), void *cookie1)
IPQ_DLL_EXPORT IPQ_RESULT | SetBasicFortranCallback (int id, double(*fcn)(double *x1, double *x2, const char *str, int l))
IPQ_DLL_EXPORT IPQ_RESULT | SetCurrentSelectedOutputUserNumber (int id, int n)
IPQ_DLL_EXPORT IPQ_RESULT | SetDumpFileName (int id, const char *filename)
IPQ_DLL_EXPORT IPQ_RESULT | SetDumpFileOn (int id, int dump_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetDumpStringOn (int id, int dump_string_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetErrorFileName (int id, const char *filename)
IPQ_DLL_EXPORT IPQ_RESULT | SetErrorFileOn (int id, int error_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetErrorOn (int id, int error_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetErrorStringOn (int id, int error_string_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetLogFileName (int id, const char *filename)
IPQ_DLL_EXPORT IPQ_RESULT | SetLogFileOn (int id, int log_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetLogStringOn (int id, int log_string_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetOutputFileName (int id, const char *filename)
IPQ_DLL_EXPORT IPQ_RESULT | SetOutputFileOn (int id, int output_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetOutputStringOn (int id, int output_string_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetSelectedOutputFileName (int id, const char *filename)
IPQ_DLL_EXPORT IPQ_RESULT | SetSelectedOutputFileOn (int id, int sel_on)
IPQ_DLL_EXPORT IPQ_RESULT | SetSelectedOutputStringOn (int id, int sel_string_on)

Detailed Description

C/Fortran Documentation.

Enumeration Type Documentation

enum IPQ_RESULT

Enumeration used to return error codes.

Enumerator
IPQ_OK | Success
IPQ_OUTOFMEMORY | Failure, Out of memory
IPQ_BADVARTYPE | Failure, Invalid VAR type
IPQ_INVALIDARG | Failure, Invalid argument
IPQ_INVALIDROW | Failure, Invalid row
IPQ_INVALIDCOL | Failure, Invalid column
IPQ_BADINSTANCE | Failure, Invalid instance id

Function Documentation

IPQ_DLL_EXPORT IPQ_RESULT AccumulateLine | ( | int | id,
 |  | const char * | line
 | ) |  |

Accumlulate line(s) for input to phreeqc.

Parameters
id | The instance id returned from CreateIPhreeqc.
line | The line(s) to add for input to phreeqc.
Return values
IPQ_OK | Success
IPQ_OUTOFMEMORY | Out of memory
See also
ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated
Fortran90 Interface:
FUNCTION AccumulateLine(ID,LINE)
  INTEGER(KIND=4),   INTENT(IN)  :: ID
  CHARACTER(LEN=*),  INTENT(IN)  :: LINE
  INTEGER(KIND=4)                :: AccumulateLine
END FUNCTION AccumulateLine
C Example:
#include <stdlib.h>
#include <IPhreeqc.h>
int main(void)
{
int id;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (AccumulateLine(id, "SOLUTION 1") != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (AccumulateLine(id, "END") != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunAccumulated(id) != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (DestroyIPhreeqc(id) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Fortran90 Example:
see GetDumpStringLine
IPQ_DLL_EXPORT int AddError | ( | int | id,
 |  | const char * | error_msg
 | ) |  |

Appends the given error message and increments the error count. Internally used to create an error condition.

Parameters
id | The instance id returned from CreateIPhreeqc.
error_msg | The error message to display.
Returns
The current error count if successful; otherwise a negative value indicates an error occured (see IPQ_RESULT).
See also
GetErrorString, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString
Fortran90 Interface:
FUNCTION AddError(ID,ERROR_MSG)
  INTEGER(KIND=4),  INTENT(IN) :: ID
  CHARACTER(LEN=*), INTENT(IN) :: ERROR_MSG
  INTEGER(KIND=4)              :: AddError
END FUNCTION AddError

IPQ_DLL_EXPORT int AddWarning | ( | int | id,
 |  | const char * | warn_msg
 | ) |  |

Appends the given warning message and increments the warning count. Internally used to create a warning condition.

Parameters
id | The instance id returned from CreateIPhreeqc.
warn_msg | The warning message to display.
Returns
The current warning count if successful; otherwise a negative value indicates an error occured (see IPQ_RESULT).
See also
GetWarningString, GetWarningStringLine, GetWarningStringLineCount, OutputWarningString
Fortran90 Interface:
FUNCTION AddWarning(ID,WARN_MSG)
  INTEGER(KIND=4),  INTENT(IN) :: ID
  CHARACTER(LEN=*), INTENT(IN) :: WARN_MSG
  INTEGER(KIND=4)              :: AddWarning
END FUNCTION AddWarning
IPQ_DLL_EXPORT IPQ_RESULT ClearAccumulatedLines ( int id )

Clears the accumulated input buffer. Input buffer is accumulated from calls to AccumulateLine.

Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
AccumulateLine, OutputAccumulatedLines, RunAccumulated
Fortran90 Interface:
FUNCTION ClearAccumulatedLines(ID)
  INTEGER(KIND=4), INTENT(IN) :: ID
  INTEGER(KIND=4)             :: ClearAccumulatedLines
END FUNCTION ClearAccumulatedLines
IPQ_DLL_EXPORT int CreateIPhreeqc ( void )

Create a new IPhreeqc instance.

Returns
A non-negative value if successful; otherwise a negative value indicates an error occured (see IPQ_RESULT).
See also
DestroyIPhreeqc
Fortran90 Interface:
FUNCTION CreateIPhreeqc()
  INTEGER(KIND=4)  :: CreateIPhreeqc
END FUNCTION CreateIPhreeqc

C Example:
#include <stdlib.h>
#include <IPhreeqc.h>
int main(void)
{
int id;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunFile(id, "ex2") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (DestroyIPhreeqc(id) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

Fortran90 Example:
PROGRAM example
USE iphreeqc
INTEGER(KIND=4) :: id
id = createiphreeqc()
IF (id.LT.0) THEN
stop
END IF
IF (loaddatabase(id, "phreeqc.dat").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
IF (runfile(id, "ex2").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
IF (destroyiphreeqc(id).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
END PROGRAM example
IPQ_DLL_EXPORT IPQ_RESULT DestroyIPhreeqc ( int id )

Release an IPhreeqc instance from memory.

Parameters
id The instance id returned from CreateIPhreeqc.
Return values
IPQ_OK | Success
IPQ_BADINSTANCE | The given id is invalid.
See also
CreateIPhreeqc
Fortran90 Interface:
FUNCTION DestroyIPhreeqc(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: DestroyIPhreeqc
END FUNCTION DestroyIPhreeqc
C Example:
see CreateIPhreeqc
Fortran90 Example:
see CreateIPhreeqc
IPQ_DLL_EXPORT const char* GetComponent | ( | int | id,
 |  | int | n
 | ) |  |

Retrieves the given component.

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The zero-based index of the component to retrieve.
Returns
A null terminated string containing the given component. Returns an empty string if n is out of range.
See also
GetComponentCount
Fortran90 Interface:
(Note: N is one-based for the Fortran interface)
SUBROUTINE GetComponent(ID,N,COMP)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  INTEGER(KIND=4),   INTENT(IN)   :: N
  CHARACTER(LEN=*),  INTENT(OUT)  :: COMP
END SUBROUTINE GetComponent

C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
int main(void)
{
int id, i;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunFile(id, "ex2") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
for (i=0; i < GetComponentCount(id); ++i) {
printf("comp %d = %s\n", i, GetComponent(id, i));
}
if (DestroyIPhreeqc(id) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

Fortran90 Example:
PROGRAM example
USE iphreeqc
INTEGER(KIND=4) :: id
INTEGER(KIND=4) :: i
CHARACTER(LEN=40) :: comp
id = createiphreeqc()
IF (id.LT.0) THEN
stop
END IF
IF (loaddatabase(id, "phreeqc.dat").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
IF (runfile(id, "ex2").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
DO i=1,getcomponentcount(id)
CALL getcomponent(id, i, comp)
WRITE(*,*) "comp ", i, " = ", comp
END DO
IF (destroyiphreeqc(id).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
END PROGRAM example
IPQ_DLL_EXPORT int GetComponentCount ( int id )

Retrieves the number of components in the current component list.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The current count of components. A negative value indicates an error occured (see IPQ_RESULT).
See also
GetComponent
Fortran90 Interface:
FUNCTION GetComponentCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetComponentCount
END FUNCTION GetComponentCount
C Example:
see GetComponent
Fortran90 Example:
see GetComponent
IPQ_DLL_EXPORT int GetCurrentSelectedOutputUserNumber ( int id )

Retrieves the current SELECTED_OUTPUT user number for use in subsequent calls to (GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue, GetSelectedOutputValue2) routines. The initial setting after calling CreateIPhreeqc is 1.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The current SELECTED_OUTPUT user number.
See also
GetNthSelectedOutputUserNumber, GetSelectedOutputCount, SetCurrentSelectedOutputUserNumber
Fortran90 Interface:
FUNCTION GetCurrentSelectedOutputUserNumber(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetCurrentSelectedOutputUserNumber
END FUNCTION GetCurrentSelectedOutputUserNumber
IPQ_DLL_EXPORT const char* GetDumpFileName ( int id )

Retrieves the name of the dump file. This file name is used if not specified within DUMP input. The default value is dump.id.out.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
filename The name of the file to write DUMP output to.
See also
GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileName, SetDumpFileOn, SetDumpStringOn
Fortran90 Interface:
SUBROUTINE GetDumpFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
END SUBROUTINE GetDumpFileName
IPQ_DLL_EXPORT int GetDumpFileOn ( int id )

Retrieves the current value of the dump file switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if output is written to the DUMP (dump.id.out if unspecified) file, 0 (zero) otherwise.
See also
GetDumpString, GetDumpStringLine, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
Fortran90 Interface:
FUNCTION GetDumpFileOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetDumpFileOn
END FUNCTION GetDumpFileOn
IPQ_DLL_EXPORT const char* GetDumpString ( int id )

Retrieves the string buffer containing DUMP output.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
A null terminated string containing DUMP output.
Precondition
SetDumpStringOn must have been set to true (non-zero) in order to receive DUMP output.
See also
GetDumpFileOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn, GetDumpStringOn, SetDumpStringOn
Fortran90 Interface:
Not implemented. (see GetDumpStringLineCount, GetDumpStringLine)

C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
#define TRUE 1
const char input[] =
"SOLUTION 1 Pure water \n"
"EQUILIBRIUM_PHASES 1 \n"
" Calcite 0 10 \n"
"SAVE solution 1 \n"
"SAVE equilibrium_phases 1 \n"
"DUMP \n"
" -solution 1 \n"
" -equilibrium_phases 1\n";
int main(void)
{
int id;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (SetDumpStringOn(id, TRUE) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunString(id, input) != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
printf("Dump:\n");
printf("%s\n", GetDumpString(id));
if (DestroyIPhreeqc(id) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
IPQ_DLL_EXPORT const char* GetDumpStringLine | ( | int | id,
 |  | int | n
 | ) |  |

Retrieves the given dump line.

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition
SetDumpStringOn must have been set to true (non-zero).
See also
GetDumpFileOn, GetDumpString, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
Fortran90 Interface:
(Note: N is one-based for the Fortran interface.)
SUBROUTINE GetDumpStringLine(ID,N,LINE)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  INTEGER(KIND=4),   INTENT(IN)   :: N
  CHARACTER(LEN=*),  INTENT(OUT)  :: LINE
END SUBROUTINE GetDumpStringLine

Fortran90 Example:
PROGRAM example
USE iphreeqc
INTEGER(KIND=4) :: id
INTEGER(KIND=4) :: i
CHARACTER(LEN=80) :: line
id = createiphreeqc()
IF (id.LT.0) THEN
stop
END IF
IF (setdumpstringon(id, .true.).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (loaddatabase(id, "phreeqc.dat").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SOLUTION 1 Pure water").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "EQUILIBRIUM_PHASES 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " Calcite 0 10").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SAVE solution 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SAVE equilibrium_phases 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "DUMP").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " -solution 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " -equilibrium_phases 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "Input:"
CALL outputaccumulatedlines(id)
IF (runaccumulated(id).NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "Dump:"
DO i=1,getdumpstringlinecount(id)
CALL getdumpstringline(id, i, line)
WRITE(*,*) trim(line)
END DO
IF (destroyiphreeqc(id).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
END PROGRAM example
IPQ_DLL_EXPORT int GetDumpStringLineCount ( int id )

Retrieves the number of lines in the current dump string buffer.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of lines.
Precondition
SetDumpStringOn must have been set to true (non-zero).
See also
GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
Fortran90 Interface:
FUNCTION GetDumpStringLineCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetDumpStringLineCount
END FUNCTION GetDumpStringLineCount
Fortran90 Example:
see GetDumpStringLine
IPQ_DLL_EXPORT int GetDumpStringOn ( int id )

Retrieves the current value of the dump string switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if output defined by the DUMP keyword is stored, 0 (zero) otherwise.
See also
GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn, SetDumpStringOn
Fortran90 Interface:
FUNCTION GetDumpStringOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetDumpStringOn
END FUNCTION GetDumpStringOn
IPQ_DLL_EXPORT const char* GetErrorFileName ( int id )

Retrieves the name of the error file. The default name is phreeqc.id.err.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
filename The name of the error file.
See also
GetErrorFileOn, GetErrorString, GetErrorStringOn, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileName, SetErrorFileOn, SetErrorStringOn
Fortran90 Interface:
SUBROUTINE GetErrorFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
END SUBROUTINE GetErrorFileName
IPQ_DLL_EXPORT int GetErrorFileOn ( int id )

Retrieves the current value of the error file switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if errors are written to the phreeqc.id.err file, 0 (zero) otherwise.
See also
SetErrorFileOn
Fortran90 Interface:
FUNCTION GetErrorFileOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetErrorFileOn
END FUNCTION GetErrorFileOn
IPQ_DLL_EXPORT int GetErrorOn ( int id )

Retrieves the current value of the error on switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if errors are generated, 0 (zero) otherwise.
See also
SetErrorOn
Fortran90 Interface:
FUNCTION GetErrorOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetErrorOn
END FUNCTION GetErrorOn
IPQ_DLL_EXPORT const char* GetErrorString ( int id )

Retrieves the error messages from the last call to RunAccumulated, RunFile, RunString, LoadDatabase, or LoadDatabaseString.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
A null terminated string containing error messages.
See also
GetErrorFileOn, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString, SetErrorFileOn
Fortran90 Interface:
Not implemented. (see GetErrorStringLineCount, GetErrorStringLine, OutputErrorString)

C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
#define TRUE 1
const char input[] =
"SOLUTION 1 Pure water \n"
"EQUILIBRIUM_PHASES 1 \n"
" Calcite 0 10 \n"
"SAVE solution 1 \n"
"SAVE equilibrium_phases 1 \n"
"DUMP \n"
" -solution 1 \n"
" -equilibrium_phases 1\n";
int main(void)
{
int id;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (SetErrorStringOn(id, TRUE) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunString(id, input) != 0) {
printf("Error:\n");
printf("%s\n", GetErrorString(id));
return EXIT_FAILURE;
}
if (DestroyIPhreeqc(id) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
IPQ_DLL_EXPORT const char* GetErrorStringLine | ( | int | id,
 |  | int | n
 | ) |  |

Retrieves the given error line.

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line of the error string buffer.
See also
GetErrorFileOn, GetErrorString, GetErrorStringLineCount, OutputErrorString, SetErrorFileOn
Fortran90 Interface:
(Note: N is one-based for the Fortran interface.)
SUBROUTINE GetErrorStringLine(ID,N,LINE)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  INTEGER(KIND=4),   INTENT(IN)   :: N
  CHARACTER(LEN=*),  INTENT(OUT)  :: LINE
END SUBROUTINE GetErrorStringLine

Fortran90 Example:
PROGRAM example
USE iphreeqc
INTEGER(KIND=4) :: id
INTEGER(KIND=4) :: i
CHARACTER(LEN=80) :: line
id = createiphreeqc()
IF (id.LT.0) THEN
stop
END IF
IF (seterrorstringon(id, .true.).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SOLUTION 1 Pure water").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "EQUILIBRIUM_PHASES 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " Calcite 0 10").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SAVE solution 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SAVE equilibrium_phases 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "Input:"
CALL outputaccumulatedlines(id)
IF (runaccumulated(id).NE.0) THEN
WRITE(*,*) "Error:"
DO i=1,geterrorstringlinecount(id)
CALL geterrorstringline(id, i, line)
WRITE(*,*) trim(line)
END DO
stop
END IF
IF (destroyiphreeqc(id).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
END PROGRAM example
IPQ_DLL_EXPORT int GetErrorStringLineCount ( int id )

Retrieves the number of lines in the current error string buffer.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of lines.
See also
GetErrorFileOn, GetErrorString, GetErrorStringLine, OutputErrorString, SetErrorFileOn
Fortran90 Interface:
FUNCTION GetErrorStringLineCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetErrorStringLineCount
END FUNCTION GetErrorStringLineCount
IPQ_DLL_EXPORT int GetErrorStringOn ( int id )

Retrieves the current value of the error string switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if output is stored, 0 (zero) otherwise.
See also
GetErrorFileOn, GetErrorString, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn, SetErrorStringOn
Fortran90 Interface:
FUNCTION GetErrorStringOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetErrorStringOn
END FUNCTION GetErrorStringOn
IPQ_DLL_EXPORT const char* GetLogFileName ( int id )

Retrieves the name of the log file. The default name is phreeqc.id.log.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
filename The name of the log file.
See also
GetLogFileOn, GetLogString, GetLogStringOn, GetLogStringLine, GetLogStringLineCount, SetLogFileName, SetLogFileOn, SetLogStringOn
Fortran90 Interface:
SUBROUTINE GetLogFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
END SUBROUTINE GetLogFileName
IPQ_DLL_EXPORT int GetLogFileOn ( int id )

Retrieves the current value of the log file switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if log messages are written to the phreeqc.id.log file, 0 (zero) otherwise.
Remarks
Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also
SetLogFileOn
Fortran90 Interface:
FUNCTION GetLogFileOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetLogFileOn
END FUNCTION GetLogFileOn
IPQ_DLL_EXPORT const char* GetLogString ( int id )

Retrieves the string buffer containing log output.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
A null terminated string containing log output.
Remarks
Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
Precondition
SetLogStringOn must have been set to true (non-zero) in order to receive log output.
See also
GetLogFileOn, GetLogStringLine, GetLogStringLineCount, SetLogFileOn, GetLogStringOn, SetLogStringOn
Fortran90 Interface:
Not implemented. (see GetLogStringLineCount, GetLogStringLine)

C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
#define TRUE 1
const char input[] =
"SOLUTION 1 Pure water \n"
"EQUILIBRIUM_PHASES 1 \n"
" Calcite 0 10 \n"
"SAVE solution 1 \n"
"SAVE equilibrium_phases 1 \n"
"DUMP \n"
" -solution 1 \n"
" -equilibrium_phases 1\n"
"KNOBS \n"
" -logfile TRUE \n";
int main(void)
{
int id;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (SetLogStringOn(id, TRUE) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunString(id, input) != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
printf("Log:\n");
printf("%s\n", GetLogString(id));
if (DestroyIPhreeqc(id) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
IPQ_DLL_EXPORT const char* GetLogStringLine | ( | int | id,
 |  | int | n
 | ) |  |

Retrieves the given log line.

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition
SetLogStringOn must have been set to true (non-zero).
See also
GetLogFileOn, GetLogString, GetLogStringLineCount, GetLogStringOn, SetLogFileOn, SetLogStringOn
Fortran90 Interface:
(Note: N is one-based for the Fortran interface.)
SUBROUTINE GetLogStringLine(ID,N,LINE)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  INTEGER(KIND=4),   INTENT(IN)   :: N
  CHARACTER(LEN=*),  INTENT(OUT)  :: LINE
END SUBROUTINE GetLogStringLine

Fortran90 Example:
PROGRAM example
USE iphreeqc
INTEGER(KIND=4) :: id
INTEGER(KIND=4) :: i
CHARACTER(LEN=80) :: line
id = createiphreeqc()
IF (id.LT.0) THEN
stop
END IF
IF (setlogstringon(id, .true.).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (loaddatabase(id, "phreeqc.dat").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SOLUTION 1 Pure water").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "EQUILIBRIUM_PHASES 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " Calcite 0 10").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SAVE solution 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SAVE equilibrium_phases 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "DUMP").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " -solution 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " -equilibrium_phases 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "KNOBS").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " -logfile TRUE").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "Input:"
CALL outputaccumulatedlines(id)
IF (runaccumulated(id).NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "Log:"
DO i=1,getlogstringlinecount(id)
CALL getlogstringline(id, i, line)
WRITE(*,*) trim(line)
END DO
IF (destroyiphreeqc(id).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
END PROGRAM example
IPQ_DLL_EXPORT int GetLogStringLineCount ( int id )

Retrieves the number of lines in the current log string buffer.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of lines.
Precondition
SetLogStringOn must have been set to true (non-zero).
See also
GetLogFileOn, GetLogString, GetLogStringLine, GetLogStringOn, SetLogFileOn, SetLogStringOn
Fortran90 Interface:
FUNCTION GetLogStringLineCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetLogStringLineCount
END FUNCTION GetLogStringLineCount
Fortran90 Example:
see GetLogStringLine
IPQ_DLL_EXPORT int GetLogStringOn ( int id )

Retrieves the current value of the log string switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if output is stored, 0 (zero) otherwise.
See also
GetLogFileOn, GetLogString, GetLogStringLine, GetLogStringLineCount, SetLogFileOn, SetLogStringOn
Fortran90 Interface:
FUNCTION GetLogStringOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetLogStringOn
END FUNCTION GetLogStringOn

IPQ_DLL_EXPORT int GetNthSelectedOutputUserNumber | ( | int | id,
 |  | int | n
 | ) |  |

Retrieves the nth user number of the currently defined SELECTED_OUTPUT keyword blocks.

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The zero-based index of the SELECTED_OUTPUT user number to retrieve.
Returns
The nth defined user number; a negative value indicates an error occured.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputCount, SetCurrentSelectedOutputUserNumber
Precondition
RunAccumulated, RunFile, RunString must have been called and returned 0 (zero) errors.
Fortran90 Interface:
(Note: N is one-based for the Fortran interface.)
FUNCTION GetNthSelectedOutputUserNumber(ID,N)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4),  INTENT(IN)  :: N
  INTEGER(KIND=4)               :: GetNthSelectedOutputUserNumber
END FUNCTION GetNthSelectedOutputUserNumber
C Example:
see SetCurrentSelectedOutputUserNumber
IPQ_DLL_EXPORT const char* GetOutputFileName ( int id )

Retrieves the name of the output file. The default name is phreeqc.id.out.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
filename The name of the output file.
See also
GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileName, SetOutputFileOn, SetOutputStringOn
Fortran90 Interface:
SUBROUTINE GetOutputFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
END SUBROUTINE GetOutputFileName
IPQ_DLL_EXPORT int GetOutputFileOn ( int id )

Retrieves the current value of the output file switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if output is written to the phreeqc.id.out file, 0 (zero) otherwise.
See also
SetOutputFileOn
Fortran90 Interface:
FUNCTION GetOutputFileOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetOutputFileOn
END FUNCTION GetOutputFileOn
IPQ_DLL_EXPORT const char* GetOutputString ( int id )

Retrieves the string buffer containing phreeqc output.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
A null terminated string containing phreeqc output.
Precondition
SetOutputStringOn must have been set to true (non-zero) in order to receive phreeqc output.
See also
GetOutputFileOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn, GetOutputStringOn, SetOutputStringOn
Fortran90 Interface:
Not implemented. (see GetOutputStringLineCount, GetOutputStringLine)

C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
#define TRUE 1
const char input[] =
"SOLUTION 1 Pure water \n"
"EQUILIBRIUM_PHASES 1 \n"
" Calcite 0 10 \n"
"SAVE solution 1 \n"
"SAVE equilibrium_phases 1 \n"
"DUMP \n"
" -solution 1 \n"
" -equilibrium_phases 1\n";
int main(void)
{
int id;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (SetOutputStringOn(id, TRUE) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunString(id, input) != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
printf("Output:\n");
printf("%s\n", GetOutputString(id));
if (DestroyIPhreeqc(id) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
IPQ_DLL_EXPORT const char* GetOutputStringLine | ( | int | id,
 |  | int | n
 | ) |  |

Retrieves the given output line.

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition
SetOutputStringOn must have been set to true (non-zero).
See also
GetOutputFileOn, GetOutputString, GetOutputStringLineCount, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn
Fortran90 Interface:
(Note: N is one-based for the Fortran interface.)
SUBROUTINE GetOutputStringLine(ID,N,LINE)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  INTEGER(KIND=4),   INTENT(IN)   :: N
  CHARACTER(LEN=*),  INTENT(OUT)  :: LINE
END SUBROUTINE GetOutputStringLine

Fortran90 Example:
PROGRAM example
USE iphreeqc
INTEGER(KIND=4) :: id
INTEGER(KIND=4) :: i
CHARACTER(LEN=80) :: line
id = createiphreeqc()
IF (id.LT.0) THEN
stop
END IF
IF (setoutputstringon(id, .true.).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (loaddatabase(id, "phreeqc.dat").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SOLUTION 1 Pure water").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "EQUILIBRIUM_PHASES 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " Calcite 0 10").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SAVE solution 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "SAVE equilibrium_phases 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, "DUMP").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " -solution 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (accumulateline(id, " -equilibrium_phases 1").NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "Input:"
CALL outputaccumulatedlines(id)
IF (runaccumulated(id).NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "Output:"
DO i=1,getoutputstringlinecount(id)
CALL getoutputstringline(id, i, line)
WRITE(*,*) trim(line)
END DO
IF (destroyiphreeqc(id).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
END PROGRAM example
IPQ_DLL_EXPORT int GetOutputStringLineCount ( int id )

Retrieves the number of lines in the current output string buffer.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of lines.
Precondition
SetOutputStringOn must have been set to true (non-zero).
See also
GetOutputFileOn, GetOutputString, GetOutputStringLine, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn
Fortran90 Interface:
FUNCTION GetOutputStringLineCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetOutputStringLineCount
END FUNCTION GetOutputStringLineCount
Fortran90 Example:
see GetOutputStringLine
IPQ_DLL_EXPORT int GetOutputStringOn ( int id )

Retrieves the current value of the output string switch.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if output is stored, 0 (zero) otherwise.
See also
GetOutputFileOn, GetOutputString, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn, SetOutputStringOn
Fortran90 Interface:
FUNCTION GetOutputStringOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetOutputStringOn
END FUNCTION GetOutputStringOn
IPQ_DLL_EXPORT int GetSelectedOutputColumnCount ( int id )

Retrieves the number of columns in the selected-output buffer.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of columns.
See also
GetSelectedOutputFileOn, GetSelectedOutputRowCount, GetSelectedOutputValue, SetSelectedOutputFileOn
Fortran90 Interface:
FUNCTION GetSelectedOutputColumnCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetSelectedOutputColumnCount
END FUNCTION GetSelectedOutputColumnCount
IPQ_DLL_EXPORT int GetSelectedOutputCount ( int id )

Retrieves the count of SELECTED_OUTPUT blocks that are currently defined.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of SELECTED_OUTPUT blocks.
See also
GetCurrentSelectedOutputUserNumber, GetNthSelectedOutputUserNumber, SetCurrentSelectedOutputUserNumber
Precondition
(RunAccumulated, RunFile, RunString) must have been called and returned 0 (zero) errors.
Fortran90 Interface:
FUNCTION GetSelectedOutputCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetSelectedOutputCount
END FUNCTION GetSelectedOutputCount
C Example:
see SetCurrentSelectedOutputUserNumber
IPQ_DLL_EXPORT const char* GetSelectedOutputFileName ( int id )

Retrieves the name of the current selected output file (see SetCurrentSelectedOutputUserNumber). This file name is used if not specified within SELECTED_OUTPUT input. The default value is selected_n.id.out.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
filename The name of the file to write SELECTED_OUTPUT output to.
See also
GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileName, SetSelectedOutputFileOn, SetSelectedOutputStringOn
Fortran90 Interface:
SUBROUTINE GetSelectedOutputFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
END SUBROUTINE GetSelectedOutputFileName
IPQ_DLL_EXPORT int GetSelectedOutputFileOn ( int id )

Retrieves the current selected-output file switch (see SetCurrentSelectedOutputUserNumber).

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if output is written to the selected-output (selected_n.id.out if unspecified) file, 0 (zero) otherwise.
See also
GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
Fortran90 Interface:
FUNCTION GetSelectedOutputFileOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetSelectedOutputFileOn
END FUNCTION GetSelectedOutputFileOn
IPQ_DLL_EXPORT int GetSelectedOutputRowCount ( int id )

Retrieves the number of rows in the current selected-output buffer (see SetCurrentSelectedOutputUserNumber).

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of rows.
See also
GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
Fortran90 Interface:
FUNCTION GetSelectedOutputRowCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetSelectedOutputRowCount
END FUNCTION GetSelectedOutputRowCount
IPQ_DLL_EXPORT const char* GetSelectedOutputString ( int id )

Retrieves the string buffer containing the current SELECTED_OUTPUT (see SetCurrentSelectedOutputUserNumber).

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
A null terminated string containing SELECTED_OUTPUT.
Precondition
SetSelectedOutputStringOn must have been set to true (non-zero) in order to receive SELECTED_OUTPUT.
See also
GetSelectedOutputFileOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, SetSelectedOutputFileOn, SetCurrentSelectedOutputUserNumber SetSelectedOutputStringOn
Fortran90 Interface:
Not implemented. (see GetSelectedOutputStringLineCount, GetSelectedOutputStringLine)

C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
#define TRUE 1
int main(void)
{
int id;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (SetSelectedOutputStringOn(id, TRUE) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunFile(id, "ex2") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
printf("selected-output:\n");
printf("%s\n", GetSelectedOutputString(id));
if (DestroyIPhreeqc(id)) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
IPQ_DLL_EXPORT const char* GetSelectedOutputStringLine | ( | int | id,
 |  | int | n
 | ) |  |

Retrieves the given line of the current selected output string (see SetCurrentSelectedOutputUserNumber).

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition
SetSelectedOutputStringOn must have been set to true (non-zero).
See also
GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
Fortran90 Interface:
(Note: N is one-based for the Fortran interface.)
SUBROUTINE GetSelectedOutputStringLine(ID,N,LINE)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  INTEGER(KIND=4),   INTENT(IN)   :: N
  CHARACTER(LEN=*),  INTENT(OUT)  :: LINE
END SUBROUTINE GetSelectedOutputStringLine

Fortran90 Example:
PROGRAM example
USE iphreeqc
INTEGER(KIND=4) :: id
INTEGER(KIND=4) :: i
CHARACTER(LEN=400):: line
id = createiphreeqc()
IF (id.LT.0) THEN
stop
END IF
IF (setselectedoutputstringon(id, .true.).NE.ipq_ok) THEN
CALL outputerrorstring(id)
stop
END IF
IF (loaddatabase(id, "phreeqc.dat").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
IF (runfile(id, "ex2").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "selected-output:"
DO i=1,getselectedoutputstringlinecount(id)
CALL getselectedoutputstringline(id, i, line)
WRITE(*,*) trim(line)
END DO
IF (destroyiphreeqc(id).NE.ipq_ok) THEN
stop
END IF
END PROGRAM example
IPQ_DLL_EXPORT int GetSelectedOutputStringLineCount ( int id )

Retrieves the number of lines in the current selected output string buffer (see SetCurrentSelectedOutputUserNumber).

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of lines.
Precondition
SetSelectedOutputStringOn must have been set to true (non-zero).
See also
GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
Fortran90 Interface:
FUNCTION GetSelectedOutputStringLineCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetSelectedOutputStringLineCount
END FUNCTION GetSelectedOutputStringLineCount
Fortran90 Example:
see GetSelectedOutputStringLine
IPQ_DLL_EXPORT int GetSelectedOutputStringOn ( int id )

Retrieves the value of the current selected output string switch (see SetCurrentSelectedOutputUserNumber).

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
Non-zero if output defined by the SELECTED_OUTPUT keyword is stored, 0 (zero) otherwise.
See also
GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
Fortran90 Interface:
FUNCTION GetSelectedOutputStringOn(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4)               :: GetSelectedOutputStringOn
END FUNCTION GetSelectedOutputStringOn

IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue | ( | int | id,
 |  | int | row,
 |  | int | col,
 |  | VAR * | pVAR
 | ) |  |

Returns the VAR associated with the specified row and column. The current SELECTED_OUTPUT block is set using the SetCurrentSelectedOutputUserNumber method.

Parameters
id | The instance id returned from CreateIPhreeqc.
row | The row index.
col | The column index.
pVAR | Pointer to the VAR to receive the requested data.
Return values
IPQ_OK | Success.
IPQ_INVALIDROW | The given row is out of range.
IPQ_INVALIDCOL | The given column is out of range.
IPQ_OUTOFMEMORY | Memory could not be allocated.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue2, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
Remarks
Row 0 contains the column headings to the selected_ouput.
Examples:
The headings will include a suffix and/or prefix in order to differentiate the columns.

Input Headings
  SELECTED_OUTPUT
    -reset false
    -totals Ca Na

  Ca(mol/kgw)  Na(mol/kgw)

  SELECTED_OUTPUT
    -reset false
    -molalities Fe+2 Hfo_sOZn+

  m_Fe+2(mol/kgw)  m_Hfo_sOZn+(mol/kgw)

  SELECTED_OUTPUT
    -reset false
    -activities H+ Ca+2

  la_H+  la_Ca+2

  SELECTED_OUTPUT
    -reset false
    -equilibrium_phases Calcite Dolomite

  Calcite  d_Calcite  Dolomite  d_Dolomite

  SELECTED_OUTPUT
    -reset false
    -saturation_indices CO2(g) Siderite

  si_CO2(g)  si_Siderite

  SELECTED_OUTPUT
    -reset false
    -gases CO2(g) N2(g)

  pressure "total mol" volume g_CO2(g) g_N2(g)

  SELECTED_OUTPUT
    -reset false
    -kinetic_reactants CH2O Pyrite

  k_CH2O dk_CH2O k_Pyrite dk_Pyrite

  SELECTED_OUTPUT
    -reset false
    -solid_solutions CaSO4 SrSO4

  s_CaSO4 s_SrSO4
Fortran90 Interface:
ROW is 1-based for the Fortran interface except that the column headings are stored in ROW=0. COL is 1-based for the Fortran interface.
    FUNCTION GetSelectedOutputValue(ID,ROW,COL,VTYPE,DVALUE,SVALUE,SLENGTH)
      INTEGER(KIND=4),   INTENT(IN)            :: ID
      INTEGER(KIND=4),   INTENT(IN)            :: ROW
      INTEGER(KIND=4),   INTENT(IN)            :: COL
      INTEGER(KIND=4),   INTENT(OUT)           :: VTYPE
      REAL(KIND=8),      INTENT(OUT)           :: DVALUE
      CHARACTER(LEN=*),  INTENT(OUT)           :: SVALUE
      INTEGER(KIND=4),   INTENT(OUT), OPTIONAL :: SLENGTH
      INTEGER(KIND=4)                          :: GetSelectedOutputValue
    END FUNCTION GetSelectedOutputValue
Parameters
ID | The instance id returned from CreateIPhreeqc.
ROW | The row index.
COL | The column index.
VTYPE | Returns the variable type. See VAR_TYPE.
DVALUE | Returns the numeric value when (VTYPE=TT_DOUBLE) or (VTYPE=TT_LONG).
SVALUE | Returns the string variable when (VTYPE=TT_STRING). When (VTYPE=TT_DOUBLE) or (VTYPE=TT_LONG) this variable is filled with a string equivalent of DVALUE.
SLENGTH | Optional, if the length of SVALUE isn't sufficient to hold the entire string value, returns the required length, otherwise returns 0 (zero).
C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
int main(void)
{
int id, i, j;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunFile(id, "ex2") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
VAR v;
VarInit(&v);
printf("selected-output:\n");
for (i = 0; i < GetSelectedOutputRowCount(id); ++i) {
for (j = 0; j < GetSelectedOutputColumnCount(id); ++j) {
if (GetSelectedOutputValue(id, i, j, &v) == IPQ_OK) {
switch (v.type) {
case TT_LONG:
printf("%ld ", v.lVal);
break;
case TT_DOUBLE:
printf("%g ", v.dVal);
break;
case TT_STRING:
printf("%s ", v.sVal);
break;
case TT_EMPTY:
printf("<empty> ");
break;
case TT_ERROR:
printf("<error> ");
break;
}
}
VarClear(&v);
}
printf("\n");
}
if (DestroyIPhreeqc(id)) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

Fortran90 Example:
PROGRAM example
USE iphreeqc
INTEGER(KIND=4) :: id
INTEGER(KIND=4) :: i
INTEGER(KIND=4) :: j
INTEGER(KIND=4) :: vt
REAL(KIND=8) :: dv
CHARACTER(LEN=40) :: sv
INTEGER(KIND=4) :: sl
id = createiphreeqc()
IF (id.LT.0) THEN
stop
END IF
IF (loaddatabase(id, "phreeqc.dat").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
IF (runfile(id, "ex2").NE.0) THEN
CALL outputerrorstring(id)
stop
END IF
WRITE(*,*) "selected-output:"
DO i=0,getselectedoutputrowcount(id)
DO j=1,getselectedoutputcolumncount(id)
IF (getselectedoutputvalue(id, i, j, vt, dv, sv, sl).EQ.ipq_ok) THEN
IF (vt.EQ.tt_double) THEN
WRITE(*,"(g12.6,A1)",advance="NO") dv, " "
ELSE IF (vt.EQ.tt_string) THEN
IF (sl.EQ.0) THEN
WRITE(*,"(A12,A1)",advance="NO") sv, " "
ELSE
WRITE(*,"(A12,A1)",advance="NO") "#ERR", " "
END IF
END IF
END IF
END DO
WRITE(*,*)
END DO
IF (destroyiphreeqc(id).NE.ipq_ok) THEN
stop
END IF
END PROGRAM example
IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue2 | ( | int | id,
 |  | int | row,
 |  | int | col,
 |  | int * | vtype,
 |  | double * | dvalue,
 |  | char * | svalue,
 |  | unsigned int | svalue_length
 | ) |  |

Returns the associated data with the specified row and column. The current SELECTED_OUTPUT block is set using the SetCurrentSelectedOutputUserNumber method.

Parameters
id | The instance id returned from CreateIPhreeqc.
row | The row index.
col | The column index.
vtype | Receives the variable type. See VAR_TYPE.
dvalue | Receives the numeric value when (VTYPE=TT_DOUBLE) or (VTYPE=TT_LONG).
svalue | Receives the string variable when (VTYPE=TT_STRING). When (VTYPE=TT_DOUBLE) or (VTYPE=TT_LONG) this variable is filled with a string equivalent of DVALUE.
svalue_length | The length of the svalue buffer.
Return values
IPQ_OK | Success.
IPQ_INVALIDROW | The given row is out of range.
IPQ_INVALIDCOL | The given column is out of range.
IPQ_OUTOFMEMORY | Memory could not be allocated.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
Remarks
Row 0 contains the column headings to the selected_ouput.
Examples:
The headings will include a suffix and/or prefix in order to differentiate the columns.

Input Headings
  SELECTED_OUTPUT
    -reset false
    -totals Ca Na

  Ca(mol/kgw)  Na(mol/kgw)

  SELECTED_OUTPUT
    -reset false
    -molalities Fe+2 Hfo_sOZn+

  m_Fe+2(mol/kgw)  m_Hfo_sOZn+(mol/kgw)

  SELECTED_OUTPUT
    -reset false
    -activities H+ Ca+2

  la_H+  la_Ca+2

  SELECTED_OUTPUT
    -reset false
    -equilibrium_phases Calcite Dolomite

  Calcite  d_Calcite  Dolomite  d_Dolomite

  SELECTED_OUTPUT
    -reset false
    -saturation_indices CO2(g) Siderite

  si_CO2(g)  si_Siderite

  SELECTED_OUTPUT
    -reset false
    -gases CO2(g) N2(g)

  pressure "total mol" volume g_CO2(g) g_N2(g)

  SELECTED_OUTPUT
    -reset false
    -kinetic_reactants CH2O Pyrite

  k_CH2O dk_CH2O k_Pyrite dk_Pyrite

  SELECTED_OUTPUT
    -reset false
    -solid_solutions CaSO4 SrSO4

  s_CaSO4 s_SrSO4
C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
const int SVALUE_LENGTH = 100;
int main(void)
{
int id, i, j, vtype;
double dvalue;
char svalue[SVALUE_LENGTH];
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunFile(id, "ex2") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
printf("selected-output:\n");
for (i = 0; i < GetSelectedOutputRowCount(id); ++i) {
for (j = 0; j < GetSelectedOutputColumnCount(id); ++j) {
if (GetSelectedOutputValue2(id, i, j, &vtype, &dvalue, svalue, SVALUE_LENGTH) == IPQ_OK) {
switch (vtype) {
case TT_LONG:
printf("%ld ", (long)dvalue);
break;
case TT_DOUBLE:
printf("%g ", dvalue);
break;
case TT_STRING:
printf("%s ", svalue);
break;
case TT_EMPTY:
printf("<empty> ");
break;
}
}
}
printf("\n");
}
if (DestroyIPhreeqc(id)) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
IPQ_DLL_EXPORT const char* GetVersionString ( void )

Retrieves the string buffer containing the version in the form of X.X.X-XXXX.

Returns
A null terminated string containing the IPhreeqc version number.
Fortran90 Interface:
SUBROUTINE GetVersionString(VERSION)
  CHARACTER(LEN=*), INTENT(OUT) :: VERSION
END SUBROUTINE GetVersionString
C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
int main(void)
{
printf("Version:\n");
printf("%s\n", GetVersionString());
return EXIT_SUCCESS;
}
Fortran90 Example:
PROGRAM example
USE iphreeqc
CHARACTER(LEN=80) :: version
WRITE(*,*) "Version:"
CALL getversionstring(version)
WRITE(*,*) trim(version)
END PROGRAM example
IPQ_DLL_EXPORT const char* GetWarningString ( int id )

Retrieves the warning messages from the last call to (RunAccumulated, RunFile, RunString, LoadDatabase, or LoadDatabaseString).

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
A null terminated string containing warning messages.
See also
GetWarningStringLine, GetWarningStringLineCount, OutputWarningString
Fortran90 Interface:
Not implemented. (see GetWarningStringLineCount, GetWarningStringLine, OutputWarningString)
IPQ_DLL_EXPORT const char* GetWarningStringLine | ( | int | id,
 |  | int | n
 | ) |  |

Retrieves the given warning line.

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The zero-based index of the line to retrieve.
Returns
A null terminated string containing the given warning line message.
See also
GetWarningString, GetWarningStringLineCount, OutputWarningString
Fortran90 Interface:
(Note: N is one-based for the Fortran interface.)
SUBROUTINE GetWarningStringLine(ID,N,LINE)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: N
  CHARACTER(LEN=*), INTENT(OUT) :: LINE
END SUBROUTINE GetWarningStringLine
IPQ_DLL_EXPORT int GetWarningStringLineCount ( int id )

Retrieves the number of lines in the current warning string buffer.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of lines.
See also
GetWarningString, GetWarningStringLine, OutputWarningString
Fortran90 Interface:
FUNCTION GetWarningStringLineCount(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: GetWarningStringLineCount
END FUNCTION GetWarningStringLineCount

IPQ_DLL_EXPORT int LoadDatabase | ( | int | id,
 |  | const char * | filename
 | ) |  |

Load the specified database file into phreeqc.

Parameters
id | The instance id returned from CreateIPhreeqc.
filename | The name of the phreeqc database to load. The full path (or relative path with respect to the working directory) must be given if the file is not in the current working directory.
Returns
The number of errors encountered.
See also
LoadDatabaseString
Remarks
All previous definitions are cleared.
Fortran90 Interface:
FUNCTION LoadDatabase(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)  :: ID
  CHARACTER(LEN=*),  INTENT(IN)  :: FILENAME
  INTEGER(KIND=4)                :: LoadDatabase
END FUNCTION LoadDatabase
C Example:
see CreateIPhreeqc
Fortran90 Example:
see CreateIPhreeqc
IPQ_DLL_EXPORT int LoadDatabaseString | ( | int | id,
 |  | const char * | input
 | ) |  |

Load the specified string as a database into phreeqc.

Parameters
id | The instance id returned from CreateIPhreeqc.
input | String containing data to be used as the phreeqc database.
Returns
The number of errors encountered.
See also
LoadDatabase
Remarks
All previous definitions are cleared.
Fortran90 Interface:
FUNCTION LoadDatabaseString(ID,INPUT)
  INTEGER(KIND=4),   INTENT(IN)  :: ID
  CHARACTER(LEN=*),  INTENT(IN)  :: INPUT
  INTEGER(KIND=4)                :: LoadDatabaseString
END FUNCTION LoadDatabaseString
IPQ_DLL_EXPORT void OutputAccumulatedLines ( int id )

Output the accumulated input buffer to stdout. This input buffer can be run with a call to RunAccumulated.

Parameters
id The instance id returned from CreateIPhreeqc.
See also
AccumulateLine, ClearAccumulatedLines, RunAccumulated
Fortran90 Interface:
SUBROUTINE OutputAccumulatedLines(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
END SUBROUTINE OutputAccumulatedLines
Fortran90 Example:
see GetDumpStringLine
IPQ_DLL_EXPORT void OutputErrorString ( int id )

Output the error messages normally stored in the phreeqc.id.err file to stdout.

Parameters
id The instance id returned from CreateIPhreeqc.
See also
GetErrorFileOn, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn
Fortran90 Interface:
SUBROUTINE OutputErrorString(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
END SUBROUTINE OutputErrorString
C Example:
see GetComponent
Fortran90 Example:
see GetDumpStringLine
IPQ_DLL_EXPORT void OutputWarningString ( int id )

Output the warning messages to stdout.

Parameters
id The instance id returned from CreateIPhreeqc.
See also
GetWarningString, GetWarningStringLine, GetWarningStringLineCount
Fortran90 Interface:
SUBROUTINE OutputWarningString(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
END SUBROUTINE OutputWarningString
IPQ_DLL_EXPORT int RunAccumulated ( int id )

Runs the input buffer as defined by calls to AccumulateLine.

Parameters
id The instance id returned from CreateIPhreeqc.
Returns
The number of errors encountered.
See also
AccumulateLine, ClearAccumulatedLines, OutputAccumulatedLines, RunFile, RunString
Remarks
The accumulated input is cleared at the next call to AccumulateLine.
Precondition
LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
Fortran90 Interface:
FUNCTION RunAccumulated(ID)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4)               :: RunAccumulated
END FUNCTION RunAccumulated
Fortran90 Example:
see GetDumpStringLine
IPQ_DLL_EXPORT int RunFile | ( | int | id,
 |  | const char * | filename
 | ) |  |

Runs the specified phreeqc input file.

Parameters
id | The instance id returned from CreateIPhreeqc.
filename | The name of the phreeqc input file to run.
Returns
The number of errors encountered during the run.
See also
RunAccumulated, RunString
Precondition
(LoadDatabase, LoadDatabaseString) must have been called and returned 0 (zero) errors.
Fortran90 Interface:
FUNCTION RunFile(ID,FNAME)
  INTEGER(KIND=4),   INTENT(IN)  :: ID
  CHARACTER(LEN=*),  INTENT(IN)  :: FNAME
  INTEGER(KIND=4)                :: RunFile
END FUNCTION RunFile
C Example:
see CreateIPhreeqc
Fortran90 Example:
see CreateIPhreeqc
IPQ_DLL_EXPORT int RunString | ( | int | id,
 |  | const char * | input
 | ) |  |

Runs the specified string as input to phreeqc.

Parameters
id | The instance id returned from CreateIPhreeqc.
input | String containing phreeqc input.
Returns
The number of errors encountered during the run.
See also
RunAccumulated, RunFile
Precondition
(LoadDatabase, LoadDatabaseString) must have been called and returned 0 (zero) errors.
Fortran90 Interface:
FUNCTION RunString(ID,INPUT)
  INTEGER(KIND=4),  INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(IN)  :: INPUT
  INTEGER(KIND=4)                :: RunString
END FUNCTION RunString
C Example:
see GetDumpString
IPQ_DLL_EXPORT IPQ_RESULT SetBasicCallback | ( | int | id,
 |  | double(*)(double x1, double x2, const char *str, void *cookie) | fcn,
 |  | void * | cookie1
 | ) |  |

Sets a C callback function for Basic programs. The syntax for the Basic command is 10 result = CALLBACK(x1, x2, string$) The syntax for the C function is double my_callback(double x1, double x2, const char * string)

Parameters
id | The instance id returned from CreateIPhreeqc.
fcn | The name of a user-defined function.
cookie1 | A user defined value to be passed to the callback function.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
Fortran90 Interface:
see SetBasicFortranCallback
C Example:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <IPhreeqc.h>
#define TRUE 1
const char input[] =
"SOLUTION 1-2 \n"
"END \n"
"EQUILIBRIUM_PHASES 1 \n"
" CO2(g) -1.5 10 \n"
"EQUILIBRIUM_PHASES 2 \n"
" Calcite 0 10 \n"
"SELECTED_OUTPUT 1 \n"
" -reset false \n"
"USER_PUNCH \n"
" -Heading pH SR(calcite) Year \n"
" 10 PUNCH -LA(\"H+\"), SR(\"calcite\") \n"
" 20 PUNCH CALLBACK(cell_no, -LA(\"H+\"), \"Year\") \n"
"END \n"
"RUN_CELLS \n"
" -cells 1-2 \n"
"END \n";
struct MyData {
double year;
};
double MyCallback(double x1, double x2, const char *str1, void *mydata)
{
/*
Use of a callback is optional.
The callback provides a way to obtain data from a Basic program
through the variables x1, x2, and str1, and send data to a
Basic program through the return value of the callback.
The void pointer mydata can be used to obtain data from the
calling program; in this example, it points to a structure.
The callback function is called whenever CALLBACK(x1, x2, str$)
is used in a Basic program (usually USER_PUNCH).
*/
if (strcmp(str1, "Year") == 0)
{
fprintf(stderr, "Callback for cell %d: pH %8.2f\n", (int) x1, x2);
return ((struct MyData *) mydata)->year;
}
return -1;
}
int main(void)
{
int id;
struct MyData mydata;
mydata.year = 2012.0;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (SetSelectedOutputFileOn(id, TRUE) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (SetBasicCallback(id, MyCallback, &mydata) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunString(id, input) != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
IPQ_DLL_EXPORT IPQ_RESULT SetBasicFortranCallback | ( | int | id,
 |  | double(*)(double *x1, double *x2, const char *str, int l) | fcn
 | ) |  |

Sets a Fortran callback function for Basic programs. The syntax for the Basic command is 10 result = CALLBACK(x1, x2, string$) The syntax for the Fortran function is REAL(KIND=C_DOUBLE) my_callback(x1, x2, string), where x1 and x2 are REAL(KIND=C_DOUBLE) and string is a CHARACTER(KIND=C_CHAR).

Parameters
id | The instance id returned from CreateIPhreeqc.
fcn | The name of a REAL(KIND=C_DOUBLE) Fortran function with three arguments (two REAL(KIND=C_DOUBLE), and one CHARACTER(KIND=C_CHAR)).
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
Fortran90 Interface:
!
! if using  include files (IPhreeqc.f.inc or IPhreeqc.f90.inc)
!
#ifdef IPHREEQC_NO_FORTRAN_MODULE
FUNCTION SetBasicFortranCallback(ID,FCN)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTERFACE
    DOUBLE PRECISION FUNCTION FCN(x1, x2, str)
      DOUBLE PRECISION, INTENT(in) :: x1
      DOUBLE PRECISION, INTENT(in) :: x2
      CHARACTER(*), INTENT(in)     :: str
    END FUNCTION
  END INTERFACE
  INTEGER(KIND=4)               :: SetBasicFortranCallback
END FUNCTION SetBasicFortranCallback
#else
!
! if using the fortran module (USE IPhreeqc)
! must also add IPhreeqc_interface.F90 to your project
!
FUNCTION SetBasicFortranCallback(ID,FCN)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTERFACE
    REAL(KIND=C_DOUBLE) FUNCTION fcn(x1, x2, str, l) BIND(C)
      USE ISO_C_BINDING
      IMPLICIT none
      REAL(KIND=C_DOUBLE),    INTENT(in)        :: x1, x2
      CHARACTER(KIND=C_CHAR), INTENT(in)        :: str(*)
      INTEGER(KIND=C_INT),    INTENT(in), VALUE :: l
    END FUNCTION fcn
  END INTERFACE
END FUNCTION SetBasicFortranCallback
#endif
Fortran90 Example:
MODULE mydata
DOUBLE PRECISION year
END MODULE mydata
MODULE callback
CONTAINS
REAL(kind=C_DOUBLE) FUNCTION mycallback(x1, x2, str, l) BIND(C, name='MyCallback')
USE mydata, ONLY : year
USE iso_c_binding
!
! Use of a callback is optional.
!
! The callback provides a way to obtain data from a Basic program
! through the variables x1, x2, and str, and send data to a
! Basic program through the return value of the callback.
!
! The callback function is called whenever CALLBACK(x1, x2, str$)
! is used in a Basic program (usually USER_PUNCH). See file "ic".
!
REAL(kind=C_DOUBLE), INTENT(in) :: x1, x2
CHARACTER(kind=C_CHAR), INTENT(in) :: str(*)
INTEGER(kind=C_INT), INTENT(in), value :: l
character(len=l) fstr
mycallback = -1.0
! An example of a datum available in main program
do i = 1, l
fstr(i:i) = str(i)
enddo
IF (trim(fstr) .EQ. "Year") THEN
WRITE (*,"(/a,i2,a,f8.2)") "Callback for cell ", int(x1), ": pH ", x2
mycallback = year
ENDIF
RETURN
END FUNCTION mycallback
END MODULE callback
PROGRAM advect
USE callback
USE mydata
USE iphreeqc
INTEGER :: id
!Create module, load database, define initial conditions and selected output
year = 2012.
id = createiphreeqc()
IF (loaddatabase(id, "phreeqc.dat") .NE. 0) THEN
CALL outputerrorstring(id)
stop
ENDIF
IF (setselectedoutputfileon(id, .true.) .NE. 0) THEN
CALL outputerrorstring(id)
stop
ENDIF
IF (setbasicfortrancallback(id, mycallback) .NE. 0) THEN
CALL outputerrorstring(id)
stop
ENDIF
IF (runfile(id, "ic") .NE. 0) THEN
CALL outputerrorstring(id)
stop
ENDIF
!Destroy module
IF (destroyiphreeqc(id) .NE. 0) CALL outputerrorstring(id)
END PROGRAM advect
File ic :
SOLUTION 1-2
END
EQUILIBRIUM_PHASES 1
CO2(g) -1.5 10
EQUILIBRIUM_PHASES 2
Calcite 0 10
SELECTED_OUTPUT 1
-reset false
USER_PUNCH
-Heading pH SR(calcite) Year
10 PUNCH -LA("H+"), SR("calcite")
20 PUNCH CALLBACK(cell_no, -LA("H+"), "Year")
END
RUN_CELLS
-cells 1-2
END
IPQ_DLL_EXPORT IPQ_RESULT SetCurrentSelectedOutputUserNumber | ( | int | id,
 |  | int | n
 | ) |  |

Sets the current SELECTED_OUTPUT user number for use in subsequent calls to (GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue, GetSelectedOutputValue2) routines. The initial setting after calling CreateIPhreeqc is 1.

Parameters
id | The instance id returned from CreateIPhreeqc.
n | The user number specified in the SELECTED_OUTPUT block.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
IPQ_INVALIDARG | The given user number is invalid.
See also
GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue
Fortran90 Interface:
FUNCTION SetCurrentSelectedOutputUserNumber(ID,N)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  INTEGER(KIND=4),  INTENT(IN)  :: N
  INTEGER(KIND=4)               :: SetCurrentSelectedOutputUserNumber
END FUNCTION SetCurrentSelectedOutputUserNumber

C Example:
#include <stdlib.h>
#include <stdio.h>
#include <IPhreeqc.h>
int main(void)
{
int id, i, n, r, c;
char buffer[30];
FILE* f;
VAR v;
id = CreateIPhreeqc();
if (id < 0) {
return EXIT_FAILURE;
}
if (LoadDatabase(id, "phreeqc.dat") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
if (RunFile(id, "multi_punch") != 0) {
OutputErrorString(id);
return EXIT_FAILURE;
}
VarInit(&v);
for (i = 0; i < GetSelectedOutputCount(id); ++i) {
n = GetNthSelectedOutputUserNumber(id, i);
sprintf(buffer, "sel_out.%d.out", n);
if ((f = fopen(buffer, "w"))) {
SetCurrentSelectedOutputUserNumber(id, n);
for (r = 0; r < GetSelectedOutputRowCount(id); ++r) {
for (c = 0; c < GetSelectedOutputColumnCount(id); ++c) {
if (GetSelectedOutputValue(id, r, c, &v) == IPQ_OK) {
switch (v.type) {
case TT_LONG:
fprintf(f, "%ld,", v.lVal);
break;
case TT_DOUBLE:
fprintf(f, "%g,", v.dVal);
break;
case TT_STRING:
fprintf(f, "%s,", v.sVal);
break;
default:
fprintf(f, ",");
break;
}
}
VarClear(&v);
}
fprintf(f, "\n");
}
fclose(f);
}
}
if (DestroyIPhreeqc(id) != IPQ_OK) {
OutputErrorString(id);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
File multi_punch :
SOLUTION 1
pH 7 charge
Na 1
Cl 1
Ca 1
C 2
END
CALCULATE_VALUES
TOTAL_C
-start
10 save TOT("C")
-end
END
EQUILIBRIUM_PHASES 1
CO2(g) -2
Dolomite 0
END
REACTION 1
HCl 1
0.1 mmol
END
GAS_PHASE
-fixed_volume
N2(g) 1.2
END
KINETICS
Calcite
-tol 1e-8
-m0 3.e-3
-m 3.e-3
-parms 50 0.6
END
SOLID_SOLUTION
Sulfate
-comp Anhydrite 1.0
-comp Barite 1.0
END
RUN_CELLS
-cell 1
SELECTED_OUTPUT
-file multi_punch_1.sel
-reset false
-sim
-state
-solution
-dist
-time
-step
-pH
-pe
-reaction
-temperature
-alkalinity
-ionic_strength
-water
-charge_balance
-percent_error
-totals Na Ca
-molalities Na+ HCO3-
-activities Ca+2 CO3-2
-equilibrium_phases CO2(g) dolomite
-saturation_indices Halite
-gases N2(g)
-kinetics Calcite
-solid_solutions Anhydrite Barite
-calculate_values TOTAL_C
-inverse false
SELECTED_OUTPUT 2
-file multi_punch_2.sel
-si Halite Calcite
USER_PUNCH 20
-heading Dummy
10 PUNCH "Dummy"
END
USER_PUNCH 2
-heading DUMMY_1 DUMMY_2
10 PUNCH "Dummy1", "Dummy2"
RUN_CELLS
-cell 1
SELECTED_OUTPUT 1
-active false
END
RUN_CELLS
-cell 1
SELECTED_OUTPUT 1
-active true
END
SOLUTION 2
pH 7 charge
END
SOLUTION 3
pH 7 charge
Na 1
Cl 1
END
INVERSE_MODELING
-solution 2 3
-phases
Halite
SELECTED_OUTPUT 3
-reset false
-file multi_punch_3.sel
END
RUN_CELLS
-cell 1
IPQ_DLL_EXPORT IPQ_RESULT SetDumpFileName | ( | int | id,
 |  | const char * | filename
 | ) |  |

Sets the name of the dump file. This file name is used if not specified within DUMP input. The default value is dump.id.out.

Parameters
id | The instance id returned from CreateIPhreeqc.
filename | The name of the file to write DUMP output to.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetDumpFileName, GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn, SetDumpStringOn
Fortran90 Interface:
FUNCTION SetDumpFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
  INTEGER(KIND=4)                 :: SetDumpFileName
END FUNCTION SetDumpFileName

IPQ_DLL_EXPORT IPQ_RESULT SetDumpFileOn | ( | int | id,
 |  | int | dump_on
 | ) |  |

Sets the dump file switch on or off. This switch controls whether or not phreeqc writes to the dump file. The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
dump_on | If non-zero, turns on output to the DUMP (dump.id.out if unspecified) file; if zero, turns off output to the DUMP file.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringOn, GetDumpStringLineCount, SetDumpStringOn
Fortran90 Interface:
FUNCTION SetDumpFileOn(ID,DUMP_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: DUMP_ON
  INTEGER(KIND=4)               :: SetDumpFileOn
END FUNCTION SetDumpFileOn

IPQ_DLL_EXPORT IPQ_RESULT SetDumpStringOn | ( | int | id,
 |  | int | dump_string_on
 | ) |  |

Sets the dump string switch on or off. This switch controls whether or not the data normally sent to the dump file are stored in a buffer for retrieval. The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
dump_string_on | If non-zero, captures the output defined by the DUMP keyword into a string buffer; if zero, output defined by the DUMP keyword is not captured to a string buffer.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetDumpFileOn, GetDumpStringOn, GetDumpString, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn
Fortran90 Interface:
FUNCTION SetDumpStringOn(ID,DUMP_STRING_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: DUMP_STRING_ON
  INTEGER(KIND=4)               :: SetDumpStringOn
END FUNCTION SetDumpStringOn
C Example:
see GetDumpString
Fortran90 Example:
see GetDumpStringLine
IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileName | ( | int | id,
 |  | const char * | filename
 | ) |  |

Sets the name of the error file. The default value is phreeqc.id.err.

Parameters
id | The instance id returned from CreateIPhreeqc.
filename | The name of the error file.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetErrorFileName, GetErrorFileOn, GetErrorString, GetErrorStringOn, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn, SetErrorStringOn
Fortran90 Interface:
FUNCTION SetErrorFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
  INTEGER(KIND=4)                 :: SetErrorFileName
END FUNCTION SetErrorFileName

IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileOn | ( | int | id,
 |  | int | error_on
 | ) |  |

Sets the error file switch on or off. This switch controls whether or not error messages are written to the phreeqc.id.err file. The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
error_on | If non-zero, writes errors to the error file; if zero, no errors are written to the error file.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetErrorFileOn, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString
Fortran90 Interface:
FUNCTION SetErrorFileOn(ID,ERR_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: ERR_ON
  INTEGER(KIND=4)               :: SetErrorFileOn
END FUNCTION SetErrorFileOn

IPQ_DLL_EXPORT IPQ_RESULT SetErrorOn | ( | int | id,
 |  | int | error_on
 | ) |  |

Sets the error switch on or off. This switch controls whether or not error messages are generated and displayed. The initial setting after calling CreateIPhreeqc is on.

Parameters
id | The instance id returned from CreateIPhreeqc.
error_on | If non-zero, writes errors to the error file and error string; if zero, no errors are written to the error file or stored in the error string.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetErrorOn, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString
Fortran90 Interface:
FUNCTION SetErrorOn(ID,ERR_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: ERR_ON
  INTEGER(KIND=4)               :: SetErrorOn
END FUNCTION SetErrorOn

IPQ_DLL_EXPORT IPQ_RESULT SetErrorStringOn | ( | int | id,
 |  | int | error_string_on
 | ) |  |

Sets the error string switch on or off. This switch controls whether or not the data normally sent to the error file are stored in a buffer for retrieval. The initial setting after calling CreateIPhreeqc is on.

Parameters
id | The instance id returned from CreateIPhreeqc.
error_string_on | If non-zero, captures the error output into a string buffer; if zero, error output is not captured to a string buffer.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetErrorFileOn, GetErrorStringOn, GetErrorString, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn
Fortran90 Interface:
FUNCTION SetErrorStringOn(ID,ERR_STRING_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: ERR_STRING_ON
  INTEGER(KIND=4)               :: SetErrorStringOn
END FUNCTION SetErrorStringOn
C Example:
see GetErrorString
Fortran90 Example:
see GetErrorStringLine
IPQ_DLL_EXPORT IPQ_RESULT SetLogFileName | ( | int | id,
 |  | const char * | filename
 | ) |  |

Sets the name of the log file. The default value is phreeqc.id.log.

Parameters
id | The instance id returned from CreateIPhreeqc.
filename | The name of the log file.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetLogFileName, GetLogFileOn, GetLogString, GetLogStringOn, GetLogStringLine, GetLogStringLineCount, SetLogFileOn, SetLogStringOn
Fortran90 Interface:
FUNCTION SetLogFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
  INTEGER(KIND=4)                 :: SetLogFileName
END FUNCTION SetLogFileName

IPQ_DLL_EXPORT IPQ_RESULT SetLogFileOn | ( | int | id,
 |  | int | log_on
 | ) |  |

Sets the log file switch on or off. This switch controls whether or not phreeqc writes log messages to the phreeqc.id.log file. The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
log_on | If non-zero, log messages are written to the log file; if zero, no log messages are written to the log file.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
Remarks
Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also
GetLogFileOn
Fortran90 Interface:
FUNCTION SetLogFileOn(ID,LOG_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: LOG_ON
  INTEGER(KIND=4)               :: SetLogFileOn
END FUNCTION SetLogFileOn

IPQ_DLL_EXPORT IPQ_RESULT SetLogStringOn | ( | int | id,
 |  | int | log_string_on
 | ) |  |

Sets the log string switch on or off. This switch controls whether or not the data normally sent to the log file are stored in a buffer for retrieval. The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
log_string_on | If non-zero, captures the log output into a string buffer; if zero, log output is not captured to a string buffer.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetLogFileOn, GetLogStringOn, GetLogString, GetLogStringLine, GetLogStringLineCount, SetLogFileOn
Fortran90 Interface:
FUNCTION SetLogStringOn(ID,LOG_STRING_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: LOG_STRING_ON
  INTEGER(KIND=4)               :: SetLogStringOn
END FUNCTION SetLogStringOn
C Example:
see GetLogString
Fortran90 Example:
see GetLogStringLine
IPQ_DLL_EXPORT IPQ_RESULT SetOutputFileName | ( | int | id,
 |  | const char * | filename
 | ) |  |

Sets the name of the output file. This file name is used if not specified within DUMP input. The default value is phreeqc.id.out.

Parameters
id | The instance id returned from CreateIPhreeqc.
filename | The name of the phreeqc output file.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetOutputFileName, GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn, SetOutputStringOn
Fortran90 Interface:
FUNCTION SetOutputFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
  INTEGER(KIND=4)                 :: SetOutputFileName
END FUNCTION SetOutputFileName

IPQ_DLL_EXPORT IPQ_RESULT SetOutputFileOn | ( | int | id,
 |  | int | output_on
 | ) |  |

Sets the output file switch on or off. This switch controls whether or not phreeqc writes to the phreeqc.id.out file. This is the output normally generated when phreeqc is run. The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
output_on | If non-zero, writes output to the output file; if zero, no output is written to the output file.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetOutputFileOn
Fortran90 Interface:
FUNCTION SetOutputFileOn(ID,OUT_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: OUT_ON
  INTEGER(KIND=4)               :: SetOutputFileOn
END FUNCTION SetOutputFileOn

IPQ_DLL_EXPORT IPQ_RESULT SetOutputStringOn | ( | int | id,
 |  | int | output_string_on
 | ) |  |

Sets the output string switch on or off. This switch controls whether or not the data normally sent to the output file are stored in a buffer for retrieval. The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
output_string_on | If non-zero, captures the phreeqc output into a string buffer; if zero, phreeqc output is not captured to a string buffer.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetOutputFileOn, GetOutputStringOn, GetOutputString, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn
Fortran90 Interface:
FUNCTION SetOutputStringOn(ID,OUTPUT_STRING_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: OUTPUT_STRING_ON
  INTEGER(KIND=4)               :: SetOutputStringOn
END FUNCTION SetOutputStringOn
C Example:
see GetOutputString
Fortran90 Example:
see GetOutputStringLine
IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputFileName | ( | int | id,
 |  | const char * | filename
 | ) |  |

Sets the name of the current selected output file (see SetCurrentSelectedOutputUserNumber). This file name is used if not specified within SELECTED_OUTPUT input. The default value is selected_n.id.out.

Parameters
id | The instance id returned from CreateIPhreeqc.
filename | The name of the file to write SELECTED_OUTPUT output to.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetSelectedOutputFileName, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
Fortran90 Interface:
FUNCTION SetSelectedOutputFileName(ID,FILENAME)
  INTEGER(KIND=4),   INTENT(IN)   :: ID
  CHARACTER(LEN=*),  INTENT(OUT)  :: FILENAME
  INTEGER(KIND=4)                 :: SetSelectedOutputFileName
END FUNCTION SetSelectedOutputFileName

IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputFileOn | ( | int | id,
 |  | int | sel_on
 | ) |  |

Sets the selected-output file switch on or off. This switch controls whether or not phreeqc writes output to the current SELECTED_OUTPUT file (see SetCurrentSelectedOutputUserNumber). The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
sel_on | If non-zero, writes output to the selected-output file; if zero, no output is written to the selected-output file.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber
Fortran90 Interface:
FUNCTION SetSelectedOutputFileOn(ID,SEL_ON)
  INTEGER(KIND=4),  INTENT(IN) :: ID
  LOGICAL(KIND=4),  INTENT(IN) :: SEL_ON
  INTEGER(KIND=4)              :: SetSelectedOutputFileOn
END FUNCTION SetSelectedOutputFileOn

IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputStringOn | ( | int | id,
 |  | int | sel_string_on
 | ) |  |

Sets the current selected output string switch on or off. This switch controls whether or not the data normally sent to the current selected output file (see SetCurrentSelectedOutputUserNumber) are stored in a buffer for retrieval. The initial setting after calling CreateIPhreeqc is off.

Parameters
id | The instance id returned from CreateIPhreeqc.
sel_string_on | If non-zero, captures the output defined by the SELECTED_OUTPUT keyword into a string buffer; if zero, output defined by the SELECTED_OUTPUT keyword is not captured to a string buffer.
Return values
IPQ_OK | Success.
IPQ_BADINSTANCE | The given id is invalid.
See also
GetSelectedOutputFileOn, GetSelectedOutputStringOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn
Fortran90 Interface:
FUNCTION SetSelectedOutputStringOn(ID,SELECTED_OUTPUT_STRING_ON)
  INTEGER(KIND=4),  INTENT(IN)  :: ID
  LOGICAL(KIND=4),  INTENT(IN)  :: SELECTED_OUTPUT_STRING_ON
  INTEGER(KIND=4)               :: SetSelectedOutputStringOn
END FUNCTION SetSelectedOutputStringOn
C Example:
see GetSelectedOutputString
Fortran90 Example:
see GetSelectedOutputStringLine


IPhreeqc: Var.h File Reference

Data Structures | Enumerations | Functions
Var.h File Reference

IPhreeqc VARIANT Documentation More...

#include "PHRQ_exports.h"

Go to the source code of this file.

Data Structures

struct VAR
Datatype used to store SELECTED_OUTPUT values. More...

Enumerations

enum VAR_TYPE {
TT_EMPTY = 0, TT_ERROR = 1, TT_LONG = 2, TT_DOUBLE = 3,
TT_STRING = 4
}
Enumeration used to determine the type of data stored in a VAR. More...
enum VRESULT {
VR_OK = 0, VR_OUTOFMEMORY = -1, VR_BADVARTYPE = -2, VR_INVALIDARG = -3,
VR_INVALIDROW = -4, VR_INVALIDCOL = -5
}
Enumeration used to return error codes. More...

Functions

IPQ_DLL_EXPORT char * | VarAllocString (const char *pSrc)
IPQ_DLL_EXPORT VRESULT | VarClear (VAR *pvar)
IPQ_DLL_EXPORT VRESULT | VarCopy (VAR *pvarDest, const VAR *pvarSrc)
IPQ_DLL_EXPORT void | VarFreeString (char *pSrc)
IPQ_DLL_EXPORT void | VarInit (VAR *pvar)

Detailed Description

IPhreeqc VARIANT Documentation

Enumeration Type Documentation

enum VAR_TYPE

Enumeration used to determine the type of data stored in a VAR.

Enumerator
TT_EMPTY | VAR contains no data
TT_ERROR | vresult is valid
TT_LONG | lVal is valid
TT_DOUBLE | dVal is valid
TT_STRING | sVal is valid
enum VRESULT

Enumeration used to return error codes.

Enumerator
VR_OK | Success
VR_OUTOFMEMORY | Failure, Out of memory
VR_BADVARTYPE | Failure, Invalid VAR type
VR_INVALIDARG | Failure, Invalid argument
VR_INVALIDROW | Failure, Invalid row
VR_INVALIDCOL | Failure, Invalid column

Function Documentation

IPQ_DLL_EXPORT char* VarAllocString ( const char * pSrc )

Allocates a new string for use in a VAR and copies the passed string into it.

Parameters
pSrc Pointer to the VAR that will be initialized.
Returns
A pointer to the string on success NULL otherwise.
IPQ_DLL_EXPORT VRESULT VarClear ( VAR * pvar )

Clears a VAR.

Parameters
pvar Pointer to the VAR that will be freed and initialized.
Return values
VR_OK | Success.
VR_BADVARTYPE | The VAR was invalid (probably uninitialized).
IPQ_DLL_EXPORT VRESULT VarCopy | ( | VAR * | pvarDest,
 |  | const VAR * | pvarSrc
 | ) |  |

Frees the destination VAR and makes a copy of the source VAR.

Parameters
pvarDest | Pointer to the VAR to receive the copy.
pvarSrc | Pointer to the VAR to be copied.
Return values
VR_OK | Success.
VR_BADVARTYPE | The source and/or the destination are invalid (usually uninitialized).
VR_OUTOFMEMORY | Memory could not be allocated for the copy.
Returns
The return value is one of the following.
IPQ_DLL_EXPORT void VarFreeString ( char * pSrc )

Frees a string allocated using VarAllocString.

Parameters
pSrc Pointer to the string to be freed.
IPQ_DLL_EXPORT void VarInit ( VAR * pvar )

Initializes a VAR.

Parameters
pvar Pointer to the VAR that will be initialized.


IPhreeqc: src Directory Reference

src Directory Reference

Files

file | IPhreeqc.h [code]
C/Fortran Documentation.
file | IPhreeqc.hpp [code]
C++ Documentation.
file | Var.h [code]
IPhreeqc VARIANT Documentation


IPhreeqc: IPhreeqc.h Source File

IPhreeqc.h
Go to the documentation of this file.
1
4 #ifndef INC_IPHREEQC_H
5 #define INC_IPHREEQC_H
6
7 #include "Var.h"
8
23 typedef enum {
24 IPQ_OK = 0,
25 IPQ_OUTOFMEMORY = -1,
26 IPQ_BADVARTYPE = -2,
27 IPQ_INVALIDARG = -3,
28 IPQ_INVALIDROW = -4,
29 IPQ_INVALIDCOL = -5,
30 IPQ_BADINSTANCE = -6
31 } IPQ_RESULT;
32
33
34 #if defined(__cplusplus)
35 extern "C" {
36 #endif
37
64 IPQ_DLL_EXPORT IPQ_RESULT AccumulateLine(int id, const char *line);
65
66
87 IPQ_DLL_EXPORT int AddError(int id, const char* error_msg);
88
89
110 IPQ_DLL_EXPORT int AddWarning(int id, const char* warn_msg);
111
112
113
131 IPQ_DLL_EXPORT IPQ_RESULT ClearAccumulatedLines(int id);
132
133
157 IPQ_DLL_EXPORT int CreateIPhreeqc(void);
158
159
184 IPQ_DLL_EXPORT IPQ_RESULT DestroyIPhreeqc(int id);
185
186
216 IPQ_DLL_EXPORT const char* GetComponent(int id, int n);
217
218
243 IPQ_DLL_EXPORT int GetComponentCount(int id);
244
265 IPQ_DLL_EXPORT int GetCurrentSelectedOutputUserNumber(int id);
266
285 IPQ_DLL_EXPORT const char* GetDumpFileName(int id);
286
287
305 IPQ_DLL_EXPORT int GetDumpFileOn(int id);
306
307
321 IPQ_DLL_EXPORT const char* GetDumpString(int id);
322
323
350 IPQ_DLL_EXPORT const char* GetDumpStringLine(int id, int n);
351
352
374 IPQ_DLL_EXPORT int GetDumpStringLineCount(int id);
375
376
394 IPQ_DLL_EXPORT int GetDumpStringOn(int id);
395
396
414 IPQ_DLL_EXPORT const char* GetErrorFileName(int id);
415
416
434 IPQ_DLL_EXPORT int GetErrorFileOn(int id);
435
453 IPQ_DLL_EXPORT int GetErrorOn(int id);
454
455
468 IPQ_DLL_EXPORT const char* GetErrorString(int id);
469
470
495 IPQ_DLL_EXPORT const char* GetErrorStringLine(int id, int n);
496
497
515 IPQ_DLL_EXPORT int GetErrorStringLineCount(int id);
516
534 IPQ_DLL_EXPORT int GetErrorStringOn(int id);
535
553 IPQ_DLL_EXPORT const char* GetLogFileName(int id);
554
555
574 IPQ_DLL_EXPORT int GetLogFileOn(int id);
575
576
591 IPQ_DLL_EXPORT const char* GetLogString(int id);
592
593
620 IPQ_DLL_EXPORT const char* GetLogStringLine(int id, int n);
621
643 IPQ_DLL_EXPORT int GetLogStringLineCount(int id);
644
645
663 IPQ_DLL_EXPORT int GetLogStringOn(int id);
664
665
690 IPQ_DLL_EXPORT int GetNthSelectedOutputUserNumber(int id, int n);
691
709 IPQ_DLL_EXPORT const char* GetOutputFileName(int id);
710
711
729 IPQ_DLL_EXPORT int GetOutputFileOn(int id);
730
744 IPQ_DLL_EXPORT const char* GetOutputString(int id);
745
772 IPQ_DLL_EXPORT const char* GetOutputStringLine(int id, int n);
773
795 IPQ_DLL_EXPORT int GetOutputStringLineCount(int id);
796
814 IPQ_DLL_EXPORT int GetOutputStringOn(int id);
815
816
834 IPQ_DLL_EXPORT int GetSelectedOutputColumnCount(int id);
835
857 IPQ_DLL_EXPORT int GetSelectedOutputCount(int id);
858
859
878 IPQ_DLL_EXPORT const char* GetSelectedOutputFileName(int id);
879
880
898 IPQ_DLL_EXPORT int GetSelectedOutputFileOn(int id);
899
900
918 IPQ_DLL_EXPORT int GetSelectedOutputRowCount(int id);
919
920
934 IPQ_DLL_EXPORT const char* GetSelectedOutputString(int id);
935
936
963 IPQ_DLL_EXPORT const char* GetSelectedOutputStringLine(int id, int n);
964
965
987 IPQ_DLL_EXPORT int GetSelectedOutputStringLineCount(int id);
988
989
1007 IPQ_DLL_EXPORT int GetSelectedOutputStringOn(int id);
1008
1009
1196 IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue(int id, int row, int col, VAR* pVAR);
1197
1198
1358 IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue2(int id, int row, int col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length);
1359
1360
1381 IPQ_DLL_EXPORT const char* GetVersionString(void);
1382
1383
1392 IPQ_DLL_EXPORT const char* GetWarningString(int id);
1393
1394
1415 IPQ_DLL_EXPORT const char* GetWarningStringLine(int id, int n);
1416
1417
1435 IPQ_DLL_EXPORT int GetWarningStringLineCount(int id);
1436
1437
1467 IPQ_DLL_EXPORT int LoadDatabase(int id, const char* filename);
1468
1469
1491 IPQ_DLL_EXPORT int LoadDatabaseString(int id, const char* input);
1492
1493
1512 IPQ_DLL_EXPORT void OutputAccumulatedLines(int id);
1513
1514
1536 IPQ_DLL_EXPORT void OutputErrorString(int id);
1537
1538
1554 IPQ_DLL_EXPORT void OutputWarningString(int id);
1555
1556
1580 IPQ_DLL_EXPORT int RunAccumulated(int id);
1581
1582
1609 IPQ_DLL_EXPORT int RunFile(int id, const char* filename);
1610
1611
1636 IPQ_DLL_EXPORT int RunString(int id, const char* input);
1637
1653 IPQ_DLL_EXPORT IPQ_RESULT SetBasicCallback(int id, double (*fcn)(double x1, double x2, const char *str, void *cookie), void *cookie1);
1654
1709 #ifdef IPHREEQC_NO_FORTRAN_MODULE
1710 IPQ_DLL_EXPORT IPQ_RESULT SetBasicFortranCallback(int id, double (*fcn)(double *x1, double *x2, char *str, size_t l));
1711 #else
1712 IPQ_DLL_EXPORT IPQ_RESULT SetBasicFortranCallback(int id, double (*fcn)(double *x1, double *x2, const char *str, int l));
1713 #endif
1714
1715
1746 IPQ_DLL_EXPORT IPQ_RESULT SetCurrentSelectedOutputUserNumber(int id, int n);
1747
1769 IPQ_DLL_EXPORT IPQ_RESULT SetDumpFileName(int id, const char* filename);
1770
1771
1794 IPQ_DLL_EXPORT IPQ_RESULT SetDumpFileOn(int id, int dump_on);
1795
1796
1826 IPQ_DLL_EXPORT IPQ_RESULT SetDumpStringOn(int id, int dump_string_on);
1827
1848 IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileName(int id, const char* filename);
1849
1872 IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileOn(int id, int error_on);
1873
1896 IPQ_DLL_EXPORT IPQ_RESULT SetErrorOn(int id, int error_on);
1897
1898
1928 IPQ_DLL_EXPORT IPQ_RESULT SetErrorStringOn(int id, int error_string_on);
1929
1950 IPQ_DLL_EXPORT IPQ_RESULT SetLogFileName(int id, const char* filename);
1951
1976 IPQ_DLL_EXPORT IPQ_RESULT SetLogFileOn(int id, int log_on);
1977
2007 IPQ_DLL_EXPORT IPQ_RESULT SetLogStringOn(int id, int log_string_on);
2008
2009
2031 IPQ_DLL_EXPORT IPQ_RESULT SetOutputFileName(int id, const char* filename);
2032
2055 IPQ_DLL_EXPORT IPQ_RESULT SetOutputFileOn(int id, int output_on);
2056
2086 IPQ_DLL_EXPORT IPQ_RESULT SetOutputStringOn(int id, int output_string_on);
2087
2088
2110 IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputFileName(int id, const char* filename);
2111
2112
2135 IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputFileOn(int id, int sel_on);
2136
2166 IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputStringOn(int id, int sel_string_on);
2167
2168 // TODO int RunWithCallback(PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie, int output_on, int error_on, int log_on, int selected_output_on);
2169
2170
2171 // TODO int CatchErrors(PFN_CATCH_CALLBACK pfn, void *cookie);
2172
2173
2174 #if defined(__cplusplus)
2175 }
2176 #endif
2177
2178 #endif // INC_IPHREEQC_H
GetDumpStringOn
IPQ_DLL_EXPORT int GetDumpStringOn(int id)
GetWarningStringLineCount
IPQ_DLL_EXPORT int GetWarningStringLineCount(int id)
SetDumpFileName
IPQ_DLL_EXPORT IPQ_RESULT SetDumpFileName(int id, const char *filename)
SetCurrentSelectedOutputUserNumber
IPQ_DLL_EXPORT IPQ_RESULT SetCurrentSelectedOutputUserNumber(int id, int n)
GetLogFileName
IPQ_DLL_EXPORT const char * GetLogFileName(int id)
GetSelectedOutputFileName
IPQ_DLL_EXPORT const char * GetSelectedOutputFileName(int id)
RunString
IPQ_DLL_EXPORT int RunString(int id, const char *input)
SetLogFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetLogFileOn(int id, int log_on)
GetComponent
IPQ_DLL_EXPORT const char * GetComponent(int id, int n)
GetLogStringOn
IPQ_DLL_EXPORT int GetLogStringOn(int id)
SetSelectedOutputFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputFileOn(int id, int sel_on)
SetLogFileName
IPQ_DLL_EXPORT IPQ_RESULT SetLogFileName(int id, const char *filename)
SetErrorOn
IPQ_DLL_EXPORT IPQ_RESULT SetErrorOn(int id, int error_on)
GetSelectedOutputValue2
IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue2(int id, int row, int col, int *vtype, double *dvalue, char *svalue, unsigned int svalue_length)
IPQ_OUTOFMEMORY
Definition: IPhreeqc.h:25
GetSelectedOutputStringOn
IPQ_DLL_EXPORT int GetSelectedOutputStringOn(int id)
GetErrorString
IPQ_DLL_EXPORT const char * GetErrorString(int id)
GetErrorFileName
IPQ_DLL_EXPORT const char * GetErrorFileName(int id)
SetLogStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetLogStringOn(int id, int log_string_on)
GetOutputString
IPQ_DLL_EXPORT const char * GetOutputString(int id)
GetLogStringLine
IPQ_DLL_EXPORT const char * GetLogStringLine(int id, int n)
AddError
IPQ_DLL_EXPORT int AddError(int id, const char *error_msg)
SetSelectedOutputFileName
IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputFileName(int id, const char *filename)
GetCurrentSelectedOutputUserNumber
IPQ_DLL_EXPORT int GetCurrentSelectedOutputUserNumber(int id)
SetDumpFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetDumpFileOn(int id, int dump_on)
SetOutputFileName
IPQ_DLL_EXPORT IPQ_RESULT SetOutputFileName(int id, const char *filename)
GetSelectedOutputValue
IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue(int id, int row, int col, VAR *pVAR)
DestroyIPhreeqc
IPQ_DLL_EXPORT IPQ_RESULT DestroyIPhreeqc(int id)
IPQ_BADVARTYPE
Definition: IPhreeqc.h:26
GetSelectedOutputStringLine
IPQ_DLL_EXPORT const char * GetSelectedOutputStringLine(int id, int n)
GetNthSelectedOutputUserNumber
IPQ_DLL_EXPORT int GetNthSelectedOutputUserNumber(int id, int n)
GetSelectedOutputCount
IPQ_DLL_EXPORT int GetSelectedOutputCount(int id)
GetSelectedOutputFileOn
IPQ_DLL_EXPORT int GetSelectedOutputFileOn(int id)
GetOutputFileOn
IPQ_DLL_EXPORT int GetOutputFileOn(int id)
SetErrorFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileOn(int id, int error_on)
GetOutputStringOn
IPQ_DLL_EXPORT int GetOutputStringOn(int id)
CreateIPhreeqc
IPQ_DLL_EXPORT int CreateIPhreeqc(void)
IPQ_OK
Definition: IPhreeqc.h:24
IPQ_RESULT
IPQ_RESULT
Enumeration used to return error codes.
Definition: IPhreeqc.h:23
GetOutputFileName
IPQ_DLL_EXPORT const char * GetOutputFileName(int id)
AccumulateLine
IPQ_DLL_EXPORT IPQ_RESULT AccumulateLine(int id, const char *line)
GetDumpFileName
IPQ_DLL_EXPORT const char * GetDumpFileName(int id)
GetDumpString
IPQ_DLL_EXPORT const char * GetDumpString(int id)
SetSelectedOutputStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputStringOn(int id, int sel_string_on)
GetErrorFileOn
IPQ_DLL_EXPORT int GetErrorFileOn(int id)
GetOutputStringLine
IPQ_DLL_EXPORT const char * GetOutputStringLine(int id, int n)
GetSelectedOutputStringLineCount
IPQ_DLL_EXPORT int GetSelectedOutputStringLineCount(int id)
IPQ_INVALIDARG
Definition: IPhreeqc.h:27
IPQ_INVALIDCOL
Definition: IPhreeqc.h:29
GetSelectedOutputColumnCount
IPQ_DLL_EXPORT int GetSelectedOutputColumnCount(int id)
SetBasicCallback
IPQ_DLL_EXPORT IPQ_RESULT SetBasicCallback(int id, double(*fcn)(double x1, double x2, const char *str, void *cookie), void *cookie1)
GetWarningStringLine
IPQ_DLL_EXPORT const char * GetWarningStringLine(int id, int n)
OutputWarningString
IPQ_DLL_EXPORT void OutputWarningString(int id)
ClearAccumulatedLines
IPQ_DLL_EXPORT IPQ_RESULT ClearAccumulatedLines(int id)
SetOutputFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetOutputFileOn(int id, int output_on)
RunFile
IPQ_DLL_EXPORT int RunFile(int id, const char *filename)
Var.h
IPhreeqc VARIANT Documentation
GetComponentCount
IPQ_DLL_EXPORT int GetComponentCount(int id)
GetLogString
IPQ_DLL_EXPORT const char * GetLogString(int id)
OutputErrorString
IPQ_DLL_EXPORT void OutputErrorString(int id)
GetLogFileOn
IPQ_DLL_EXPORT int GetLogFileOn(int id)
RunAccumulated
IPQ_DLL_EXPORT int RunAccumulated(int id)
GetSelectedOutputString
IPQ_DLL_EXPORT const char * GetSelectedOutputString(int id)
GetErrorStringOn
IPQ_DLL_EXPORT int GetErrorStringOn(int id)
GetDumpFileOn
IPQ_DLL_EXPORT int GetDumpFileOn(int id)
GetSelectedOutputRowCount
IPQ_DLL_EXPORT int GetSelectedOutputRowCount(int id)
VAR
Datatype used to store SELECTED_OUTPUT values.
Definition: Var.h:40
GetErrorStringLine
IPQ_DLL_EXPORT const char * GetErrorStringLine(int id, int n)
OutputAccumulatedLines
IPQ_DLL_EXPORT void OutputAccumulatedLines(int id)
IPQ_BADINSTANCE
Definition: IPhreeqc.h:30
SetBasicFortranCallback
IPQ_DLL_EXPORT IPQ_RESULT SetBasicFortranCallback(int id, double(*fcn)(double *x1, double *x2, const char *str, int l))
LoadDatabase
IPQ_DLL_EXPORT int LoadDatabase(int id, const char *filename)
SetErrorStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetErrorStringOn(int id, int error_string_on)
AddWarning
IPQ_DLL_EXPORT int AddWarning(int id, const char *warn_msg)
IPQ_INVALIDROW
Definition: IPhreeqc.h:28
SetDumpStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetDumpStringOn(int id, int dump_string_on)
SetOutputStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetOutputStringOn(int id, int output_string_on)
GetWarningString
IPQ_DLL_EXPORT const char * GetWarningString(int id)
GetErrorOn
IPQ_DLL_EXPORT int GetErrorOn(int id)
GetDumpStringLineCount
IPQ_DLL_EXPORT int GetDumpStringLineCount(int id)
LoadDatabaseString
IPQ_DLL_EXPORT int LoadDatabaseString(int id, const char *input)
GetVersionString
IPQ_DLL_EXPORT const char * GetVersionString(void)
GetLogStringLineCount
IPQ_DLL_EXPORT int GetLogStringLineCount(int id)
GetErrorStringLineCount
IPQ_DLL_EXPORT int GetErrorStringLineCount(int id)
GetOutputStringLineCount
IPQ_DLL_EXPORT int GetOutputStringLineCount(int id)
SetErrorFileName
IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileName(int id, const char *filename)
GetDumpStringLine
IPQ_DLL_EXPORT const char * GetDumpStringLine(int id, int n)


IPhreeqc: IPhreeqc.hpp File Reference

Data Structures
IPhreeqc.hpp File Reference

C++ Documentation. More...

#include <exception>
#include <list>
#include <vector>
#include <map>
#include <cstdarg>
#include "IPhreeqcCallbacks.h"
#include "Var.h"
#include "PHRQ_io.h"
#include "PHRQ_exports.h"

Go to the source code of this file.

Data Structures

class | IPhreeqcStop
This class is derived from std::exception and is thrown when an unrecoverable error has occured. More...
class | IPhreeqc
Provides an interface to PHREEQC (Version 3)–A Computer Program for Speciation, Batch-Reaction, One-Dimensional Transport, and Inverse Geochemical Calculations. More...

Detailed Description

C++ Documentation.


IPhreeqc: IPhreeqc.hpp Source File

IPhreeqc.hpp
Go to the documentation of this file.
1
5 #ifndef INC_IPHREEQC_HPP
6 #define INC_IPHREEQC_HPP
7
8 #include <exception>
9 #include <list>
10 #include <vector>
11 #include <map>
12 #include <cstdarg>
13 #include "IPhreeqcCallbacks.h" /* PFN_PRERUN_CALLBACK, PFN_POSTRUN_CALLBACK, PFN_CATCH_CALLBACK */
14 #include "Var.h" /* VRESULT */
15 #include "PHRQ_io.h"
16
17 #include "PHRQ_exports.h"
18
19 class Phreeqc;
20 class IErrorReporter;
21 class CSelectedOutput;
22 class SelectedOutput;
23
30 class IPQ_DLL_EXPORT IPhreeqcStop : public std::exception
31 {
32 public:
33 virtual const char *what() const throw () {return "Failure in IPhreeqc\n";}
34 };
35
44 class IPQ_DLL_EXPORT IPhreeqc : public PHRQ_io
45 {
46 public:
53 IPhreeqc(void);
54
58 virtual ~IPhreeqc(void);
59
60 public:
61
69 VRESULT AccumulateLine(const char *line);
70
78 size_t AddError(const char* error_msg);
79
87 size_t AddWarning(const char* warning_msg);
88
93 void ClearAccumulatedLines(void);
94
101 const std::string& GetAccumulatedLines(void);
102
110 const char* GetComponent(int n);
111
117 size_t GetComponentCount(void);
118
124 int GetCurrentSelectedOutputUserNumber(void)const;
125
132 const char* GetDumpFileName(void)const;
133
140 bool GetDumpFileOn(void)const;
141
149 const char* GetDumpString(void)const;
150
159 const char* GetDumpStringLine(int n);
160
167 int GetDumpStringLineCount(void)const;
168
175 bool GetDumpStringOn(void)const;
176
182 const char* GetErrorFileName(void)const;
183
190 bool GetErrorFileOn(void)const;
191
198 bool GetErrorOn(void)const;
199
205 const char* GetErrorString(void);
206
213 const char* GetErrorStringLine(int n);
214
220 int GetErrorStringLineCount(void)const;
221
228 bool GetErrorStringOn(void)const;
229
235 int GetId(void)const;
236
242 const char* GetLogFileName(void)const;
243
252 bool GetLogFileOn(void)const;
253
261 const char* GetLogString(void)const;
262
271 const char* GetLogStringLine(int n)const;
272
279 int GetLogStringLineCount(void)const;
280
287 bool GetLogStringOn(void)const;
288
295 int GetNthSelectedOutputUserNumber(int n)const;
296
302 const char* GetOutputFileName(void)const;
303
310 bool GetOutputFileOn(void)const;
311
319 const char* GetOutputString(void)const;
320
329 const char* GetOutputStringLine(int n)const;
330
337 int GetOutputStringLineCount(void)const;
338
345 bool GetOutputStringOn(void)const;
346
352 int GetSelectedOutputColumnCount(void)const;
353
359 int GetSelectedOutputCount(void)const;
360
367 const char* GetSelectedOutputFileName(void)const;
368
375 bool GetSelectedOutputFileOn(void)const;
376
382 int GetSelectedOutputRowCount(void)const;
383
391 const char* GetSelectedOutputString(void)const;
392
401 const char* GetSelectedOutputStringLine(int n);
402
409 int GetSelectedOutputStringLineCount(void)const;
410
417 bool GetSelectedOutputStringOn(void)const;
418
571 VRESULT GetSelectedOutputValue(int row, int col, VAR* pVAR);
572
592 VRESULT GetSelectedOutputValue2(int row, int col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length);
593
598 static const char* GetVersionString(void);
599
605 const char* GetWarningString(void);
606
613 const char* GetWarningStringLine(int n);
614
620 int GetWarningStringLineCount(void)const;
621
627 std::list< std::string > ListComponents(void);
628
639 int LoadDatabase(const char* filename);
640
649 int LoadDatabaseString(const char* input);
650
655 void OutputAccumulatedLines(void);
656
662 void OutputErrorString(void);
663
668 void OutputWarningString(void);
669
679 int RunAccumulated(void);
680
689 int RunFile(const char* filename);
690
699 int RunString(const char* input);
700
710 void SetBasicCallback(double (*fcn)(double x1, double x2, const char *str, void *cookie), void * cookie1);
711
720 #ifdef IPHREEQC_NO_FORTRAN_MODULE
721 void SetBasicFortranCallback(double (*fcn)(double *x1, double *x2, char *str, size_t l));
722 #else
723 void SetBasicFortranCallback(double (*fcn)(double *x1, double *x2, const char *str, int l));
724 #endif
725
736 VRESULT SetCurrentSelectedOutputUserNumber(int n);
737
744 void SetDumpFileName(const char *filename);
745
754 void SetDumpFileOn(bool bValue);
755
763 void SetDumpStringOn(bool bValue);
764
770 void SetErrorFileName(const char *filename);
771
779 void SetErrorFileOn(bool bValue);
780
788 void SetErrorOn(bool bValue);
789
796 void SetErrorStringOn(bool bValue);
797
803 void SetLogFileName(const char *filename);
804
813 void SetLogFileOn(bool bValue);
814
821 void SetLogStringOn(bool bValue);
822
828 void SetOutputFileName(const char *filename);
829
837 void SetOutputFileOn(bool bValue);
838
845 void SetOutputStringOn(bool bValue);
846
853 void SetSelectedOutputFileName(const char *filename);
854
862 void SetSelectedOutputFileOn(bool bValue);
863
872 void SetSelectedOutputStringOn(bool bValue);
873
874 public:
875 // overrides
876 virtual void error_msg(const char *str, bool stop=false);
877 virtual void log_msg(const char * str);
878 virtual void output_msg(const char *str);
879 virtual void punch_msg(const char *str);
880 virtual void screen_msg(const char *str);
881 virtual void warning_msg(const char *str);
882
883 virtual void fpunchf(const char *name, const char *format, double d);
884 virtual void fpunchf(const char *name, const char *format, char * d);
885 virtual void fpunchf(const char *name, const char *format, int d);
886 virtual void fpunchf_end_row(const char *format);
887
888 virtual bool output_open(const char *file_name, std::ios_base::openmode mode = std::ios_base::out);
889 virtual bool punch_open(const char *file_name, std::ios_base::openmode mode = std::ios_base::out, int n_user = 1);
890
891 protected:
892 int EndRow(void);
893 void AddSelectedOutput(const char* name, const char* format, va_list argptr);
894 void UnLoadDatabase(void);
895
896 void check_database(const char* sz_routine);
897 int close_input_files(void);
898 int close_output_files(void);
899 void open_output_files(const char* sz_routine);
900
901 void do_run(const char* sz_routine, std::istream* pis, PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie);
902
903 void update_errors(void);
904
905 int load_db(const char* filename);
906 int load_db_str(const char* filename);
907 int test_db(void);
908
909 bool get_sel_out_file_on(int n)const;
910 std::string sel_file_name(int n_user);
911
912 std::string create_file_name(const char *prefix, const char *suffix);
913
914 bool get_sel_out_string_on(int n)const;
915
916 protected:
917 #if defined(_MSC_VER)
918 /* disable warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' */
919 #pragma warning(disable:4251)
920 #endif
921
922 bool DatabaseLoaded;
923 bool ClearAccumulated;
924 bool UpdateComponents;
925 std::map< int, bool > SelectedOutputFileOnMap;
926
927 bool OutputFileOn;
928
929 bool LogFileOn;
930 bool ErrorFileOn;
931 bool DumpOn;
932
933 bool DumpStringOn;
934
935 bool OutputStringOn;
936 std::string OutputString;
937 std::vector< std::string > OutputLines;
938
939 bool LogStringOn;
940 std::string LogString;
941 std::vector< std::string > LogLines;
942
943 bool ErrorStringOn;
944 IErrorReporter *ErrorReporter;
945 std::string ErrorString;
946 std::vector< std::string > ErrorLines;
947
948 bool WarningStringOn;
949 IErrorReporter *WarningReporter;
950 std::string WarningString;
951 std::vector< std::string > WarningLines;
952
953 int CurrentSelectedOutputUserNumber;
954 std::map< int, CSelectedOutput* > SelectedOutputMap;
955 std::string StringInput;
956
957 std::string DumpString;
958 std::vector< std::string > DumpLines;
959
960 std::list< std::string > Components;
961 std::list< std::string > EquilibriumPhasesList;
962 const std::list<std::string> &GetEquilibriumPhasesList() { return this->EquilibriumPhasesList; };
963 std::list< std::string > GasComponentsList;
964 const std::list<std::string> &GetGasComponentsList() { return this->GasComponentsList; };
965 std::list< std::string > KineticReactionsList;
966 const std::list<std::string> &GetKineticReactionsList() { return this->KineticReactionsList; };
967 std::list< std::string > SolidSolutionComponentsList;
968 const std::list<std::string> &GetSolidSolutionComponentsList() { return this->SolidSolutionComponentsList; };
969 std::list< std::string > SolidSolutionNamesList;
970 const std::list<std::string> &GetSolidSolutionNamesList() { return this->SolidSolutionNamesList; };
971 //std::list< std::string > SurfaceSpeciesList;
972 //const std::list<std::string> &GetSurfaceSpeciesList() { return this->SurfaceSpeciesList; };
973 std::list< std::string > SurfaceTypeList;
974 const std::list<std::string> &GetSurfaceTypeList() { return this->SurfaceTypeList; };
975 std::list< std::string > SurfaceNamesList;
976 const std::list<std::string> &GetSurfaceNamesList() { return this->SurfaceNamesList; };
977 //std::list< std::string > ExchangeSpeciesList;
978 //const std::list<std::string> &GetExchangeSpeciesList() { return this->ExchangeSpeciesList; };
979 std::list< std::string > ExchangeNamesList;
980 const std::list<std::string> &GetExchangeNamesList() { return this->ExchangeNamesList; };
981
982 std::map< int, std::string > SelectedOutputFileNameMap;
983
984 std::string OutputFileName;
985 std::string ErrorFileName;
986 std::string LogFileName;
987 std::string DumpFileName;
988
989 std::map< int, bool > SelectedOutputStringOn;
990 std::map< int, std::string > SelectedOutputStringMap;
991 std::map< int, std::vector< std::string > > SelectedOutputLinesMap;
992
993 protected:
994 Phreeqc* PhreeqcPtr;
995 FILE *input_file;
996 FILE *database_file;
997
998 friend class IPhreeqcLib;
999 static std::map<size_t, IPhreeqc*> Instances;
1000 static size_t InstancesIndex;
1001 size_t Index;
1002
1003 static std::string Version;
1004
1005 #if defined(_MSC_VER)
1006 /* reset warning C4251 */
1007 #pragma warning(default:4251)
1008 #endif
1009
1010 #if defined(CPPUNIT)
1011 friend class TestIPhreeqc;
1012 friend class TestSelectedOutput;
1013 #endif
1014
1015 private:
1019 IPhreeqc(const IPhreeqc&);
1020
1024 IPhreeqc& operator=(const IPhreeqc&);
1025 };
1026
1027 #endif // INC_IPHREEQC_HPP
GetDumpStringOn
IPQ_DLL_EXPORT int GetDumpStringOn(int id)
GetWarningStringLineCount
IPQ_DLL_EXPORT int GetWarningStringLineCount(int id)
SetDumpFileName
IPQ_DLL_EXPORT IPQ_RESULT SetDumpFileName(int id, const char *filename)
SetCurrentSelectedOutputUserNumber
IPQ_DLL_EXPORT IPQ_RESULT SetCurrentSelectedOutputUserNumber(int id, int n)
GetLogFileName
IPQ_DLL_EXPORT const char * GetLogFileName(int id)
GetSelectedOutputFileName
IPQ_DLL_EXPORT const char * GetSelectedOutputFileName(int id)
RunString
IPQ_DLL_EXPORT int RunString(int id, const char *input)
SetLogFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetLogFileOn(int id, int log_on)
GetComponent
IPQ_DLL_EXPORT const char * GetComponent(int id, int n)
GetLogStringOn
IPQ_DLL_EXPORT int GetLogStringOn(int id)
SetSelectedOutputFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputFileOn(int id, int sel_on)
SetLogFileName
IPQ_DLL_EXPORT IPQ_RESULT SetLogFileName(int id, const char *filename)
SetErrorOn
IPQ_DLL_EXPORT IPQ_RESULT SetErrorOn(int id, int error_on)
GetSelectedOutputValue2
IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue2(int id, int row, int col, int *vtype, double *dvalue, char *svalue, unsigned int svalue_length)
GetSelectedOutputStringOn
IPQ_DLL_EXPORT int GetSelectedOutputStringOn(int id)
GetErrorString
IPQ_DLL_EXPORT const char * GetErrorString(int id)
GetErrorFileName
IPQ_DLL_EXPORT const char * GetErrorFileName(int id)
SetLogStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetLogStringOn(int id, int log_string_on)
GetOutputString
IPQ_DLL_EXPORT const char * GetOutputString(int id)
GetLogStringLine
IPQ_DLL_EXPORT const char * GetLogStringLine(int id, int n)
AddError
IPQ_DLL_EXPORT int AddError(int id, const char *error_msg)
SetSelectedOutputFileName
IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputFileName(int id, const char *filename)
GetCurrentSelectedOutputUserNumber
IPQ_DLL_EXPORT int GetCurrentSelectedOutputUserNumber(int id)
SetDumpFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetDumpFileOn(int id, int dump_on)
SetOutputFileName
IPQ_DLL_EXPORT IPQ_RESULT SetOutputFileName(int id, const char *filename)
GetSelectedOutputValue
IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue(int id, int row, int col, VAR *pVAR)
GetSelectedOutputStringLine
IPQ_DLL_EXPORT const char * GetSelectedOutputStringLine(int id, int n)
GetNthSelectedOutputUserNumber
IPQ_DLL_EXPORT int GetNthSelectedOutputUserNumber(int id, int n)
GetSelectedOutputCount
IPQ_DLL_EXPORT int GetSelectedOutputCount(int id)
GetSelectedOutputFileOn
IPQ_DLL_EXPORT int GetSelectedOutputFileOn(int id)
GetOutputFileOn
IPQ_DLL_EXPORT int GetOutputFileOn(int id)
SetErrorFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileOn(int id, int error_on)
GetOutputStringOn
IPQ_DLL_EXPORT int GetOutputStringOn(int id)
GetOutputFileName
IPQ_DLL_EXPORT const char * GetOutputFileName(int id)
AccumulateLine
IPQ_DLL_EXPORT IPQ_RESULT AccumulateLine(int id, const char *line)
GetDumpFileName
IPQ_DLL_EXPORT const char * GetDumpFileName(int id)
GetDumpString
IPQ_DLL_EXPORT const char * GetDumpString(int id)
SetSelectedOutputStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetSelectedOutputStringOn(int id, int sel_string_on)
GetErrorFileOn
IPQ_DLL_EXPORT int GetErrorFileOn(int id)
GetOutputStringLine
IPQ_DLL_EXPORT const char * GetOutputStringLine(int id, int n)
GetSelectedOutputStringLineCount
IPQ_DLL_EXPORT int GetSelectedOutputStringLineCount(int id)
GetSelectedOutputColumnCount
IPQ_DLL_EXPORT int GetSelectedOutputColumnCount(int id)
SetBasicCallback
IPQ_DLL_EXPORT IPQ_RESULT SetBasicCallback(int id, double(*fcn)(double x1, double x2, const char *str, void *cookie), void *cookie1)
GetWarningStringLine
IPQ_DLL_EXPORT const char * GetWarningStringLine(int id, int n)
OutputWarningString
IPQ_DLL_EXPORT void OutputWarningString(int id)
ClearAccumulatedLines
IPQ_DLL_EXPORT IPQ_RESULT ClearAccumulatedLines(int id)
SetOutputFileOn
IPQ_DLL_EXPORT IPQ_RESULT SetOutputFileOn(int id, int output_on)
RunFile
IPQ_DLL_EXPORT int RunFile(int id, const char *filename)
Var.h
IPhreeqc VARIANT Documentation
GetComponentCount
IPQ_DLL_EXPORT int GetComponentCount(int id)
GetLogString
IPQ_DLL_EXPORT const char * GetLogString(int id)
OutputErrorString
IPQ_DLL_EXPORT void OutputErrorString(int id)
GetLogFileOn
IPQ_DLL_EXPORT int GetLogFileOn(int id)
RunAccumulated
IPQ_DLL_EXPORT int RunAccumulated(int id)
GetSelectedOutputString
IPQ_DLL_EXPORT const char * GetSelectedOutputString(int id)
GetErrorStringOn
IPQ_DLL_EXPORT int GetErrorStringOn(int id)
GetDumpFileOn
IPQ_DLL_EXPORT int GetDumpFileOn(int id)
GetSelectedOutputRowCount
IPQ_DLL_EXPORT int GetSelectedOutputRowCount(int id)
VAR
Datatype used to store SELECTED_OUTPUT values.
Definition: Var.h:40
GetErrorStringLine
IPQ_DLL_EXPORT const char * GetErrorStringLine(int id, int n)
OutputAccumulatedLines
IPQ_DLL_EXPORT void OutputAccumulatedLines(int id)
SetBasicFortranCallback
IPQ_DLL_EXPORT IPQ_RESULT SetBasicFortranCallback(int id, double(*fcn)(double *x1, double *x2, const char *str, int l))
LoadDatabase
IPQ_DLL_EXPORT int LoadDatabase(int id, const char *filename)
SetErrorStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetErrorStringOn(int id, int error_string_on)
AddWarning
IPQ_DLL_EXPORT int AddWarning(int id, const char *warn_msg)
SetDumpStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetDumpStringOn(int id, int dump_string_on)
SetOutputStringOn
IPQ_DLL_EXPORT IPQ_RESULT SetOutputStringOn(int id, int output_string_on)
GetWarningString
IPQ_DLL_EXPORT const char * GetWarningString(int id)
GetErrorOn
IPQ_DLL_EXPORT int GetErrorOn(int id)
GetDumpStringLineCount
IPQ_DLL_EXPORT int GetDumpStringLineCount(int id)
LoadDatabaseString
IPQ_DLL_EXPORT int LoadDatabaseString(int id, const char *input)
VRESULT
VRESULT
Enumeration used to return error codes.
Definition: Var.h:29
GetVersionString
IPQ_DLL_EXPORT const char * GetVersionString(void)
GetLogStringLineCount
IPQ_DLL_EXPORT int GetLogStringLineCount(int id)
GetErrorStringLineCount
IPQ_DLL_EXPORT int GetErrorStringLineCount(int id)
IPhreeqcStop
This class is derived from std::exception and is thrown when an unrecoverable error has occured...
Definition: IPhreeqc.hpp:30
GetOutputStringLineCount
IPQ_DLL_EXPORT int GetOutputStringLineCount(int id)
SetErrorFileName
IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileName(int id, const char *filename)
GetDumpStringLine
IPQ_DLL_EXPORT const char * GetDumpStringLine(int id, int n)
IPhreeqc
Provides an interface to PHREEQC (Version 3)–A Computer Program for Speciation, Batch-Reaction, One-Dimensional Transport, and Inverse Geochemical Calculations.
Definition: IPhreeqc.hpp:44


IPhreeqc: VAR Struct Reference

Data Fields
VAR Struct Reference

Datatype used to store SELECTED_OUTPUT values. More...

#include <Var.h>

Data Fields

VAR_TYPE type
long | lVal
double | dVal
char * | sVal
VRESULT vresult

Detailed Description

Datatype used to store SELECTED_OUTPUT values.

Field Documentation

double VAR::dVal

valid when (type == TT_DOUBLE)

long VAR::lVal

valid when (type == TT_LONG)

char* VAR::sVal

valid when (type == TT_STRING)

VAR_TYPE VAR::type

holds datatype of VAR

VRESULT VAR::vresult

valid when (type == TT_ERROR)

The documentation for this struct was generated from the following file:
  • Var.h


IPhreeqc: Var.h Source File

Var.h
Go to the documentation of this file.
1
4 // Var.h
5
6 #ifndef __VAR_H_INC
7 #define __VAR_H_INC
8
9 #include "PHRQ_exports.h"
10
11 #if defined(R_SO) || defined(NO_NAMELESS_UNION)
12 #define VAR_UNION_NAME u
13 #else
14 #define VAR_UNION_NAME
15 #endif
16
19 typedef enum {
20 TT_EMPTY = 0,
21 TT_ERROR = 1,
22 TT_LONG = 2,
23 TT_DOUBLE = 3,
24 TT_STRING = 4
25 } VAR_TYPE;
26
29 typedef enum {
30 VR_OK = 0,
31 VR_OUTOFMEMORY = -1,
32 VR_BADVARTYPE = -2,
33 VR_INVALIDARG = -3,
34 VR_INVALIDROW = -4,
35 VR_INVALIDCOL = -5
36 } VRESULT;
37
40 typedef struct {
41 VAR_TYPE type;
42 union {
43 long lVal;
44 double dVal;
45 char* sVal;
46 VRESULT vresult;
47 } VAR_UNION_NAME;
48 } VAR;
49
50
51 #if defined(__cplusplus)
52 extern "C" {
53 #endif
54
59 IPQ_DLL_EXPORT char* VarAllocString(const char* pSrc);
60
66 IPQ_DLL_EXPORT VRESULT VarClear(VAR* pvar);
67
76 IPQ_DLL_EXPORT VRESULT VarCopy(VAR* pvarDest, const VAR* pvarSrc);
77
81 IPQ_DLL_EXPORT void VarFreeString(char* pSrc);
82
86 IPQ_DLL_EXPORT void VarInit(VAR* pvar);
87
88 #if defined(__cplusplus)
89 }
90 #endif
91
92 #if defined(__cplusplus)
93
94 #include <ostream> // std::ostream
95
96 inline std::ostream& operator<< (std::ostream &os, const VAR_TYPE& vt)
97 {
98 switch(vt)
99 {
100 case TT_EMPTY:
101 os << "TT_EMPTY";
102 break;
103 case TT_ERROR:
104 os << "TT_ERROR";
105 break;
106 case TT_LONG:
107 os << "TT_LONG";
108 break;
109 case TT_DOUBLE:
110 os << "TT_DOUBLE";
111 break;
112 case TT_STRING:
113 os << "TT_STRING";
114 break;
115 default:
116 os << (int)vt;
117 break;
118 }
119 return os;
120 }
121
122 inline std::ostream& operator<< (std::ostream &os, const VRESULT& vr)
123 {
124 switch(vr)
125 {
126 case VR_OK:
127 os << "VR_OK";
128 break;
129 case VR_OUTOFMEMORY:
130 os << "VR_OUTOFMEMORY";
131 break;
132 case VR_BADVARTYPE:
133 os << "VR_BADVARTYPE";
134 break;
135 case VR_INVALIDARG:
136 os << "VR_INVALIDARG";
137 break;
138 case VR_INVALIDROW:
139 os << "VR_INVALIDROW";
140 break;
141 case VR_INVALIDCOL:
142 os << "VR_INVALIDCOL";
143 break;
144 default:
145 os << (int)vr;
146 break;
147 }
148 return os;
149 }
150 #endif /* __cplusplus */
151
152 #endif /* __VAR_H_INC */
VAR::type
VAR_TYPE type
Definition: Var.h:41
VAR::dVal
double dVal
Definition: Var.h:44
VR_OUTOFMEMORY
Definition: Var.h:31
VR_BADVARTYPE
Definition: Var.h:32
TT_LONG
Definition: Var.h:22
VarAllocString
IPQ_DLL_EXPORT char * VarAllocString(const char *pSrc)
VarCopy
IPQ_DLL_EXPORT VRESULT VarCopy(VAR *pvarDest, const VAR *pvarSrc)
TT_STRING
Definition: Var.h:24
VR_INVALIDCOL
Definition: Var.h:35
TT_EMPTY
Definition: Var.h:20
VAR
Datatype used to store SELECTED_OUTPUT values.
Definition: Var.h:40
VarFreeString
IPQ_DLL_EXPORT void VarFreeString(char *pSrc)
VAR::vresult
VRESULT vresult
Definition: Var.h:46
TT_ERROR
Definition: Var.h:21
VAR::sVal
char * sVal
Definition: Var.h:45
VarInit
IPQ_DLL_EXPORT void VarInit(VAR *pvar)
VR_OK
Definition: Var.h:30
TT_DOUBLE
Definition: Var.h:23
VAR::lVal
long lVal
Definition: Var.h:43
VAR_TYPE
VAR_TYPE
Enumeration used to determine the type of data stored in a VAR.
Definition: Var.h:19
VR_INVALIDARG
Definition: Var.h:33
VRESULT
VRESULT
Enumeration used to return error codes.
Definition: Var.h:29
VR_INVALIDROW
Definition: Var.h:34
VarClear
IPQ_DLL_EXPORT VRESULT VarClear(VAR *pvar)