[Rd] [R] variance/mean
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Mar 24 16:15:22 CET 2009
William Dunlap wrote:
> Doesn't Fortran still require that the arguments to
> a function not alias each other (in whole or in part)?
>
what do you mean? the following works pretty fine:
echo '
program foo
implicit none
integer, target :: a = 1
integer, pointer :: p1, p2, p3
integer :: gee
p1 => a
p2 => a
p3 => a
write(*,*) p1, p2, p3
call bar (p1, p2, p3)
write(*,*) p1, p2, p3
a = gee(p1, p2, p3)
write(*,*) p1, p2, p3
end program foo
subroutine bar (p1, p2, p3)
integer :: p1, p2, p3
p3 = p1 + p2
end subroutine bar
function gee(p1, p2, p3)
integer :: p1, p2, p3, gee
p3 = p1 + p2
gee = p3
return
end function gee
' > foo.f95
gfortran foo.f95 -o foo
./foo
# 1 1 1
# 2 2 2
# 4 4 4
clearly, p1, p2, and p3 are aliases of each other, and there is an
assignment made in both the subroutine and the function. have i
misunderstood what you said?
vQ
More information about the R-devel
mailing list