Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

Allocatable arrays problem

vbernhardt
Beginner
1,107 Views
I developp a DLL.
I define the following module
module tableaux
save
real*8, allocatable :: PDL(:),PX(:),PY(:),PA(:),PGH(:)
real*8, allocatable :: PYCG(:),IPS(:),PU(:),PGHSS(:),PYCGSS(:)
end module tableaux

Then I include "use tableaux" in each file from which I need these arrays.
When running the application calling the DLL, I get an error message 151 (array already allocated). If I try to deallocate instead, I get error message 153 (array not allocated).

If I delete the "use tableaux" lines, and define instead the arrays directly in each file, it works.
But I want to use the tableaux module, in order to share the arrays between all my Fortran files.

The only differences I can see between the example I had and that works and my code are the following :
- the example was an EXE, not a DLL
- it was compiled with Fortran PowerStation, not with Compaq Visual Fortran.
But in the docs I have, I find no mention about incompatibilities with DLLs etc.

What's the problem with the "use tableaux" line ? Or is it with the tableaux module ?
Please help me !

Valrie
0 Kudos
6 Replies
Steven_L_Intel1
Employee
1,107 Views
To do this properly, you must 1) Add a !DEC$ ATTRIBUTES DLLEXPORT for the arrays, 2) Use CVF 6.6A (or perhaps even a newer compiler, send mail to vf-support@compaq.com if it doesn't work with 6.6A), 3) Be sure that the EXE is linked against the DLL form of the run-time libraries.

Steve
0 Kudos
vbernhardt
Beginner
1,107 Views
Thank you very much.

1) My module now looks like this :
module tableaux
save
real*8, allocatable :: myreal(:)
!DEC$ ATTRIBUTES DLLEXPORT::myreal
end module tableaux
Should the !DEC... be added before or after the array declaration ?
Is it needed even the array is used only inside the DLL (I mean the array won't be used directly from the main program)

2) My CVF version was 6.6.0. O downloaded the update from the Compaq website, and now I have version 6.6.A
I compiled my DLL again. But it still won't work.
Is it an official problem from CVF ? I mean, you seem to know it's normal it shouldn't work with 6.6.0 ?
Note : I tried to do exactly the same in an exe file, with the same compiler : it works alright. So I guess the problem rather comes from the fact it is a DLL than from the compiler ?

3) What does it mean "the main program is linked against the DLL form of the DLL" ?

Valrie.

0 Kudos
vbernhardt
Beginner
1,107 Views
One more information : I just checked the main program (until now, I just used it, because I didn't write it).
It's not a Fortran program, it's a Visual Basic 6 program.
The DLL is declared that way :
Declare Sub talcalc Lib "t:validation alcalc.dll" ()

Can that cause the problem ?

Valrie.
0 Kudos
Steven_L_Intel1
Employee
1,107 Views
Sorry, I misunderstood what you were doing. I thought you had a Fortran executable using your DLL. Since all of the Fortran is inside the DLL, you don't need DLLEXPORT and the compiler problem I referred to is not of interest.

Please send a ZIP archive of your project, along with a description of the problem, to CVF support at vf-support@compaq.com We'll take a look at it.

Steve
0 Kudos
vbernhardt
Beginner
1,107 Views
Thank you for your answer.
I tried to simplify my project a lot, to sent it to technical support.
And then it worked.
I don't know what I changed, but it works !

Valrie.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,107 Views
I know the problem is solved, but I'd just add for the future reference: such problems are frequently symptoms of out-of-array bounds access. My experience shows that these exact errors are often a consequence of trying to write something into array(0). Of course, that can happen only after repeated allocations/deallocations, not for the very first allocation.
0 Kudos
Reply