LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I simulate Fortran code in LabWindows?

For a project I have a finite volume code in Fortran that simulates magnetohydrodynamics and I want to use it as an observer in LabWindows. This code basically is going to simulate the system using the measurements taken.

What should I do? I heard something about creating a Fortran dll and using it in LabWindows. How can I do that?

0 Kudos
Message 1 of 16
(4,927 Views)

Hello, You are on the right track, you can call into dll's created in other languages from LabWindows/CVI. However you cannot create a Fortran dll using LabWindows/CVI.

 

Thanks,

 

National Instruments
Message 2 of 16
(4,901 Views)

CVI ships with multiple example DLL projects that can help you understand how to create and call DLLs in CVI.  In your case, as Anna said, you need to call functions in a DLL, not create a DLL in CVI.  You need to use your Fortran compiler to create the DLL and .LIB file, and then you can use CVI to call functions in that DLL.

 

Look at the simple DLL example projects in C:\Documents and Settings\All Users\Documents\National Instruments\CVI90\samples\dll\simple\cvi.  (Note: the directory may be different depending on your CVI installation and version.)

 

First you need to build the DLL.  Open mydll.prj, then, from the CVI menu, select Build >> Create Debuggable Dynamic Link Library.  This is the step in your real project that you will need to do using your Fortran compiler.

 

Then build the executable to call functions from your DLL.  Open simple.prj, then Build >> Create Debuggable Executable.  You can now run your project, and browse simple.c to see how it calls functions in your DLL.

 

Remember that for the purpose of this example, you're building a DLL in CVI, but for your real project, you'll be using your Fortran compiler to build your DLL and LIB.  Copy the DLL and LIB files to your CVI project directory, add the LIB file to your CVI project, and in your .c file which will call the DLL functions, #include a .h file which contains the prototypes for the DLL functions you'll be calling.

 

Message 3 of 16
(4,887 Views)

The Fortran compiler may or may not generate the import library (the .LIB file).  If it doesn't you may have to call the DLL file explicitly as detailed here:

 

http://zone.ni.com/devzone/cda/tut/p/id/8503

 

Alternatively you be able to use lib.exe to create the .LIB file once you have the .DLL (you may need to have MS Visual Studio installed to have access to lib.exe).

0 Kudos
Message 4 of 16
(4,869 Views)

By the way, as long as you already have the .dll and .h files, CVI can generate the import library for you: open the .h file in CVI, and then select Options>>Generate DLL Import Library.

 

Luis

0 Kudos
Message 5 of 16
(4,825 Views)

So I understand I need to use my Fortran compiler (Intel compiler) to create the DLL. How do I do that? I have found info online about how to create a Fortran DLL to be called from Visual Basic. Is the procedure any similar?

 

Felipe

0 Kudos
Message 6 of 16
(4,722 Views)

If you need help on compiling the Fortran code, I would post such a question to a Fortan developers blog, as knowledge in this language is less common. Here on the CVI forums you will find C developers. Best of luck!

National Instruments
0 Kudos
Message 7 of 16
(4,681 Views)

 


@chimbotano wrote:

So I understand I need to use my Fortran compiler (Intel compiler) to create the DLL. How do I do that? I have found info online about how to create a Fortran DLL to be called from Visual Basic. Is the procedure any similar?

 

Felipe


 

The proceedure to create the DLL with the Fortran compiler should be independent of the language used to call the DLL, so these instructions should be what you need on the Fortran side.

 

I've created DLLs in Delphi (Pascal) and called them from CVI.

 

0 Kudos
Message 8 of 16
(4,614 Views)

I have already created a DLL using Intel Fortran Compiler for Windows and now I want to use implicit linking to call it from LabWindows. I understand that I need to provide three files: *.dll, *.h (header file) and *.lib (I can create this one as long as I have the DLL and the header).

The *.h file only needs to have the prototypes of the Fortran procedures that I plan to use, right?

0 Kudos
Message 9 of 16
(4,606 Views)

Correct.  The only prototypes you need are for the functions that you will be calling directly from CVI.

0 Kudos
Message 10 of 16
(4,603 Views)