Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29239 Discussions

Passing assumed-shaped arrays from Fortran(g95) program to a Fortran(Intel) dll

galatyp
Beginner
379 Views
The code below is the main program (compiled withanother fortran compiler)calling a function in a dll which is compiled with Intel Fortran Compiler.
Code:
PROGRAM prgSample
 interface
    function DllFunc(Array)
      Real(4),intent(in) :: Array(:)
      Real(4) :: DllFunc
    end function
  end interface
  
  Real(4)::Array(10),DllReturn

  Array=0
  
  DllReturn=DllFunc(Array)
  PRINT*,'Size of Array: ',DllReturn
END PROGRAM prgSample
this is the code of the dll function (compiled with Visual Fortran)
Code:
function DllFunc(Array)
implicit none
  Real(4),intent(in) :: Array(:)
  Real(4) :: DLLFUNC

  DllFunc=Size(Array)
end function

when i run the program, it prints "Size of Array: 4" although it's 10.

if i compile the dll with same compiler it works. Is there any possibility of array descriptor structure of the compilers wouldn't be same ?

Or maybe, Visual Fortran compiler default expects a normal array reference not a descriptor reference from the outside calls ?

I'm really stuck here therefore any help would be great. Thanks in advance.

0 Kudos
1 Reply
Steven_L_Intel1
Employee
379 Views
The array descriptors are not the same. Close, but not compatible. An alternative is to pass the array length as a separate argument and use "adjustable arrays" such as this:
function DllFunc(Array,N)
implicit none
Integer(4), intent(in) :: N ! Must be declared first!
Real(4),intent(in) :: Array(N)
Real(4) :: DLLFUNC

DllFunc=Size(Array)
end function
0 Kudos
Reply