08-02-2011 04:52 PM
Hello, I'm new to LabVIEW and relatively new to Fortran as well. I'm currently attempting to use the "Call Library Function Node" to use a Fortran .dll that I have written. I'm passing several values into the library node and would like to see them updated by the subroutine I've selected so that they will come out the other side of the node with new values.
Currently, when running the VI, I receive an error "Error 1097 occurred at Call Library Function Node in MyDllTest.vi". I've tried selecting both types of calling conventions, but it doesn't seem to make a difference. Also, the values that I input into the dll block simply come out the other side untouched. I am able to pick my subroutine as an option when setting up the dll node, but I've had to add all of the variables manually. I'm not sure if that's correct behavior or not.
I have attached both my .vi and my Fortran code.
08-04-2011 08:46 AM
Hi adams156,
The error is saying that there is something wrong with your fortran code. I would check your data types. I don't know if fortran considers a logical to be an integer.
There is an example on this page you might find useful:
http://forums.ni.com/t5/LabVIEW/Calling-compaq-visual-fortran-dll-from-labview/td-p/148244
Lastly, filling in the parameters yourself is expected for this type of dll.
08-04-2011 09:23 AM
Thank you for your response. That forum post is actually the guideline that I was going by when I started this project. In order to check the fortran code, I went so far as to write a main function and compile it as an executable. It compiled and ran succesfully.
As far as the logical to integer conversion goes, I couldn't find a "Type" in the call library function parameter settings that corresponded to bool or logical or anything such as that. Integer was the closest type I could find, and some other user recommended it as well. Maybe that is where the problem lies though, and I may need to use some other data type to represent my logical.
08-04-2011 09:31 AM
Hi adams,
Could you change the logical it to an integer in your fortran just to double check whether that is the problem?
Also, you might try parsing down your subroutine to just a couple of values and work up from there.
Let me know how it goes.
08-04-2011 09:37 AM
I may try that, but for now, I actually tried passing the boolean as "Adapt to Type". That has gotten rid of the error, though the code still doesn't function as intended. I'll look at it for a while and let you know what I figure out.
08-05-2011 09:36 AM
I've been working at this today, and I seem to have it working aside from the boolean. I simply took the boolean out of the Fortran and the vi and everything worked fine. Apparently, I've yet to find the appropriate way to designate a Fortran boolean variable in the call library function node.
08-05-2011 09:40 AM
Good morning adams156,
I think that how booleans are stored is specific to each language, you would have to track it down for your version of Fortran. It might be easier just to store it as an integer. The discussion below hits on this for c:
http://lavag.org/topic/3433-return-boolean-from-c-dll-to-call-library-function-node/
08-05-2011 02:37 PM
I think I finally have it! I start off with a boolean in the .vi which I then type cast to a 4 byte signed integer (turns out that's what a default fortran logical is), and feed that into the call library node, which is expecting a 4 byte signed integer. Everything seems to be working great now. Thanks for your help.
08-05-2011 05:40 PM
Good to hear!
Would you mind posting your working example so other people who come across this thread can use it?
Take care
08-10-2011 11:44 AM
This should do it. The Source1.txt was an .f90 file but I couldn't use the attachment system to put it up here with that extention.