Software Archive
Read-only legacy content
17061 Discussions

Explicit Shape Specifications

Intel_C_Intel
Employee
405 Views
I would like to know how after defining an array, in my main program, with explicit values for the bounds, I can pass this array to multiple subroutines.
Currently, if I use a common statement, I get an error that automatic arrays are not allowed in common statements.

I have 20 such arrays, all of which have to be passed to multiple subroutines.

Thanks,
Richard
0 Kudos
1 Reply
cfrieler
Beginner
405 Views
When you say that you are providing explicit bounds, do you mean in the declaration?

If you are declaring the array as "Allocatable" and then explicitly dimensioning it in an "Allocate" statement, the compiler is telling you that it needs to know the size and shape of all elements in the common at compile time.

If you are declaring the array explicitly, the error message is probably generated by the common statement where you have tried to use something like:

Common /Shared_Data/ Big_Array(:,:)

In any case...
The best method for sharing data between routines is to pass it through an explicit interface. This provides the best compile time error checking.
Admittedly, 20 arrays is a little much for a calling interface. So, the second best method is to write a "Module" that contains the data and "Use" that module in each of the routines. The CVF documentation or any text on Fortran90 will get you started.
0 Kudos
Reply