(j3.2006) How to assign to the declared-type part of a polymorphic allocatable array?

Clune, Thomas L. GSFC-6101 thomas.l.clune
Fri Sep 23 08:48:58 EDT 2016


Nice.   I guess I?ve had a blind eye towards using TYPE instead of CLASS in this context.

- Tom


> On Sep 23, 2016, at 4:55 AM, Cohen Malcolm <malcolm at nag-j.co.jp> wrote:
> 
> <<<
> Is there a way to assign to the declared-type part of a polymorphic
> allocatable array, other than one component at a time?
>>>> 
> 
> Yes, use a procedure, for example:
> 
> Elemental Subroutine assign_t_only(a,b)
>  Type(t),Intent(Out) :: a
>  Type(t),Intent(In) :: b
>  a = b
> End Subroutine
> 
> That handles things with a declared type of T whether polymorphic or not, to 
> handle things with a declared type that is an extension of T you need only 
> use the additional procedure:
> 
> Elemental Subroutine assign_t_only_e(aa,bb)
>  Class(t),Intent(InOut) :: aa
>  Class(t),Intent(In) :: bb
>  Call assign_t_only(aa,bb)
> End Subroutine
> 
> (This second one could be a type-bound procedure of T, and the first could 
> be an internal procedure of the second.)
> 
> Cheers,
> -- 
> ........................Malcolm Cohen, Nihon NAG, Tokyo. 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3




More information about the J3 mailing list