- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a way of using array slices in Fortran that are not merely continuous segments of an array and that neither are made up of elements accessible by a constant stride value? (as an example, would it be possible to create an array slice comprising the array's elements 1, 3, 17, 18, 25?) If this cannot be accomplished using array slices, what would be the most elegant and/or efficient way of doing this?
Thanks a lot in advance :)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does the following example address your question? Note the use of the integer array ix in the WRITE statement. The contents of the array can be any integers with acceptable values (less than 25)
[fortran]
program idx
implicit none
integer, dimension(5) :: ix = [1, 3, 17, 18, 25]
integer, dimension(25) :: array
integer :: i
do i=1,25
array(i)=i
end do
write(*,*)array(ix)
end program idx
[/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej4, thanks a lot for your reply, this is exactly what I've been looking for!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page