Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

.DLL file Link #C

Kim__Young
Beginner
152 Views

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
Steve_Lionel
Black Belt Retired Employee
152 Views

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.

Greg_T_
Valued Contributor I
152 Views

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

Reply