(j3.2006) a question on same_type_as and type parameters

Bill Long longb
Thu Aug 28 10:55:28 EDT 2008



Jim Xia wrote:
>
> 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)

I don't think this reference is legal.  The spec requires that the types 
of the arguments be extensible, which is not the case for intrinsic 
types. The "same type" wording relies on the description of what is 
means for two derived types to be the same.

Cheers,
Bill


>     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
> ------------------------------------------------------------------------
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
>   

-- 
Bill Long                                   longb at cray.com
Fortran Technical Support    &              voice: 651-605-9024
Bioinformatics Software Development         fax:   651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120

            




More information about the J3 mailing list