Discussion:
Fortran subroutine?
(too old to reply)
battler.
2008-08-07 10:10:11 UTC
Permalink
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.
Aashish_M
2008-08-08 21:10:05 UTC
Permalink
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: <a href="http://support.microsoft.com/kb/123841" target="_blank"> How To Create a FORTRAN DLL and Call It from Visual Basic</a>

&nbsp;

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 <a href="http://zone.ni.com/devzone/cda/epd/p/id/4489" target="_blank"> Writing a Wrapper Function for an External Code Function</a>.
battler.
2008-08-08 23:10:04 UTC
Permalink
Thanks.
What about this "!DEC$ ATTRIBUTES DLLEXPORT"?&nbsp; Where does this come into it?
altenbach
2008-08-09 00:10:05 UTC
Permalink
battler. wrote:What about this "!DEC$ ATTRIBUTES DLLEXPORT"?&nbsp; Where does this come into it?

This is a directive to tell&nbsp;which of&nbsp;your fortran subroutines should be exported as a public procedure. Often, your fortran code has many other&nbsp;subroutines that you don't want to expose to the user of the DLL.
&nbsp;
For an example, see the <a href="http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=88786&amp;requireLogin=False" target="_blank">old thread </a>mentioned above)
&nbsp;

(see also&nbsp;e.g. <a href="http://www.canaimasoft.com/f90vb/OnlineManuals/UserManual/TH_60.htm" target="_blank">http://www.canaimasoft.com/f90vb/OnlineManuals/UserManual/TH_60.htm</a>)
Loading...