Conceptual Models > Incorporation PHREEQC in programming languages

Question for using IPHREEQC function


Jeonghwan Hwang:
Hello, this is Jeonghwan Hwang

This is probably a very basic question.
But I need help.

I want to use a function that is utilized in IPHREEQC.
The functions were provided at the address below.

But I can't use them.
For example, when I use 'iphreeqc.GetcomponentCount', it says undefined function.
Rather, I can use 'iphreeqc.GetcomponentList'. But it does not include in above address.

Is there anything else I need to install or declare in order to use these functions?
Thank you for any advise

Jeonghwan Hwang

You don't say which language you are using, but your link points to C or Fortran. I'm going to assume Fortran.

If you look at the documentation for the method CreateIPhreeqc, you will find an example program that should serve as a model. You should be able to use any IPhreeqc methods in this program. Perhaps you have not included the USE statement?

If you are using C++, there is an equivalent program defined in the documentation for the constructor IPhreeqc.

--- Code: ---PROGRAM example
  USE iphreeqc
  INTEGER(KIND=4) :: id
  id = createiphreeqc()
  IF (id.LT.0) THEN
  IF (loaddatabase(id, "phreeqc.dat").NE.0) THEN
     CALL outputerrorstring(id)
  IF (runfile(id, "ex2").NE.0) THEN
     CALL outputerrorstring(id)
  IF (destroyiphreeqc(id).NE.ipq_ok) THEN
     CALL outputerrorstring(id)

--- End code ---

PhreeqcRM uses several IPhreeqc instances to do calculations. It is possible to get references to those instances and perform calculations with IPhreeqc instances as opposed to the normal PhreeqcRM methods. Look at the advection examples of PhreeqcRM (toward the bottom of the code) to see how this is done.

Jeonghwan Hwang:
Sorry for not providing program information.

I use matlab.

My understanding is that matlab functions are different from functions in fortran, is that correct?

So the iphreeqc function in the above address is a fortran function, and cannot be used in matlab.

Is my understanding correct?

Sorry, I'm not familiar with using IPhreeqc in Matlab; I think you are using the COM version of IPhreeqc.

The documentation is available at

When you download the documentation, you may need to unblock the file. In PowerShell you would use this command

Unblock-File '.\IPhreeqcCOM.chm'

I don't know the syntax for Matlab, but here is an example for VBScript that uses the method GetComponentList():

--- Code: ---Dim iphreeqc, comp, comps, str
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
str = "components:" & vbNewLine
comps = iphreeqc.GetComponentList()
For Each comp in comps
    str = str & comp & vbNewLine

--- End code ---


[0] Message Index

Go to full version