Hello,
I was experimenting a bit with the is_contiguous intrinsic function and found a strange effect: the program below outputs two different answers for the same array section:
program test_is_contiguous implicit none real, dimension(100), target :: array real, dimension(10,10), target :: matrix real, dimension(:), pointer :: parray real, dimension(:,:), pointer :: pmatrix write( *, '(a,/)' ) 'Contiguous and non-contiguous arrays and sections:' pmatrix => matrix(:,1:1) write( *, '(a,a)' ) 'Pointer to matrix section (:,1): ', report(is_contiguous(pmatrix)) parray => array(1::2) write( *, '(a,a)' ) 'Pointer to section (stride 2): ', report(is_contiguous(parray)) pmatrix => matrix(:,1:1) write( *, '(a,a)' ) 'Pointer to matrix section (:,1): ', report(is_contiguous(pmatrix)) contains function report(condition ) logical :: condition character(len=14) :: report report = merge( 'contiguous ', 'non-contiguous', is_contiguous(parray) ) end function report end program test_is_contiguous
Using Intel Fortran 15.0.1.148, I get:
Contiguous and non-contiguous arrays and sections: Pointer to matrix section (:,1): contiguous Pointer to section (stride 2): non-contiguous Pointer to matrix section (:,1): non-contiguous
If I remove the second write statement, the answer is twice "contiguous"
I compile and link it with just default options.