Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
8 Views

.DLL file Link #C

First of all, let me introduce myself I am engineer. I am developing the mooring analysis program using the Intel® Parallel Studio XE 2017 Professional Edition for Windows which is installed on the Microsoft Visual Studio Professional 2017(C#).

I have been compiling this program to use the Fortran Libraries (- Runtime Library : Multithreaded) and Fortran Language (- Process OpenMP Directives : Disable) to make “ssc.dll” file.

The following is head of program.

 

FUNCTION IMOORLNG(InputFile, OutFile1, OutFile2, OutFile3,

     *                drope,    List_a, listcount,

     *                dolName1, dolname2, dolname3,

     *                dolName4, dolname5, dolname6,

     *                dolName7, dolname8, dolname9,

     *                dolName10, dolname11, dolname12,

     *                dolName13, dolname14,

     *                dolCount, errstr)

      !DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS : "IMOORLNG" :: IMOORLNG

 

I tried to call this ssc.dll in the main program of the C# base. However, it did not call ssc.dll.

Please help me how to call this ssc.dll.

0 Kudos
2 Replies
Highlighted
Black Belt
8 Views

Please show us the C# code

Please show us the C# code you used.  Did you get any kind of run-time error, or did it just appear to do nothing? Other than the use of obsolete fixed-form, I don't spot anything wrong in the Fortran code you posted. 

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/276038 has a worked example - take a look at this and compare to your code to see if you can spot the problem.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
New Contributor III
8 Views

When I call Fortran routines

When I call Fortran routines from C# I need to include the following information in the .cs file, which might help you.  I add "using System.Runtime.InteropServices;" at the top of the *.cs file:

using System.Runtime.InteropServices;

 

I declare an interface to the Fortran subroutine by adding the DllImport parameter and a declaration with the arguments for the routine that will be called.

[DllImport("my_dll_name")]

static extern void my_subroutine_name_in_dll(ref int my_scalar_variable, int[] my_integer_array, ....);

 

I have found that I can omit the .dll file extension in the DllImport statement and the Windows or Linux OS will find the file when the DLL is located with the main program executable.  I pass all arguments by reference from C# to Fortran.  Scalars need the "ref" keyword in the declaration. Arrays are passed by reference by default.

Regards, Greg

0 Kudos