(j3.2006) a question on same_type_as and type parameters
Jim Xia
jimxia
Thu Aug 28 10:09:02 EDT 2008
Just to clarify this issue. Consider the following program
class(*), allocatable :: a, b
allocate (real :: a)
allocate (double precision :: b)
print *, same_type_as (a, b)
end
Should the PRINT statement print true or false? Based on the standard, it
seems that only type matters in deterring the value of the intrinsic, so
it appears the program should print true. However this may not provide
enough information for the user since there is no way to query a or b's
type parameter values. So it's still unclear to the user, for example, if
the two entities are of the same size so it's safe to do an internal
memory transfer from a to b. So the question is: do we really intend to
have the SAME_TYPE_AS only checks for the types of two variables and
ignore their type parameter values?
The same question also applies to parameterized derived types as can be
illustrated by the following example
type t (k)
integer, kind :: k
real :: x(k)
end type
type (t(5)) a
type (t(10)) b
print *, same_type_as (a, b)
end
Jim Xia
RL Fortran Compiler Test
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
Phone (905) 413-3444 Tie-line 313-3444
email: jimxia at ca.ibm.com
D2/YF7/8200 /MKM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3-fortran.org/pipermail/j3/attachments/20080828/f1b7a647/attachment.html
More information about the J3
mailing list