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

Is it possible to use arrays on this way

cobek
Beginner
340 Views
Hello, I wonder if this can work?

*)dll subroutine:

subroutine Test(array)
!DEC$ ATTRIBUTES DLLEXPORT :: Test
use dflib
implicit none
character($MAXPATH), allocatable :: array(:)
integer n

n=4
allocate(array(n))
array(1)='A '
array(2)='B '
array(3)='C '
array(4)='D '
end subroutine




*)caller subroutine

...
...
interface
subroutine Test(array)
!DEC$ ATTRIBUTES DLLIMPORT :: Test
use dflib
implicit none
character($MAXPATH), allocatable :: array(:)
end subroutine
end interface
...
...

call Test(array)
...
...!do something with array
...
deallocate(array)


0 Kudos
1 Reply
Steven_L_Intel1
Employee
340 Views
It is not standard Fortran 95, but having an ALLOCATABLE routine argument is part of a "Technical Report" for Fortran 2000 which is implemented by CVF 6.6B. This should work in that version of CVF. Make sure that the EXE is linked against the DLL form of the Fortran run-time library (the project wizard asks you if you'll be using a Fortran DLL when you create the project - say yes.) Otherwise the deallocate will fail.

Steve
0 Kudos
Reply