- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code below is part of a DLL. I call the functions from VBA in Excel.
I have a function that employs the DZBREN root finding IMSL routine. The code follows at the end of this description. THe problem is with the function name that is declared in the EXTERNAL statement (Note: in the code below i have the EXTERNAL statement commented out, as well as the DZBREN routine). When i try to compile the code with the EXTERNAL statement not commented out, i get the LNK error 2001: unresolved external symbol _TFROMHABSERRORFNC. I'm pretty sure i need to declare it EXTERNAL to get the DZBREN routine to work. WHen the DZBREN routine is uncommented, the whole thing crashes
THese functions are contained in a MODULE, just in case that matters. Also, I know that the result of DZBREN is Tb, but I was returning Ta as a debugging measure.
Can someone help me figure this out? Seems simple enough, but i'm beginning to think i'm not smart enough even for simple things...
[fxfortran] real (8) function TfromHabs_fnc(h,X) C h Gas enthalpy (kJ/kg) C X Array containing mixture mol fractions C TfromHass_fnc returned temperature (K) corresponding to h !dec$ attributes dllexport :: TfromHabs_fnc !dec$ attributes stdcall, REFERENCE, alias :'TFROMHABS_F' :: TfromHabs_fnc USE MolecularWeights implicit none include 'Common_Gases.for' real(8) h, X(11),Xpassed(11), hPassed real (8) Fraction, Ta, Tb logical bContinue common/PassTfromHasbErrorFnc/hPassed, Xpassed C External TfromHabsErrorFnc Xpassed=X hPassed = h Tb = 4000.0 Fraction = 1.0 bContinue = .FALSE. do while (.not.bContinue) Fraction =Fraction*0.9 if (Tb*Fraction.LT.220.0) then TfromHabs_fnc = -999.0 return endif if (TfromHabsErrorFnc(Tb)*TfromHabsErrorFnc(Tb*Fraction).lt.0.0) then bContinue = .TRUE. Endif end do Ta = Tb * Fraction ! call DZBREN(TfromHabsErrorFnc, 0.0, 0.001, Ta, Tb, 100) TfromHabs_fnc = Ta return end function TfromHabs_fnc real (8) function TfromHabsErrorFnc(T) C h Gas enthalpy (kJ/kg) C X Array containing mixture mol fractions C TfromHass_fnc returned temperature (K) corresponding to h implicit none include 'Common_Gases.for' common/PassTfromHasbErrorFnc/hPassed, Xpassed real(8) T,hPassed, Xpassed(11) TfromHabsErrorFnc=hPassed - habs_fnc(T,Xpassed) return end function TfromHabsErrorFnc [/fxfortran]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you debugged this - set breakpoints in the function and see where it dies? What compiler options are you using? You must make sure you are not using /iface:cvf.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On breakpoints, i have not been successful at adding them to a DLL and getting it to work. I also turned off the /iface:cvf long ago (I think because of a suggestion you provided to someone else).
Can you direct me to a good spot on how to set up a DLL for debugging? If i did actually learn how to do that, I would save an immense amount of time -- Duh...
Following are what i think are the compiler options (I copied this from the command line option). I happened to have it set to release, but i have also attempted a debug version without success in debugging.
/nologo /I"C:\Program Files (x86)\VNI\imsl\fnl600\IA32\include\dll" /gen-interfaces /extend_source:132 /Qopenmp /warn:interfaces /fpconstant /module:"Release\" /object:"Release\" /libs:static /threads /c
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page