| Michael Metcalf 2004-05-12, 9:08 pm |
|
"Fernando M. Roxo da Motta" <roxo@roxo.org> wrote in message
news:slrnc9lqbq.2ti.roxo@mamaeh.roxo...
>
> Is it possible to do the same in Fortran 9x ?
>
Not legally, as you've discovered. It is always possible to cheat, for
instance by using common, as in
common/a/x
real, pointer :: x(:)
allocate(x(10))
x = 6
call s(size(x))
end
subroutine s(n)
common/a/j
integer, pointer :: j(:)
print *, j(:n)
end
This is not guaranteed to work by the standard (j is formally undefined),
but will on all known compilers (see also "Fortran 90/95 Explained", Section
11.2).
Have you looked at the transfer function (ibid., Section 8.9)? That allows
you to write statements such as
i = transfer(a(j), i)
and is perefectly standard (it was put into f90 with just this applicatioin
in mind).
Hope that helps,
Mike Metcalf
|