Fortran Memory storage of multidimensional arrays in fortran 90

Click For Summary
In Fortran 90, multidimensional arrays may not be stored contiguously in memory, a departure from the stricter storage rules of Fortran 77 and C. The storage layout can depend on the specific compiler used, such as ifort or gfortran. Generally, it is noted that the first index of an array is contiguous in most implementations. However, subarrays defined with strides (e.g., A(1:50:10)) are not contiguous, and when passed as arguments, they are typically copied to a contiguous temporary array. For arrays defined with a straightforward format, like A(10,20,30), they are usually contiguous in most cases. Further insights or clarifications on this topic are encouraged.
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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

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
6K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K