User account creation filtered due to spam.
Assume a module with the following definitions:
(a) real, allocatable, dimension(:) :: array
(b) real, dimension(500) :: array
Both arrays are contiguous as one cannot allocate strides
allocate(array(1:1000:2)) ! invalid
Thus: Only pointers or dummy arguments can have strides.
If one accesses the array in a loop, this can slow down the calculation considerably.
real, dimension(500) :: array
! real, allocatable, dimension(:) :: array
integer :: n, i
real :: x(n)
do i = 1, n
x(i) = array(i)
end subroutine test
end module a
From the dump difference:
- (*x)[(int8) i + -1] = array[(int8) i + -1];
+ (*x)[(int8) i + -1] = (*(real4[0:] *) array.data)[(int8) i * array.dim.stride + array.offset];
Full example, see:
("Program slowdown when calling function with dynamic arrays" by Paul Hilscher)
Gfortran should know that stride==1 for allocatables, as was suggested by Tomas Koenig in #32131, comment 5.
*** This bug has been marked as a duplicate of 32131 ***