- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could you explain the difference between the two calls?
The first call changes the expected values while the second provides zero.
Thanks,
Pierre
module essai
contains
subroutine testarray(array)
real(4),dimension(:) :: array
array(:)=1
end subroutine
end module
program moi
use essai
real(4), dimension(1,20), target :: array
integer, dimension(2) :: part = (/1,4/)
array=0
call testarray(array(1,1:4:3))
array=0
call testarray(array(1,part))
end program
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the second CALL, the actual argument is an array section with a variable used to designate the section. Therefore, I believe, the actual argument is an expression and is, therefore, in the subroutine you are not allowed to assign a value to it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The second call uses what is called a "vector subscript". This causes a temporary copy to be passed and any changes discarded. Consider what would happen if part was defined instead as (/3,3/).

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