IPhreeqc 2.18
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_RESULT AccumulateLine (int id, const char *line)
int AddError (int id, const char *error_msg)
int AddWarning (int id, const char *warn_msg)
IPQ_RESULT ClearAccumulatedLines (int id)
int CreateIPhreeqc (void)
IPQ_RESULT DestroyIPhreeqc (int id)
const char * GetComponent (int id, int n)
int GetComponentCount (int id)
int GetDumpFileOn (int id)
const char * GetDumpString (int id)
const char * GetDumpStringLine (int id, int n)
int GetDumpStringLineCount (int id)
int GetDumpStringOn (int id)
int GetErrorFileOn (int id)
const char * GetErrorString (int id)
const char * GetErrorStringLine (int id, int n)
int GetErrorStringLineCount (int id)
int GetLogFileOn (int id)
int GetOutputFileOn (int id)
int GetSelectedOutputColumnCount (int id)
int GetSelectedOutputFileOn (int id)
int GetSelectedOutputRowCount (int id)
IPQ_RESULT GetSelectedOutputValue (int id, int row, int col, VAR *pVAR)
const char * GetWarningString (int id)
const char * GetWarningStringLine (int id, int n)
int GetWarningStringLineCount (int id)
int LoadDatabase (int id, const char *filename)
int LoadDatabaseString (int id, const char *input)
void OutputAccumulatedLines (int id)
void OutputErrorString (int id)
void OutputWarningString (int id)
int RunAccumulated (int id)
int RunFile (int id, const char *filename)
int RunString (int id, const char *input)
IPQ_RESULT SetDumpFileOn (int id, int dump_on)
IPQ_RESULT SetDumpStringOn (int id, int dump_string_on)
IPQ_RESULT SetErrorFileOn (int id, int error_on)
IPQ_RESULT SetLogFileOn (int id, int log_on)
IPQ_RESULT SetOutputFileOn (int id, int output_on)
IPQ_RESULT SetSelectedOutputFileOn (int id, int sel_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_RESULT AccumulateLine ( int  id,
const char *  line 
)

Accumlulate line(s) for input to phreeqc.

Parameters:
idThe instance id returned from CreateIPhreeqc.
lineThe line(s) to add for input to phreeqc.
Return values:
IPQ_OKSuccess
IPQ_OUTOFMEMORYOut 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
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:
idThe instance id returned from CreateIPhreeqc.
error_msgThe 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
  
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:
idThe instance id returned from CreateIPhreeqc.
error_msgThe 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_RESULT ClearAccumulatedLines ( int  id)

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

Return values:
IPQ_OKSuccess.
IPQ_BADINSTANCEThe 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
  
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
  INCLUDE "IPhreeqc.f90.inc"
  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_RESULT DestroyIPhreeqc ( int  id)

Release an IPhreeqc instance from memory.

Parameters:
idThe instance id returned from CreateIPhreeqc.
Return values:
IPQ_OKSuccess
IPQ_BADINSTANCEThe 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
const char* GetComponent ( int  id,
int  n 
)

Retrieves the given component.

Parameters:
idThe instance id returned from CreateIPhreeqc.
nThe 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
  INCLUDE "IPhreeqc.f90.inc"
  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
int GetComponentCount ( int  id)

Retrieves the number of components in the current component list .

Parameters:
idThe 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
int GetDumpFileOn ( int  id)

Retrieves the current value of the dump file switch.

Parameters:
idThe instance id returned from CreateIPhreeqc.
Returns:
Non-zero if output is written to the DUMP (dump.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
  
const char* GetDumpString ( int  id)

Retrieves the string buffer containing DUMP output.

Parameters:
idThe 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 recieve 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;
}
const char* GetDumpStringLine ( int  id,
int  n 
)

Retrieves the given dump line.

Parameters:
idThe instance id returned from CreateIPhreeqc.
nThe 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
  INCLUDE "IPhreeqc.f90.inc"
  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
int GetDumpStringLineCount ( int  id)

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

Parameters:
idThe 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
int GetDumpStringOn ( int  id)

Retrieves the current value of the dump string switch.

Parameters:
idThe 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
  
int GetErrorFileOn ( int  id)

Retrieves the current value of the error file switch.

Parameters:
idThe instance id returned from CreateIPhreeqc.
Returns:
Non-zero if errors are written to the phreeqc.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
  
const char* GetErrorString ( int  id)

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

Parameters:
idThe 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)
const char* GetErrorStringLine ( int  id,
int  n 
)

Retrieves the given error line.

Parameters:
idThe instance id returned from CreateIPhreeqc.
nThe 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
  
int GetErrorStringLineCount ( int  id)

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

Parameters:
idThe 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
  
int GetLogFileOn ( int  id)

Retrieves the current value of the log file switch.

Parameters:
idThe instance id returned from CreateIPhreeqc.
Returns:
Non-zero if log messages are written to the phreeqc.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
  
int GetOutputFileOn ( int  id)

Retrieves the current value of the output file switch.

Parameters:
idThe instance id returned from CreateIPhreeqc.
Returns:
Non-zero if output is written to the phreeqc.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
  
int GetSelectedOutputColumnCount ( int  id)

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

Parameters:
idThe 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
  
int GetSelectedOutputFileOn ( int  id)

Retrieves the selected-output file switch.

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

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

Parameters:
idThe instance id returned from CreateIPhreeqc.
Returns:
The number of rows.
See also:
GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputValue, SetSelectedOutputFileOn
Fortran90 Interface:
  FUNCTION GetSelectedOutputRowCount(ID)
    INTEGER(KIND=4),  INTENT(IN)  :: ID
    INTEGER(KIND=4)               :: GetSelectedOutputRowCount
  END FUNCTION GetSelectedOutputRowCount
  
