Can you pass a non-target variable to a subroutine where it is defined
to have the target attribute?
To clarify, is the following code legal F90? It compiles with my
compiler, and seems to work, but I am worried it isn't standard
compliant.
module ValStorageMod
type ValStorage
real, pointer :: valPtr
end type
contains
subroutine setStoragePtr( storage, v )
type (ValStorage) :: storage
real, target :: v
storage%valPtr => v
end subroutine
subroutine setVal( storage, x )
type (ValStorage) :: storage
real :: x
storage%valPtr = x
end subroutine
end module
program main
use ValStorageMod
type (ValStorage) :: valStore
real :: r
call setStoragePtr(valStore, r )
call setVal( valStore, 5.0 )
print *, 'r is ', r ! Should this print out 5?
end
Drew
========================================
Dr. Drew McCormack (Kmr. R153)
Afd. Theoretische Chemie
Faculteit Exacte Wetenschappen
Vrije Universiteit Amsterdam
De Boelelaan 1083
1081 HV Amsterdam
The Netherlands
Email [log in to unmask]
Telephone +31 20 44 47623
Mobile +31 6 483 21307
Fax +31 20 44 47629
|