(j3.2006) How to assign to the declared-type part of a polymorphic allocatable array?
Cohen Malcolm
malcolm
Fri Sep 23 04:55:50 EDT 2016
<<<
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.
More information about the J3
mailing list