allocatable array or common-block?

allocatable array or common-block?

Hello,

I have an older code which uses a large common-block containing a onedimensional real*8 array for storing and sharing. The disadvantage is, that I have to specify the size of the array on compile-time. Therefore I think about switchung to an allocatable array defined in a module.

What works faster, the common-block or the allocatable array? Or is there no difference? Does anyone have experience?

Thank you and best regards,
Heinz

 

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

Does it matter if you can't get the behavior you want with a COMMON block? You may not be able to measure any performance penalty using an allocatable array and it is what I would recommend.

Steve - Intel Developer Support

Thank you Steve, you have answered my question.

Regards
Heinz

I have changed from a large common-block containing a one dimensional real*8 array for storing and sharing; to an allocatable array in a module.
.
I have not noticed any performance penalty but there are some coding changes.
.
On the -ve side, I had 3 arrays; real*8, integer*4 and logical*4, which were all equivalenced. This allowed me to use the appropriate kind array when calling, to avoid type/kind warning when compiling. Equivalence is not readily available and requires some changes to these arrays.
On the +ve side, I have transferred a number of key arrays from previously being "allocated" to now being allocatable arrays that are always available, recognising that these are typically "small" arrays, given the amount of free memory now available. This has simplified a lot of the disk storage interfaces. I now have small, medium and large arrays and try to limit my sharing to the few large arrays.
.
Using this key storage module has simplified the array storage management, enabling simpler memory and disk storage management. The main change has been to change my disk storage library to manage records larger than 2gb.
.
As COMMON is limited to 2gb, you must change to allocatable arrays if you want to utilise 64_bit addressing. Treat is as an opportunity for improved coding flexibility, rather than a hastle.
.
I would recommend the change to allocatable arrays, and incorporate a review of the key definition arrays, for them to become allocatable, rather than disposable, as in earlier memory management approaches.
.
John

Leave a Comment

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