BillJohnson
Joined: 31 Aug 2011 Posts: 30 Location: Connecticut
|
Posted: Thu Sep 15, 2011 7:18 pm Post subject: Memory Pointers from VB.NET to FORTRAN Subroutine. |
|
|
I think I have a memory pointer issue between VB.NET calling a Compiled FORTRAN Subroutine because the call works the first time; however, subsequent calls to the same FORTRAN Subroutine produces weird values. I've tried setting some of the output variables equal to nothing in thinking that the Garbage Collector will release the memory pointers.
Below is the VB.NET parent calling function and the FORTRAN subroutine:
<<VB.NET Code>>
Dim ierr As Long
Dim x(20), y(20) As Double
Dim z(20) As Double
Dim D, D1, Dv As Double
Dim q, erg, h, s, Cp, Cv, w As Double
Dim HFLD_st As String = "C:/Program Files/REFPROP/Fluids/WATER.FLD"
Dim HFMIX_st As String = "C:/Program Files/REFPROP/Fluids/HMX.BNC"
Dim HERR_st As String = ""
For ii = 1 To 253
HERR_st += " "
Next
HERR_st = "Ok" & HERR_st
Dim press_kPa As Double
Dim temp_degK As Double
Dim Enthalpy_metric As Double
Dim entropy_metric As Double
temp_degK = Nothing
press_kPa = Nothing
AxtRefprop.HSFLSHdll(Enthalpy_metric, entropy_metric, z, temp_degK, press_kPa, D, D1, Dv, x, y, q, erg, Cv, Cp, w, ierr, HERR_ch)
<<FORTRAN Code>>
subroutine myHSFLSH (h,s,z,t,p,D,Dl,Dv,x,y,q,e,cv,cp,w,ierr,herr)
ASSEMBLY_INTERFACE(NAME="HSFLSHdll")
implicit double precision (a-h,o-z)
implicit integer (i-k,m,n)
parameter (ncmax=20) !max number of components in mixture
character*255 herr
double precision x( , y( , z(
double precision, INTENT(OUT) :: t,p,D,Dl,Dv,x,y,q,e,cv,cp,w
integer, INTENT(OUT) :: ierr
Does anyone see anything fishy or usual here? All comments are welcomed.
Regards,
Bill |
|