exporting allocatable arrays

exporting allocatable arrays

Dear all,
I'm using Visual Fortran for Windows and I can't solve the problem of exporting allocatable arrays defined and allocated inside my subroutines...I'd like to export them in my main but I don't know how.
I would avoid solutions like modules because the ultimate aim of my job is to generate .dll libraries.
Is there any way to export dynamic arrays from subroutines that will become part of a dll?
Thanks for your attention.

Your sincerely

Roberto

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

First of all, dllexporting global data does not quite match my idea of clean interface. The most common approach is to let the caller allocate the storage and pass it to your routine as an assumed-shape array. The second best approach is that you dllexport two or three routines - one to allocate storage, second to return pointer to it to the caller (one can do both), and third to free it. What language is that supposed to be called from?

Further, an allocatable array cannot be global unless it's in a module -- why do you think that modules are incompatible with dlls? The following is supposed to work (I didn't test it)

MODULE MyModExport

REAL, ALLOCATABLE:: AnArray(:)
!DEC$ATTRIBUTES DLLEXPORT, ALIAS: "_AnArray":: AnArray

END MODULE MyModExport

In the caller:

MODULE MyModImport

REAL, ALLOCATABLE:: AnArray(:)
!DEC$ATTRIBUTES DLLIMPORT, ALIAS: "_AnArray":: AnArray

END MODULE MyModImport

Jugoslav

Jugoslav
www.xeffort.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today