Memory storage of multidimensional arrays in fortran 90

Click For Summary
SUMMARY

In Fortran 90, multidimensional arrays may be stored non-contiguously in memory, depending on the compiler used. Both Intel Fortran Compiler (ifort) and GNU Fortran (gfortran) adhere to this flexibility. While the language does not enforce a specific storage implementation, it is generally accepted that the first index of an array is contiguous. Subarrays defined with strides, such as A(1:50:10), are not contiguous and are typically copied to a contiguous temporary when passed as arguments.

PREREQUISITES
  • Understanding of Fortran 90 array structures
  • Familiarity with compiler behavior in Fortran, specifically ifort and gfortran
  • Knowledge of memory storage concepts
  • Experience with array slicing and subarrays in programming
NEXT STEPS
  • Investigate the memory layout of arrays in Fortran 90
  • Explore the differences in array storage between Fortran 90 and Fortran 77
  • Learn about the implications of using subarrays with strides in Fortran
  • Examine performance considerations when passing arrays to functions in Fortran
USEFUL FOR

Fortran developers, compiler engineers, and anyone involved in optimizing memory usage and performance in Fortran applications.

vacuum
Messages
75
Reaction score
0
Hello,

I think i heard somewhere that a multidimensional array in fortran 90 may be stored non-contiguously in memory. Is this true? Even if it the size was known at compile time?

If your answer is it depends on a compiler, what about ifort and gfortran?
 
Technology news on Phys.org
OK, after some investigation, I found that fortran 90, unlike fortran 77 (and C) does not impose a storage implementation on the arrays. But, according to some people, in all implementations at least the first index is contiguous. What is certainly not contiguous are subarrays chosen with a stride of course (A(1:50:10)), though when used as an argument they are usually copied to a contiguous temporary. The pointers to such arrays are also not contiguous.
If arrays are defined with a simple format, e.g. A(10,20,30), they are, in most (all?) cases contiguous.

Any further comments or clarifications would be welcome.
 

Similar threads

  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 19 ·
Replies
19
Views
7K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
8K