Is there a memory difference between using shared blocks and modules in Fortran 90

I recently studied Fortran without any guidance and experimented with different versions. I found from this site :

Is a MODULE better than a COMMON block?

Almost always yes. The only reasons for using COMMON blocks are: expect to use your program on a computer with only the FORTRAN 77 compiler (they still exist), or if it is very important that you control the order in which your data is stored in memory.

Well, using modules is certainly syntactically sweeter than using shared blocks. But what are the differences in memory usage and allocation in both cases? Does it also matter in terms of performance and access speed? Does this question make sense?

+4
source share
2 answers

MSB has this in its answer, but, in my opinion, does not sufficiently emphasize this. Variables in COMMON blocks are laid out in memory exactly in the order in the block definition. It follows from this that the restriction immediately follows that no dynamic memory objects (allocatable, pointer) can be in the COMMON block.

"Serial association" means that you can count on placing variables in such a way that you can, for example, use the following two arrays as large ones.

COMMON blocks probably have no place in modern code, although they are not deprecated.

, , , COMMON.

+4

, , . (. Fortran, ). , , . FORTRAN , , , , , . .

COMMON . " ", .

+4

Source: https://habr.com/ru/post/1541352/


All Articles