IPQ_RESULT GetSelectedOutputValue ( int  id,
int  row,
int  col,
VAR pVAR 
)

Returns the VAR associated with the specified row and column.

Parameters:
idThe instance id returned from CreateIPhreeqc.
rowThe row index.
colThe column index.
pVARPointer to the VAR to recieve the requested data.
Return values:
IPQ_OKSuccess.
IPQ_INVALIDROWThe given row is out of range.
IPQ_INVALIDCOLThe given column is out of range.
IPQ_OUTOFMEMORYMemory could not be allocated.
IPQ_BADINSTANCEThe given id is invalid.
See also:
GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, 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)
    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)                 :: GetSelectedOutputValue
  END FUNCTION GetSelectedOutputValue
  
Parameters:
IDThe instance id returned from CreateIPhreeqc.
ROWThe row index.
COLThe column index.
VTYPEReturns the variable type. See VAR_TYPE.
DVALUEReturns the numeric value when (VTYPE=TT_DOUBLE) or (VTYPE=TT_LONG).
SVALUEReturns 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.
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) == VR_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;
        }
      }
      VarClear(&v);
    }
    printf("\n");
  }

  if (DestroyIPhreeqc(id)) {
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}

Fortran90 Example:
PROGRAM example
  INCLUDE "IPhreeqc.f90.inc"
  INTEGER(KIND=4)   :: id
  INTEGER(KIND=4)   :: i
  INTEGER(KIND=4)   :: j
  INTEGER(KIND=4)   :: vt
  REAL(KIND=8)      :: dv
  CHARACTER(LEN=40) :: sv
  
  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).EQ.IPQ_OK) THEN
           IF (vt.EQ.TT_DOUBLE) THEN
              WRITE(*,"(g12.6,A1)",ADVANCE="NO") dv, " "
           ELSE IF (vt.EQ.TT_STRING) THEN
              WRITE(*,"(A12,A1)",ADVANCE="NO") sv, " "
           END IF
        END IF
     END DO
     WRITE(*,*)
  END DO

  IF (DestroyIPhreeqc(id).NE.IPQ_OK) THEN
     STOP
  END IF
END PROGRAM example
const char* GetWarningString ( int  id)

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

Parameters:
idThe 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)
const char* GetWarningStringLine ( int  id,
int  n 
)

Retrieves the given warning line.

Parameters:
idThe instance id returned from CreateIPhreeqc.
nThe 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
  
int GetWarningStringLineCount ( int  id)

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

Parameters:
idThe 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
  
int LoadDatabase ( int  id,
const char *  filename 
)

Load the specified database file into phreeqc.

Parameters:
idThe instance id returned from CreateIPhreeqc.
filenameThe 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
int LoadDatabaseString ( int  id,
const char *  input 
)

Load the specified string as a database into phreeqc.

Parameters:
idThe instance id returned from CreateIPhreeqc.
inputString 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
  
void OutputAccumulatedLines ( int  id)

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

Parameters:
idThe 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
void OutputErrorString ( int  id)

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

Parameters:
idThe 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
void OutputWarningString ( int  id)

Output the warning messages to stdout.

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

Runs the input buffer as defined by calls to AccumulateLine.

Parameters:
idThe 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
int RunFile ( int  id,
const char *  filename 
)

Runs the specified phreeqc input file.

Parameters:
idThe instance id returned from CreateIPhreeqc.
filenameThe 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
int RunString ( int  id,
const char *  input 
)

Runs the specified string as input to phreeqc.

Parameters:
idThe instance id returned from CreateIPhreeqc.
inputString 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_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:
idThe instance id returned from CreateIPhreeqc.
dump_onIf non-zero, turns on output to the DUMP (dump.out if unspecified) file; if zero, turns off output to the DUMP file.
Return values:
IPQ_OKSuccess.
IPQ_BADINSTANCEThe 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_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:
idThe instance id returned from CreateIPhreeqc.
dump_string_onIf 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_OKSuccess.
IPQ_BADINSTANCEThe 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_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.err file. The initial setting after calling CreateIPhreeqc is off.

Parameters:
idThe instance id returned from CreateIPhreeqc.
error_onIf non-zero, writes errors to the error file; if zero, no errors are written to the error file.
Return values:
IPQ_OKSuccess.
IPQ_BADINSTANCEThe 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_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.log file. The initial setting after calling CreateIPhreeqc is off.

Parameters:
idThe instance id returned from CreateIPhreeqc.
log_onIf non-zero, log messages are written to the log file; if zero, no log messages are written to the log file.
Return values:
IPQ_OKSuccess.
IPQ_BADINSTANCEThe 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_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.out file. This is the output normally generated when phreeqc is run. The initial setting after calling CreateIPhreeqc is off.

Parameters:
idThe instance id returned from CreateIPhreeqc.
output_onIf non-zero, writes output to the output file; if zero, no output is written to the output file.
Return values:
IPQ_OKSuccess.
IPQ_BADINSTANCEThe 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_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 SELECTED_OUTPUT (selected.out if unspecified) file. The initial setting after calling CreateIPhreeqc is off.

Parameters:
idThe instance id returned from CreateIPhreeqc.
sel_onIf non-zero, writes output to the selected-output file; if zero, no output is written to the selected-output file.
Return values:
IPQ_OKSuccess.
IPQ_BADINSTANCEThe given id is invalid.
See also:
GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue
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