LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fortran subroutine?

Hello everyone,

I'm a really new user of labview and I'm trying to mix labview VI and Fortran programs.
I've done some research, and I know it has to be done through DLL.
I'm looking for more information, a tutorial or real example.
If anyone knows about it, it would be great.
thanks

klaks
0 Kudos
Message 1 of 11
(8,795 Views)
I suggest you start with the "Using External Code in LabVIEW" manual, which ships in PDF format with LabVIEW. It's also available here.

The manual is written from a C point of view, but as long as your DLL supports the calling conventions and datatypes that the LabVIEW Call Library Function supports, it should work.

You can also search for "dll" in Example Finder (Help > Find Examples) or on Developer Zone. Also a Developer Zone search of "fortran" turned up several hits.

Steven H.
Message 2 of 11
(8,780 Views)
The manual that Steven mentioned above is a good start.

For a very simple example using Compaq Visual Fortran, have a look at my posts in this old thread.

What kind of Fortran compiler are you using?
Message 3 of 11
(8,773 Views)
Tanks guys ,
This is what I needed.I understand now how to do it .

Thanks a lot again

kl
0 Kudos
Message 4 of 11
(8,764 Views)
hello again,

I' m using the Compaq Visual Fortran, using the Compaq fortran 95 compiler.
I think I understand how to do it from scratch, but if I already have my Fortran programs already working...
Is there a way to just to link my VI to a .exe and give the function definition, inputs ..outputs ...
I mean, without having the function node generating the skeleton code for me ?
I'm sure it explained somewhere , but i haven't found it yet 🙂
thanks

kl
0 Kudos
Message 5 of 11
(8,751 Views)
If your fortran program is already working, you just need to add the "!DEC$ ATTRIBUTES DLLEXPORT ..." line and then build the DLL.
In LabVIEW you then manually configure a fresh "Call Library Function Node" by selecting the just built DLL and defining the function name and parameters.

Nothing LabVIEW related will ever built you skeleton code in Fortran, that's just for C 😉
0 Kudos
Message 6 of 11
(8,735 Views)
Thank you very much,
I think I was trying to look for something to complicated while it was simple.
I just had to create a .dll from the commande line, and configure the call library node.

thanks again altenbach


kl
0 Kudos
Message 7 of 11
(8,705 Views)

Hi there,

I have Fortran source code.  I know nothing about it, except that it works.  I have all the uncompiled (.for) files and the compiled files (.obj) with I can only assume a compiled library file (.lib).  What does the .lib file contain?

 Someone mentioned that you need to add "!DEC$ ATTRIBUTES DLLEXPORT ... (and something else?)" to every source code file then compile into a .dll to call it from LabVIEW.  So you just add this line and that's it?  How do I know what version of Fortran my source code is written in (77, 90... etc)?

Can someone please explain the process of taking this Fortran source code, compiling it into a DLL and being able to call the functions from LabVIEW.

Thanks,

Battler.

0 Kudos
Message 8 of 11
(7,714 Views)

Hey Battler,

 

You'd need to look up how you can convert Fortran to a DLL. Here's link I got from a quick Google search: How To Create a FORTRAN DLL and Call It from Visual Basic

 

Once you develop the DLL you'll have to create a C wrapper for LabVIEW to understand the Fortran DLL. A good reference for this would be Writing a Wrapper Function for an External Code Function.

Aashish M
CEO
TransferFi
www.transferfi.com
0 Kudos
Message 9 of 11
(7,682 Views)

Thanks.

What about this "!DEC$ ATTRIBUTES DLLEXPORT"?  Where does this come into it?

0 Kudos
Message 10 of 11
(7,672 Views)