(j3.2006) How to assign to the declared-type part of a polymorphic allocatable array?
Van Snyder
Van.Snyder
Fri Sep 23 14:37:09 EDT 2016
On Fri, 2016-09-23 at 17:55 +0900, Cohen Malcolm 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.)
The first can't be type-bound if it has a passed-object dummy argument.
>
> Cheers,
More information about the J3
mailing list