Conceptual Models > Incorporation PHREEQC in programming languages

Question for using IPHREEQC function

(1/1)

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.
https://wwwbrr.cr.usgs.gov/projects/GWC_coupled/iphreeqc/IPhreeqc_8h.html

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

Sincerely,
Jeonghwan Hwang

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

--- 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?


dlparkhurst:
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 https://water.usgs.gov/water-resources/software/PHREEQC/IPhreeqcCOM.chm

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")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.RunFile("ex2")
str = "components:" & vbNewLine
comps = iphreeqc.GetComponentList()
For Each comp in comps
    str = str & comp & vbNewLine
Next
WScript.Echo(str)

--- End code ---

Navigation

[0] Message Index

Go to full version