Allocatable arrays problem

Allocatable arrays problem

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

7 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

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

Steve

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.

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.

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

Steve

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.

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.

Jugoslav www.xeffort.com

Connectez-vous pour laisser un commentaire.