- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not seeing that behavior (removing write changes last value) in 17.0.1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, in that case, the problem must have been solved already. I was rather surprised about it.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page