- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
![](/skins/images/7B0AB6865064EAE32B30EC9A4E94B48A/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page